From fb1fcc4b747470f33b798f6a602d736b9f78c881 Mon Sep 17 00:00:00 2001 From: Jennifer Lu Date: Wed, 17 Mar 2021 16:42:02 -0400 Subject: [PATCH] Fixing make_kreport.py if no unclassified reads --- make_kreport.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/make_kreport.py b/make_kreport.py index f4afe20..5cba160 100755 --- a/make_kreport.py +++ b/make_kreport.py @@ -161,9 +161,10 @@ def main(): sys.stdout.write(">> STEP 4/4: Printing report file to %s...\n" % args.out_file) o_file = open(args.out_file,'w') #Write line for unclassified reads: - o_file.write("%6.2f\t" % (float(taxid2counts['0'])/float(read_count)*100)) - o_file.write("%i\t%i\t" % (taxid2counts['0'],taxid2counts['0'])) - o_file.write('U\t0\tunclassified\n') + if '0' in taxid2counts: + o_file.write("%6.2f\t" % (float(taxid2counts['0'])/float(read_count)*100)) + o_file.write("%i\t%i\t" % (taxid2counts['0'],taxid2counts['0'])) + o_file.write('U\t0\tunclassified\n') #Get remaining lines parse_nodes = [root_node] while len(parse_nodes) > 0: