varcode 9.3.4__tar.gz → 9.3.6__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.
Files changed (168) hide show
  1. {varcode-9.3.4/varcode.egg-info → varcode-9.3.6}/PKG-INFO +3 -1
  2. {varcode-9.3.4 → varcode-9.3.6}/pyproject.toml +1 -0
  3. {varcode-9.3.4 → varcode-9.3.6}/tests/test_annotator_divergence_scenarios.py +38 -0
  4. varcode-9.3.6/tests/test_osteosarc_dataset.py +69 -0
  5. {varcode-9.3.4 → varcode-9.3.6}/tests/test_selenocysteine_proteins.py +61 -3
  6. {varcode-9.3.4 → varcode-9.3.6}/varcode/annotators/protein_diff.py +7 -2
  7. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/effect_prediction.py +5 -2
  8. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/selenocysteine.py +11 -5
  9. {varcode-9.3.4 → varcode-9.3.6}/varcode/mutant_transcript.py +10 -3
  10. {varcode-9.3.4 → varcode-9.3.6}/varcode/transcript_layout.py +5 -1
  11. varcode-9.3.6/varcode/version.py +1 -0
  12. {varcode-9.3.4 → varcode-9.3.6/varcode.egg-info}/PKG-INFO +3 -1
  13. {varcode-9.3.4 → varcode-9.3.6}/varcode.egg-info/SOURCES.txt +1 -0
  14. {varcode-9.3.4 → varcode-9.3.6}/varcode.egg-info/requires.txt +5 -0
  15. varcode-9.3.4/varcode/version.py +0 -1
  16. {varcode-9.3.4 → varcode-9.3.6}/LICENSE +0 -0
  17. {varcode-9.3.4 → varcode-9.3.6}/MANIFEST.in +0 -0
  18. {varcode-9.3.4 → varcode-9.3.6}/README.md +0 -0
  19. {varcode-9.3.4 → varcode-9.3.6}/requirements.txt +0 -0
  20. {varcode-9.3.4 → varcode-9.3.6}/setup.cfg +0 -0
  21. {varcode-9.3.4 → varcode-9.3.6}/tests/test_annotator_parity_adversarial.py +0 -0
  22. {varcode-9.3.4 → varcode-9.3.6}/tests/test_annotators.py +0 -0
  23. {varcode-9.3.4 → varcode-9.3.6}/tests/test_bnd_retained_segments.py +0 -0
  24. {varcode-9.3.4 → varcode-9.3.6}/tests/test_cli_effects.py +0 -0
  25. {varcode-9.3.4 → varcode-9.3.6}/tests/test_cli_genes.py +0 -0
  26. {varcode-9.3.4 → varcode-9.3.6}/tests/test_cli_without_pkg_resources.py +0 -0
  27. {varcode-9.3.4 → varcode-9.3.6}/tests/test_collection_filtering.py +0 -0
  28. {varcode-9.3.4 → varcode-9.3.6}/tests/test_collection_variants_attr_consistency.py +0 -0
  29. {varcode-9.3.4 → varcode-9.3.6}/tests/test_common.py +0 -0
  30. {varcode-9.3.4 → varcode-9.3.6}/tests/test_cosmic_mutations.py +0 -0
  31. {varcode-9.3.4 → varcode-9.3.6}/tests/test_cryptic_exons.py +0 -0
  32. {varcode-9.3.4 → varcode-9.3.6}/tests/test_csv_roundtrip.py +0 -0
  33. {varcode-9.3.4 → varcode-9.3.6}/tests/test_dbnsfp_validation.py +0 -0
  34. {varcode-9.3.4 → varcode-9.3.6}/tests/test_default_structural_helpers.py +0 -0
  35. {varcode-9.3.4 → varcode-9.3.6}/tests/test_documentation_examples.py +0 -0
  36. {varcode-9.3.4 → varcode-9.3.6}/tests/test_effect_annotation_errors.py +0 -0
  37. {varcode-9.3.4 → varcode-9.3.6}/tests/test_effect_candidates.py +0 -0
  38. {varcode-9.3.4 → varcode-9.3.6}/tests/test_effect_classes.py +0 -0
  39. {varcode-9.3.4 → varcode-9.3.6}/tests/test_effect_collection.py +0 -0
  40. {varcode-9.3.4 → varcode-9.3.6}/tests/test_effect_collection_serialization.py +0 -0
  41. {varcode-9.3.4 → varcode-9.3.6}/tests/test_effect_collection_sort_order.py +0 -0
  42. {varcode-9.3.4 → varcode-9.3.6}/tests/test_effect_hypotheses.py +0 -0
  43. {varcode-9.3.4 → varcode-9.3.6}/tests/test_effects_from_mutagenix_variants.py +0 -0
  44. {varcode-9.3.4 → varcode-9.3.6}/tests/test_exacto_fusions.py +0 -0
  45. {varcode-9.3.4 → varcode-9.3.6}/tests/test_exonic_splice_site.py +0 -0
  46. {varcode-9.3.4 → varcode-9.3.6}/tests/test_fast_path.py +0 -0
  47. {varcode-9.3.4 → varcode-9.3.6}/tests/test_frameshift_cterminus_regression.py +0 -0
  48. {varcode-9.3.4 → varcode-9.3.6}/tests/test_frameshift_helpers.py +0 -0
  49. {varcode-9.3.4 → varcode-9.3.6}/tests/test_fusion_partner_candidates.py +0 -0
  50. {varcode-9.3.4 → varcode-9.3.6}/tests/test_genome_contig_validation.py +0 -0
  51. {varcode-9.3.4 → varcode-9.3.6}/tests/test_genome_sequence.py +0 -0
  52. {varcode-9.3.4 → varcode-9.3.6}/tests/test_genomic_layout.py +0 -0
  53. {varcode-9.3.4 → varcode-9.3.6}/tests/test_genotype.py +0 -0
  54. {varcode-9.3.4 → varcode-9.3.6}/tests/test_genotype_from_vcf.py +0 -0
  55. {varcode-9.3.4 → varcode-9.3.6}/tests/test_germline_context.py +0 -0
  56. {varcode-9.3.4 → varcode-9.3.6}/tests/test_germline_effects.py +0 -0
  57. {varcode-9.3.4 → varcode-9.3.6}/tests/test_haplotype_effect.py +0 -0
  58. {varcode-9.3.4 → varcode-9.3.6}/tests/test_maf.py +0 -0
  59. {varcode-9.3.4 → varcode-9.3.6}/tests/test_mitochondrial.py +0 -0
  60. {varcode-9.3.4 → varcode-9.3.6}/tests/test_mm10_klf6_frameshift.py +0 -0
  61. {varcode-9.3.4 → varcode-9.3.6}/tests/test_mouse.py +0 -0
  62. {varcode-9.3.4 → varcode-9.3.6}/tests/test_mutant_transcript.py +0 -0
  63. {varcode-9.3.4 → varcode-9.3.6}/tests/test_mutate.py +0 -0
  64. {varcode-9.3.4 → varcode-9.3.6}/tests/test_no_duplicate_variants.py +0 -0
  65. {varcode-9.3.4 → varcode-9.3.6}/tests/test_nonlocal_sv_transcripts.py +0 -0
  66. {varcode-9.3.4 → varcode-9.3.6}/tests/test_osteosarc_fusions.py +0 -0
  67. {varcode-9.3.4 → varcode-9.3.6}/tests/test_partial_annotators.py +0 -0
  68. {varcode-9.3.4 → varcode-9.3.6}/tests/test_premature_stop_short_description.py +0 -0
  69. {varcode-9.3.4 → varcode-9.3.6}/tests/test_problematic_variants.py +0 -0
  70. {varcode-9.3.4 → varcode-9.3.6}/tests/test_protein_diff_parity.py +0 -0
  71. {varcode-9.3.4 → varcode-9.3.6}/tests/test_read_phase_resolver.py +0 -0
  72. {varcode-9.3.4 → varcode-9.3.6}/tests/test_real_world_callers.py +0 -0
  73. {varcode-9.3.4 → varcode-9.3.6}/tests/test_reference.py +0 -0
  74. {varcode-9.3.4 → varcode-9.3.6}/tests/test_reference_mismatch_error.py +0 -0
  75. {varcode-9.3.4 → varcode-9.3.6}/tests/test_reference_segments.py +0 -0
  76. {varcode-9.3.4 → varcode-9.3.6}/tests/test_rna_evidence.py +0 -0
  77. {varcode-9.3.4 → varcode-9.3.6}/tests/test_rna_haplotype_sequences.py +0 -0
  78. {varcode-9.3.4 → varcode-9.3.6}/tests/test_rna_read_phasing_source.py +0 -0
  79. {varcode-9.3.4 → varcode-9.3.6}/tests/test_selenocysteine.py +0 -0
  80. {varcode-9.3.4 → varcode-9.3.6}/tests/test_silent_aa_pos.py +0 -0
  81. {varcode-9.3.4 → varcode-9.3.6}/tests/test_silent_hgvs_description.py +0 -0
  82. {varcode-9.3.4 → varcode-9.3.6}/tests/test_splice_graph.py +0 -0
  83. {varcode-9.3.4 → varcode-9.3.6}/tests/test_splice_outcomes.py +0 -0
  84. {varcode-9.3.4 → varcode-9.3.6}/tests/test_splice_site_effects.py +0 -0
  85. {varcode-9.3.4 → varcode-9.3.6}/tests/test_stop_codon_classification_bugs.py +0 -0
  86. {varcode-9.3.4 → varcode-9.3.6}/tests/test_string_helpers.py +0 -0
  87. {varcode-9.3.4 → varcode-9.3.6}/tests/test_structural_variant_annotator.py +0 -0
  88. {varcode-9.3.4 → varcode-9.3.6}/tests/test_structural_variants.py +0 -0
  89. {varcode-9.3.4 → varcode-9.3.6}/tests/test_sv_selenocysteine.py +0 -0
  90. {varcode-9.3.4 → varcode-9.3.6}/tests/test_sv_sequence_changes.py +0 -0
  91. {varcode-9.3.4 → varcode-9.3.6}/tests/test_sv_tabular_metadata.py +0 -0
  92. {varcode-9.3.4 → varcode-9.3.6}/tests/test_symbolic_alleles.py +0 -0
  93. {varcode-9.3.4 → varcode-9.3.6}/tests/test_symbolic_sv_padding.py +0 -0
  94. {varcode-9.3.4 → varcode-9.3.6}/tests/test_timings.py +0 -0
  95. {varcode-9.3.4 → varcode-9.3.6}/tests/test_transcript_layout.py +0 -0
  96. {varcode-9.3.4 → varcode-9.3.6}/tests/test_transcript_model.py +0 -0
  97. {varcode-9.3.4 → varcode-9.3.6}/tests/test_transforms_left_align.py +0 -0
  98. {varcode-9.3.4 → varcode-9.3.6}/tests/test_transforms_pair_breakends.py +0 -0
  99. {varcode-9.3.4 → varcode-9.3.6}/tests/test_variant.py +0 -0
  100. {varcode-9.3.4 → varcode-9.3.6}/tests/test_variant_collection.py +0 -0
  101. {varcode-9.3.4 → varcode-9.3.6}/tests/test_vcf.py +0 -0
  102. {varcode-9.3.4 → varcode-9.3.6}/tests/test_vcf_output.py +0 -0
  103. {varcode-9.3.4 → varcode-9.3.6}/tests/test_vcf_parsing.py +0 -0
  104. {varcode-9.3.4 → varcode-9.3.6}/tests/test_vcf_phase_resolver.py +0 -0
  105. {varcode-9.3.4 → varcode-9.3.6}/tests/test_vcf_spec_examples.py +0 -0
  106. {varcode-9.3.4 → varcode-9.3.6}/varcode/__init__.py +0 -0
  107. {varcode-9.3.4 → varcode-9.3.6}/varcode/annotators/__init__.py +0 -0
  108. {varcode-9.3.4 → varcode-9.3.6}/varcode/annotators/fast.py +0 -0
  109. {varcode-9.3.4 → varcode-9.3.6}/varcode/annotators/registry.py +0 -0
  110. {varcode-9.3.4 → varcode-9.3.6}/varcode/cli/__init__.py +0 -0
  111. {varcode-9.3.4 → varcode-9.3.6}/varcode/cli/effects_script.py +0 -0
  112. {varcode-9.3.4 → varcode-9.3.6}/varcode/cli/genes_script.py +0 -0
  113. {varcode-9.3.4 → varcode-9.3.6}/varcode/cli/logging.conf +0 -0
  114. {varcode-9.3.4 → varcode-9.3.6}/varcode/cli/variant_args.py +0 -0
  115. {varcode-9.3.4 → varcode-9.3.6}/varcode/cli/version_info.py +0 -0
  116. {varcode-9.3.4 → varcode-9.3.6}/varcode/common.py +0 -0
  117. {varcode-9.3.4 → varcode-9.3.6}/varcode/cryptic_exons.py +0 -0
  118. {varcode-9.3.4 → varcode-9.3.6}/varcode/csv_helpers.py +0 -0
  119. {varcode-9.3.4 → varcode-9.3.6}/varcode/effect_candidates.py +0 -0
  120. {varcode-9.3.4 → varcode-9.3.6}/varcode/effect_hypotheses.py +0 -0
  121. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/__init__.py +0 -0
  122. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/classify.py +0 -0
  123. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/codon_tables.py +0 -0
  124. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/common.py +0 -0
  125. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/effect_classes.py +0 -0
  126. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/effect_collection.py +0 -0
  127. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/effect_helpers.py +0 -0
  128. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/effect_ordering.py +0 -0
  129. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/effect_prediction_coding.py +0 -0
  130. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/effect_prediction_coding_frameshift.py +0 -0
  131. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/effect_prediction_coding_in_frame.py +0 -0
  132. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/fast_path.py +0 -0
  133. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/mutate.py +0 -0
  134. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/sequence_change.py +0 -0
  135. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/structural.py +0 -0
  136. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/transcript_helpers.py +0 -0
  137. {varcode-9.3.4 → varcode-9.3.6}/varcode/effects/translate.py +0 -0
  138. {varcode-9.3.4 → varcode-9.3.6}/varcode/errors.py +0 -0
  139. {varcode-9.3.4 → varcode-9.3.6}/varcode/exacto.py +0 -0
  140. {varcode-9.3.4 → varcode-9.3.6}/varcode/genome.py +0 -0
  141. {varcode-9.3.4 → varcode-9.3.6}/varcode/genome_sequence.py +0 -0
  142. {varcode-9.3.4 → varcode-9.3.6}/varcode/genomic_layout.py +0 -0
  143. {varcode-9.3.4 → varcode-9.3.6}/varcode/genotype.py +0 -0
  144. {varcode-9.3.4 → varcode-9.3.6}/varcode/germline.py +0 -0
  145. {varcode-9.3.4 → varcode-9.3.6}/varcode/maf.py +0 -0
  146. {varcode-9.3.4 → varcode-9.3.6}/varcode/nucleotides.py +0 -0
  147. {varcode-9.3.4 → varcode-9.3.6}/varcode/phasing.py +0 -0
  148. {varcode-9.3.4 → varcode-9.3.6}/varcode/realized_effects.py +0 -0
  149. {varcode-9.3.4 → varcode-9.3.6}/varcode/reference.py +0 -0
  150. {varcode-9.3.4 → varcode-9.3.6}/varcode/rna_evidence.py +0 -0
  151. {varcode-9.3.4 → varcode-9.3.6}/varcode/rna_read_phasing.py +0 -0
  152. {varcode-9.3.4 → varcode-9.3.6}/varcode/splice_graph.py +0 -0
  153. {varcode-9.3.4 → varcode-9.3.6}/varcode/splice_outcomes.py +0 -0
  154. {varcode-9.3.4 → varcode-9.3.6}/varcode/string_helpers.py +0 -0
  155. {varcode-9.3.4 → varcode-9.3.6}/varcode/structural_variant.py +0 -0
  156. {varcode-9.3.4 → varcode-9.3.6}/varcode/sv_allele_parser.py +0 -0
  157. {varcode-9.3.4 → varcode-9.3.6}/varcode/transcript_model.py +0 -0
  158. {varcode-9.3.4 → varcode-9.3.6}/varcode/transforms/__init__.py +0 -0
  159. {varcode-9.3.4 → varcode-9.3.6}/varcode/ucsc_reference_names.py +0 -0
  160. {varcode-9.3.4 → varcode-9.3.6}/varcode/util.py +0 -0
  161. {varcode-9.3.4 → varcode-9.3.6}/varcode/variant.py +0 -0
  162. {varcode-9.3.4 → varcode-9.3.6}/varcode/variant_collection.py +0 -0
  163. {varcode-9.3.4 → varcode-9.3.6}/varcode/vcf.py +0 -0
  164. {varcode-9.3.4 → varcode-9.3.6}/varcode/vcf_output.py +0 -0
  165. {varcode-9.3.4 → varcode-9.3.6}/varcode/vcf_parsing.py +0 -0
  166. {varcode-9.3.4 → varcode-9.3.6}/varcode.egg-info/dependency_links.txt +0 -0
  167. {varcode-9.3.4 → varcode-9.3.6}/varcode.egg-info/entry_points.txt +0 -0
  168. {varcode-9.3.4 → varcode-9.3.6}/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.4
3
+ Version: 9.3.6
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
  [![Tests](https://github.com/openvax/varcode/actions/workflows/tests.yml/badge.svg)](https://github.com/openvax/varcode/actions/workflows/tests.yml)
@@ -35,6 +35,7 @@ include = ["varcode", "varcode.*"]
35
35
 
36
36
  [project.optional-dependencies]
37
37
  rna = ["pysam>=0.21"]
38
+ test-data = ["osteosarc==0.1.0; python_version >= '3.10'"]
38
39
 
39
40
  [project.scripts]
40
41
  varcode-genes = "varcode.cli.genes_script:main"
@@ -331,6 +331,44 @@ 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("annotator", ["fast", "protein_diff", "transcript_model"])
335
+ @pytest.mark.parametrize("transcript_id", [BRCA1_ID, CFTR_ID])
336
+ @pytest.mark.parametrize("alt", ["CAG", "CAA", "CAT", "TTT", "A", "AG"])
337
+ def test_insertion_before_retained_start_codon_is_five_prime_utr(
338
+ annotator, transcript_id, alt):
339
+ from varcode.mutant_transcript import _translate_from_cds, apply_variant_to_transcript
340
+
341
+ t = ensembl_grch38.transcript_by_id(transcript_id)
342
+ anchor = (max(t.start_codon_positions) if t.on_backward_strand
343
+ else min(t.start_codon_positions) - 1)
344
+ variant = Variant(t.contig, anchor, "", alt, ensembl_grch38)
345
+ mt = apply_variant_to_transcript(variant, t)
346
+ assert _translate_from_cds(mt.cdna_sequence, t, mt.edits) == t.protein_sequence
347
+ effect = variant.effect_on_transcript(t, annotator=annotator)
348
+ assert isinstance(effect, FivePrimeUTR)
349
+ assert effect.modifies_coding_sequence is False
350
+ assert effect.modifies_protein_sequence is False
351
+
352
+
353
+ @pytest.mark.parametrize("annotator", ["fast", "protein_diff", "transcript_model"])
354
+ @pytest.mark.parametrize("transcript_id", [BRCA1_ID, CFTR_ID])
355
+ @pytest.mark.parametrize("case", ["first_base_substitution", "internal_insertion"])
356
+ def test_edit_touching_start_codon_remains_coding(annotator, transcript_id, case):
357
+ t = ensembl_grch38.transcript_by_id(transcript_id)
358
+ first = (max(t.start_codon_positions) if t.on_backward_strand
359
+ else min(t.start_codon_positions))
360
+ if case == "first_base_substitution":
361
+ ref, alt = ("T", "G") if t.on_backward_strand else ("A", "C")
362
+ variant = Variant(t.contig, first, ref, alt, ensembl_grch38)
363
+ else:
364
+ # Insert after the first base of ATG in transcript orientation.
365
+ anchor = first - 1 if t.on_backward_strand else first
366
+ variant = Variant(t.contig, anchor, "", "AAA", ensembl_grch38)
367
+ effect = variant.effect_on_transcript(t, annotator=annotator)
368
+ assert effect.modifies_coding_sequence is True
369
+ assert not isinstance(effect, FivePrimeUTR)
370
+
371
+
334
372
  def test_divergence_frameshift_immediate_stop():
335
373
  """Frameshift that creates a stop codon at (or very near) the
336
374
  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
@@ -9,13 +9,20 @@ import pytest
9
9
  from pyensembl import cached_release
10
10
 
11
11
  from varcode import StructuralVariant, TranscriptEdit, Variant
12
- from varcode.effects import GeneFusion
12
+ from varcode.effects import GeneFusion, PrematureStop
13
13
  from varcode.effects import structural
14
14
  from varcode.effects.codon_tables import translate_sequence
15
- from varcode.effects.selenocysteine import edited_selenocysteine, reference_selenocysteine
15
+ from varcode.effects.selenocysteine import (
16
+ edited_selenocysteine,
17
+ layout_selenocysteine,
18
+ reference_selenocysteine,
19
+ )
16
20
  from varcode.effects.sequence_change import structural_sequence_changes
21
+ from varcode.genomic_layout import GenomicLayout, LayoutSegment
17
22
  from varcode.mutant_transcript import apply_variant_to_transcript, apply_variants_to_transcript
18
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
19
26
 
20
27
  # GPX1 (-), GPX4 (+), SEPP1 (-, ten Sec), TXNRD1 (+, Sec is the penultimate residue).
21
28
  SELENOPROTEINS = ["ENST00000419783", "ENST00000354171", "ENST00000514985", "ENST00000525566"]
@@ -120,6 +127,58 @@ def test_edited_selenocysteine_codon_is_translated_literally():
120
127
  assert edited_selenocysteine(t, (TranscriptEdit(sec, sec, "AAA"),)) == {sec + 3}
121
128
 
122
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
+
123
182
  def test_deleting_the_whole_three_prime_utr_leaves_uga_a_stop():
124
183
  t = _transcript("ENST00000354171")
125
184
  utr = max(t.stop_codon_spliced_offsets) + 1
@@ -187,4 +246,3 @@ def test_fusion_that_drops_the_selenoprotein_utr_stops_at_selenocysteine():
187
246
  model, effect = _fusion(gpx4, breakpoint, cftr, cftr.end - 10)
188
247
  assert model.mutant_protein_sequence == gpx4.protein_sequence[:gpx4.protein_sequence.index("U")]
189
248
  assert effect.modifies_protein_sequence is True
190
-
@@ -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
- cds_start:cds_start + 3].upper()
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:
@@ -535,8 +535,11 @@ def exonic_transcript_effect(variant, exon, exon_number, transcript):
535
535
 
536
536
  utr5_length = min(transcript.start_codon_spliced_offsets)
537
537
 
538
- # does the variant start inside the 5' UTR?
539
- if utr5_length > transcript_offset:
538
+ # A reverse-strand insertion goes before its anchor base. An anchor
539
+ # on the first CDS base therefore still places the insertion in the UTR.
540
+ if (utr5_length > transcript_offset
541
+ or (n_ref == 0 and transcript.on_backward_strand
542
+ and utr5_length == transcript_offset)):
540
543
  # does the variant end after the 5' UTR, within the coding region?
541
544
  if utr5_length < transcript_offset + n_ref:
542
545
  # TODO: we *might* lose the Kozak sequence or the start codon
@@ -103,25 +103,31 @@ def layout_selenocysteine(transcript, layouts):
103
103
  """cDNA offsets of annotated Sec codons in concatenated genomic layouts.
104
104
 
105
105
  Each layout exposes ``origins()`` as ``(contig, position, kind)`` per base,
106
- in transcript orientation. Empty when no base of an annotated 3' UTR
107
- remains.
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.
108
109
  """
109
110
  offsets = set(reference_selenocysteine(transcript))
110
111
  if not offsets:
111
112
  return set()
112
113
  utr_start = _three_prime_utr_start(transcript)
113
114
  found, index = set(), 0
115
+ previous = (None, None)
114
116
  utr_present = utr_start >= len(transcript.sequence)
115
117
  for layout in layouts:
116
118
  for contig, position, kind in layout.origins():
119
+ reference = None
117
120
  if contig == transcript.contig and kind != "inverted":
118
121
  try:
119
122
  reference = transcript.spliced_offset(position)
120
123
  except ValueError:
121
124
  reference = None
122
- if reference in offsets:
123
- found.add(index)
124
- elif reference is not None and reference >= utr_start:
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:
125
130
  utr_present = True
131
+ previous = (previous[1], reference)
126
132
  index += 1
127
133
  return found if utr_present else set()
@@ -388,6 +388,14 @@ def _resolve_variant_edit(variant, transcript, full_sequence):
388
388
  return (edit, cdna_offset)
389
389
 
390
390
 
391
+ def _mutant_cds_start(transcript, edits=()):
392
+ """Map the reference CDS start past edits wholly upstream of it."""
393
+ from .effects.selenocysteine import edit_shift
394
+
395
+ reference_start = min(transcript.start_codon_spliced_offsets)
396
+ return reference_start + edit_shift(reference_start, edits)
397
+
398
+
391
399
  def _translate_from_cds(mutant_cdna, transcript, edits=()):
392
400
  """Translate ``mutant_cdna`` from the canonical CDS start to the
393
401
  first stop. ``edits`` (in reference coordinates) locate that start,
@@ -398,9 +406,8 @@ def _translate_from_cds(mutant_cdna, transcript, edits=()):
398
406
  codon_table_for_transcript,
399
407
  translate_sequence,
400
408
  )
401
- from .effects.selenocysteine import edit_shift, edited_selenocysteine
402
- reference_start = min(transcript.start_codon_spliced_offsets)
403
- cds_start = reference_start + edit_shift(reference_start, edits)
409
+ from .effects.selenocysteine import edited_selenocysteine
410
+ cds_start = _mutant_cds_start(transcript, edits)
404
411
  if cds_start >= len(mutant_cdna):
405
412
  return None
406
413
  codon_table = codon_table_for_transcript(transcript)
@@ -467,7 +467,11 @@ def _unchanged_product_effect(variant, transcript, mutant):
467
467
  stop_offsets = tuple(transcript.stop_codon_spliced_offsets)
468
468
  cds_end = max(stop_offsets) + 1 if stop_offsets else (
469
469
  cds_start + 3 * len(str(transcript.protein_sequence)))
470
- if first_offset < cds_start:
470
+ # On the reverse strand, inserted bases precede their genomic anchor.
471
+ # Anchoring on the retained first CDS base leaves the insertion in the UTR.
472
+ if (first_offset < cds_start
473
+ or (getattr(variant, "is_insertion", False)
474
+ and transcript.on_backward_strand and first_offset == cds_start)):
471
475
  return FivePrimeUTR(variant, transcript)
472
476
  if first_offset >= cds_end:
473
477
  return ThreePrimeUTR(variant, transcript)
@@ -0,0 +1 @@
1
+ __version__ = "9.3.6"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: varcode
3
- Version: 9.3.4
3
+ Version: 9.3.6
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
  [![Tests](https://github.com/openvax/varcode/actions/workflows/tests.yml/badge.svg)](https://github.com/openvax/varcode/actions/workflows/tests.yml)
@@ -49,6 +49,7 @@ tests/test_mutant_transcript.py
49
49
  tests/test_mutate.py
50
50
  tests/test_no_duplicate_variants.py
51
51
  tests/test_nonlocal_sv_transcripts.py
52
+ tests/test_osteosarc_dataset.py
52
53
  tests/test_osteosarc_fusions.py
53
54
  tests/test_partial_annotators.py
54
55
  tests/test_premature_stop_short_description.py
@@ -7,3 +7,8 @@ sercol>=0.1.4
7
7
 
8
8
  [rna]
9
9
  pysam>=0.21
10
+
11
+ [test-data]
12
+
13
+ [test-data:python_version >= "3.10"]
14
+ osteosarc==0.1.0
@@ -1 +0,0 @@
1
- __version__ = "9.3.4"
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