Skip to content

Commit

Permalink
fixed issue with parsing kraken report files which lack an unclassifi…
Browse files Browse the repository at this point in the history
…ed line
  • Loading branch information
ArthurVM committed Jun 22, 2022
1 parent ae793d8 commit fb19e7c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Afanc/screen/report/parseK2report.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ def readK2report(report):
prev_node = -1

with open(report, "r") as fin:
## capture the first line, but discard
unclassifiedline = fin.readline()

for line in fin.readlines():
name, level_int, clade_perc, clade_reads, taxa_reads, taxa_level, ncbi_taxID = parseK2line(line)

if name == "unclassified":
continue

## handle tree root
if ncbi_taxID == 1:
root_node = Tree(line, name, level_int, clade_perc, clade_reads, taxa_reads, taxa_level, ncbi_taxID)
Expand Down Expand Up @@ -159,7 +160,7 @@ def makeJson(branch_box, output_prefix, reportsDir, pct_threshold, num_threshold

out_json = f"{reportsDir}/{output_prefix}.k2.json"

json_dict = { "Thresholds" : { "reads" : num_threshold, "percentage" : pct_threshold, "local_threshold" : local_threshold }, "Detection_events" : []}
json_dict = { "Thresholds" : { "reads" : num_threshold, "percentage" : pct_threshold, "local_threshold" : local_threshold }, "Detection_events" : [] }

## create json report dict
for node in branch_box:
Expand Down

0 comments on commit fb19e7c

Please sign in to comment.