forked from jodyphelan/TBProfiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtb-profiler
executable file
·80 lines (65 loc) · 5.17 KB
/
tb-profiler
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
#! /usr/bin/python
from __future__ import division
import sys
import os.path
from tbprofiler import tbp_main,collate
import argparse
script_dir = os.path.dirname(os.path.realpath(__file__))
file_json = "%s/conf.json" % script_dir
tbprofiler_version = "0.3.8"
def main_profile(args):
obj = tbp_main.tbp_seq_obj(args.conf,args.prefix,fq1=args.read1,fq2=args.read2,bam=args.bam,platform=args.platform,threads=args.threads,verbose=args.verbose,stor_dir=args.dir,db=args.db,caller=args.caller,mapper=args.mapper,min_gene_frac=args.min_gene_frac,outfmt=args.format,tbpv=tbprofiler_version,af=args.af)
obj.run_profiler()
def main_collate(args):
obj = collate.profiling_results(args.conf,args.samples,args.prefix,args.dir,args.full,args.all_variants,db=args.db)
obj.results2tab()
def main_version(args):
print("\nTBProfiler version %s\n\nContact: Jody Phelan ([email protected])\n" % tbprofiler_version)
def main_call_variants(args):
obj = tbp_main.tbp_seq_obj(args.conf,args.prefix,fq1=args.read1,fq2=args.read2,bam=args.bam,platform=args.platform,threads=args.threads,verbose=args.verbose,stor_dir=args.dir)
obj.call_genome_variants(gvcf=args.gvcf)
if __name__=="__main__":
parser = argparse.ArgumentParser(description='TBProfiler pipeline',formatter_class=argparse.ArgumentDefaultsHelpFormatter)
subparsers = parser.add_subparsers(help="Task to perform")
parser_sub = subparsers.add_parser('profile', help='Run whole pipeline', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_sub.add_argument('--platform','-m',choices=["Illumina","minION"],default="Illumina",help='NGS Platform')
parser_sub.add_argument('--read1','-1',help='First read file')
parser_sub.add_argument('--read2','-2',help='Second read file')
parser_sub.add_argument('--bam','-a',help='Second read file')
parser_sub.add_argument('--prefix','-p',default="tbprofiler",help='Sample prefix')
parser_sub.add_argument('--threads','-t',default=1,help='Threads',type=int)
parser_sub.add_argument('--caller','-x',default="lofreq", choices=["lofreq","bcftools"],help="Variant calling tool to use",type=str)
parser_sub.add_argument('--mapper','-z',default="bwa", choices=["bwa","minimap2","bowtie2"],help="Mapping tools to use",type=str)
parser_sub.add_argument('--dir','-d',default=".",help='Storage directory')
parser_sub.add_argument('--db','-b',help='Full path to mutation database json file to use (default: TBProfiler panel)')
parser_sub.add_argument('--format','-f',default="classic",choices=["classic","new","tex"],help='Output format [classic,new,tex]')
parser_sub.add_argument('--conf','-c',default=file_json,help='Configuration file')
parser_sub.add_argument('--verbose','-v',default=0, choices=[0,1,2],help="Verbosity increases from 0 to 2",type=int)
parser_sub.add_argument('--min_gene_frac',default=0.9,type=float,help='Used to infer a deletion if the fraction of a gene covered falls below this value. Also used to see if sample is high quality to continue by checking the fraction for rpoB (where deletion should not occur).')
parser_sub.add_argument('--af',default=0.9,type=float,help='Allele frequency cutoff for minority variants')
parser_sub.set_defaults(func=main_profile)
parser_sub = subparsers.add_parser('call_variants', help='Collate results form multiple samples together', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_sub.add_argument('--platform','-m',choices=["Illumina","minION"],default="Illumina",help='NGS Platform')
parser_sub.add_argument('--read1','-1',help='First read file')
parser_sub.add_argument('--read2','-2',help='Second read file')
parser_sub.add_argument('--bam','-a',help='Second read file')
parser_sub.add_argument('--prefix','-p',default="tbprofiler",help='Sample prefix')
parser_sub.add_argument('--gvcf','-g',action="store_true",help='Storage directory')
parser_sub.add_argument('--threads','-t',default=1,help='Threads',type=int)
parser_sub.add_argument('--dir','-d',default=".",help='Storage directory')
parser_sub.add_argument('--conf','-c',default=file_json,help='Configuration file')
parser_sub.add_argument('--verbose','-v',default=0, choices=[0,1,2],help="Verbosity increases from 0 to 2",type=int)
parser_sub.set_defaults(func=main_call_variants)
parser_sub = subparsers.add_parser('collate', help='Collate results form multiple samples together', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_sub.add_argument('samples',help='File with samples (one per line)')
parser_sub.add_argument('prefix',help='Output file name')
parser_sub.add_argument('--dir','-d',default=".",help='Storage directory')
parser_sub.add_argument('--conf','-c',default=file_json,help='Configuration file')
parser_sub.add_argument('--full',action="store_true",help='Output mutations in main file')
parser_sub.add_argument('--all_variants',action="store_true",help='Output all variants in variant matrix')
parser_sub.add_argument('--db','-b',help='Full path to mutation database json file to use (default: TBProfiler panel)')
parser_sub.set_defaults(func=main_collate)
parser_sub = subparsers.add_parser('version', help='Output program version and exit', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_sub.set_defaults(func=main_version)
args = parser.parse_args()
args.func(args)