-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
191 lines (167 loc) · 8.08 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#! /usr/bin/python
'''
@intention: to build distribution package of PFMS with 'python setup.py sdist' command
- and installing PFMS by users with 'python setup.py install [-normal]' command
@author: Husen Umer
@organization: LCB centre for BioInformatics at Uppsala University
@since: 18 Mar 2011
@version: 1.1
'''
import distutils
from distutils.core import setup
import os
import sys
from tests import test_install
from tests import test_normal_install
def main():
distutils.debug = "true"
distutils.DISTUTILS_DEBUG = "true"
setup_args = dict(name='PFMS',
version='1.1',
description='PeakFinder Ranking',
author='Marcin Kruczyk & Husen Umer',
author_email='[email protected]; [email protected]',
url='http://www.lcb.uu.se/',
license='GNU',
long_description='Find the best pest genome peaks',
platforms=['Linux', 'MACOS', 'Windows'],
packages=['src'],
package_dir={'src': 'src'},
scripts=['src/PFMetaserver'],
data_files=[('', ['README.txt'])],
package_data={'src': ['../PeakFinders/pfms.conf',
'../PeakFinders/sissrs_v1.4/sissrs.pl',
'../PeakFinders/SeparateReads.jar',
'../PeakFinders/SeqSite1.0/*',
'../PeakFinders/findpeaks/*',
'../PeakFinders/Erange/commoncode/rnapath/*',
'../PeakFinders/Erange/commoncode/*.*',
'../PeakFinders/cisGenome-2.0/bin/*',
'../PeakFinders/cisGenome-2.0/datatable/*',
'../PeakFinders/cisGenome-2.0/src/*',
'../PeakFinders/MACS-1.3.7.1/*.py',
'../PeakFinders/MACS-1.3.7.1/*.cfg',
'../PeakFinders/MACS-1.3.7.1/*.in',
'../PeakFinders/MACS-1.3.7.1/PKG-INFO',
'../PeakFinders/MACS-1.3.7.1/00README',
'../PeakFinders/MACS-1.3.7.1/COPYING',
'../PeakFinders/MACS-1.3.7.1/INSTALL',
'../PeakFinders/MACS-1.3.7.1/TODO',
'../PeakFinders/MACS-1.3.7.1/ChangeLog',
'../PeakFinders/MACS-1.3.7.1/bin/*',
'../PeakFinders/MACS-1.3.7.1/lib/*.*',
'../PeakFinders/MACS-1.3.7.1/lib/IO/*',
'../PeakFinders/MACS-1.3.7.1/MACS.egg-info/*'
'../PeakFinders/HPeak/HPeak-1.1/*.*',
'../PeakFinders/HPeak/HPeak-1.1/data/*'
],
},
classifiers=[
'Development Status :: Under Developement',
'Environment :: Console',
'Intended Audience :: Chip-Seq Users, Bioinformaticians',
'License :: Artistic License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: Linux',
'Programming Language :: Python',
]
)
setup( ** setup_args)
def install_BEDTools(BEDTools_path, root_path):
os.chdir(BEDTools_path)
os.system("make")
os.chdir(root_path)
def copy_BEDTools_bin(BEDTools_path, destination_path, root_path):
os.chdir(BEDTools_path)
os.system("sudo cp bin/* "+ destination_path)
os.chdir(root_path)
def install_macs(macs_path, sudo, root_path):
os.chdir(macs_path)
os.system(sudo + " chmod +x macs")
os.chdir(root_path)
def install_cisgenome(cisgenome_path, root_path):
os.chdir(cisgenome_path)
os.system("make bin")
os.system("make clean")
os.chdir(root_path)
def install_seqsite(seqsite_path, root_path):
os.chdir(seqsite_path)
os.system("make")
os.chdir(root_path)
def install_hpeak(hpeak_path, root_path):
os.chdir(hpeak_path)
os.system("g++ -o chiphmm chiphmm.cpp")
os.system("g++ -o hmmminus chiphmmminus.cpp")
os.chdir(root_path)
if __name__ == '__main__':
if not float(sys.version[:3]) >= 2.4:
sys.stderr.write("Error: Python 2.4 or greater is required! python 2.6.2 is recommended!\n")
sys.exit(1)
#install the pfs if arg[1]==install
if 'install' in sys.argv:
if '-normal' in sys.argv:
print "Installing the Peakfinders"
install_BEDTools("./PeakFinders/BEDTools-Version-2.16.2/", os.getcwd())
install_cisgenome("./PeakFinders/cisGenome-2.0/src/", os.getcwd())
install_hpeak("./PeakFinders/HPeak/HPeak-1.1/", os.getcwd())
install_seqsite("./PeakFinders/SeqSite1.0/", os.getcwd())
install_macs("./PeakFinders/MACS-1.3.7.1/bin/", "", os.getcwd())
test_normal_install()
else:
main()
sudo = "sudo " #on windows set it to null
if sys.platform.lower().startswith("win"):
sudo = ''
#if the PeakFinders directory is not exist then create on
if not os.path.isdir(sys.prefix + "/PeakFinders"):
os.system(sudo + "mkdir " + sys.prefix + "/PeakFinders")
os.system(sudo + "cp -f -r PeakFinders/* " + sys.prefix + "/PeakFinders/")
print "Installing the Peakfinders"
install_BEDTools("./PeakFinders/BEDTools-Version-2.16.2/", os.getcwd())
copy_BEDTools_bin("PeakFinders/BEDTools-Version-2.16.2/", "/usr/local/bin/", os.getcwd())
install_cisgenome(sys.prefix + "/PeakFinders/cisGenome-2.0/src/", "./")
install_hpeak(sys.prefix + "/PeakFinders/HPeak/HPeak-1.1/", "./")
install_seqsite(sys.prefix + "/PeakFinders/SeqSite1.0/", "./")
install_macs(sys.prefix + "/PeakFinders/MACS-1.3.7.1/bin/", sudo, "./")
test_install()
#Remove the installed files
elif "remove" in sys.argv:
if os.access(sys.prefix + "/PeakFinders/", os.F_OK):
try:
os.removedirs(get_python_lib() + "/src")
except:
os.system("rm -r " + sys.prefix + "/PeakFinders/")
if os.access(sys.prefix + "/README.txt", os.F_OK):
os.remove(sys.prefix + "/README.txt")
if os.access("/usr/bin/" + "/PFMetaserver", os.F_OK):
os.remove("/usr/bin/" + "/PFMetaserver")
if os.access("/usr/local/bin/" + "/PFMetaserver", os.F_OK):
os.remove("/usr/local/bin/" + "/PFMetaserver")
from distutils.sysconfig import get_python_lib
if os.access(get_python_lib() + "/src", os.F_OK):
try:
os.removedirs(get_python_lib() + "/src")
except:
os.system("rm -r " + get_python_lib() + "/src")
if os.access(sys.prefix + "/local" + get_python_lib()[4:] + "/src", os.F_OK):
try:
os.removedirs(sys.prefix + "/local" + get_python_lib()[4:] + "/src")
except:
os.system("rm -r " + sys.prefix + "/local" + get_python_lib()[4:] + "/src")
if os.access(get_python_lib() + "/PeakFinders", os.F_OK):
try:
os.removedirs(get_python_lib() + "/PeakFinders")
except:
os.system("rm -r " + get_python_lib() + "/PeakFinders")
if os.access(sys.prefix + "/local" + get_python_lib()[4:] + "/PeakFinders", os.F_OK):
try:
os.removedirs(sys.prefix + "/local" + get_python_lib()[4:] + "/PeakFinders")
except:
os.system("rm -r " + sys.prefix + "/local" + get_python_lib()[4:] + "/PeakFinders")
if os.access(get_python_lib() + "/PFMS-1.0.egg-info", os.F_OK):
os.remove(get_python_lib() + "/PFMS-1.0.egg-info")
if os.access(sys.prefix + "/local" + get_python_lib()[4:] + "/PFMS-1.0.egg-info", os.F_OK):
os.remove(sys.prefix + "/local" + get_python_lib()[4:] + "/PFMS-1.0.egg-info")
else:
main()