Skip to content

Commit b9b6600

Browse files
committed
Report None/0.0 when no data available for abundance level
1 parent 51b89cc commit b9b6600

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

bin/bracken_top_n_linelist.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@ def main(args):
3131
for n in range(args.top_n):
3232
num = str(n + 1)
3333
name_field = 'abundance_' + num + '_name'
34-
output_line[name_field] = bracken_report_sorted[n]['name']
34+
try:
35+
output_line[name_field] = bracken_report_sorted[n]['name']
36+
except IndexError as e:
37+
output_line[name_field] = "None"
3538
output_fields.append(name_field)
3639
fraction_total_reads_field = 'abundance_' + num + '_fraction_total_reads'
37-
output_line[fraction_total_reads_field] = bracken_report_sorted[n]['fraction_total_reads']
40+
try:
41+
output_line[fraction_total_reads_field] = bracken_report_sorted[n]['fraction_total_reads']
42+
except IndexError as e:
43+
output_line[fraction_total_reads_field] = 0.0
3844
output_fields.append(fraction_total_reads_field)
3945

4046

0 commit comments

Comments
 (0)