Skip to content

Commit e7a9a8d

Browse files
committed
fix vcf error logging
1 parent 7243909 commit e7a9a8d

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tb-profiler

+15-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ def cleanup():
2121
for f in glob.glob(files_prefix+"*"):
2222
os.remove(f)
2323
import traceback
24-
with open(args.prefix+".errlog", "w") as O:
24+
25+
if "prefix" in vars(args):
26+
outfile = "%s.errlog" % args.prefix
27+
elif "vcf" in vars(args):
28+
outfile = "%s.errlog" % args.vcf.split("/")[-1]
29+
30+
with open(outfile, "w") as O:
2531
O.write("# tb-profiler error report\n\n")
2632
O.write("* OS: %s\n" % sys.platform)
2733
O.write("* Program version: %s\n" % tbp._VERSION)
@@ -49,7 +55,7 @@ https://github.com/jodyphelan/TBProfiler/issues/new and paste or attach the
4955
contents of the error log (%s)
5056
5157
###############################################################################
52-
""" % (args.prefix+".errlog"))
58+
""" % (outfile))
5359

5460

5561
try:
@@ -340,6 +346,12 @@ def main_vcf_profile(args):
340346
if pp.nofolder(args.dir+"/"+x):
341347
os.mkdir(args.dir+"/"+x)
342348

349+
global conf
350+
if args.external_db:
351+
conf = get_conf_dict(args.external_db)
352+
else:
353+
conf = get_conf_dict(sys.base_prefix+"/share/tbprofiler/%s" % args.db)
354+
343355
if args.lofreq_sample_name:
344356
import re
345357
modified_vcf = "%s.lofreq_modified.vcf" % pp.vcf(args.vcf).prefix
@@ -372,10 +384,7 @@ def main_vcf_profile(args):
372384
if args.db=="tbdb" and not args.external_db and pp.nofile(sys.base_prefix+"/share/tbprofiler/tbdb.fasta"):
373385
pp.log("Can't find the tbdb file at %s. Please run 'tb-profiler update_tbdb' to load the default library or specify another using the '--external_db' flag" % sys.base_prefix,ext=True)
374386

375-
if args.external_db:
376-
conf = get_conf_dict(args.external_db)
377-
else:
378-
conf = get_conf_dict(sys.base_prefix+"/share/tbprofiler/%s" % args.db)
387+
379388
for sample_name in vcf_obj.samples:
380389
args.sample_name = sample_name
381390
files_prefix = args.dir+"/"+sample_name

0 commit comments

Comments
 (0)