Skip to content

Commit

Permalink
Contig stitcher: do not munge the final contigs
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Jan 13, 2024
1 parent 7b358e2 commit 4c9829a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions micall/core/contig_stitcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,13 +587,22 @@ def stitch_consensus(contigs: Iterable[GenotypedContig]) -> Iterable[GenotypedCo

def combine(group_ref):
contigs = sorted(consensus_parts[group_ref], key=lambda x: x.alignment.r_st)
ret = combine_contigs(contigs)
if len(contigs) == 1:
return contigs[0]

seq = ''.join([contig.seq for contig in contigs])
match_fraction = min([contig.match_fraction for contig in contigs])
ret = GenotypedContig(name=generate_new_name(),
seq=seq, ref_name=contigs[0].ref_name,
group_ref=contigs[0].group_ref,
ref_seq=contigs[0].ref_seq,
match_fraction=match_fraction)

logger.info("Combined these contigs for final output for %r: %s,"
" resulting in %r at [%s, %s]->[%s, %s].", group_ref,
[repr(x.name) for x in contigs],
ret.name, ret.alignment.q_st, ret.alignment.q_ei,
ret.alignment.r_st, ret.alignment.r_ei,
" resulting in %r of length %s.", group_ref,
[repr(x.name) for x in contigs], ret.name, len(ret.seq),
extra={"action": "finalcombine", "contigs": contigs, "result": ret})

return ret

yield from map(combine, consensus_parts)
Expand Down
2 changes: 1 addition & 1 deletion micall/tests/test_contig_stitcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def test_correct_processing_complex_logs(exact_aligner):

assert len(handler.logs) == 0
list(stitch_consensus(contigs))
assert len(handler.logs) == 158
assert len(handler.logs) == 150

info_messages = [m for m in handler.logs if m.levelname == 'INFO']
debug_messages = [m for m in handler.logs if m.levelname == 'DEBUG']
Expand Down

0 comments on commit 4c9829a

Please sign in to comment.