Skip to content

Commit

Permalink
Contig stitcher: simplify the munge operation
Browse files Browse the repository at this point in the history
Use strip_query operations to avoid coordinate arithmetic.
  • Loading branch information
Donaim committed Nov 15, 2023
1 parent ea58060 commit 4d61b41
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions micall/core/contig_stitcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,20 @@ def cut_reference(self, cut_point: float) -> 'FrankensteinContig':

@staticmethod
def munge(left: AlignedContig, right: AlignedContig) -> AlignedContig:
left_query_seq = left.seq[0:left.alignment.q_ei + 1]
right_query_seq = right.seq[right.alignment.q_st:]
query_seq = left_query_seq + right_query_seq
query_seq = left.rstrip_query().seq + right.lstrip_query().seq
query = GenotypedContig(seq=query_seq,
name=f'{left.name}+{right.name}',
ref_name=left.ref_name,
ref_seq=left.ref_seq,
matched_fraction=None)

left_alignment = left.alignment
right_alignment = \
right.alignment.translate(
query_delta=(-1 * right.alignment.q_st + len(left_query_seq)),
query_delta=(-1 * right.alignment.q_st + left.alignment.q_ei + 1),
reference_delta=0)
alignment = left_alignment.connect(right_alignment)

query = GenotypedContig(seq=query_seq,
name=f'{left.name}+{right.name}',
ref_name=left.ref_name,
ref_seq=left.ref_seq,
matched_fraction=None)
return AlignedContig(query, alignment)


Expand Down

0 comments on commit 4d61b41

Please sign in to comment.