Skip to content

Commit

Permalink
Patch: Ensure samples with no classification information are included…
Browse files Browse the repository at this point in the history
… in resulting output file.
  • Loading branch information
skchronicles committed Feb 14, 2025
1 parent 80f6ecb commit 80f65c2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions workflow/scripts/create_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ def build_matrix(file, matrix_dict, join_index, parse_index, clean_suffix=None):
if clean_suffix:
# maybe replace with regex later
sample = sample.split(clean_suffix)[0]
# Ensures empty files with no classification
# are reported properly in the output file
if sample not in matrix_dict:
matrix_dict[sample] = {}
for line in fh:
linelist = line.lstrip().rstrip().split('\t')
j_field = linelist[join_index]
j_value = linelist[parse_index]
if sample not in matrix_dict:
matrix_dict[sample] = {}
matrix_dict[sample][j_field] = j_value
return matrix_dict

Expand Down Expand Up @@ -261,4 +263,4 @@ def main():
try:
main()
except BrokenPipeError:
pass
pass

0 comments on commit 80f65c2

Please sign in to comment.