varcode 9.3.3__tar.gz → 9.3.5__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.3.3/varcode.egg-info → varcode-9.3.5}/PKG-INFO +3 -1
- {varcode-9.3.3 → varcode-9.3.5}/pyproject.toml +1 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_annotator_divergence_scenarios.py +14 -0
- varcode-9.3.5/tests/test_osteosarc_dataset.py +69 -0
- varcode-9.3.5/tests/test_selenocysteine_proteins.py +248 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/annotators/protein_diff.py +7 -2
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/codon_tables.py +9 -1
- varcode-9.3.5/varcode/effects/selenocysteine.py +133 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/sequence_change.py +12 -59
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/structural.py +15 -6
- {varcode-9.3.3 → varcode-9.3.5}/varcode/mutant_transcript.py +21 -7
- {varcode-9.3.3 → varcode-9.3.5}/varcode/splice_outcomes.py +14 -10
- {varcode-9.3.3 → varcode-9.3.5}/varcode/transcript_layout.py +7 -2
- varcode-9.3.5/varcode/version.py +1 -0
- {varcode-9.3.3 → varcode-9.3.5/varcode.egg-info}/PKG-INFO +3 -1
- {varcode-9.3.3 → varcode-9.3.5}/varcode.egg-info/SOURCES.txt +3 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode.egg-info/requires.txt +5 -0
- varcode-9.3.3/varcode/version.py +0 -1
- {varcode-9.3.3 → varcode-9.3.5}/LICENSE +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/MANIFEST.in +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/README.md +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/requirements.txt +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/setup.cfg +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_annotator_parity_adversarial.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_annotators.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_bnd_retained_segments.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_cli_effects.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_cli_genes.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_cli_without_pkg_resources.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_collection_filtering.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_collection_variants_attr_consistency.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_common.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_cosmic_mutations.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_cryptic_exons.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_csv_roundtrip.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_dbnsfp_validation.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_default_structural_helpers.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_documentation_examples.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_effect_annotation_errors.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_effect_candidates.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_effect_classes.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_effect_collection.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_effect_collection_serialization.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_effect_collection_sort_order.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_effect_hypotheses.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_effects_from_mutagenix_variants.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_exacto_fusions.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_exonic_splice_site.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_fast_path.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_frameshift_cterminus_regression.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_frameshift_helpers.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_fusion_partner_candidates.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_genome_contig_validation.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_genome_sequence.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_genomic_layout.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_genotype.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_genotype_from_vcf.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_germline_context.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_germline_effects.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_haplotype_effect.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_maf.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_mitochondrial.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_mm10_klf6_frameshift.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_mouse.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_mutant_transcript.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_mutate.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_no_duplicate_variants.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_nonlocal_sv_transcripts.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_osteosarc_fusions.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_partial_annotators.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_premature_stop_short_description.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_problematic_variants.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_protein_diff_parity.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_read_phase_resolver.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_real_world_callers.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_reference.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_reference_mismatch_error.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_reference_segments.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_rna_evidence.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_rna_haplotype_sequences.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_rna_read_phasing_source.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_selenocysteine.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_silent_aa_pos.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_silent_hgvs_description.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_splice_graph.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_splice_outcomes.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_splice_site_effects.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_stop_codon_classification_bugs.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_string_helpers.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_structural_variant_annotator.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_structural_variants.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_sv_selenocysteine.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_sv_sequence_changes.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_sv_tabular_metadata.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_symbolic_alleles.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_symbolic_sv_padding.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_timings.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_transcript_layout.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_transcript_model.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_transforms_left_align.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_transforms_pair_breakends.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_variant.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_variant_collection.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_vcf.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_vcf_output.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_vcf_parsing.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_vcf_phase_resolver.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/tests/test_vcf_spec_examples.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/__init__.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/annotators/__init__.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/annotators/fast.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/annotators/registry.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/cli/__init__.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/cli/effects_script.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/cli/genes_script.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/cli/logging.conf +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/cli/variant_args.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/cli/version_info.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/common.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/cryptic_exons.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/csv_helpers.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effect_candidates.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effect_hypotheses.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/__init__.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/classify.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/common.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/effect_classes.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/effect_collection.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/effect_helpers.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/effect_ordering.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/effect_prediction.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/effect_prediction_coding.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/effect_prediction_coding_frameshift.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/effect_prediction_coding_in_frame.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/fast_path.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/mutate.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/transcript_helpers.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/effects/translate.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/errors.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/exacto.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/genome.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/genome_sequence.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/genomic_layout.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/genotype.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/germline.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/maf.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/nucleotides.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/phasing.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/realized_effects.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/reference.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/rna_evidence.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/rna_read_phasing.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/splice_graph.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/string_helpers.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/structural_variant.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/sv_allele_parser.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/transcript_model.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/transforms/__init__.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/ucsc_reference_names.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/util.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/variant.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/variant_collection.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/vcf.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/vcf_output.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode/vcf_parsing.py +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode.egg-info/dependency_links.txt +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode.egg-info/entry_points.txt +0 -0
- {varcode-9.3.3 → varcode-9.3.5}/varcode.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: varcode
|
|
3
|
-
Version: 9.3.
|
|
3
|
+
Version: 9.3.5
|
|
4
4
|
Summary: Variant annotation in Python
|
|
5
5
|
Author-email: Alex Rubinsteyn <alex.rubinsteyn@unc.edu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/openvax/varcode
|
|
@@ -23,6 +23,8 @@ Requires-Dist: serializable>=1.1.0
|
|
|
23
23
|
Requires-Dist: sercol>=0.1.4
|
|
24
24
|
Provides-Extra: rna
|
|
25
25
|
Requires-Dist: pysam>=0.21; extra == "rna"
|
|
26
|
+
Provides-Extra: test-data
|
|
27
|
+
Requires-Dist: osteosarc==0.1.0; python_version >= "3.10" and extra == "test-data"
|
|
26
28
|
Dynamic: license-file
|
|
27
29
|
|
|
28
30
|
[](https://github.com/openvax/varcode/actions/workflows/tests.yml)
|
|
@@ -331,6 +331,20 @@ def test_alternate_start_codon_atg_to_ctg_agrees(dual_annotator):
|
|
|
331
331
|
assert effect.short_description == "alternate-start-codon (ATG>CTG)"
|
|
332
332
|
|
|
333
333
|
|
|
334
|
+
@pytest.mark.parametrize("alt", ["CAG", "CAA", "CAT", "TTT"])
|
|
335
|
+
def test_insertion_before_retained_start_codon_is_five_prime_utr(alt):
|
|
336
|
+
from varcode.mutant_transcript import apply_variant_to_transcript
|
|
337
|
+
|
|
338
|
+
t = ensembl_grch38.transcript_by_id(BRCA1_ID)
|
|
339
|
+
variant = Variant("17", 43124096, "", alt, ensembl_grch38)
|
|
340
|
+
mt = apply_variant_to_transcript(variant, t)
|
|
341
|
+
assert mt.mutant_protein_sequence == t.protein_sequence
|
|
342
|
+
effect = _PDIFF.annotate_on_transcript(variant, t)
|
|
343
|
+
assert isinstance(effect, FivePrimeUTR)
|
|
344
|
+
assert effect.modifies_coding_sequence is False
|
|
345
|
+
assert effect.modifies_protein_sequence is False
|
|
346
|
+
|
|
347
|
+
|
|
334
348
|
def test_divergence_frameshift_immediate_stop():
|
|
335
349
|
"""Frameshift that creates a stop codon at (or very near) the
|
|
336
350
|
insertion point. Fast may report FrameShift with a short
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Opt-in, offline checks against the pinned public osteosarc snapshot.
|
|
2
|
+
|
|
3
|
+
See tests/README.md for acquisition and invocation. Source annotations are
|
|
4
|
+
provenance, not an independent oracle for protein consequences.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
from importlib.metadata import version
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
from pyensembl import cached_release
|
|
12
|
+
|
|
13
|
+
from varcode import Variant
|
|
14
|
+
from varcode.mutant_transcript import apply_variant_to_transcript
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
SNAPSHOT_ID = "9b34ea0e13f9c1c35c3c88b7e646c0e608b86a143dee0e668bf3f74b909f815c"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@pytest.fixture(scope="module")
|
|
21
|
+
def dataset():
|
|
22
|
+
snapshot = os.environ.get("OSTEOSARC_TEST_SNAPSHOT")
|
|
23
|
+
if not snapshot:
|
|
24
|
+
pytest.skip("set OSTEOSARC_TEST_SNAPSHOT to enable the offline corpus checks")
|
|
25
|
+
# Once explicitly requested, missing dependencies/cache entries must fail.
|
|
26
|
+
from osteosarc import Cache, Dataset
|
|
27
|
+
|
|
28
|
+
assert version("osteosarc") == "0.1.0"
|
|
29
|
+
cache = Cache(os.environ.get("OSTEOSARC_TEST_CACHE"), offline=True)
|
|
30
|
+
data = Dataset.open(snapshot, cache=cache, offline=True)
|
|
31
|
+
assert data.id == SNAPSHOT_ID
|
|
32
|
+
return data
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_osteosarc_native_variants_preserve_alleles_and_provenance(dataset):
|
|
36
|
+
entries = dataset.variants(status="ready")
|
|
37
|
+
assert len(dataset.variants()) == 182
|
|
38
|
+
assert len(entries) == 177
|
|
39
|
+
genome = cached_release(81)
|
|
40
|
+
native = entries.to_varcode(genome=genome)
|
|
41
|
+
expected_ids = {entry.id for entry in entries}
|
|
42
|
+
actual_ids = set()
|
|
43
|
+
for variant in native:
|
|
44
|
+
assert variant.genome is genome
|
|
45
|
+
metadata = native.metadata[variant]
|
|
46
|
+
assert metadata["source"]["snapshot_id"] == SNAPSHOT_ID
|
|
47
|
+
assert metadata["source"]["receipts"]
|
|
48
|
+
for entry in metadata["entries"]:
|
|
49
|
+
actual_ids.add(entry["id"])
|
|
50
|
+
contig, position, ref, alt = entries[entry["id"]].allele
|
|
51
|
+
assert variant == Variant(contig.removeprefix("chr"), position, ref, alt, genome)
|
|
52
|
+
assert actual_ids == expected_ids
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_osteosarc_corrected_map2_is_a_distinct_complex_allele(dataset):
|
|
56
|
+
entry = dataset.variants()["MAP2-chr2-209694768"]
|
|
57
|
+
assert entry.allele == (
|
|
58
|
+
"chr2", 209694768, "CCTGGGCTACTGTGTGTTCAATAAGTACACAGT", "CAGGG")
|
|
59
|
+
assert "allele-MAP2-chr2-209694768" in entry.annotations["corrections"]
|
|
60
|
+
genome = cached_release(81)
|
|
61
|
+
selected = dataset.variants().select(ids=entry.id).to_varcode(genome=genome)
|
|
62
|
+
variant, = selected
|
|
63
|
+
old_deletion = Variant("2", 209694768, "CCTGGGCTACTGTGTGTTCAATA", "C", genome)
|
|
64
|
+
assert variant != old_deletion
|
|
65
|
+
t = genome.transcript_by_id("ENST00000360351")
|
|
66
|
+
model = apply_variant_to_transcript(variant, t)
|
|
67
|
+
assert model is not None
|
|
68
|
+
assert model.mutant_protein_sequence is not None
|
|
69
|
+
assert model.mutant_protein_sequence != t.protein_sequence
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"""Stored mutant proteins read annotated selenocysteine UGA codons (#470).
|
|
2
|
+
|
|
3
|
+
Ensembl marks Sec as U in the reference protein. Translators read those codons
|
|
4
|
+
as Sec unless the mutant keeps no selenoprotein 3' UTR, where the SECIS element
|
|
5
|
+
lies. Also covers the CDS start shifted by upstream 5' UTR edits (#471).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
from pyensembl import cached_release
|
|
10
|
+
|
|
11
|
+
from varcode import StructuralVariant, TranscriptEdit, Variant
|
|
12
|
+
from varcode.effects import GeneFusion, PrematureStop
|
|
13
|
+
from varcode.effects import structural
|
|
14
|
+
from varcode.effects.codon_tables import translate_sequence
|
|
15
|
+
from varcode.effects.selenocysteine import (
|
|
16
|
+
edited_selenocysteine,
|
|
17
|
+
layout_selenocysteine,
|
|
18
|
+
reference_selenocysteine,
|
|
19
|
+
)
|
|
20
|
+
from varcode.effects.sequence_change import structural_sequence_changes
|
|
21
|
+
from varcode.genomic_layout import GenomicLayout, LayoutSegment
|
|
22
|
+
from varcode.mutant_transcript import apply_variant_to_transcript, apply_variants_to_transcript
|
|
23
|
+
from varcode.splice_outcomes import _build_exon_skip_mutant_transcript
|
|
24
|
+
from varcode.transcript_layout import realize_exon_path
|
|
25
|
+
from varcode.transcript_model import _provider_for_genome
|
|
26
|
+
|
|
27
|
+
# GPX1 (-), GPX4 (+), SEPP1 (-, ten Sec), TXNRD1 (+, Sec is the penultimate residue).
|
|
28
|
+
SELENOPROTEINS = ["ENST00000419783", "ENST00000354171", "ENST00000514985", "ENST00000525566"]
|
|
29
|
+
COMPLEMENT = dict(zip("ACGT", "TGCA"))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _transcript(transcript_id):
|
|
33
|
+
return cached_release(81).transcript_by_id(transcript_id)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _genomic(transcript, offset):
|
|
37
|
+
for exon in transcript.exons:
|
|
38
|
+
length = exon.end - exon.start + 1
|
|
39
|
+
if offset < length:
|
|
40
|
+
return exon.end - offset if transcript.strand == "-" else exon.start + offset
|
|
41
|
+
offset -= length
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _variant(transcript, offset, ref, alt):
|
|
45
|
+
"""A variant given in transcript orientation at a cDNA offset."""
|
|
46
|
+
if transcript.strand == "-":
|
|
47
|
+
ref = "".join(COMPLEMENT[b] for b in reversed(ref))
|
|
48
|
+
alt = "".join(COMPLEMENT[b] for b in reversed(alt))
|
|
49
|
+
position = _genomic(transcript, offset + len(ref) - 1)
|
|
50
|
+
else:
|
|
51
|
+
position = _genomic(transcript, offset)
|
|
52
|
+
return Variant(transcript.contig, position, ref, alt, transcript.genome)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _snv(transcript, residue, base, alt):
|
|
56
|
+
offset = min(transcript.start_codon_spliced_offsets) + 3 * residue + base
|
|
57
|
+
return _variant(transcript, offset, transcript.sequence[offset], alt)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _cases(transcript):
|
|
61
|
+
"""Point variants at, before, and after the first Sec codon."""
|
|
62
|
+
u = transcript.protein_sequence.index("U")
|
|
63
|
+
start = min(transcript.start_codon_spliced_offsets)
|
|
64
|
+
|
|
65
|
+
def codon(i):
|
|
66
|
+
return transcript.sequence[start + 3 * i:start + 3 * i + 3]
|
|
67
|
+
|
|
68
|
+
def other(base):
|
|
69
|
+
return "A" if base != "A" else "C"
|
|
70
|
+
|
|
71
|
+
silent = next(i for i in range(u + 1, len(transcript.protein_sequence))
|
|
72
|
+
if codon(i)[:2] in ("CT", "GT", "TC", "CC", "AC", "GC", "CG", "GG"))
|
|
73
|
+
return {
|
|
74
|
+
"sec_to_trp": _snv(transcript, u, 2, "G"),
|
|
75
|
+
"before_sec": _snv(transcript, 10, 1, other(codon(10)[1])),
|
|
76
|
+
"after_sec": _snv(transcript, u + 1, 1, other(codon(u + 1)[1])),
|
|
77
|
+
"silent_after_sec": _snv(transcript, silent, 2, other(codon(silent)[2])),
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_translate_sequence_reads_listed_tga_as_selenocysteine():
|
|
82
|
+
assert translate_sequence("ATGTGAGGCTAA") == "M"
|
|
83
|
+
assert translate_sequence("ATGTGAGGCTAA", selenocysteine={3}) == "MUG"
|
|
84
|
+
# Only a TGA at a listed codon offset is read as Sec.
|
|
85
|
+
assert translate_sequence("ATGTAAGGC", selenocysteine={3}) == "M"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@pytest.mark.parametrize("transcript_id", SELENOPROTEINS)
|
|
89
|
+
@pytest.mark.parametrize("case", ["sec_to_trp", "before_sec", "after_sec", "silent_after_sec"])
|
|
90
|
+
@pytest.mark.parametrize("annotator", ["protein_diff", "transcript_model"])
|
|
91
|
+
def test_annotators_agree_with_fast_on_selenoproteins(transcript_id, case, annotator):
|
|
92
|
+
t = _transcript(transcript_id)
|
|
93
|
+
variant = _cases(t)[case]
|
|
94
|
+
expected = variant.effect_on_transcript(t, annotator="fast")
|
|
95
|
+
effect = variant.effect_on_transcript(t, annotator=annotator)
|
|
96
|
+
assert (type(effect), effect.short_description) == (type(expected), expected.short_description)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_gpx1_calls_are_pinned():
|
|
100
|
+
t = _transcript("ENST00000419783")
|
|
101
|
+
for annotator in ("fast", "protein_diff", "transcript_model"):
|
|
102
|
+
assert _snv(t, 48, 2, "G").effect_on_transcript(
|
|
103
|
+
t, annotator=annotator).short_description == "p.U49W"
|
|
104
|
+
assert _snv(t, 53, 0, "T").effect_on_transcript(
|
|
105
|
+
t, annotator=annotator).short_description == "p.R54W"
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@pytest.mark.parametrize("transcript_id", SELENOPROTEINS)
|
|
109
|
+
def test_stored_protein_continues_past_selenocysteine(transcript_id):
|
|
110
|
+
t = _transcript(transcript_id)
|
|
111
|
+
mt = apply_variant_to_transcript(_cases(t)["after_sec"], t)
|
|
112
|
+
protein = mt.mutant_protein_sequence
|
|
113
|
+
assert len(protein) == len(t.protein_sequence)
|
|
114
|
+
assert [i for i, aa in enumerate(protein) if aa == "U"] == [
|
|
115
|
+
i for i, aa in enumerate(t.protein_sequence) if aa == "U"]
|
|
116
|
+
assert sum(a != b for a, b in zip(protein, t.protein_sequence)) == 1
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def test_edited_selenocysteine_codon_is_translated_literally():
|
|
120
|
+
t = _transcript("ENST00000354171")
|
|
121
|
+
sec, = reference_selenocysteine(t)
|
|
122
|
+
assert edited_selenocysteine(t, ()) == {sec}
|
|
123
|
+
assert edited_selenocysteine(t, (TranscriptEdit(sec + 2, sec + 3, "G"),)) == set()
|
|
124
|
+
assert edited_selenocysteine(t, (TranscriptEdit(sec + 1, sec + 1, "A"),)) == set()
|
|
125
|
+
# A 5' UTR deletion shifts the codon; an insertion at its first base precedes it.
|
|
126
|
+
assert edited_selenocysteine(t, (TranscriptEdit(10, 12, ""),)) == {sec - 2}
|
|
127
|
+
assert edited_selenocysteine(t, (TranscriptEdit(sec, sec, "AAA"),)) == {sec + 3}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def test_insertion_disrupting_sec_codon_creates_a_stop():
|
|
131
|
+
t = _transcript("ENST00000354171")
|
|
132
|
+
variant = Variant("19", 1105403, "", "GAC", t.genome)
|
|
133
|
+
layout = GenomicLayout.from_transcript(
|
|
134
|
+
t, sequence_provider=_provider_for_genome(t.genome))
|
|
135
|
+
product = realize_exon_path(t, layout.apply_point_variant(variant))
|
|
136
|
+
# The new TGA retains only the annotated Sec codon's first base.
|
|
137
|
+
assert product.protein_sequence == t.protein_sequence[:72]
|
|
138
|
+
for annotator in ("fast", "protein_diff", "transcript_model"):
|
|
139
|
+
effect = variant.effect_on_transcript(t, annotator=annotator)
|
|
140
|
+
assert isinstance(effect, PrematureStop)
|
|
141
|
+
assert effect.short_description == "p.U73*"
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@pytest.mark.parametrize("transcript_id", SELENOPROTEINS[:2])
|
|
145
|
+
@pytest.mark.parametrize("change", [
|
|
146
|
+
"intact", "inserted", "deleted", "inverted", "foreign", "truncated", "duplicated",
|
|
147
|
+
])
|
|
148
|
+
def test_layout_sec_requires_three_contiguous_origins(transcript_id, change):
|
|
149
|
+
t = _transcript(transcript_id)
|
|
150
|
+
sec, = reference_selenocysteine(t)
|
|
151
|
+
utr = max(t.stop_codon_spliced_offsets) + 1
|
|
152
|
+
|
|
153
|
+
def base(offset, contig=None, kind="reference"):
|
|
154
|
+
position = _genomic(t, offset)
|
|
155
|
+
return LayoutSegment(
|
|
156
|
+
contig or t.contig, position, position, strand=t.strand,
|
|
157
|
+
sequence=t.sequence[offset], origin_kind=kind)
|
|
158
|
+
|
|
159
|
+
segments = [base(sec + i) for i in range(3)]
|
|
160
|
+
expected = {0}
|
|
161
|
+
if change == "inserted":
|
|
162
|
+
segments.insert(1, LayoutSegment(None, None, None, sequence="GA"))
|
|
163
|
+
expected = set()
|
|
164
|
+
elif change == "deleted":
|
|
165
|
+
segments = [segments[0], base(sec + 3), base(sec + 4)]
|
|
166
|
+
expected = set()
|
|
167
|
+
elif change in ("inverted", "foreign"):
|
|
168
|
+
segments[1] = base(sec + 1, kind="inverted") if change == "inverted" else base(sec + 1, contig="other")
|
|
169
|
+
expected = set()
|
|
170
|
+
elif change == "truncated":
|
|
171
|
+
segments = segments[:2]
|
|
172
|
+
expected = set()
|
|
173
|
+
elif change == "duplicated":
|
|
174
|
+
segments += [base(sec + i, kind="duplicated") for i in range(3)]
|
|
175
|
+
expected = {0, 3}
|
|
176
|
+
segments.append(base(utr))
|
|
177
|
+
# Preserve continuity across layout boundaries, including on the minus strand.
|
|
178
|
+
layouts = tuple(GenomicLayout((segment,)) for segment in segments)
|
|
179
|
+
assert layout_selenocysteine(t, layouts) == expected
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def test_deleting_the_whole_three_prime_utr_leaves_uga_a_stop():
|
|
183
|
+
t = _transcript("ENST00000354171")
|
|
184
|
+
utr = max(t.stop_codon_spliced_offsets) + 1
|
|
185
|
+
assert edited_selenocysteine(t, (TranscriptEdit(utr, len(t.sequence), ""),)) == set()
|
|
186
|
+
assert edited_selenocysteine(t, (TranscriptEdit(utr, len(t.sequence) - 1, ""),))
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
@pytest.mark.parametrize("transcript_id", ["ENST00000003084", "ENST00000354171"])
|
|
190
|
+
def test_joint_translation_follows_a_five_prime_utr_indel(transcript_id):
|
|
191
|
+
# #471: a 5' UTR deletion shifts the CDS start in the mutant cDNA.
|
|
192
|
+
t = _transcript(transcript_id)
|
|
193
|
+
start = min(t.start_codon_spliced_offsets)
|
|
194
|
+
utr = start // 2
|
|
195
|
+
deletion = _variant(t, utr, t.sequence[utr:utr + 2], t.sequence[utr])
|
|
196
|
+
missense = _snv(t, 1, 1, "A" if t.sequence[start + 4] != "A" else "C")
|
|
197
|
+
alone = apply_variant_to_transcript(missense, t).mutant_protein_sequence
|
|
198
|
+
joint = apply_variants_to_transcript([deletion, missense], t)
|
|
199
|
+
assert joint.mutant_protein_sequence == alone
|
|
200
|
+
assert len(alone) == len(t.protein_sequence)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@pytest.mark.parametrize("transcript_id,index", [
|
|
204
|
+
("ENST00000514985", 2), # SEPP1 (-): between its first and second Sec
|
|
205
|
+
("ENST00000525566", 15), # TXNRD1 (+): just upstream of its Sec
|
|
206
|
+
])
|
|
207
|
+
def test_exon_skipping_keeps_selenocysteine(transcript_id, index):
|
|
208
|
+
t = _transcript(transcript_id)
|
|
209
|
+
exon = t.exons[index]
|
|
210
|
+
variant = StructuralVariant(t.contig, exon.start, "DEL", end=exon.end, genome=t.genome)
|
|
211
|
+
mt = _build_exon_skip_mutant_transcript(variant, t, exon)
|
|
212
|
+
skipped = (exon.end - exon.start + 1) // 3
|
|
213
|
+
assert mt.mutant_protein_sequence.count("U") == t.protein_sequence.count("U")
|
|
214
|
+
assert len(mt.mutant_protein_sequence) == len(t.protein_sequence) - skipped
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def _fusion(five_prime, five_prime_position, three_prime, three_prime_position):
|
|
218
|
+
model = structural._build_fusion_mutant_transcript(
|
|
219
|
+
five_prime, five_prime, five_prime_position, three_prime, three_prime_position)
|
|
220
|
+
variant = StructuralVariant(five_prime.contig, five_prime_position, "BND",
|
|
221
|
+
genome=five_prime.genome)
|
|
222
|
+
return model, GeneFusion(variant, five_prime, three_prime, mutant_transcript=model)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def test_fused_selenoprotein_three_prime_partner_keeps_selenocysteine():
|
|
226
|
+
# The 3' partner brings its own 3' UTR, and so its SECIS.
|
|
227
|
+
cftr, gpx4 = _transcript("ENST00000003084"), _transcript("ENST00000354171")
|
|
228
|
+
model, _ = _fusion(cftr, cftr.exons[4].end, gpx4, gpx4.exons[1].start)
|
|
229
|
+
protein = model.mutant_protein_sequence
|
|
230
|
+
assert "U" in protein
|
|
231
|
+
assert protein.endswith(gpx4.protein_sequence[-20:])
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def test_fusion_in_five_prime_partner_utr_keeps_reference_protein_but_flags_unknown():
|
|
235
|
+
gpx4, cftr = _transcript("ENST00000354171"), _transcript("ENST00000003084")
|
|
236
|
+
model, effect = _fusion(gpx4, gpx4.end - 10, cftr, cftr.end - 10)
|
|
237
|
+
assert model.mutant_protein_sequence == gpx4.protein_sequence
|
|
238
|
+
# Whether the kept part of the 3' UTR still holds the SECIS is unknown.
|
|
239
|
+
assert structural_sequence_changes(effect) == (False, None)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def test_fusion_that_drops_the_selenoprotein_utr_stops_at_selenocysteine():
|
|
243
|
+
gpx4, cftr = _transcript("ENST00000354171"), _transcript("ENST00000003084")
|
|
244
|
+
sec, = reference_selenocysteine(gpx4)
|
|
245
|
+
breakpoint = _genomic(gpx4, sec + 30)
|
|
246
|
+
model, effect = _fusion(gpx4, breakpoint, cftr, cftr.end - 10)
|
|
247
|
+
assert model.mutant_protein_sequence == gpx4.protein_sequence[:gpx4.protein_sequence.index("U")]
|
|
248
|
+
assert effect.modifies_protein_sequence is True
|
|
@@ -55,7 +55,7 @@ from ..effects.effect_classes import (
|
|
|
55
55
|
NoncodingTranscript,
|
|
56
56
|
ThreePrimeUTR,
|
|
57
57
|
)
|
|
58
|
-
from ..mutant_transcript import apply_variant_to_transcript
|
|
58
|
+
from ..mutant_transcript import _mutant_cds_start, apply_variant_to_transcript
|
|
59
59
|
from ..version import __version__ as _varcode_version
|
|
60
60
|
from .fast import FastEffectAnnotator
|
|
61
61
|
|
|
@@ -163,8 +163,9 @@ class ProteinDiffEffectAnnotator:
|
|
|
163
163
|
cds_start = min(transcript.start_codon_spliced_offsets)
|
|
164
164
|
ref_first_codon = str(
|
|
165
165
|
transcript.sequence)[cds_start:cds_start + 3]
|
|
166
|
+
mutant_cds_start = _mutant_cds_start(transcript, mt.edits)
|
|
166
167
|
mut_first_codon = mt.cdna_sequence[
|
|
167
|
-
|
|
168
|
+
mutant_cds_start:mutant_cds_start + 3].upper()
|
|
168
169
|
if (mut_first_codon != ref_first_codon
|
|
169
170
|
and mut_protein
|
|
170
171
|
and mut_protein[0] != "M"
|
|
@@ -178,6 +179,10 @@ class ProteinDiffEffectAnnotator:
|
|
|
178
179
|
# both here because the shared classifier doesn't have
|
|
179
180
|
# access to the cDNA edit offset for the correct aa_pos.
|
|
180
181
|
if ref_protein == mut_protein:
|
|
182
|
+
# An insertion immediately before the retained start can have a
|
|
183
|
+
# CDS anchor on the minus strand, but only changes the 5' UTR.
|
|
184
|
+
if mt.edits and all(e.cdna_end <= cds_start for e in mt.edits):
|
|
185
|
+
return FivePrimeUTR(variant, transcript)
|
|
181
186
|
if ref_first_codon != mut_first_codon:
|
|
182
187
|
codon_table = codon_table_for_transcript(transcript)
|
|
183
188
|
if mut_first_codon in codon_table.start_codons:
|
|
@@ -117,7 +117,8 @@ def codon_table_for_transcript(transcript):
|
|
|
117
117
|
def translate_sequence(
|
|
118
118
|
nucleotide_sequence,
|
|
119
119
|
codon_table=STANDARD,
|
|
120
|
-
to_stop=True
|
|
120
|
+
to_stop=True,
|
|
121
|
+
selenocysteine=()):
|
|
121
122
|
"""Translate a cDNA string to amino acids using ``codon_table``.
|
|
122
123
|
|
|
123
124
|
Parameters
|
|
@@ -130,6 +131,10 @@ def translate_sequence(
|
|
|
130
131
|
If True (default), stop translation at the first stop codon and
|
|
131
132
|
return the protein up to (but not including) the stop. If False,
|
|
132
133
|
include ``'*'`` characters for in-sequence stops.
|
|
134
|
+
selenocysteine : collection of int
|
|
135
|
+
Offsets into ``nucleotide_sequence`` of TGA codons to read as
|
|
136
|
+
selenocysteine (``'U'``), e.g. annotated Sec codons whose SECIS
|
|
137
|
+
element is retained. See :mod:`varcode.effects.selenocysteine`.
|
|
133
138
|
"""
|
|
134
139
|
seq = str(nucleotide_sequence).upper()
|
|
135
140
|
if len(seq) % 3 != 0:
|
|
@@ -141,6 +146,9 @@ def translate_sequence(
|
|
|
141
146
|
result = []
|
|
142
147
|
for i in range(0, len(seq), 3):
|
|
143
148
|
codon = seq[i:i + 3]
|
|
149
|
+
if codon == "TGA" and i in selenocysteine:
|
|
150
|
+
result.append("U")
|
|
151
|
+
continue
|
|
144
152
|
if codon in stops:
|
|
145
153
|
if to_stop:
|
|
146
154
|
break
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
# you may not use this file except in compliance with the License.
|
|
3
|
+
# You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and
|
|
11
|
+
# limitations under the License.
|
|
12
|
+
|
|
13
|
+
"""Where annotated selenocysteine UGA codons survive in a mutant cDNA.
|
|
14
|
+
|
|
15
|
+
Ensembl marks selenocysteine (Sec) as U in the reference protein, on an
|
|
16
|
+
in-frame UGA. UGA encodes Sec only with a SECIS element in the same mRNA's
|
|
17
|
+
3' UTR, and SECIS positions aren't annotated. Translators read these codons
|
|
18
|
+
as Sec unless the mutant keeps no selenoprotein 3' UTR at all. The SV change
|
|
19
|
+
flags also treat a partly kept 3' UTR as uncertain; one stored protein
|
|
20
|
+
follows the reference reading.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def reference_selenocysteine(transcript):
|
|
25
|
+
"""cDNA offsets of the first base of each annotated Sec codon."""
|
|
26
|
+
protein = getattr(transcript, "protein_sequence", None)
|
|
27
|
+
if not protein or "U" not in protein or not getattr(transcript, "complete", False):
|
|
28
|
+
return ()
|
|
29
|
+
start = min(transcript.start_codon_spliced_offsets)
|
|
30
|
+
return tuple(start + 3 * i for i, aa in enumerate(protein) if aa == "U")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _three_prime_utr_start(transcript):
|
|
34
|
+
return max(transcript.stop_codon_spliced_offsets) + 1
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def edit_shift(offset, edits):
|
|
38
|
+
"""Net length change from edits wholly upstream of reference ``offset``."""
|
|
39
|
+
return sum(len(e.alt_bases) - (e.cdna_end - e.cdna_start)
|
|
40
|
+
for e in edits if e.cdna_end <= offset)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def edited_selenocysteine(transcript, edits):
|
|
44
|
+
"""Mutant cDNA offsets of annotated Sec codons that no edit touches.
|
|
45
|
+
|
|
46
|
+
For a reference cDNA with point-level edits. Empty when the edits delete
|
|
47
|
+
the transcript's whole 3' UTR, since no SECIS can remain.
|
|
48
|
+
"""
|
|
49
|
+
offsets = reference_selenocysteine(transcript)
|
|
50
|
+
if not offsets:
|
|
51
|
+
return set()
|
|
52
|
+
utr_start, utr_end = _three_prime_utr_start(transcript), len(transcript.sequence)
|
|
53
|
+
deleted = sum(max(0, min(e.cdna_end, utr_end) - max(e.cdna_start, utr_start))
|
|
54
|
+
for e in edits)
|
|
55
|
+
if utr_end > utr_start and deleted == utr_end - utr_start:
|
|
56
|
+
return set()
|
|
57
|
+
return {ref + edit_shift(ref, edits) for ref in offsets
|
|
58
|
+
if not any((e.cdna_start < ref + 3 and ref < e.cdna_end)
|
|
59
|
+
or ref < e.cdna_start == e.cdna_end < ref + 3 for e in edits)}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def segment_selenocysteine(model):
|
|
63
|
+
"""Observed offsets of TGA codons mapped by segments onto annotated Sec codons.
|
|
64
|
+
|
|
65
|
+
Return ``(decoded, uncertain, terminating)``: a codon is decoded where the
|
|
66
|
+
model keeps its transcript contiguously from that codon through the 3'
|
|
67
|
+
end. With no selenoprotein 3' UTR sequence at all there is no SECIS, so
|
|
68
|
+
UGA terminates. Otherwise decoding is unknown. None when segments don't
|
|
69
|
+
render the cDNA or point edits are overlaid.
|
|
70
|
+
"""
|
|
71
|
+
sequence = model.cdna_sequence
|
|
72
|
+
segments = model.reference_segments or ()
|
|
73
|
+
if (sequence is None or model.edits
|
|
74
|
+
or sum(s.length for s in segments) != len(sequence)):
|
|
75
|
+
return None
|
|
76
|
+
runs, offset = [], 0
|
|
77
|
+
for segment in segments:
|
|
78
|
+
if segment.strand == "+":
|
|
79
|
+
last = runs[-1] if runs else None
|
|
80
|
+
if (last and last[0] == segment.source and last[2] == segment.start
|
|
81
|
+
and last[3] + last[2] - last[1] == offset):
|
|
82
|
+
last[2] = segment.end # A split that continues the same reference.
|
|
83
|
+
else:
|
|
84
|
+
runs.append([segment.source, segment.start, segment.end, offset])
|
|
85
|
+
offset += segment.length
|
|
86
|
+
decoded, uncertain = set(), set()
|
|
87
|
+
secis_possible = False
|
|
88
|
+
for source, ref_start, ref_end, observed in runs:
|
|
89
|
+
selenocysteine = reference_selenocysteine(source)
|
|
90
|
+
if selenocysteine and ref_end > _three_prime_utr_start(source):
|
|
91
|
+
secis_possible = True
|
|
92
|
+
for ref in selenocysteine:
|
|
93
|
+
pos = observed + ref - ref_start
|
|
94
|
+
if (ref_start <= ref and ref + 3 <= ref_end
|
|
95
|
+
and sequence[pos:pos + 3].upper() == "TGA"):
|
|
96
|
+
(decoded if ref_end == len(source.sequence) else uncertain).add(pos)
|
|
97
|
+
if not secis_possible:
|
|
98
|
+
return decoded, set(), uncertain
|
|
99
|
+
return decoded, uncertain, set()
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def layout_selenocysteine(transcript, layouts):
|
|
103
|
+
"""cDNA offsets of annotated Sec codons in concatenated genomic layouts.
|
|
104
|
+
|
|
105
|
+
Each layout exposes ``origins()`` as ``(contig, position, kind)`` per base,
|
|
106
|
+
in transcript orientation. All three bases must map consecutively to the
|
|
107
|
+
annotated codon, including across layout boundaries. Empty when no base
|
|
108
|
+
of an annotated 3' UTR remains.
|
|
109
|
+
"""
|
|
110
|
+
offsets = set(reference_selenocysteine(transcript))
|
|
111
|
+
if not offsets:
|
|
112
|
+
return set()
|
|
113
|
+
utr_start = _three_prime_utr_start(transcript)
|
|
114
|
+
found, index = set(), 0
|
|
115
|
+
previous = (None, None)
|
|
116
|
+
utr_present = utr_start >= len(transcript.sequence)
|
|
117
|
+
for layout in layouts:
|
|
118
|
+
for contig, position, kind in layout.origins():
|
|
119
|
+
reference = None
|
|
120
|
+
if contig == transcript.contig and kind != "inverted":
|
|
121
|
+
try:
|
|
122
|
+
reference = transcript.spliced_offset(position)
|
|
123
|
+
except ValueError:
|
|
124
|
+
reference = None
|
|
125
|
+
if reference is not None:
|
|
126
|
+
if (reference - 2 in offsets
|
|
127
|
+
and previous == (reference - 2, reference - 1)):
|
|
128
|
+
found.add(index - 2)
|
|
129
|
+
if reference >= utr_start:
|
|
130
|
+
utr_present = True
|
|
131
|
+
previous = (previous[1], reference)
|
|
132
|
+
index += 1
|
|
133
|
+
return found if utr_present else set()
|