varcode.transforms.combine_cis_snvs — combine in-cis adjacent SNVs into MNVs
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 87
- Forks
- 28
- Avg merge
- 3h 27m
- Merged PRs (30d)
- 27
Description
Follow-up from #364 / #367 (the varcode.transforms module shape). One of four planned transforms enumerated in docs/transforms.md and the module docstring.
Scope
Reduce two or more adjacent SNVs that share a phase set (or are otherwise determined cis) into a single MNV. Removes the need for HaplotypeEffect/PhaseAmbiguousEffect wrapping in the common case where two SNVs sit in the same codon on the same haplotype and can be classified as one combined codon substitution.
Signature:
def combine_cis_snvs(vc, phase_resolver) -> VariantCollection:
"""Combine adjacent in-codon SNVs sharing a phase set into MNVs.
Cardinality: reduces.
"""
Contract (per transforms module conventions)
- Cardinality: reduces.
- Provenance: combined MNV carries
source_variants=(snv1, snv2, ...). - Metadata behavior: GT must agree across all source SNVs (raises on mismatch — same rule as
pair_breakends); other FORMAT fields taken from the lex-earlier source.
Pairing rule
Two SNVs are combined when all of:
- Both share a phase set (the
phase_resolveranswersin_cis(a, b) is True), OR both are homozygous-alt for the same sample at distinct positions within a single codon. - They sit within a transcript codon window (3 bp at the same codon position).
- They're on the same contig.
Tests
- Two SNVs at codon positions 1+2 of the same codon, in cis -> single MNV; effect prediction emits one
Substitutioninstead of two adjacent ones. - Two SNVs in cis but spanning a codon boundary -> not combined (out of codon window).
- Two SNVs in trans -> not combined.
- Phase unknown -> not combined; existing
PhaseAmbiguousEffectpath still handles them. - Three SNVs in cis within one codon -> one MNV with
source_variants=(a, b, c).
Composition
Should compose cleanly after pair_breakends (separate scopes; both reduce; both idempotent).
See also
- #364 — BND mate pairing (the first transform).
- #367 — varcode.transforms module shape PR.
- #269 — phase resolver infrastructure.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docs/transforms.md and the varcode.transforms module docstring, then read the transform shape from #367 and the phase-resolver infrastructure in #269. Review #364 for conventions around reducing variants, provenance, and metadata. Done means the listed cis, trans, phase-unknown, codon-boundary, and three-SNV cases are covered, with clean composition after pair_breakends.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- bioinformatics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100