Skip to content

Commit

Permalink
add external_db
Browse files Browse the repository at this point in the history
  • Loading branch information
Jody Phelan committed Aug 12, 2019
1 parent a1a615f commit 3aeb63d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 49 deletions.
5 changes: 3 additions & 2 deletions meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ source:
build:
script: python -m pip install --no-deps --ignore-installed .
noarch: python
number: 0
number: 2

requirements:
host:
- python
- pip
run:
- python>=3.6
- pathogen-profiler>=1.3
- pathogen-profiler>=1.5
- tqdm
- git
test:
imports:
- tbprofiler
Expand Down
35 changes: 0 additions & 35 deletions osx_install.sh

This file was deleted.

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"])]
)
29 changes: 20 additions & 9 deletions tb-profiler
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,31 @@ 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"]:
if pp.nofolder(args.dir+"/"+x):
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)):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion tbprofiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 3aeb63d

Please sign in to comment.