From dfbf39fd21ecb2253d0a525e45e052b84728de04 Mon Sep 17 00:00:00 2001 From: Adam Ewing Date: Mon, 17 Oct 2016 14:50:05 +1000 Subject: [PATCH] add dependency checks to setup --- setup.py | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/setup.py b/setup.py index 1f5775b..b154c97 100644 --- a/setup.py +++ b/setup.py @@ -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', @@ -25,4 +109,7 @@ 'scripts/seperation.py', 'scripts/match_fasta_to_bam.py'], packages=find_packages(), + install_requires = [ + 'pysam>=0.8.1', + ], )