Skip to content

Commit dfbf39f

Browse files
committed
add dependency checks to setup
1 parent f2d48e0 commit dfbf39f

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

setup.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,89 @@
11
from setuptools import setup, find_packages
22

3+
import sys
4+
import subprocess
5+
6+
7+
def check_bwa():
8+
p = subprocess.Popen(['bwa'], stderr=subprocess.PIPE)
9+
for line in p.stderr:
10+
if line.startswith('Version:'):
11+
major, minor, sub = line.strip().split()[1].split('.')
12+
sub = sub.split('-')[0]
13+
if int(major) >= 0 and int(minor) >= 7 and int(sub) >= 12:
14+
return True
15+
return False
16+
17+
18+
def check_samtools():
19+
p = subprocess.Popen(['samtools'], stderr=subprocess.PIPE)
20+
for line in p.stderr:
21+
if line.startswith('Version:'):
22+
major, minor = line.strip().split()[1].split('.')[:2]
23+
minor = minor.split('-')[0]
24+
if int(major) >= 1 and int(minor) >= 2:
25+
return True
26+
return False
27+
28+
29+
def check_bcftools():
30+
p = subprocess.Popen(['bcftools'], stderr=subprocess.PIPE)
31+
for line in p.stderr:
32+
if line.startswith('Version:'):
33+
major, minor = line.strip().split()[1].split('.')[:2]
34+
minor = minor.split('-')[0]
35+
if int(major) >= 1 and int(minor) >= 2:
36+
return True
37+
return False
38+
39+
40+
def check_wgsim():
41+
p = subprocess.Popen(['wgsim'], stderr=subprocess.PIPE)
42+
for line in p.stderr:
43+
if line.startswith('Version:'):
44+
major, minor = line.strip().split()[1].split('.')[:2]
45+
minor = minor.split('-')[0]
46+
if int(major) >= 0 and int(minor) >= 2:
47+
return True
48+
return False
49+
50+
51+
def check_velvet():
52+
p = subprocess.Popen(['velvetg'], stdout=subprocess.PIPE)
53+
for line in p.stdout:
54+
if line.startswith('Version'):
55+
major, minor = line.strip().split()[1].split('.')[:2]
56+
minor = minor.split('-')[0]
57+
if int(major) >= 1 and int(minor) >= 2:
58+
return True
59+
return False
60+
61+
62+
def check_exonerate():
63+
p = subprocess.Popen(['exonerate'], stdout=subprocess.PIPE)
64+
for line in p.stdout:
65+
if line.startswith('exonerate from exonerate'):
66+
major, minor = line.strip().split()[-1].split('.')[:2]
67+
minor = minor.split('-')[0]
68+
if int(major) >= 2 and int(minor) >= 2:
69+
return True
70+
return False
71+
72+
73+
def check_python():
74+
return sys.hexversion >= 0x20702f0
75+
76+
77+
if __name__ == '__main__':
78+
if not check_python(): sys.exit('Dependency problem: python >= 2.7.2 is required')
79+
if not check_bwa(): sys.exit('Dependency problem: bwa >= 0.7.12 not found')
80+
if not check_samtools(): sys.exit('Dependency problem: samtools >= 1.2 not found')
81+
if not check_bcftools(): sys.exit('Dependency problem: bcftools >= 1.2 not found')
82+
if not check_wgsim(): sys.exit('Dependency problem: wgsim not found (required for addsv)')
83+
if not check_velvet(): sys.exit('Dependency problem: velvet >= 1.2 not found (required for addsv)')
84+
if not check_exonerate(): sys.exit('Dependency problem: exonerate >= 2.2 not found (required for addsv)')
85+
86+
387
setup(name='bamsurgeon',
488
version='1.0',
589
author='Adam Ewing',
@@ -25,4 +109,7 @@
25109
'scripts/seperation.py',
26110
'scripts/match_fasta_to_bam.py'],
27111
packages=find_packages(),
112+
install_requires = [
113+
'pysam>=0.8.1',
114+
],
28115
)

0 commit comments

Comments
 (0)