-
Notifications
You must be signed in to change notification settings - Fork 4
/
install_glimmer.py
executable file
·182 lines (146 loc) · 5.7 KB
/
install_glimmer.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
#!/usr/bin/env python
import os, subprocess, glob, sys, stat, shutil
############################################################
# install_glimmer.py
#
# Compile source and set paths for Glimmer-MG.
#
# Author: David Kelley
############################################################
prior_phymm_dir = ''
install_phymm = True
install_scimm = True
install_elph = True
install_glimmer = True
############################################################
# main
############################################################
def main():
installdir = os.getcwd()
############################################
# Phymm
############################################
if install_phymm:
if prior_phymm_dir:
if not os.path.islink('phymm'):
os.symlink(prior_phymm_dir, 'phymm')
else:
if not os.path.isdir('phymm'):
os.mkdir('phymm')
os.chdir('phymm')
# download
p = subprocess.Popen('curl -o phymmbl_installer.tar.gz http://www.cbcb.umd.edu/software/phymm/phymmbl_installer.tar.gz', shell=True)
os.waitpid(p.pid, 0)
# unzip
p = subprocess.Popen('tar -xzvf phymmbl_installer.tar.gz', shell=True)
os.waitpid(p.pid, 0)
# patch
shutil.copy('../phymm_patch/0_getNCBIpages.pl', '.scripts/.taxonomyInfo/0_getNCBIpages.pl')
# install
p = subprocess.Popen('./phymmblSetup.pl', shell=True)
os.waitpid(p.pid, 0)
os.chdir('..')
############################################
# PhyScimm
############################################
if install_scimm:
# unzip
if not os.path.isdir('scimm'):
scimm_ver = glob.glob('scimm*tar.gz')[0][:-7]
p = subprocess.Popen('tar -xzvf %s.tar.gz' % scimm_ver, shell=True)
os.waitpid(p.pid, 0)
os.chdir('scimm')
# compile IMM code
os.chdir('glimmer3.02/src')
p = subprocess.Popen('make clean; make', shell=True)
os.waitpid(p.pid,0)
os.chdir('../..')
# set IMM links
if not os.path.isfile('bin/simple-score'):
os.symlink('../glimmer3.02/bin/simple-score','bin/simple-score')
if not os.path.isfile('bin/build-icm'):
os.symlink('../glimmer3.02/bin/build-icm', 'bin/build-icm')
# set scimm bin variable
p = subprocess.Popen('sed \'s,scimm_bin = ".*",scimm_bin = "%s/scimm/bin",\' bin/scimm.py > sc.tmp' % installdir, shell=True)
os.waitpid(p.pid, 0)
os.rename('sc.tmp', 'bin/scimm.py')
p = subprocess.Popen('chmod ug+x bin/scimm.py', shell=True)
os.waitpid(p.pid,0)
# set physcimm bin variable
p = subprocess.Popen('sed \'s,phymmdir = ".*",phymmdir = "%s/phymm",\' bin/physcimm.py > ph.tmp' % installdir, shell=True)
os.waitpid(p.pid, 0)
os.rename('ph.tmp', 'bin/physcimm.py')
p = subprocess.Popen('chmod ug+x bin/physcimm.py', shell=True)
os.waitpid(p.pid,0)
os.chdir('..')
############################################
# ELPH
############################################
if install_elph:
# download
p = subprocess.Popen('curl -o ELPH-1.0.1.tar.gz ftp://ftp.cbcb.umd.edu/pub/software/elph/ELPH-1.0.1.tar.gz', shell=True)
os.waitpid(p.pid, 0)
# unzip
p = subprocess.Popen('tar -xzvf ELPH-1.0.1.tar.gz', shell=True)
os.waitpid(p.pid, 0)
# compile
os.chdir('ELPH/sources')
p = subprocess.Popen('make', shell=True)
os.waitpid(p.pid, 0)
os.chdir('../..')
############################################
# Glimmer
############################################
if install_glimmer:
# compile
os.chdir('src')
p = subprocess.Popen('sed \'s/static string ICM_dir = ".*"/static string ICM_dir = "%s\/phymm\/.genomeData"/\' Glimmer/glimmer-mg.cc > glim.tmp' % installdir.replace('/','\/'), shell=True)
os.waitpid(p.pid,0)
os.rename('glim.tmp','Glimmer/glimmer-mg.cc')
p = subprocess.Popen('make clean; make', shell=True)
os.waitpid(p.pid,0)
os.chdir('..')
set_awk_path()
# build gene IMMs
p = subprocess.Popen('scripts/train_all.py', shell=True)
os.waitpid(p.pid, 0)
# find informative genomes
p = subprocess.Popen('scripts/informative_genomes.py', shell=True)
os.waitpid(p.pid, 0)
# make double icms
p = subprocess.Popen('scripts/double_icms.py', shell=True)
os.waitpid(p.pid, 0)
############################################################
# set_awk_path
############################################################
def set_awk_path():
# find awk
awk_path = ''
for path in os.environ['PATH'].split(':'):
if os.path.isfile(os.path.join(path,'awk')):
awk_path = os.path.join(path,'awk')
break
if awk_path == '':
print >> sys.stderr, 'Cannot find Awk'
exit(1)
else:
# change all scripts
for awkf in glob.glob('scripts/*.awk'):
os.rename(awkf,awkf+'.tmp')
newf = open(awkf, 'w')
print >> newf, '#!%s -f' % awk_path
oldf = open(awkf+'.tmp')
line = oldf.readline()
line = oldf.readline()
while line:
print >> newf, line,
line = oldf.readline()
oldf.close()
newf.close()
shutil.copymode(awkf+'.tmp', awkf)
os.remove(awkf+'.tmp')
############################################################
# __main__
############################################################
if __name__ == '__main__':
main()