1
1
#!/usr/bin/env python
2
2
3
- import sys , pkg_resources
4
- import re
3
+ import sys , os , re , pkg_resources , subprocess
5
4
6
5
def mycmp (version1 , version2 ):
7
6
def normalize (v ):
8
7
return [int (x ) for x in re .sub (r'(\.0+)*$' ,'' , v ).split ("." )]
9
8
return cmp (normalize (version1 ), normalize (version2 ))
9
+
10
+ def check_version1 (name ):
11
+ try :
12
+ vers = subprocess .Popen ([name , '-version' ], stdout = subprocess .PIPE ).communicate ()[0 ].split ('\n ' )[0 ]
13
+ vers = vers .replace (': ' , ' v' )
14
+ except OSError as e :
15
+ if e .errno == os .errno .ENOENT :
16
+ return (name + ': not installed' )
17
+ return (vers )
18
+
19
+ def check_version2 (name ):
20
+ try :
21
+ if name == 'augustus' :
22
+ vers = subprocess .Popen ([name , '--version' ], stderr = subprocess .STDOUT , stdout = subprocess .PIPE ).communicate ()[0 ].rstrip ()
23
+ elif name == 'bamtools' :
24
+ vers = subprocess .Popen ([name , '--version' ], stdout = subprocess .PIPE ).communicate ()[0 ].split ('\n ' )[1 ]
25
+ vers = vers .replace ('bamtools ' , 'bamtools v' )
26
+ elif name == 'gmap' :
27
+ vers = subprocess .Popen ([name , '--version' ], stderr = subprocess .STDOUT , stdout = subprocess .PIPE ).communicate ()[0 ].split ('\n ' )
28
+ for i in vers :
29
+ if i .startswith ('GMAP' ):
30
+ vers = i
31
+ break
32
+ vers = vers .split (' called' )[0 ].replace ('version' , 'v' )
33
+ else :
34
+ vers = subprocess .Popen ([name , '--version' ], stdout = subprocess .PIPE ).communicate ()[0 ].split ('\n ' )[0 ]
35
+ if 'exonerate' in vers :
36
+ vers = vers .replace ('exonerate from ' , '' )
37
+ if 'AUGUSTUS' in vers :
38
+ vers = vers .split (' is ' )[0 ].replace ('(' ,'v' ).replace (')' , '' )
39
+ vers = vers .replace ('version ' , 'v' )
40
+ except OSError as e :
41
+ if e .errno == os .errno .ENOENT :
42
+ return (name + ': not installed' )
43
+ return (vers )
44
+
45
+ def check_version3 (name ):
46
+ try :
47
+ vers = subprocess .Popen ([name , '-v' ], stdout = subprocess .PIPE ).communicate ()[0 ].split ('\n ' )[0 ]
48
+ vers = vers .replace ('version open-' , 'v' )
49
+ except OSError as e :
50
+ if e .errno == os .errno .ENOENT :
51
+ return (name + ': not installed' )
52
+ return (vers )
53
+
54
+ def check_version4 (name ):
55
+ try :
56
+ vers = subprocess .Popen ([name , 'version' ], stdout = subprocess .PIPE ).communicate ()[0 ].split ('\n ' )[0 ]
57
+ vers = vers .replace ('version ' , 'v' )
58
+ if name == 'ete3' :
59
+ vers = 'ete3 v' + vers
60
+ except OSError as e :
61
+ if e .errno == os .errno .ENOENT :
62
+ return (name + ': not installed' )
63
+ return (vers )
64
+
65
+ def check_version5 (name ):
66
+ try :
67
+ if name == 'gmes_petap.pl' :
68
+ vers = subprocess .Popen ([name ], stdout = subprocess .PIPE ).communicate ()[0 ].split ('\n ' )
69
+ for i in vers :
70
+ if i .startswith ('GeneMark-ES' ):
71
+ vers = i
72
+ vers = vers .replace ('version ' , 'v' )
73
+ elif name == 'blat' :
74
+ vers = subprocess .Popen ([name ], stdout = subprocess .PIPE ).communicate ()[0 ].split ('\n ' )[0 ]
75
+ vers = vers .split (' fast' )[0 ]
76
+ vers = vers .split ('Standalone ' )[- 1 ].replace ('v. ' , 'v' )
77
+ except OSError as e :
78
+ if e .errno == os .errno .ENOENT :
79
+ return (name + ': not installed' )
80
+ return (vers )
81
+
82
+ def check_version6 (name ):
83
+ try :
84
+ vers = subprocess .Popen ([name , '-h' ], stdout = subprocess .PIPE ).communicate ()[0 ].split ('\n ' )
85
+ for i in vers :
86
+ if i .startswith ('# HMMER' ):
87
+ vers = i
88
+ break
89
+ vers = vers .split (';' )[0 ].replace ('# ' , '' )
90
+ except OSError as e :
91
+ if e .errno == os .errno .ENOENT :
92
+ return (name + ': not installed' )
93
+ return (vers )
10
94
11
95
funannotate = ['numpy' , 'pandas' , 'matplotlib' , 'scipy' , 'scikit-learn' , 'psutil' , 'natsort' , 'goatools' , 'seaborn' , 'biopython' ]
12
96
min_versions = {'numpy' : '1.10.0' , 'pandas' : '0.16.1' , 'matplotlib' : '1.5.0' , 'scipy' : '0.17.0' , 'scikit-learn' : '0.17.0' , 'psutil' : '4.0.0' , 'natsort' : '4.0.0' , 'goatools' : '0.6.4' , 'seaborn' : '0.7.0' , 'biopython' : '1.65' }
@@ -31,4 +115,24 @@ def normalize(v):
31
115
print x ,'=>' ,vers
32
116
except pkg_resources .DistributionNotFound :
33
117
print x ,'=! ERROR. Not installed'
34
- print "-----------------------"
118
+ print "-----------------------"
119
+ print "External Dependencies:"
120
+ print "-----------------------"
121
+
122
+ programs1 = ['tblastn' , 'blastp' , 'blastn' , 'makeblastdb' , 'rmblastn' ] #-version
123
+ programs2 = ['exonerate' , 'bedtools' , 'bamtools' , 'augustus' , 'braker.pl' , 'gmap' ] #--version
124
+ programs3 = ['RepeatModeler' , 'RepeatMasker' ] #-v
125
+ programs4 = ['diamond' , 'ete3' ] #version
126
+ programs5 = ['gmes_petap.pl' , 'blat' ] #no version option at all, a$$holes
127
+ for i in programs1 :
128
+ print check_version1 (i )
129
+ for i in programs2 :
130
+ print check_version2 (i )
131
+ for i in programs3 :
132
+ print check_version3 (i )
133
+ for i in programs4 :
134
+ print check_version4 (i )
135
+ for i in programs5 :
136
+ print check_version5 (i )
137
+ print check_version6 ('hmmsearch' )
138
+
0 commit comments