Skip to content

fix: accumulate counts when combining mutations#19

Merged
gp201 merged 3 commits intomainfrom
fix/repetitive_mutations
Mar 11, 2026
Merged

fix: accumulate counts when combining mutations#19
gp201 merged 3 commits intomainfrom
fix/repetitive_mutations

Conversation

@gp201
Copy link
Collaborator

@gp201 gp201 commented Mar 11, 2026

This pull request updates the mutation chaining logic in the check_mutation_chain function and adds a new unit test to verify its correctness. The main improvements are in how mutations are combined.

Mutation chaining logic update:

  • Modified check_mutation_chain in convert_paths2barcodes.py to increment the count of an existing mutation when combining mutations, rather than setting it to 1. This ensures that mutation counts are accurately preserved during chaining.

Testing enhancements:

  • Added a new unit test test_check_mutation_chain in test_barcoding.py to verify that mutation chaining produces the expected barcode output when combining mutations.

Example:

A225G > G225T > T225C > C225A > A225T > T225C
  • Bug: The code collapses A225G > G225T to A225T. Since A225T is already present in the mutations path instead of incrementing the count of seeing the mutation to 2 it sets to 1.

  • Fix: The code has now been patched to increment the count.

lineage_path.txt

Use += when adding an already-existing combined mutation so counts are
summed instead of overwritten.
@gp201 gp201 changed the title Accumulate counts when combining mutations fix: accumulate counts when combining mutations Mar 11, 2026
@gp201 gp201 enabled auto-merge (squash) March 11, 2026 21:24
@gp201 gp201 merged commit aeb715a into main Mar 11, 2026
6 checks passed
@gp201 gp201 deleted the fix/repetitive_mutations branch March 11, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant