Skip to content

Commit

Permalink
add dependency checks to setup
Browse files Browse the repository at this point in the history
  • Loading branch information
adamewing committed Oct 17, 2016
1 parent f2d48e0 commit dfbf39f
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,89 @@
from setuptools import setup, find_packages

import sys
import subprocess


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]
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)')


setup(name='bamsurgeon',
version='1.0',
author='Adam Ewing',
Expand All @@ -25,4 +109,7 @@
'scripts/seperation.py',
'scripts/match_fasta_to_bam.py'],
packages=find_packages(),
install_requires = [
'pysam>=0.8.1',
],
)

0 comments on commit dfbf39f

Please sign in to comment.