neherlab / pangraph

A bioinformatic toolkit to align genome assemblies into pangenome graphs
https://neherlab.github.io/pangraph
MIT License
87 stars 7 forks source link

fix: avoid frame shifts when applying insertions #72

Closed ivan-aksamentov closed 7 months ago

ivan-aksamentov commented 7 months ago

Here I sort insertions in reverse order according to their positions. This means that the sequence grows starting from back (rightmost insertions are applied first).

This prevents frame shifts, compared to when applying left-to-right or, worse, in some unspecified order. But the correctness of this needs to be double-checked.

The Ord trait sorts instances ofIns by pos first and then by seq in case of equality. It is important to preserve order of fields in the struct. Otherwise, we may implement Ord trait explicitly.