varcode 9.4.0__tar.gz → 9.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {varcode-9.4.0/varcode.egg-info → varcode-9.4.2}/PKG-INFO +1 -1
- varcode-9.4.2/tests/test_fusion_insertions.py +135 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_osteosarc_dataset.py +23 -7
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/structural.py +34 -6
- {varcode-9.4.0 → varcode-9.4.2}/varcode/structural_variant.py +36 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/sv_allele_parser.py +20 -0
- varcode-9.4.2/varcode/version.py +1 -0
- {varcode-9.4.0 → varcode-9.4.2/varcode.egg-info}/PKG-INFO +1 -1
- {varcode-9.4.0 → varcode-9.4.2}/varcode.egg-info/SOURCES.txt +1 -0
- varcode-9.4.0/varcode/version.py +0 -1
- {varcode-9.4.0 → varcode-9.4.2}/LICENSE +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/MANIFEST.in +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/README.md +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/pyproject.toml +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/requirements.txt +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/setup.cfg +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_annotator_divergence_scenarios.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_annotator_haplotypes.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_annotator_parity_adversarial.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_annotators.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_bnd_retained_segments.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_cli_effects.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_cli_genes.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_cli_without_pkg_resources.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_collection_filtering.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_collection_variants_attr_consistency.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_common.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_cosmic_mutations.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_cryptic_exons.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_csv_roundtrip.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_dbnsfp_validation.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_default_structural_helpers.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_documentation_examples.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_effect_annotation_errors.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_effect_candidates.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_effect_classes.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_effect_collection.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_effect_collection_serialization.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_effect_collection_sort_order.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_effect_hypotheses.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_effects_from_mutagenix_variants.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_exacto_fusions.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_exonic_splice_site.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_fast_path.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_frameshift_cterminus_regression.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_frameshift_helpers.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_fusion_partner_candidates.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_genome_contig_validation.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_genome_sequence.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_genomic_layout.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_genotype.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_genotype_from_vcf.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_germline_context.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_germline_effects.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_haplotype_effect.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_maf.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_mitochondrial.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_mm10_klf6_frameshift.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_mouse.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_mutant_transcript.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_mutate.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_no_duplicate_variants.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_nonlocal_sv_transcripts.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_osteosarc_fusions.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_osteosarc_variants.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_partial_annotators.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_premature_stop_short_description.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_problematic_variants.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_protein_diff_parity.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_read_phase_resolver.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_real_world_callers.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_reference.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_reference_mismatch_error.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_reference_segments.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_rna_evidence.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_rna_haplotype_sequences.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_rna_read_phasing_source.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_selenocysteine.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_selenocysteine_proteins.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_silent_aa_pos.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_silent_hgvs_description.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_splice_graph.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_splice_outcomes.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_splice_site_effects.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_stop_codon_classification_bugs.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_string_helpers.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_structural_variant_annotator.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_structural_variants.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_sv_selenocysteine.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_sv_sequence_changes.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_sv_tabular_metadata.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_symbolic_alleles.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_symbolic_sv_padding.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_timings.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_transcript_layout.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_transcript_model.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_transcript_model_start_codons.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_transforms_left_align.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_transforms_pair_breakends.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_variant.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_variant_collection.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_vcf.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_vcf_output.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_vcf_parsing.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_vcf_phase_resolver.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/tests/test_vcf_spec_examples.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/__init__.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/annotators/__init__.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/annotators/fast.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/annotators/protein_diff.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/annotators/registry.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/cli/__init__.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/cli/effects_script.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/cli/genes_script.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/cli/logging.conf +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/cli/variant_args.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/cli/version_info.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/common.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/cryptic_exons.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/csv_helpers.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effect_candidates.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effect_hypotheses.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/__init__.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/classify.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/codon_tables.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/common.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/effect_classes.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/effect_collection.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/effect_helpers.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/effect_ordering.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/effect_prediction.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/effect_prediction_coding.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/effect_prediction_coding_frameshift.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/effect_prediction_coding_in_frame.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/fast_path.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/mutate.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/selenocysteine.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/sequence_change.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/transcript_helpers.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/effects/translate.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/errors.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/exacto.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/genome.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/genome_sequence.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/genomic_layout.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/genotype.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/germline.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/maf.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/mutant_transcript.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/nucleotides.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/phasing.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/realized_effects.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/reference.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/rna_evidence.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/rna_read_phasing.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/splice_graph.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/splice_outcomes.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/string_helpers.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/transcript_layout.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/transcript_model.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/transforms/__init__.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/ucsc_reference_names.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/util.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/variant.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/variant_collection.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/vcf.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/vcf_output.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode/vcf_parsing.py +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode.egg-info/dependency_links.txt +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode.egg-info/entry_points.txt +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode.egg-info/requires.txt +0 -0
- {varcode-9.4.0 → varcode-9.4.2}/varcode.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""VCF 4.5 junction inserts must survive fusion assembly (#485).
|
|
2
|
+
|
|
3
|
+
Fixture construction is inline: each test writes a minimal VCF and loads it
|
|
4
|
+
through the public loader. The real one-base ZNF236::GALR1 allele is from
|
|
5
|
+
Osteosarc T0 Personalis ESVEE records 42280/42296; the zero/two-base controls
|
|
6
|
+
alter only the insert. Source:
|
|
7
|
+
https://sid-sijbrandij-osteosarc-dataset.s3.us-west-2.amazonaws.com/kamil/oncoanalyser/IPISRC044_T0_personalis/esvee/IPISRC044_tumor_T0_personalis.esvee.somatic.vcf.gz
|
|
8
|
+
SHA256: c1ccf669accc0ba33ebaa139a4752700310c44f42ecf50dbfe72d9171928b281
|
|
9
|
+
No download or local report is needed to regenerate the fixture.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from types import SimpleNamespace
|
|
13
|
+
|
|
14
|
+
import pytest
|
|
15
|
+
from pyensembl import cached_release
|
|
16
|
+
|
|
17
|
+
from varcode import StructuralVariant
|
|
18
|
+
from varcode.effects.codon_tables import translate_sequence
|
|
19
|
+
from varcode.effects import GeneFusion
|
|
20
|
+
from varcode.effects.structural import _build_fusion_mutant_transcript
|
|
21
|
+
from varcode.nucleotides import reverse_complement
|
|
22
|
+
from varcode.sv_allele_parser import breakend_inserted_sequence
|
|
23
|
+
|
|
24
|
+
from .test_osteosarc_fusions import _load_esvee_records
|
|
25
|
+
from varcode.transforms import pair_breakends
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@pytest.mark.parametrize("first_side,second_side", [
|
|
29
|
+
("left", "right"), ("left", "left"), ("right", "left"), ("right", "right")])
|
|
30
|
+
@pytest.mark.parametrize("insert", ["", "A", "AC", "ACG"])
|
|
31
|
+
def test_reciprocal_junction_sequence_in_all_orientations(first_side, second_side, insert):
|
|
32
|
+
"""The same traversal must give identical bases from either VCF record."""
|
|
33
|
+
def record(contig, pos, mate, mate_pos, side, mate_side, bases):
|
|
34
|
+
local = bases if side == "left" else reverse_complement(bases)
|
|
35
|
+
bracket = "[" if mate_side == "right" else "]"
|
|
36
|
+
locus = "%s%s:%d%s" % (bracket, mate, mate_pos, bracket)
|
|
37
|
+
alt = "C" + local + locus if side == "left" else locus + local + "C"
|
|
38
|
+
return StructuralVariant(contig, pos, "BND", ref="C", alt=alt,
|
|
39
|
+
mate_contig=mate, mate_start=mate_pos)
|
|
40
|
+
|
|
41
|
+
a = record("1", 100, "2", 200, first_side, second_side, insert)
|
|
42
|
+
b = record("2", 200, "1", 100, second_side, first_side, reverse_complement(insert))
|
|
43
|
+
junction = a.junctions[0]
|
|
44
|
+
assert a.junction_inserted_sequence(junction) == insert
|
|
45
|
+
assert b.junction_inserted_sequence(junction) == insert
|
|
46
|
+
assert a.junction_inserted_sequence(junction[::-1]) == reverse_complement(insert)
|
|
47
|
+
a.source_variants = (a, b)
|
|
48
|
+
assert a.junction_inserted_sequence(junction) == insert
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@pytest.mark.parametrize("ref,alt", [
|
|
52
|
+
("C", "A[2:200["), ("C", "]2:200]A"), ("CC", "CCA[2:200["),
|
|
53
|
+
("C", "C[2:200]"), ("C", "C[2:200[C"), ("C", "<BND>")])
|
|
54
|
+
def test_uninterpretable_replacement_is_not_an_empty_insert(ref, alt):
|
|
55
|
+
assert breakend_inserted_sequence(ref, alt) is None
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@pytest.mark.parametrize("insert,expected_length", [("", 1184), ("A", 1237), ("AA", 1188)])
|
|
59
|
+
@pytest.mark.parametrize("svtype", ["BND", "DEL"])
|
|
60
|
+
def test_znf236_galr1_from_raw_reciprocal_and_paired_records(tmp_path, insert, expected_length, svtype):
|
|
61
|
+
"""The real exonic Osteosarc junction, with zero/one/two inserted bases."""
|
|
62
|
+
vc = _load_esvee_records(tmp_path, [
|
|
63
|
+
("chr18", "76920050", "a", "C", "C" + insert + "[chr18:77271549[",
|
|
64
|
+
"60", "PASS", "SVTYPE=" + svtype + ";MATEID=b"),
|
|
65
|
+
("chr18", "77271549", "b", "A", "]chr18:76920050]" + insert + "A",
|
|
66
|
+
"60", "PASS", "SVTYPE=" + svtype + ";MATEID=a"),
|
|
67
|
+
])
|
|
68
|
+
genome = cached_release(95)
|
|
69
|
+
five = genome.transcript_by_id("ENST00000253159")
|
|
70
|
+
three = genome.transcript_by_id("ENST00000299727")
|
|
71
|
+
cdna = five.sequence[:five.spliced_offset(76920050) + 1] + insert + three.sequence[three.spliced_offset(77271549):]
|
|
72
|
+
coding = cdna[min(five.start_codon_spliced_offsets):]
|
|
73
|
+
protein = translate_sequence(coding[:len(coding) // 3 * 3], to_stop=True)
|
|
74
|
+
assert len(protein) == expected_length
|
|
75
|
+
for variant in list(vc) + list(pair_breakends(vc)):
|
|
76
|
+
for transcript in (five, three):
|
|
77
|
+
fusion = next(c.effect for c in variant.effect_on_transcript(transcript).candidates
|
|
78
|
+
if isinstance(c.effect, GeneFusion)
|
|
79
|
+
and c.effect.five_prime_transcript.id == five.id
|
|
80
|
+
and c.effect.three_prime_transcript.id == three.id)
|
|
81
|
+
model = fusion.mutant_transcript
|
|
82
|
+
assert model.cdna_sequence == cdna
|
|
83
|
+
assert model.mutant_protein_sequence == protein
|
|
84
|
+
assert "".join(s.source.sequence[s.start:s.end]
|
|
85
|
+
for s in model.reference_segments) == cdna
|
|
86
|
+
if insert:
|
|
87
|
+
assert model.reference_segments[1].label == "junction_insertion"
|
|
88
|
+
assert model.evidence["junction_insertion_status"] == "retained"
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _transcript(reverse=False):
|
|
92
|
+
return SimpleNamespace(sequence="ATGAAACCCGGGTAA", complete=True,
|
|
93
|
+
start_codon_spliced_offsets=[0, 1, 2],
|
|
94
|
+
contig="1", strand="-" if reverse else "+",
|
|
95
|
+
on_backward_strand=reverse,
|
|
96
|
+
exons=[SimpleNamespace(start=100, end=114)])
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@pytest.mark.parametrize("reverse", [False, True])
|
|
100
|
+
@pytest.mark.parametrize("insert,protein", [("", "MKPG"), ("A", "MKTRV"), ("AC", "MKTPG"), ("ACG", "MKTPG")])
|
|
101
|
+
def test_exonic_insert_translation_on_both_strands(reverse, insert, protein):
|
|
102
|
+
five, three = _transcript(reverse), _transcript(reverse)
|
|
103
|
+
five_pos, three_pos = (109, 108) if reverse else (105, 106)
|
|
104
|
+
model = _build_fusion_mutant_transcript(five, five, five_pos, three, three_pos, insert)
|
|
105
|
+
assert model.cdna_sequence == "ATGAAA" + insert + "CCCGGGTAA"
|
|
106
|
+
assert model.mutant_protein_sequence == protein
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@pytest.mark.parametrize("five_pos,three_pos,status", [
|
|
110
|
+
(115, 99, "excluded_by_reference_splicing"),
|
|
111
|
+
(105, 99, "unresolved_insertion_retention"),
|
|
112
|
+
(115, 106, "unresolved_insertion_retention")])
|
|
113
|
+
def test_insertion_retention_requires_splicing_evidence(five_pos, three_pos, status):
|
|
114
|
+
five, three = _transcript(), _transcript()
|
|
115
|
+
model = _build_fusion_mutant_transcript(five, five, five_pos, three, three_pos, "AC")
|
|
116
|
+
assert model.evidence["junction_inserted_sequence"] == "AC"
|
|
117
|
+
if status.startswith("unresolved"):
|
|
118
|
+
assert model.evidence["sequence_status"] == status
|
|
119
|
+
assert model.cdna_sequence is None
|
|
120
|
+
assert model.mutant_protein_sequence is None
|
|
121
|
+
else:
|
|
122
|
+
assert model.evidence["junction_insertion_status"] == status
|
|
123
|
+
assert model.cdna_sequence == five.sequence + three.sequence
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def test_conflicting_mates_do_not_invent_a_junction_sequence():
|
|
127
|
+
a = StructuralVariant("1", 100, "BND", ref="C", alt="CA[2:200[", mate_contig="2", mate_start=200)
|
|
128
|
+
b = StructuralVariant("2", 200, "BND", ref="C", alt="]1:100]TC", mate_contig="1", mate_start=100)
|
|
129
|
+
a.source_variants = (a, b)
|
|
130
|
+
assert a.junction_inserted_sequence(a.junctions[0]) is None
|
|
131
|
+
five, three = _transcript(), _transcript()
|
|
132
|
+
model = _build_fusion_mutant_transcript(five, five, 105, three, 106, None)
|
|
133
|
+
assert model.cdna_sequence is None
|
|
134
|
+
assert model.mutant_protein_sequence is None
|
|
135
|
+
assert model.evidence["sequence_status"] == "unresolved_junction_insertion"
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Offline checks against the bundled, pinned public osteosarc snapshot.
|
|
2
2
|
|
|
3
3
|
See tests/README.md for acquisition and invocation. Source annotations are
|
|
4
4
|
provenance, not an independent oracle for protein consequences.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
import hashlib
|
|
7
8
|
import os
|
|
8
9
|
import shutil
|
|
10
|
+
import zipfile
|
|
9
11
|
from dataclasses import replace
|
|
10
12
|
from importlib.metadata import version
|
|
13
|
+
from pathlib import Path
|
|
11
14
|
|
|
12
15
|
import pytest
|
|
13
16
|
from pyensembl import cached_release
|
|
@@ -18,17 +21,30 @@ from varcode.mutant_transcript import apply_variant_to_transcript
|
|
|
18
21
|
from .osteosarc_variants import SNAPSHOT_ID, read_fixture
|
|
19
22
|
|
|
20
23
|
|
|
24
|
+
SNAPSHOT_NAME = "2026-09-18t"
|
|
25
|
+
SNAPSHOT_ARCHIVE = Path(__file__).parent / "data" / "osteosarc_snapshot_2026-09-18t.zip"
|
|
26
|
+
SNAPSHOT_ARCHIVE_SHA256 = "cbb688ca5cbe775fc4e6a826124f861d6d605c65e34473582c5d86853a6018fa"
|
|
27
|
+
|
|
21
28
|
|
|
22
29
|
@pytest.fixture(scope="module")
|
|
23
|
-
def dataset():
|
|
30
|
+
def dataset(tmp_path_factory):
|
|
24
31
|
snapshot = os.environ.get("OSTEOSARC_TEST_SNAPSHOT")
|
|
32
|
+
cache_root = os.environ.get("OSTEOSARC_TEST_CACHE")
|
|
25
33
|
if not snapshot:
|
|
26
|
-
pytest.
|
|
27
|
-
|
|
34
|
+
pytest.importorskip("osteosarc", reason="install .[test-data] on Python 3.10+")
|
|
35
|
+
# Hash before unpacking the trusted fixture into an isolated cache.
|
|
36
|
+
# Dataset.open additionally verifies every source receipt and object.
|
|
37
|
+
assert hashlib.sha256(SNAPSHOT_ARCHIVE.read_bytes()).hexdigest() == SNAPSHOT_ARCHIVE_SHA256
|
|
38
|
+
cache_root = tmp_path_factory.mktemp("osteosarc-snapshot")
|
|
39
|
+
with zipfile.ZipFile(SNAPSHOT_ARCHIVE) as archive:
|
|
40
|
+
archive.extractall(cache_root)
|
|
41
|
+
snapshot = SNAPSHOT_NAME
|
|
42
|
+
# Once an external snapshot is requested, missing dependencies/cache
|
|
43
|
+
# entries fail rather than skipping or falling back to the fixture.
|
|
28
44
|
from osteosarc import Cache, Dataset
|
|
29
45
|
|
|
30
46
|
assert version("osteosarc") == "0.1.4"
|
|
31
|
-
cache = Cache(
|
|
47
|
+
cache = Cache(cache_root, offline=True)
|
|
32
48
|
data = Dataset.open(snapshot, cache=cache, offline=True)
|
|
33
49
|
assert data.id == SNAPSHOT_ID
|
|
34
50
|
return data
|
|
@@ -101,8 +117,8 @@ def test_shared_cache_offline_reuse_and_integrity(dataset, tmp_path):
|
|
|
101
117
|
from osteosarc import Cache, Dataset, IntegrityError, OfflineError
|
|
102
118
|
from osteosarc.cache import Receipt
|
|
103
119
|
|
|
104
|
-
shared = Cache(
|
|
105
|
-
reopened = Dataset.open(
|
|
120
|
+
shared = Cache(dataset.cache.root, offline=True)
|
|
121
|
+
reopened = Dataset.open(dataset.manifest["name"],
|
|
106
122
|
cache=shared, offline=True)
|
|
107
123
|
assert reopened.id == dataset.id
|
|
108
124
|
receipt = Receipt(**dataset.variants().source["receipts"]["source_variants"])
|
|
@@ -463,7 +463,7 @@ def _translate_fused_cdna(fused_cdna, five_prime_transcript, five_prime_len,
|
|
|
463
463
|
def _build_fusion_mutant_transcript(
|
|
464
464
|
reference_transcript,
|
|
465
465
|
five_prime_transcript, five_prime_position,
|
|
466
|
-
three_prime_transcript, three_prime_position):
|
|
466
|
+
three_prime_transcript, three_prime_position, inserted_sequence=""):
|
|
467
467
|
"""Build a :class:`MutantTranscript` for a :class:`GeneFusion`
|
|
468
468
|
(#336).
|
|
469
469
|
|
|
@@ -471,7 +471,9 @@ def _build_fusion_mutant_transcript(
|
|
|
471
471
|
followed by the 3' partner's from its breakpoint on, each keeping
|
|
472
472
|
the base at its breakpoint. When the 5' partner's start codon lies
|
|
473
473
|
in the retained portion, the protein is translated through the
|
|
474
|
-
junction.
|
|
474
|
+
junction. Inserted bases are retained at exonic joins. At two intronic
|
|
475
|
+
breakpoints they are excluded under the reference-splicing assumption;
|
|
476
|
+
mixed exonic/intronic retention, or unknown insert sequence, is unresolved.
|
|
475
477
|
|
|
476
478
|
``reference_transcript`` is the transcript being annotated, which
|
|
477
479
|
may be either partner, so an effect and its mutant transcript
|
|
@@ -491,9 +493,6 @@ def _build_fusion_mutant_transcript(
|
|
|
491
493
|
five_prime_transcript, five_prime_position, True)
|
|
492
494
|
three_prime_start = _cdna_cut(
|
|
493
495
|
three_prime_transcript, three_prime_position, False)
|
|
494
|
-
fused_cdna = (
|
|
495
|
-
five_prime_cdna[:five_prime_end]
|
|
496
|
-
+ three_prime_cdna[three_prime_start:])
|
|
497
496
|
segments = (
|
|
498
497
|
ReferenceSegment(
|
|
499
498
|
source=five_prime_transcript, start=0, end=five_prime_end,
|
|
@@ -503,10 +502,35 @@ def _build_fusion_mutant_transcript(
|
|
|
503
502
|
start=three_prime_start, end=len(three_prime_cdna),
|
|
504
503
|
strand="+", label="3p_partner"),
|
|
505
504
|
)
|
|
505
|
+
evidence = {}
|
|
506
|
+
if inserted_sequence is None:
|
|
507
|
+
evidence["sequence_status"] = "unresolved_junction_insertion"
|
|
508
|
+
elif inserted_sequence:
|
|
509
|
+
exonic = [any(e.start <= pos <= e.end for e in t.exons)
|
|
510
|
+
for t, pos in ((five_prime_transcript, five_prime_position),
|
|
511
|
+
(three_prime_transcript, three_prime_position))]
|
|
512
|
+
evidence["junction_inserted_sequence"] = inserted_sequence
|
|
513
|
+
if all(exonic):
|
|
514
|
+
insertion = ReferenceSegment(
|
|
515
|
+
source=_AssembledAllele(inserted_sequence), start=0,
|
|
516
|
+
end=len(inserted_sequence), label="junction_insertion")
|
|
517
|
+
segments = segments[:1] + (insertion,) + segments[1:]
|
|
518
|
+
evidence["junction_insertion_status"] = "retained"
|
|
519
|
+
elif any(exonic):
|
|
520
|
+
evidence["sequence_status"] = "unresolved_insertion_retention"
|
|
521
|
+
else:
|
|
522
|
+
evidence["junction_insertion_status"] = "excluded_by_reference_splicing"
|
|
523
|
+
if "sequence_status" in evidence:
|
|
524
|
+
return MutantTranscript(
|
|
525
|
+
reference_transcript=reference_transcript,
|
|
526
|
+
reference_segments=segments, evidence=evidence,
|
|
527
|
+
annotator_name="structural_variant")
|
|
528
|
+
fused_cdna = "".join(s.source.sequence[s.start:s.end] for s in segments)
|
|
506
529
|
model = MutantTranscript(
|
|
507
530
|
reference_transcript=reference_transcript,
|
|
508
531
|
reference_segments=segments,
|
|
509
532
|
cdna_sequence=fused_cdna,
|
|
533
|
+
evidence=evidence,
|
|
510
534
|
annotator_name="structural_variant")
|
|
511
535
|
# Read Sec where a SECIS may remain; the change flags report whether
|
|
512
536
|
# that reading is certain.
|
|
@@ -862,6 +886,9 @@ def _fusion_across_junction(variant, transcript, assembly):
|
|
|
862
886
|
else:
|
|
863
887
|
five, five_position = partner, far.position
|
|
864
888
|
three, three_position = transcript, near.position
|
|
889
|
+
junction = (near, far) if five_prime else (far, near)
|
|
890
|
+
inserted = (variant.junction_inserted_sequence(junction)
|
|
891
|
+
if hasattr(variant, "junction_inserted_sequence") else None)
|
|
865
892
|
fusions.append(GeneFusion(
|
|
866
893
|
variant=variant,
|
|
867
894
|
transcript=transcript,
|
|
@@ -869,7 +896,8 @@ def _fusion_across_junction(variant, transcript, assembly):
|
|
|
869
896
|
five_prime_transcript=five,
|
|
870
897
|
three_prime_transcript=three,
|
|
871
898
|
mutant_transcript=assembly or _build_fusion_mutant_transcript(
|
|
872
|
-
transcript, five, five_position, three, three_position
|
|
899
|
+
transcript, five, five_position, three, three_position,
|
|
900
|
+
inserted_sequence=inserted)))
|
|
873
901
|
if not fusions:
|
|
874
902
|
return None
|
|
875
903
|
primary = fusions[0]
|
|
@@ -419,6 +419,42 @@ class StructuralVariant(Variant):
|
|
|
419
419
|
return (keeping_left, keeping_right)
|
|
420
420
|
return ()
|
|
421
421
|
|
|
422
|
+
def junction_inserted_sequence(self, junction):
|
|
423
|
+
"""Bases inserted while traversing ``junction[0]`` to ``junction[1]``.
|
|
424
|
+
|
|
425
|
+
The sequence is oriented away from the retained first end towards
|
|
426
|
+
the retained second end. Reciprocal records therefore give the same
|
|
427
|
+
answer for the same ordered junction. Paired events use their original
|
|
428
|
+
breakends, whose coordinates can differ from the combined span.
|
|
429
|
+
Conflicting or unreadable alleles return ``None``; ``""`` means no
|
|
430
|
+
insertion. Simple symbolic DEL/DUP/INV alleles have no insertion.
|
|
431
|
+
"""
|
|
432
|
+
from .nucleotides import reverse_complement
|
|
433
|
+
from .sv_allele_parser import breakend_inserted_sequence, breakend_sides
|
|
434
|
+
|
|
435
|
+
if junction not in self.junctions and junction[::-1] not in self.junctions:
|
|
436
|
+
raise ValueError("Junction does not belong to this variant")
|
|
437
|
+
sequences = set()
|
|
438
|
+
sources = getattr(self, "source_variants", ()) or (self,)
|
|
439
|
+
for source in sources:
|
|
440
|
+
sides = breakend_sides(source.symbolic_alt)
|
|
441
|
+
if sides is None:
|
|
442
|
+
if source.sv_type in {"DEL", "DUP", "INV"}:
|
|
443
|
+
sequences.add("")
|
|
444
|
+
continue
|
|
445
|
+
return None
|
|
446
|
+
if (junction not in source.junctions
|
|
447
|
+
and junction[::-1] not in source.junctions):
|
|
448
|
+
return None
|
|
449
|
+
inserted = breakend_inserted_sequence(source.ref, source.symbolic_alt)
|
|
450
|
+
if inserted is None:
|
|
451
|
+
return None
|
|
452
|
+
local = Breakend(source.contig, source.start, sides[0])
|
|
453
|
+
if (local.keeps == "right") != (local == junction[1]):
|
|
454
|
+
inserted = reverse_complement(inserted)
|
|
455
|
+
sequences.add(inserted)
|
|
456
|
+
return sequences.pop() if len(sequences) == 1 else None
|
|
457
|
+
|
|
422
458
|
@property
|
|
423
459
|
def breakpoints(self) -> Tuple[Tuple[str, int], ...]:
|
|
424
460
|
"""Distinct ``(contig, position)`` breakpoints of this variant's
|
|
@@ -89,6 +89,26 @@ def _breakend_local_side(alt):
|
|
|
89
89
|
return None
|
|
90
90
|
|
|
91
91
|
|
|
92
|
+
def breakend_inserted_sequence(ref, alt):
|
|
93
|
+
"""Inserted bases in the local forward strand, or ``None`` if unknown.
|
|
94
|
+
|
|
95
|
+
VCF 4.5 section 5.4.1 places the retained REF anchor before the insert
|
|
96
|
+
in a prefix ALT and after it in a suffix ALT. Only single-base anchors
|
|
97
|
+
are supported here: a longer replacement needs explicit reference-span
|
|
98
|
+
handling. An empty string denotes a known absence of inserted bases.
|
|
99
|
+
"""
|
|
100
|
+
sides = breakend_sides(alt)
|
|
101
|
+
if sides is None or not ref or len(ref) != 1:
|
|
102
|
+
return None
|
|
103
|
+
match = _BREAKEND_RE.match(alt)
|
|
104
|
+
ref = ref.upper()
|
|
105
|
+
if sides[0] == "left":
|
|
106
|
+
bases = match.group("prefix").upper()
|
|
107
|
+
return bases[1:] if bases.startswith(ref) else None
|
|
108
|
+
bases = match.group("suffix").upper()
|
|
109
|
+
return bases[:-1] if bases.endswith(ref) else None
|
|
110
|
+
|
|
111
|
+
|
|
92
112
|
def _extract_info(info, key):
|
|
93
113
|
"""Pull an INFO field value, handling list-of-ints from CIPOS /
|
|
94
114
|
CIEND and plain ints/strings otherwise. Returns ``None`` if
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "9.4.2"
|
|
@@ -33,6 +33,7 @@ tests/test_exonic_splice_site.py
|
|
|
33
33
|
tests/test_fast_path.py
|
|
34
34
|
tests/test_frameshift_cterminus_regression.py
|
|
35
35
|
tests/test_frameshift_helpers.py
|
|
36
|
+
tests/test_fusion_insertions.py
|
|
36
37
|
tests/test_fusion_partner_candidates.py
|
|
37
38
|
tests/test_genome_contig_validation.py
|
|
38
39
|
tests/test_genome_sequence.py
|
varcode-9.4.0/varcode/version.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "9.4.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|