varcode 9.2.5__tar.gz → 9.2.7__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 (162) hide show
  1. {varcode-9.2.5/varcode.egg-info → varcode-9.2.7}/PKG-INFO +1 -1
  2. varcode-9.2.7/tests/test_documentation_examples.py +205 -0
  3. varcode-9.2.7/varcode/version.py +1 -0
  4. {varcode-9.2.5 → varcode-9.2.7/varcode.egg-info}/PKG-INFO +1 -1
  5. varcode-9.2.5/tests/test_documentation_examples.py +0 -127
  6. varcode-9.2.5/varcode/version.py +0 -1
  7. {varcode-9.2.5 → varcode-9.2.7}/LICENSE +0 -0
  8. {varcode-9.2.5 → varcode-9.2.7}/MANIFEST.in +0 -0
  9. {varcode-9.2.5 → varcode-9.2.7}/README.md +0 -0
  10. {varcode-9.2.5 → varcode-9.2.7}/pyproject.toml +0 -0
  11. {varcode-9.2.5 → varcode-9.2.7}/requirements.txt +0 -0
  12. {varcode-9.2.5 → varcode-9.2.7}/setup.cfg +0 -0
  13. {varcode-9.2.5 → varcode-9.2.7}/tests/test_annotator_divergence_scenarios.py +0 -0
  14. {varcode-9.2.5 → varcode-9.2.7}/tests/test_annotator_parity_adversarial.py +0 -0
  15. {varcode-9.2.5 → varcode-9.2.7}/tests/test_annotators.py +0 -0
  16. {varcode-9.2.5 → varcode-9.2.7}/tests/test_bnd_retained_segments.py +0 -0
  17. {varcode-9.2.5 → varcode-9.2.7}/tests/test_cli_effects.py +0 -0
  18. {varcode-9.2.5 → varcode-9.2.7}/tests/test_cli_genes.py +0 -0
  19. {varcode-9.2.5 → varcode-9.2.7}/tests/test_cli_without_pkg_resources.py +0 -0
  20. {varcode-9.2.5 → varcode-9.2.7}/tests/test_collection_filtering.py +0 -0
  21. {varcode-9.2.5 → varcode-9.2.7}/tests/test_collection_variants_attr_consistency.py +0 -0
  22. {varcode-9.2.5 → varcode-9.2.7}/tests/test_common.py +0 -0
  23. {varcode-9.2.5 → varcode-9.2.7}/tests/test_cosmic_mutations.py +0 -0
  24. {varcode-9.2.5 → varcode-9.2.7}/tests/test_cryptic_exons.py +0 -0
  25. {varcode-9.2.5 → varcode-9.2.7}/tests/test_csv_roundtrip.py +0 -0
  26. {varcode-9.2.5 → varcode-9.2.7}/tests/test_dbnsfp_validation.py +0 -0
  27. {varcode-9.2.5 → varcode-9.2.7}/tests/test_default_structural_helpers.py +0 -0
  28. {varcode-9.2.5 → varcode-9.2.7}/tests/test_effect_annotation_errors.py +0 -0
  29. {varcode-9.2.5 → varcode-9.2.7}/tests/test_effect_candidates.py +0 -0
  30. {varcode-9.2.5 → varcode-9.2.7}/tests/test_effect_classes.py +0 -0
  31. {varcode-9.2.5 → varcode-9.2.7}/tests/test_effect_collection.py +0 -0
  32. {varcode-9.2.5 → varcode-9.2.7}/tests/test_effect_collection_serialization.py +0 -0
  33. {varcode-9.2.5 → varcode-9.2.7}/tests/test_effect_collection_sort_order.py +0 -0
  34. {varcode-9.2.5 → varcode-9.2.7}/tests/test_effect_hypotheses.py +0 -0
  35. {varcode-9.2.5 → varcode-9.2.7}/tests/test_effects_from_mutagenix_variants.py +0 -0
  36. {varcode-9.2.5 → varcode-9.2.7}/tests/test_exacto_fusions.py +0 -0
  37. {varcode-9.2.5 → varcode-9.2.7}/tests/test_exonic_splice_site.py +0 -0
  38. {varcode-9.2.5 → varcode-9.2.7}/tests/test_fast_path.py +0 -0
  39. {varcode-9.2.5 → varcode-9.2.7}/tests/test_frameshift_cterminus_regression.py +0 -0
  40. {varcode-9.2.5 → varcode-9.2.7}/tests/test_frameshift_helpers.py +0 -0
  41. {varcode-9.2.5 → varcode-9.2.7}/tests/test_genome_contig_validation.py +0 -0
  42. {varcode-9.2.5 → varcode-9.2.7}/tests/test_genome_sequence.py +0 -0
  43. {varcode-9.2.5 → varcode-9.2.7}/tests/test_genomic_layout.py +0 -0
  44. {varcode-9.2.5 → varcode-9.2.7}/tests/test_genotype.py +0 -0
  45. {varcode-9.2.5 → varcode-9.2.7}/tests/test_genotype_from_vcf.py +0 -0
  46. {varcode-9.2.5 → varcode-9.2.7}/tests/test_germline_context.py +0 -0
  47. {varcode-9.2.5 → varcode-9.2.7}/tests/test_germline_effects.py +0 -0
  48. {varcode-9.2.5 → varcode-9.2.7}/tests/test_haplotype_effect.py +0 -0
  49. {varcode-9.2.5 → varcode-9.2.7}/tests/test_maf.py +0 -0
  50. {varcode-9.2.5 → varcode-9.2.7}/tests/test_mitochondrial.py +0 -0
  51. {varcode-9.2.5 → varcode-9.2.7}/tests/test_mm10_klf6_frameshift.py +0 -0
  52. {varcode-9.2.5 → varcode-9.2.7}/tests/test_mouse.py +0 -0
  53. {varcode-9.2.5 → varcode-9.2.7}/tests/test_mutant_transcript.py +0 -0
  54. {varcode-9.2.5 → varcode-9.2.7}/tests/test_mutate.py +0 -0
  55. {varcode-9.2.5 → varcode-9.2.7}/tests/test_no_duplicate_variants.py +0 -0
  56. {varcode-9.2.5 → varcode-9.2.7}/tests/test_nonlocal_sv_transcripts.py +0 -0
  57. {varcode-9.2.5 → varcode-9.2.7}/tests/test_osteosarc_fusions.py +0 -0
  58. {varcode-9.2.5 → varcode-9.2.7}/tests/test_partial_annotators.py +0 -0
  59. {varcode-9.2.5 → varcode-9.2.7}/tests/test_premature_stop_short_description.py +0 -0
  60. {varcode-9.2.5 → varcode-9.2.7}/tests/test_problematic_variants.py +0 -0
  61. {varcode-9.2.5 → varcode-9.2.7}/tests/test_protein_diff_parity.py +0 -0
  62. {varcode-9.2.5 → varcode-9.2.7}/tests/test_read_phase_resolver.py +0 -0
  63. {varcode-9.2.5 → varcode-9.2.7}/tests/test_real_world_callers.py +0 -0
  64. {varcode-9.2.5 → varcode-9.2.7}/tests/test_reference.py +0 -0
  65. {varcode-9.2.5 → varcode-9.2.7}/tests/test_reference_mismatch_error.py +0 -0
  66. {varcode-9.2.5 → varcode-9.2.7}/tests/test_reference_segments.py +0 -0
  67. {varcode-9.2.5 → varcode-9.2.7}/tests/test_rna_evidence.py +0 -0
  68. {varcode-9.2.5 → varcode-9.2.7}/tests/test_rna_haplotype_sequences.py +0 -0
  69. {varcode-9.2.5 → varcode-9.2.7}/tests/test_rna_read_phasing_source.py +0 -0
  70. {varcode-9.2.5 → varcode-9.2.7}/tests/test_selenocysteine.py +0 -0
  71. {varcode-9.2.5 → varcode-9.2.7}/tests/test_silent_aa_pos.py +0 -0
  72. {varcode-9.2.5 → varcode-9.2.7}/tests/test_silent_hgvs_description.py +0 -0
  73. {varcode-9.2.5 → varcode-9.2.7}/tests/test_splice_graph.py +0 -0
  74. {varcode-9.2.5 → varcode-9.2.7}/tests/test_splice_outcomes.py +0 -0
  75. {varcode-9.2.5 → varcode-9.2.7}/tests/test_splice_site_effects.py +0 -0
  76. {varcode-9.2.5 → varcode-9.2.7}/tests/test_stop_codon_classification_bugs.py +0 -0
  77. {varcode-9.2.5 → varcode-9.2.7}/tests/test_string_helpers.py +0 -0
  78. {varcode-9.2.5 → varcode-9.2.7}/tests/test_structural_variant_annotator.py +0 -0
  79. {varcode-9.2.5 → varcode-9.2.7}/tests/test_structural_variants.py +0 -0
  80. {varcode-9.2.5 → varcode-9.2.7}/tests/test_sv_tabular_metadata.py +0 -0
  81. {varcode-9.2.5 → varcode-9.2.7}/tests/test_symbolic_alleles.py +0 -0
  82. {varcode-9.2.5 → varcode-9.2.7}/tests/test_symbolic_sv_padding.py +0 -0
  83. {varcode-9.2.5 → varcode-9.2.7}/tests/test_timings.py +0 -0
  84. {varcode-9.2.5 → varcode-9.2.7}/tests/test_transcript_layout.py +0 -0
  85. {varcode-9.2.5 → varcode-9.2.7}/tests/test_transcript_model.py +0 -0
  86. {varcode-9.2.5 → varcode-9.2.7}/tests/test_transforms_left_align.py +0 -0
  87. {varcode-9.2.5 → varcode-9.2.7}/tests/test_transforms_pair_breakends.py +0 -0
  88. {varcode-9.2.5 → varcode-9.2.7}/tests/test_variant.py +0 -0
  89. {varcode-9.2.5 → varcode-9.2.7}/tests/test_variant_collection.py +0 -0
  90. {varcode-9.2.5 → varcode-9.2.7}/tests/test_vcf.py +0 -0
  91. {varcode-9.2.5 → varcode-9.2.7}/tests/test_vcf_output.py +0 -0
  92. {varcode-9.2.5 → varcode-9.2.7}/tests/test_vcf_parsing.py +0 -0
  93. {varcode-9.2.5 → varcode-9.2.7}/tests/test_vcf_phase_resolver.py +0 -0
  94. {varcode-9.2.5 → varcode-9.2.7}/tests/test_vcf_spec_examples.py +0 -0
  95. {varcode-9.2.5 → varcode-9.2.7}/varcode/__init__.py +0 -0
  96. {varcode-9.2.5 → varcode-9.2.7}/varcode/annotators/__init__.py +0 -0
  97. {varcode-9.2.5 → varcode-9.2.7}/varcode/annotators/fast.py +0 -0
  98. {varcode-9.2.5 → varcode-9.2.7}/varcode/annotators/protein_diff.py +0 -0
  99. {varcode-9.2.5 → varcode-9.2.7}/varcode/annotators/registry.py +0 -0
  100. {varcode-9.2.5 → varcode-9.2.7}/varcode/cli/__init__.py +0 -0
  101. {varcode-9.2.5 → varcode-9.2.7}/varcode/cli/effects_script.py +0 -0
  102. {varcode-9.2.5 → varcode-9.2.7}/varcode/cli/genes_script.py +0 -0
  103. {varcode-9.2.5 → varcode-9.2.7}/varcode/cli/logging.conf +0 -0
  104. {varcode-9.2.5 → varcode-9.2.7}/varcode/cli/variant_args.py +0 -0
  105. {varcode-9.2.5 → varcode-9.2.7}/varcode/cli/version_info.py +0 -0
  106. {varcode-9.2.5 → varcode-9.2.7}/varcode/common.py +0 -0
  107. {varcode-9.2.5 → varcode-9.2.7}/varcode/cryptic_exons.py +0 -0
  108. {varcode-9.2.5 → varcode-9.2.7}/varcode/csv_helpers.py +0 -0
  109. {varcode-9.2.5 → varcode-9.2.7}/varcode/effect_candidates.py +0 -0
  110. {varcode-9.2.5 → varcode-9.2.7}/varcode/effect_hypotheses.py +0 -0
  111. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/__init__.py +0 -0
  112. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/classify.py +0 -0
  113. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/codon_tables.py +0 -0
  114. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/common.py +0 -0
  115. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/effect_classes.py +0 -0
  116. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/effect_collection.py +0 -0
  117. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/effect_helpers.py +0 -0
  118. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/effect_ordering.py +0 -0
  119. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/effect_prediction.py +0 -0
  120. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/effect_prediction_coding.py +0 -0
  121. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/effect_prediction_coding_frameshift.py +0 -0
  122. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/effect_prediction_coding_in_frame.py +0 -0
  123. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/fast_path.py +0 -0
  124. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/mutate.py +0 -0
  125. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/structural.py +0 -0
  126. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/transcript_helpers.py +0 -0
  127. {varcode-9.2.5 → varcode-9.2.7}/varcode/effects/translate.py +0 -0
  128. {varcode-9.2.5 → varcode-9.2.7}/varcode/errors.py +0 -0
  129. {varcode-9.2.5 → varcode-9.2.7}/varcode/exacto.py +0 -0
  130. {varcode-9.2.5 → varcode-9.2.7}/varcode/genome.py +0 -0
  131. {varcode-9.2.5 → varcode-9.2.7}/varcode/genome_sequence.py +0 -0
  132. {varcode-9.2.5 → varcode-9.2.7}/varcode/genomic_layout.py +0 -0
  133. {varcode-9.2.5 → varcode-9.2.7}/varcode/genotype.py +0 -0
  134. {varcode-9.2.5 → varcode-9.2.7}/varcode/germline.py +0 -0
  135. {varcode-9.2.5 → varcode-9.2.7}/varcode/maf.py +0 -0
  136. {varcode-9.2.5 → varcode-9.2.7}/varcode/mutant_transcript.py +0 -0
  137. {varcode-9.2.5 → varcode-9.2.7}/varcode/nucleotides.py +0 -0
  138. {varcode-9.2.5 → varcode-9.2.7}/varcode/phasing.py +0 -0
  139. {varcode-9.2.5 → varcode-9.2.7}/varcode/realized_effects.py +0 -0
  140. {varcode-9.2.5 → varcode-9.2.7}/varcode/reference.py +0 -0
  141. {varcode-9.2.5 → varcode-9.2.7}/varcode/rna_evidence.py +0 -0
  142. {varcode-9.2.5 → varcode-9.2.7}/varcode/rna_read_phasing.py +0 -0
  143. {varcode-9.2.5 → varcode-9.2.7}/varcode/splice_graph.py +0 -0
  144. {varcode-9.2.5 → varcode-9.2.7}/varcode/splice_outcomes.py +0 -0
  145. {varcode-9.2.5 → varcode-9.2.7}/varcode/string_helpers.py +0 -0
  146. {varcode-9.2.5 → varcode-9.2.7}/varcode/structural_variant.py +0 -0
  147. {varcode-9.2.5 → varcode-9.2.7}/varcode/sv_allele_parser.py +0 -0
  148. {varcode-9.2.5 → varcode-9.2.7}/varcode/transcript_layout.py +0 -0
  149. {varcode-9.2.5 → varcode-9.2.7}/varcode/transcript_model.py +0 -0
  150. {varcode-9.2.5 → varcode-9.2.7}/varcode/transforms/__init__.py +0 -0
  151. {varcode-9.2.5 → varcode-9.2.7}/varcode/ucsc_reference_names.py +0 -0
  152. {varcode-9.2.5 → varcode-9.2.7}/varcode/util.py +0 -0
  153. {varcode-9.2.5 → varcode-9.2.7}/varcode/variant.py +0 -0
  154. {varcode-9.2.5 → varcode-9.2.7}/varcode/variant_collection.py +0 -0
  155. {varcode-9.2.5 → varcode-9.2.7}/varcode/vcf.py +0 -0
  156. {varcode-9.2.5 → varcode-9.2.7}/varcode/vcf_output.py +0 -0
  157. {varcode-9.2.5 → varcode-9.2.7}/varcode/vcf_parsing.py +0 -0
  158. {varcode-9.2.5 → varcode-9.2.7}/varcode.egg-info/SOURCES.txt +0 -0
  159. {varcode-9.2.5 → varcode-9.2.7}/varcode.egg-info/dependency_links.txt +0 -0
  160. {varcode-9.2.5 → varcode-9.2.7}/varcode.egg-info/entry_points.txt +0 -0
  161. {varcode-9.2.5 → varcode-9.2.7}/varcode.egg-info/requires.txt +0 -0
  162. {varcode-9.2.5 → varcode-9.2.7}/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.2.5
3
+ Version: 9.2.7
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
@@ -0,0 +1,205 @@
1
+ """Keep the reader-facing examples executable, using their actual Markdown."""
2
+
3
+ from pathlib import Path
4
+ import ast
5
+ import re
6
+ import shutil
7
+
8
+ import pytest
9
+ from pyensembl import cached_release
10
+
11
+ import varcode
12
+ from varcode import EffectCandidate, StructuralVariant, Variant
13
+ from varcode.effects.effect_classes import HaplotypeEffect
14
+ from varcode.effect_hypotheses import RealizedEffectCandidate
15
+
16
+
17
+ ROOT = Path(__file__).resolve().parents[1]
18
+
19
+
20
+ def _blocks(path, heading=None):
21
+ text = (ROOT / path).read_text()
22
+ if heading is not None:
23
+ text = text.split(heading + "\n", 1)[1]
24
+ return re.findall(r"```python\n(.*?)```", text, re.S)
25
+
26
+
27
+ def _run(blocks, namespace=None):
28
+ namespace = {} if namespace is None else namespace
29
+ for block in blocks:
30
+ exec(compile(block, "documentation example", "exec"), namespace)
31
+ return namespace
32
+
33
+
34
+ @pytest.fixture
35
+ def input_directory(tmp_path, monkeypatch):
36
+ for fixture in (ROOT / "tests/data/documentation").glob("*.vcf"):
37
+ shutil.copy(fixture, tmp_path / fixture.name)
38
+ shutil.copy(tmp_path / "variants.vcf", tmp_path / "tumor.vcf")
39
+ monkeypatch.chdir(tmp_path)
40
+ return tmp_path
41
+
42
+
43
+ @pytest.mark.parametrize("path,count", [
44
+ ("README.md", 2),
45
+ ("docs/getting_started.md", 4),
46
+ ("docs/index.md", 1),
47
+ ("docs/effect_annotation.md", 3),
48
+ ("docs/structural_variants.md", 1),
49
+ ("docs/transforms.md", 1),
50
+ ("docs/germline.md", 1),
51
+ ("docs/phasing.md", 1),
52
+ ])
53
+ def test_documentation_first_steps(path, count, input_directory):
54
+ namespace = _run(_blocks(path)[:count])
55
+ if path == "docs/transforms.md":
56
+ assert len(namespace["paired"]) == len(namespace["normalized"]) == 1
57
+ else:
58
+ assert len(namespace["effects"]) > 0
59
+ if path in ("README.md", "docs/getting_started.md"):
60
+ assert namespace["protein"][158] == "M"
61
+ if path == "docs/getting_started.md":
62
+ assert (input_directory / "effects.csv").is_file()
63
+ if path == "docs/structural_variants.md":
64
+ assert namespace["variants"][0].is_structural
65
+ if path == "docs/phasing.md":
66
+ variants = namespace["phased_variants"]
67
+ assert namespace["phaser"].in_cis(*variants) is True
68
+ assert any(isinstance(effect, HaplotypeEffect)
69
+ for effect in namespace["effects"])
70
+
71
+
72
+ def test_documentation_germline_scenarios():
73
+ namespace = _run(_blocks(
74
+ "docs/phasing.md", "## Two variants in one codon")[:4])
75
+ assert namespace["eff_cis"].short_description == "p.S159T"
76
+ assert namespace["eff_trans"].short_description == "p.L159M"
77
+ assert {c.effect.short_description for c in namespace["eff"].candidates} == {
78
+ "p.S159T", "p.L159M"}
79
+
80
+ namespace["effects"] = varcode.VariantCollection(
81
+ [namespace["germline"]]).effects(germline=namespace["ctx"])
82
+ _run(_blocks("docs/germline.md", "## Loss of heterozygosity (LOH)")[:1], namespace)
83
+ assert any(getattr(effect, "is_loh", False) for effect in namespace["effects"])
84
+
85
+ validation = _blocks("docs/germline.md", "## Cross-VCF build mismatch")[:1]
86
+ namespace["somatic_variants"] = varcode.VariantCollection([namespace["somatic"]])
87
+ namespace["germline_ctx"] = namespace["ctx"]
88
+ _run(validation, namespace)
89
+ namespace["germline_ctx"] = varcode.GermlineContext.from_variants(
90
+ [namespace["germline"]], reference_name="GRCh37")
91
+ with pytest.raises(varcode.GenomeBuildMismatchError):
92
+ _run(validation, namespace)
93
+
94
+
95
+ def test_documentation_germline_with_vcf_phase(input_directory):
96
+ namespace = _run(_blocks("docs/germline.md")[:1])
97
+ _run(_blocks("docs/phasing.md", "## Phased VCF")[:1], namespace)
98
+ namespace["rna"] = varcode.NullRNAEvidenceResolver()
99
+ _run(_blocks("docs/phasing.md", "## Combining evidence")[:1], namespace)
100
+ cftr = [effect for effect in namespace["effects"]
101
+ if effect.transcript_id == "ENST00000003084"]
102
+ assert len(cftr) == 1
103
+ assert cftr[0].short_description == "p.S159T"
104
+
105
+
106
+ def test_documentation_effect_families_keep_all_classes():
107
+ source = ast.parse((ROOT / "varcode/effects/effect_classes.py").read_text())
108
+ classes = {node.name for node in source.body if isinstance(node, ast.ClassDef)}
109
+ guide = (ROOT / "docs/effect_types.md").read_text()
110
+ documented = re.findall(r"^::: varcode.effects.effect_classes\.(\w+)$", guide, re.M)
111
+ assert set(documented) == classes
112
+ assert len(documented) == len(classes)
113
+ assert "::: varcode.SpliceOutcomeSet" in guide
114
+
115
+
116
+ @pytest.mark.parametrize("path,anchor,destination", [
117
+ ("structural_variants.md", "alleles-coordinates-and-exports", "sv_reference.md"),
118
+ ("structural_variants.md", "importing-observed-rna-structures", "rna_structures.md"),
119
+ ("germline.md", "concrete-example-same-codon-three-scenarios", "phasing.md"),
120
+ ("germline.md", "known-deletion-haplotypes-in-rna-alignments", "phasing.md"),
121
+ ("api.md", "varcode.Variant.effects", "api_variants.md"),
122
+ ("api.md", "varcode.MutantTranscript", "api_rna.md"),
123
+ ("api.md", "varcode.VCFPhaseResolver", "api_phasing.md"),
124
+ ])
125
+ def test_documentation_topic_links_preserve_old_fragments(path, anchor, destination):
126
+ guide = (ROOT / "docs" / path).read_text()
127
+ row = next(line for line in guide.splitlines() if f'id="{anchor}"' in line)
128
+ assert f"]({destination}" in row
129
+ assert (ROOT / "docs" / destination).is_file()
130
+
131
+
132
+ def test_documentation_api_objects_have_one_heading():
133
+ topics = list((ROOT / "docs").glob("api_*.md"))
134
+ assert len(topics) == 5
135
+ for topic in topics:
136
+ text = topic.read_text()
137
+ assert "::: varcode." in text
138
+ assert not re.search(r"^### `varcode\.", text, re.M)
139
+
140
+
141
+ def test_documentation_splice_accessors():
142
+ namespace = _run(_blocks("docs/splice_variants.md"))
143
+ assert isinstance(namespace["splice_set"], varcode.SpliceOutcomeSet)
144
+ assert namespace["coding"] is not None
145
+ assert namespace["preferred"] is not None
146
+
147
+
148
+ def test_documentation_moved_sections_keep_incoming_links():
149
+ guide = (ROOT / "docs/effect_annotation.md").read_text()
150
+ destinations = {
151
+ "splice-disrupting-variants": "splice_variants.md",
152
+ "how-it-composes": "transcript_models.md",
153
+ "annotator-selection": "experimental_annotators.md",
154
+ "writing-an-annotator": "annotator_contract.md",
155
+ "provenance": "csv.md#annotation-provenance",
156
+ }
157
+ for anchor, destination in destinations.items():
158
+ # Old fragment URLs land beside a link to the relocated content.
159
+ row = next(line for line in guide.splitlines() if f'id="{anchor}"' in line)
160
+ assert f"]({destination})" in row
161
+ assert (ROOT / "docs" / destination.split("#")[0]).is_file()
162
+
163
+
164
+ def test_documentation_custom_annotator_adapter():
165
+ namespace = _run(_blocks("docs/annotator_contract.md")[:1])
166
+ adapter = namespace["MyAnnotator"]
167
+ variant = Variant("7", 117531100, "T", "A", genome=81)
168
+ transcript = variant.genome.transcript_by_id("ENST00000003084")
169
+ effect = variant.effect_on_transcript(transcript)
170
+ supported = adapter(lambda variant, transcript: effect)
171
+ unsupported = adapter(lambda variant, transcript: None)
172
+ assert supported.annotate_on_transcript(variant, transcript) is effect
173
+ assert unsupported.annotate_on_transcript(variant, transcript) is NotImplemented
174
+
175
+
176
+ @pytest.mark.parametrize("kind", ["point", "BND", "CNV"])
177
+ def test_documentation_experimental_result_access(kind):
178
+ genome = cached_release(81)
179
+ transcript = genome.transcript_by_id("ENST00000003084")
180
+ if kind == "point":
181
+ variant = Variant("7", 117531100, "T", "A", genome)
182
+ elif kind == "BND":
183
+ variant = StructuralVariant(
184
+ "7", transcript.start + 50, "BND", alt="N]22:15500000]",
185
+ mate_contig="22", mate_start=15500000, genome=genome)
186
+ else:
187
+ variant = StructuralVariant(
188
+ "7", transcript.start + 50, "CNV", end=transcript.start + 100,
189
+ genome=genome)
190
+ namespace = dict(varcode=varcode, variant=variant, transcript=transcript)
191
+ advanced_blocks = _blocks("docs/experimental_annotators.md")
192
+ assert "comparison =" in advanced_blocks[0]
193
+ assert "candidate.outcomes" in advanced_blocks[1]
194
+ _run(advanced_blocks[:2], namespace)
195
+ _run(_blocks("docs/transcript_models.md"), namespace)
196
+ candidates = getattr(namespace["experimental"], "candidates", ())
197
+ if kind == "point":
198
+ assert candidates and all(isinstance(c, RealizedEffectCandidate)
199
+ for c in candidates)
200
+ assert namespace["protein"][158] == "M"
201
+ elif kind == "BND":
202
+ assert candidates and all(isinstance(c, EffectCandidate) for c in candidates)
203
+ else:
204
+ assert not candidates
205
+ assert isinstance(namespace["experimental"], varcode.Unresolved)
@@ -0,0 +1 @@
1
+ __version__ = "9.2.7"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: varcode
3
- Version: 9.2.5
3
+ Version: 9.2.7
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
@@ -1,127 +0,0 @@
1
- """Keep the reader-facing examples executable, using their actual Markdown."""
2
-
3
- from pathlib import Path
4
- import re
5
- import shutil
6
-
7
- import pytest
8
- from pyensembl import cached_release
9
-
10
- import varcode
11
- from varcode import EffectCandidate, StructuralVariant, Variant
12
- from varcode.effect_hypotheses import RealizedEffectCandidate
13
-
14
-
15
- ROOT = Path(__file__).resolve().parents[1]
16
-
17
-
18
- def _blocks(path, heading=None):
19
- text = (ROOT / path).read_text()
20
- if heading is not None:
21
- text = text.split(heading + "\n", 1)[1]
22
- return re.findall(r"```python\n(.*?)```", text, re.S)
23
-
24
-
25
- def _run(blocks, namespace=None):
26
- namespace = {} if namespace is None else namespace
27
- for block in blocks:
28
- exec(compile(block, "documentation example", "exec"), namespace)
29
- return namespace
30
-
31
-
32
- @pytest.fixture
33
- def input_directory(tmp_path, monkeypatch):
34
- for fixture in (ROOT / "tests/data/documentation").glob("*.vcf"):
35
- shutil.copy(fixture, tmp_path / fixture.name)
36
- shutil.copy(tmp_path / "variants.vcf", tmp_path / "tumor.vcf")
37
- monkeypatch.chdir(tmp_path)
38
- return tmp_path
39
-
40
-
41
- @pytest.mark.parametrize("path,count", [
42
- ("README.md", 2),
43
- ("docs/getting_started.md", 4),
44
- ("docs/index.md", 1),
45
- ("docs/effect_annotation.md", 3),
46
- ("docs/structural_variants.md", 1),
47
- ("docs/transforms.md", 1),
48
- ("docs/germline.md", 1),
49
- ])
50
- def test_documentation_first_steps(path, count, input_directory):
51
- namespace = _run(_blocks(path)[:count])
52
- if path == "docs/transforms.md":
53
- assert len(namespace["paired"]) == len(namespace["normalized"]) == 1
54
- else:
55
- assert len(namespace["effects"]) > 0
56
- if path in ("README.md", "docs/getting_started.md"):
57
- assert namespace["protein"][158] == "M"
58
- if path == "docs/getting_started.md":
59
- assert (input_directory / "effects.csv").is_file()
60
- if path == "docs/structural_variants.md":
61
- assert namespace["variants"][0].is_structural
62
-
63
-
64
- def test_documentation_germline_scenarios():
65
- namespace = _run(_blocks(
66
- "docs/germline.md", "## Concrete example: same codon, three scenarios")[:4])
67
- assert namespace["eff_cis"].short_description == "p.S159T"
68
- assert namespace["eff_trans"].short_description == "p.L159M"
69
- assert {c.effect.short_description for c in namespace["eff"].candidates} == {
70
- "p.S159T", "p.L159M"}
71
-
72
- _run(_blocks("docs/germline.md", "## Loss of heterozygosity (LOH)")[:1],
73
- namespace)
74
- assert any(getattr(effect, "is_loh", False)
75
- for effect in namespace["overlap"].effects(germline=namespace["ctx"]))
76
-
77
- validation = _blocks("docs/germline.md", "## Cross-VCF build mismatch")[:1]
78
- _run(validation, namespace)
79
- namespace["ctx"] = varcode.GermlineContext.from_variants(
80
- [namespace["germline"]], reference_name="GRCh37")
81
- with pytest.raises(varcode.GenomeBuildMismatchError):
82
- _run(validation, namespace)
83
-
84
-
85
- def test_documentation_splice_accessors():
86
- text = (ROOT / "docs/effect_annotation.md").read_text()
87
- section = text.split("### The `SpliceOutcomeSet` shape\n", 1)[1]
88
- section = section.split("### RNA evidence reconciliation\n", 1)[0]
89
- blocks = re.findall(r"```python\n(.*?)```", section, re.S)
90
- namespace = _run(blocks[:1])
91
- namespace["effect"] = namespace["splice_set"]
92
- _run(blocks[1:], namespace)
93
- assert isinstance(namespace["splice_set"], varcode.SpliceOutcomeSet)
94
- assert namespace["coding"] is not None
95
-
96
-
97
- @pytest.mark.parametrize("kind", ["point", "BND", "CNV"])
98
- def test_documentation_experimental_result_access(kind):
99
- genome = cached_release(81)
100
- transcript = genome.transcript_by_id("ENST00000003084")
101
- if kind == "point":
102
- variant = Variant("7", 117531100, "T", "A", genome)
103
- elif kind == "BND":
104
- variant = StructuralVariant(
105
- "7", transcript.start + 50, "BND", alt="N]22:15500000]",
106
- mate_contig="22", mate_start=15500000, genome=genome)
107
- else:
108
- variant = StructuralVariant(
109
- "7", transcript.start + 50, "CNV", end=transcript.start + 100,
110
- genome=genome)
111
- namespace = dict(varcode=varcode, variant=variant, transcript=transcript)
112
- advanced_blocks = _blocks("docs/effect_annotation.md",
113
- "## Advanced: annotators and implementation limits")
114
- assert "comparison =" in advanced_blocks[0]
115
- assert "candidate.outcomes" in advanced_blocks[1]
116
- _run(advanced_blocks[:2], namespace)
117
- _run(_blocks("docs/effect_annotation.md", "## Read an effect")[:1], namespace)
118
- candidates = getattr(namespace["experimental"], "candidates", ())
119
- if kind == "point":
120
- assert candidates and all(isinstance(c, RealizedEffectCandidate)
121
- for c in candidates)
122
- assert namespace["protein"][158] == "M"
123
- elif kind == "BND":
124
- assert candidates and all(isinstance(c, EffectCandidate) for c in candidates)
125
- else:
126
- assert not candidates
127
- assert isinstance(namespace["experimental"], varcode.Unresolved)
@@ -1 +0,0 @@
1
- __version__ = "9.2.5"
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