diff --git a/meta.yaml b/meta.yaml index 0c15163..ac658f5 100644 --- a/meta.yaml +++ b/meta.yaml @@ -13,7 +13,7 @@ source: build: script: python -m pip install --no-deps --ignore-installed . noarch: python - number: 0 + number: 2 requirements: host: @@ -21,8 +21,9 @@ requirements: - pip run: - python>=3.6 - - pathogen-profiler>=1.3 + - pathogen-profiler>=1.5 - tqdm + - git test: imports: - tbprofiler diff --git a/osx_install.sh b/osx_install.sh deleted file mode 100644 index d3bfe4c..0000000 --- a/osx_install.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env sh -export CPP_INCLUDE_PATH=${CONDA_PREFIX}/include -export CXX_INCLUDE_PATH=${CONDA_PREFIX}/include -export CPLUS_INCLUDE_PATH=${CONDA_PREFIX}/include -export LIBRARY_PATH=${CONDA_PREFIX}/lib -conda install -y htslib libboost wget samtools bcftools bwa minimap2 bowtie2 tqdm parallel trimmomatic - -cd /tmp/ -wget https://github.com/dellytools/delly/archive/v0.8.1.tar.gz -tar -xvf v0.8.1.tar.gz -cd delly-0.8.1 -make all -cp ./src/delly ${CONDA_PREFIX}/bin/delly_0.8.1 -echo '#!/bin/sh' > ${CONDA_PREFIX}/bin/delly -echo export DYLD_FALLBACK_LIBRARY_PATH=${CONDA_PREFIX}/lib >> ${CONDA_PREFIX}/bin/delly -echo ${CONDA_PREFIX}/bin/delly_0.8.1 '$@' >> ${CONDA_PREFIX}/bin/delly -chmod 755 ${CONDA_PREFIX}/bin/delly - - -cd /tmp/ -wget https://github.com/jodyphelan/pathogen-profiler/archive/v1.1.tar.gz -tar -xvf v1.1.tar.gz -cd pathogen-profiler-1.1/ -python setup.py install - -cd /tmp/ -wget https://github.com/jodyphelan/TBProfiler/archive/v2.1.tar.gz -tar -xvf v2.1.tar.gz -cd TBProfiler-2.1/ -python setup.py install - -cd /tmp/ -mkdir ${CONDA_PREFIX}/share/tbprofiler -tb-profiler update_tbdb -rm -fr v0.8.1.tar.gz delly-0.8.1 tbdb TBProfiler-2.1 v2.1.tar.gz v1.1.tar.gz pathogen-profiler-1.1 diff --git a/setup.py b/setup.py index 004c1c0..9108a91 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setuptools.setup( name="tbprofiler", - version="2.5.0", + version="2.6.0", packages=["tbprofiler",], license="MIT", long_description="TBProfiler command line tool", @@ -23,5 +23,5 @@ 'scripts/tbprofiler_generate_haplotypes.py', 'scripts/tbprofiler_summarise_mutations.py', ], - data_files=[('share/tbprofiler',["db/tbdb.ann.txt","db/tbdb.barcode.bed","db/tbdb.bed","db/tbdb.dr.json","db/tbdb.fasta","db/tbdb.gff","example_data/tbprofiler.test.fq.gz"])] + data_files=[('share/tbprofiler',["db/tbdb.ann.txt","db/tbdb.barcode.bed","db/tbdb.bed","db/tbdb.dr.json","db/tbdb.fasta","db/tbdb.gff","db/tbdb.version.json","example_data/tbprofiler.test.fq.gz"])] ) diff --git a/tb-profiler b/tb-profiler index 9aef8fe..7e21db5 100644 --- a/tb-profiler +++ b/tb-profiler @@ -48,12 +48,21 @@ def main_profile(args): args.webserver_root = "/srv/www/htdocs/" args.dir = "/srv/www/htdocs/input" - conf_file = sys.base_prefix+"/share/tbprofiler/%s.config.json" % args.db - if pp.nofile(conf_file): - if args.db=="tbdb": - pp.run_cmd("tb-profiler update_tbdb") - else: - pp.log("Can't find config file for db: %s" % conf_file,ext=True) + if args.external_db: + if pp.nofile(args.external_db+".config.json"): + files = {"gff":".gff","ref":".fasta","ann":".ann.txt","barcode":".barcode.bed","bed":".bed","json_db":".dr.json","version":".version.json"} + new_conf = {} + for key in files: + new_conf[key] = args.external_db+files[key] + json.dump(new_conf,open(args.external_db+".config.json","w")) + conf_file = args.external_db+".config.json" + else: + conf_file = sys.base_prefix+"/share/tbprofiler/"+args.db+".config.json" + if pp.nofile(conf_file): + if args.db=="tbdb": + pp.run_cmd("tb-profiler update_tbdb") + else: + pp.log("Can't find config file for db: %s" % conf_file,ext=True) conf = json.load(open(conf_file)) for x in ["bam","vcf","results"]: @@ -61,9 +70,9 @@ def main_profile(args): os.mkdir(args.dir+"/"+x) if args.platform=="minION": args.mapper = "minimap2" + pp.log("Using conf file: %s" % conf_file) + - conf_file = pp.filecheck(sys.base_prefix+"/share/tbprofiler/"+args.db+".config.json") - conf = json.load(open(conf_file)) if args.webserver: fastqs = [] for l in pp.cmd_out("ls %s/input/%s* | grep fastq" % (args.webserver_root,args.prefix)): @@ -141,7 +150,8 @@ def main_load_library(args): pp.run_cmd("cp %s %s" % (args.prefix+files[key],new_conf[key])) json.dump(new_conf,open(sys.base_prefix+"/share/tbprofiler/"+lib_prefix+".config.json","w")) pp.run_cmd("samtools faidx %s" % sys.base_prefix+"/share/tbprofiler/"+lib_prefix+".fasta") - pp.run_cmd("gatk CreateSequenceDictionary -R %s" % sys.base_prefix+"/share/tbprofiler/"+lib_prefix+".fasta") + if pp.nofile(sys.base_prefix+"/share/tbprofiler/"+lib_prefix+".dict"): + pp.run_cmd("gatk CreateSequenceDictionary -R %s" % sys.base_prefix+"/share/tbprofiler/"+lib_prefix+".fasta") pp.log("Sucessfully imported library") def main_lineage(args): @@ -241,6 +251,7 @@ if __name__=="__main__": parser_sub.add_argument('--bam','-a',help='BAM file. Make sure it has been generated using the H37Rv genome (GCA_000195955.2)') parser_sub.add_argument('--prefix','-p',default="tbprofiler",help='Sample prefix for all results generated') parser_sub.add_argument('--db',default='tbdb',help='Mutation panel name') + parser_sub.add_argument('--external_db',type=str,help='Path to db files prefix (overrides "--db" parameter)') parser_sub.add_argument('--mapper',default="bwa", choices=["bwa","minimap2","bowtie2"],help="Mapping tool to use. If you are using minION data it will default to minimap2",type=str) parser_sub.add_argument('--caller',default="GATK", choices=["BCFtools","GATK"],help="Variant calling tool to use.",type=str) parser_sub.add_argument('--min_depth',default=10,type=int,help='Minimum depth required to call variant. Bases with depth below this cutoff will be marked as missing') diff --git a/tbprofiler/__init__.py b/tbprofiler/__init__.py index 91b6a3f..c50ba8e 100644 --- a/tbprofiler/__init__.py +++ b/tbprofiler/__init__.py @@ -7,4 +7,4 @@ from .vcfprofile import * import os _ROOT = os.path.abspath(os.path.dirname(__file__)) -_VERSION = "2.5.0" +_VERSION = "2.6.0"