forked from adamewing/bamsurgeon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
125 lines (106 loc) · 3.99 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
from setuptools import setup, find_packages
import sys
import subprocess
import re
def check_java():
p = subprocess.Popen(['java', '-version'], stderr=subprocess.PIPE)
for line in p.stderr:
if line.startswith('java version'):
return True
return False
def check_bwa():
p = subprocess.Popen(['bwa'], stderr=subprocess.PIPE)
for line in p.stderr:
if line.startswith('Version:'):
major, minor, sub = line.strip().split()[1].split('.')
sub = sub.split('-')[0]
digit_pattern = re.compile(r'\D')
sub = filter(None, digit_pattern.split(sub))[0]
if int(major) >= 0 and int(minor) >= 7 and int(sub) >= 12:
return True
return False
def check_samtools():
p = subprocess.Popen(['samtools'], stderr=subprocess.PIPE)
for line in p.stderr:
if line.startswith('Version:'):
major, minor = line.strip().split()[1].split('.')[:2]
minor = minor.split('-')[0]
if int(major) >= 1 and int(minor) >= 2:
return True
return False
def check_bcftools():
p = subprocess.Popen(['bcftools'], stderr=subprocess.PIPE)
for line in p.stderr:
if line.startswith('Version:'):
major, minor = line.strip().split()[1].split('.')[:2]
minor = minor.split('-')[0]
if int(major) >= 1 and int(minor) >= 2:
return True
return False
def check_wgsim():
p = subprocess.Popen(['wgsim'], stderr=subprocess.PIPE)
for line in p.stderr:
if line.startswith('Version:'):
major, minor = line.strip().split()[1].split('.')[:2]
minor = minor.split('-')[0]
if int(major) >= 0 and int(minor) >= 2:
return True
return False
def check_velvet():
p = subprocess.Popen(['velvetg'], stdout=subprocess.PIPE)
for line in p.stdout:
if line.startswith('Version'):
major, minor = line.strip().split()[1].split('.')[:2]
minor = minor.split('-')[0]
if int(major) >= 1 and int(minor) >= 2:
return True
return False
def check_exonerate():
p = subprocess.Popen(['exonerate'], stdout=subprocess.PIPE)
for line in p.stdout:
if line.startswith('exonerate from exonerate'):
major, minor = line.strip().split()[-1].split('.')[:2]
minor = minor.split('-')[0]
if int(major) >= 2 and int(minor) >= 2:
return True
return False
def check_python():
return sys.hexversion >= 0x20702f0
if __name__ == '__main__':
if not check_python(): sys.exit('Dependency problem: python >= 2.7.2 is required')
if not check_bwa(): sys.exit('Dependency problem: bwa >= 0.7.12 not found')
if not check_samtools(): sys.exit('Dependency problem: samtools >= 1.2 not found')
if not check_bcftools(): sys.exit('Dependency problem: bcftools >= 1.2 not found')
if not check_wgsim(): sys.exit('Dependency problem: wgsim not found (required for addsv)')
if not check_velvet(): sys.exit('Dependency problem: velvet >= 1.2 not found (required for addsv)')
if not check_exonerate(): sys.exit('Dependency problem: exonerate >= 2.2 not found (required for addsv)')
if not check_java(): sys.exit('Dependency problem: java not found')
setup(name='bamsurgeon',
version='1.2',
author='Adam Ewing',
license='MIT',
scripts=['bin/addindel.py',
'bin/addsnv.py',
'bin/addsv.py',
'scripts/bamregions_from_vcf.py',
'scripts/bamsplit.py',
'scripts/bamsplit_proportion.py',
'scripts/bamsplit_multiple.py',
'scripts/bsrg.py',
'scripts/covered_segments.py',
'scripts/dedup.py',
'scripts/evaluator.py',
'scripts/makevcf.py',
'scripts/makevcf_indels.py',
'scripts/makevcf_sv.py',
'scripts/postprocess.py',
'scripts/randomsites.py',
'scripts/remove_unpaired.py',
'scripts/rename_reads.py',
'scripts/seperation.py',
'scripts/match_fasta_to_bam.py'],
packages=find_packages(),
install_requires = [
'pysam>=0.8.1',
],
)