Structural effect JSON serialization fails on missing primary_effects
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 87
- Forks
- 28
- Avg merge
- 3h 27m
- Merged PRs (30d)
- 27
Description
Bug
Serializing structural effects fails because Serializable.to_dict() infers
constructor argument names, including primary_effects, while
StructuralVariantEffect only stores _primary_effects.
Confirmed using the implementation from main commit
9113af081b59978d9fa74832ad7f5d8053eff9ff, before the structural-helper cleanup.
The failure also affects EffectCollection.to_json() containing these effects.
from pyensembl import cached_release
from varcode import StructuralVariant
genome = cached_release(81)
variant = StructuralVariant(
"7", 117531100, sv_type="DEL", end=117531200, genome=genome)
transcript = genome.transcript_by_id("ENST00000003084")
effect = variant.effect_on_transcript(transcript, annotator="fast")
effect.to_json()
# AttributeError: 'LargeDeletion' object has no attribute 'primary_effects'
The same missing-attribute error occurs in cleanup parity checks for DEL, DUP,
INV, CNV, INS, and BND returning TranslocationToIntergenic, with and without
alt_assembly.
Fix requirements
- Define an explicit serialization/round-trip representation for structural
effects, including primary, cryptic, splice and externally attached candidates,
mutant transcript sequences/segments, and provenance. - Do not simply expose
_primary_effectsas a property: its default is(self,),
so naive recursive serialization could cycle back into the parent effect. - Cover direct effects and enclosing collections, including fusions, in tests.
Related: #417 covers SV dataframe export; this is the distinct JSON/object
serialization failure. Found while testing the default/structural cleanup;
not caused by that refactor and intentionally kept out of its scope.
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 by tracing Serializable.to_dict() through StructuralVariantEffect and EffectCollection.to_json(), then inspect how structural effects store primary, cryptic, splice, external candidates, mutant sequences or segments, and provenance. Reproduce the DEL example and add tests covering direct effects, enclosing collections, and fusions; done means round-trip JSON serialization works without recursive cycles for the listed structural variants.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- bioinformatics
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100