varcode 10.2.1__tar.gz → 10.3.0__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 (193) hide show
  1. {varcode-10.2.1/varcode.egg-info → varcode-10.3.0}/PKG-INFO +1 -1
  2. {varcode-10.2.1 → varcode-10.3.0}/tests/test_germline_effects.py +302 -29
  3. {varcode-10.2.1 → varcode-10.3.0}/tests/test_read_phase_resolver.py +62 -0
  4. {varcode-10.2.1 → varcode-10.3.0}/tests/test_transcript_model.py +94 -4
  5. {varcode-10.2.1 → varcode-10.3.0}/varcode/__init__.py +14 -1
  6. {varcode-10.2.1 → varcode-10.3.0}/varcode/effect_hypotheses.py +3 -2
  7. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/__init__.py +2 -0
  8. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/effect_classes.py +43 -1
  9. {varcode-10.2.1 → varcode-10.3.0}/varcode/errors.py +18 -0
  10. {varcode-10.2.1 → varcode-10.3.0}/varcode/germline.py +252 -153
  11. {varcode-10.2.1 → varcode-10.3.0}/varcode/phasing.py +37 -10
  12. {varcode-10.2.1 → varcode-10.3.0}/varcode/transcript_model.py +73 -35
  13. varcode-10.3.0/varcode/version.py +1 -0
  14. {varcode-10.2.1 → varcode-10.3.0/varcode.egg-info}/PKG-INFO +1 -1
  15. varcode-10.2.1/varcode/version.py +0 -1
  16. {varcode-10.2.1 → varcode-10.3.0}/LICENSE +0 -0
  17. {varcode-10.2.1 → varcode-10.3.0}/MANIFEST.in +0 -0
  18. {varcode-10.2.1 → varcode-10.3.0}/README.md +0 -0
  19. {varcode-10.2.1 → varcode-10.3.0}/pyproject.toml +0 -0
  20. {varcode-10.2.1 → varcode-10.3.0}/requirements.txt +0 -0
  21. {varcode-10.2.1 → varcode-10.3.0}/setup.cfg +0 -0
  22. {varcode-10.2.1 → varcode-10.3.0}/tests/__init__.py +0 -0
  23. {varcode-10.2.1 → varcode-10.3.0}/tests/benchmark_vcf_load.py +0 -0
  24. {varcode-10.2.1 → varcode-10.3.0}/tests/common.py +0 -0
  25. {varcode-10.2.1 → varcode-10.3.0}/tests/data.py +0 -0
  26. {varcode-10.2.1 → varcode-10.3.0}/tests/test_annotator_divergence_scenarios.py +0 -0
  27. {varcode-10.2.1 → varcode-10.3.0}/tests/test_annotator_haplotypes.py +0 -0
  28. {varcode-10.2.1 → varcode-10.3.0}/tests/test_annotator_parity_adversarial.py +0 -0
  29. {varcode-10.2.1 → varcode-10.3.0}/tests/test_annotators.py +0 -0
  30. {varcode-10.2.1 → varcode-10.3.0}/tests/test_bnd_retained_segments.py +0 -0
  31. {varcode-10.2.1 → varcode-10.3.0}/tests/test_cli_effects.py +0 -0
  32. {varcode-10.2.1 → varcode-10.3.0}/tests/test_cli_genes.py +0 -0
  33. {varcode-10.2.1 → varcode-10.3.0}/tests/test_cli_records.py +0 -0
  34. {varcode-10.2.1 → varcode-10.3.0}/tests/test_cli_without_pkg_resources.py +0 -0
  35. {varcode-10.2.1 → varcode-10.3.0}/tests/test_collection_filtering.py +0 -0
  36. {varcode-10.2.1 → varcode-10.3.0}/tests/test_collection_variants_attr_consistency.py +0 -0
  37. {varcode-10.2.1 → varcode-10.3.0}/tests/test_common.py +0 -0
  38. {varcode-10.2.1 → varcode-10.3.0}/tests/test_cosmic_mutations.py +0 -0
  39. {varcode-10.2.1 → varcode-10.3.0}/tests/test_cryptic_exons.py +0 -0
  40. {varcode-10.2.1 → varcode-10.3.0}/tests/test_csv_roundtrip.py +0 -0
  41. {varcode-10.2.1 → varcode-10.3.0}/tests/test_dbnsfp_validation.py +0 -0
  42. {varcode-10.2.1 → varcode-10.3.0}/tests/test_default_structural_helpers.py +0 -0
  43. {varcode-10.2.1 → varcode-10.3.0}/tests/test_documentation_examples.py +0 -0
  44. {varcode-10.2.1 → varcode-10.3.0}/tests/test_effect_annotation_errors.py +0 -0
  45. {varcode-10.2.1 → varcode-10.3.0}/tests/test_effect_candidates.py +0 -0
  46. {varcode-10.2.1 → varcode-10.3.0}/tests/test_effect_classes.py +0 -0
  47. {varcode-10.2.1 → varcode-10.3.0}/tests/test_effect_collection.py +0 -0
  48. {varcode-10.2.1 → varcode-10.3.0}/tests/test_effect_collection_serialization.py +0 -0
  49. {varcode-10.2.1 → varcode-10.3.0}/tests/test_effect_collection_sort_order.py +0 -0
  50. {varcode-10.2.1 → varcode-10.3.0}/tests/test_effect_hypotheses.py +0 -0
  51. {varcode-10.2.1 → varcode-10.3.0}/tests/test_effects_from_mutagenix_variants.py +0 -0
  52. {varcode-10.2.1 → varcode-10.3.0}/tests/test_exacto_fusions.py +0 -0
  53. {varcode-10.2.1 → varcode-10.3.0}/tests/test_exonic_splice_site.py +0 -0
  54. {varcode-10.2.1 → varcode-10.3.0}/tests/test_fast_path.py +0 -0
  55. {varcode-10.2.1 → varcode-10.3.0}/tests/test_frameshift_cterminus_regression.py +0 -0
  56. {varcode-10.2.1 → varcode-10.3.0}/tests/test_frameshift_helpers.py +0 -0
  57. {varcode-10.2.1 → varcode-10.3.0}/tests/test_fusion_insertions.py +0 -0
  58. {varcode-10.2.1 → varcode-10.3.0}/tests/test_fusion_partner_candidates.py +0 -0
  59. {varcode-10.2.1 → varcode-10.3.0}/tests/test_genome_contig_validation.py +0 -0
  60. {varcode-10.2.1 → varcode-10.3.0}/tests/test_genome_sequence.py +0 -0
  61. {varcode-10.2.1 → varcode-10.3.0}/tests/test_genomic_layout.py +0 -0
  62. {varcode-10.2.1 → varcode-10.3.0}/tests/test_genotype.py +0 -0
  63. {varcode-10.2.1 → varcode-10.3.0}/tests/test_genotype_from_vcf.py +0 -0
  64. {varcode-10.2.1 → varcode-10.3.0}/tests/test_germline_context.py +0 -0
  65. {varcode-10.2.1 → varcode-10.3.0}/tests/test_germline_overlap.py +0 -0
  66. {varcode-10.2.1 → varcode-10.3.0}/tests/test_haplotype_effect.py +0 -0
  67. {varcode-10.2.1 → varcode-10.3.0}/tests/test_local_sv_insertions.py +0 -0
  68. {varcode-10.2.1 → varcode-10.3.0}/tests/test_maf.py +0 -0
  69. {varcode-10.2.1 → varcode-10.3.0}/tests/test_mitochondrial.py +0 -0
  70. {varcode-10.2.1 → varcode-10.3.0}/tests/test_mm10_klf6_frameshift.py +0 -0
  71. {varcode-10.2.1 → varcode-10.3.0}/tests/test_mouse.py +0 -0
  72. {varcode-10.2.1 → varcode-10.3.0}/tests/test_mutant_transcript.py +0 -0
  73. {varcode-10.2.1 → varcode-10.3.0}/tests/test_mutate.py +0 -0
  74. {varcode-10.2.1 → varcode-10.3.0}/tests/test_no_duplicate_variants.py +0 -0
  75. {varcode-10.2.1 → varcode-10.3.0}/tests/test_nonlocal_layout.py +0 -0
  76. {varcode-10.2.1 → varcode-10.3.0}/tests/test_nonlocal_sv_transcripts.py +0 -0
  77. {varcode-10.2.1 → varcode-10.3.0}/tests/test_osteosarc_dataset.py +0 -0
  78. {varcode-10.2.1 → varcode-10.3.0}/tests/test_osteosarc_fusions.py +0 -0
  79. {varcode-10.2.1 → varcode-10.3.0}/tests/test_osteosarc_variants.py +0 -0
  80. {varcode-10.2.1 → varcode-10.3.0}/tests/test_partial_annotators.py +0 -0
  81. {varcode-10.2.1 → varcode-10.3.0}/tests/test_premature_stop_short_description.py +0 -0
  82. {varcode-10.2.1 → varcode-10.3.0}/tests/test_problematic_variants.py +0 -0
  83. {varcode-10.2.1 → varcode-10.3.0}/tests/test_protein_diff_parity.py +0 -0
  84. {varcode-10.2.1 → varcode-10.3.0}/tests/test_real_world_callers.py +0 -0
  85. {varcode-10.2.1 → varcode-10.3.0}/tests/test_reference.py +0 -0
  86. {varcode-10.2.1 → varcode-10.3.0}/tests/test_reference_mismatch_error.py +0 -0
  87. {varcode-10.2.1 → varcode-10.3.0}/tests/test_reference_segments.py +0 -0
  88. {varcode-10.2.1 → varcode-10.3.0}/tests/test_rna_evidence.py +0 -0
  89. {varcode-10.2.1 → varcode-10.3.0}/tests/test_rna_haplotype_sequences.py +0 -0
  90. {varcode-10.2.1 → varcode-10.3.0}/tests/test_rna_read_phasing_source.py +0 -0
  91. {varcode-10.2.1 → varcode-10.3.0}/tests/test_sample_identity.py +0 -0
  92. {varcode-10.2.1 → varcode-10.3.0}/tests/test_selenocysteine.py +0 -0
  93. {varcode-10.2.1 → varcode-10.3.0}/tests/test_selenocysteine_proteins.py +0 -0
  94. {varcode-10.2.1 → varcode-10.3.0}/tests/test_silent_aa_pos.py +0 -0
  95. {varcode-10.2.1 → varcode-10.3.0}/tests/test_silent_hgvs_description.py +0 -0
  96. {varcode-10.2.1 → varcode-10.3.0}/tests/test_splice_graph.py +0 -0
  97. {varcode-10.2.1 → varcode-10.3.0}/tests/test_splice_outcomes.py +0 -0
  98. {varcode-10.2.1 → varcode-10.3.0}/tests/test_splice_site_effects.py +0 -0
  99. {varcode-10.2.1 → varcode-10.3.0}/tests/test_stop_codon_classification_bugs.py +0 -0
  100. {varcode-10.2.1 → varcode-10.3.0}/tests/test_string_helpers.py +0 -0
  101. {varcode-10.2.1 → varcode-10.3.0}/tests/test_structural_serialization.py +0 -0
  102. {varcode-10.2.1 → varcode-10.3.0}/tests/test_structural_variant_annotator.py +0 -0
  103. {varcode-10.2.1 → varcode-10.3.0}/tests/test_structural_variants.py +0 -0
  104. {varcode-10.2.1 → varcode-10.3.0}/tests/test_sv_comparison.py +0 -0
  105. {varcode-10.2.1 → varcode-10.3.0}/tests/test_sv_consequences.py +0 -0
  106. {varcode-10.2.1 → varcode-10.3.0}/tests/test_sv_selenocysteine.py +0 -0
  107. {varcode-10.2.1 → varcode-10.3.0}/tests/test_sv_sequence_changes.py +0 -0
  108. {varcode-10.2.1 → varcode-10.3.0}/tests/test_sv_tabular_metadata.py +0 -0
  109. {varcode-10.2.1 → varcode-10.3.0}/tests/test_symbolic_alleles.py +0 -0
  110. {varcode-10.2.1 → varcode-10.3.0}/tests/test_symbolic_sv_padding.py +0 -0
  111. {varcode-10.2.1 → varcode-10.3.0}/tests/test_test_script.py +0 -0
  112. {varcode-10.2.1 → varcode-10.3.0}/tests/test_timings.py +0 -0
  113. {varcode-10.2.1 → varcode-10.3.0}/tests/test_transcript_layout.py +0 -0
  114. {varcode-10.2.1 → varcode-10.3.0}/tests/test_transcript_model_start_codons.py +0 -0
  115. {varcode-10.2.1 → varcode-10.3.0}/tests/test_transforms_left_align.py +0 -0
  116. {varcode-10.2.1 → varcode-10.3.0}/tests/test_transforms_pair_breakends.py +0 -0
  117. {varcode-10.2.1 → varcode-10.3.0}/tests/test_variant.py +0 -0
  118. {varcode-10.2.1 → varcode-10.3.0}/tests/test_variant_collection.py +0 -0
  119. {varcode-10.2.1 → varcode-10.3.0}/tests/test_vcf.py +0 -0
  120. {varcode-10.2.1 → varcode-10.3.0}/tests/test_vcf_export_integrity.py +0 -0
  121. {varcode-10.2.1 → varcode-10.3.0}/tests/test_vcf_limits.py +0 -0
  122. {varcode-10.2.1 → varcode-10.3.0}/tests/test_vcf_output.py +0 -0
  123. {varcode-10.2.1 → varcode-10.3.0}/tests/test_vcf_parsing.py +0 -0
  124. {varcode-10.2.1 → varcode-10.3.0}/tests/test_vcf_phase_resolver.py +0 -0
  125. {varcode-10.2.1 → varcode-10.3.0}/tests/test_vcf_spec_examples.py +0 -0
  126. {varcode-10.2.1 → varcode-10.3.0}/varcode/_sample_vcf.py +0 -0
  127. {varcode-10.2.1 → varcode-10.3.0}/varcode/annotators/__init__.py +0 -0
  128. {varcode-10.2.1 → varcode-10.3.0}/varcode/annotators/fast.py +0 -0
  129. {varcode-10.2.1 → varcode-10.3.0}/varcode/annotators/protein_diff.py +0 -0
  130. {varcode-10.2.1 → varcode-10.3.0}/varcode/annotators/registry.py +0 -0
  131. {varcode-10.2.1 → varcode-10.3.0}/varcode/cli/__init__.py +0 -0
  132. {varcode-10.2.1 → varcode-10.3.0}/varcode/cli/effects_script.py +0 -0
  133. {varcode-10.2.1 → varcode-10.3.0}/varcode/cli/genes_script.py +0 -0
  134. {varcode-10.2.1 → varcode-10.3.0}/varcode/cli/logging.conf +0 -0
  135. {varcode-10.2.1 → varcode-10.3.0}/varcode/cli/main.py +0 -0
  136. {varcode-10.2.1 → varcode-10.3.0}/varcode/cli/sample_checks.py +0 -0
  137. {varcode-10.2.1 → varcode-10.3.0}/varcode/cli/variant_args.py +0 -0
  138. {varcode-10.2.1 → varcode-10.3.0}/varcode/cli/version_info.py +0 -0
  139. {varcode-10.2.1 → varcode-10.3.0}/varcode/common.py +0 -0
  140. {varcode-10.2.1 → varcode-10.3.0}/varcode/cryptic_exons.py +0 -0
  141. {varcode-10.2.1 → varcode-10.3.0}/varcode/csv_helpers.py +0 -0
  142. {varcode-10.2.1 → varcode-10.3.0}/varcode/effect_candidates.py +0 -0
  143. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/classify.py +0 -0
  144. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/codon_tables.py +0 -0
  145. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/common.py +0 -0
  146. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/effect_collection.py +0 -0
  147. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/effect_helpers.py +0 -0
  148. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/effect_ordering.py +0 -0
  149. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/effect_prediction.py +0 -0
  150. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/effect_prediction_coding.py +0 -0
  151. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/effect_prediction_coding_frameshift.py +0 -0
  152. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/effect_prediction_coding_in_frame.py +0 -0
  153. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/fast_path.py +0 -0
  154. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/mutate.py +0 -0
  155. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/selenocysteine.py +0 -0
  156. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/sequence_change.py +0 -0
  157. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/structural.py +0 -0
  158. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/structural_serialization.py +0 -0
  159. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/transcript_helpers.py +0 -0
  160. {varcode-10.2.1 → varcode-10.3.0}/varcode/effects/translate.py +0 -0
  161. {varcode-10.2.1 → varcode-10.3.0}/varcode/exacto.py +0 -0
  162. {varcode-10.2.1 → varcode-10.3.0}/varcode/genome.py +0 -0
  163. {varcode-10.2.1 → varcode-10.3.0}/varcode/genome_sequence.py +0 -0
  164. {varcode-10.2.1 → varcode-10.3.0}/varcode/genomic_layout.py +0 -0
  165. {varcode-10.2.1 → varcode-10.3.0}/varcode/genotype.py +0 -0
  166. {varcode-10.2.1 → varcode-10.3.0}/varcode/maf.py +0 -0
  167. {varcode-10.2.1 → varcode-10.3.0}/varcode/mutant_transcript.py +0 -0
  168. {varcode-10.2.1 → varcode-10.3.0}/varcode/nucleotides.py +0 -0
  169. {varcode-10.2.1 → varcode-10.3.0}/varcode/realized_effects.py +0 -0
  170. {varcode-10.2.1 → varcode-10.3.0}/varcode/reference.py +0 -0
  171. {varcode-10.2.1 → varcode-10.3.0}/varcode/rna_evidence.py +0 -0
  172. {varcode-10.2.1 → varcode-10.3.0}/varcode/rna_read_phasing.py +0 -0
  173. {varcode-10.2.1 → varcode-10.3.0}/varcode/sample_identity.py +0 -0
  174. {varcode-10.2.1 → varcode-10.3.0}/varcode/splice_graph.py +0 -0
  175. {varcode-10.2.1 → varcode-10.3.0}/varcode/splice_outcomes.py +0 -0
  176. {varcode-10.2.1 → varcode-10.3.0}/varcode/string_helpers.py +0 -0
  177. {varcode-10.2.1 → varcode-10.3.0}/varcode/structural_variant.py +0 -0
  178. {varcode-10.2.1 → varcode-10.3.0}/varcode/sv_allele_parser.py +0 -0
  179. {varcode-10.2.1 → varcode-10.3.0}/varcode/sv_comparison.py +0 -0
  180. {varcode-10.2.1 → varcode-10.3.0}/varcode/transcript_layout.py +0 -0
  181. {varcode-10.2.1 → varcode-10.3.0}/varcode/transforms/__init__.py +0 -0
  182. {varcode-10.2.1 → varcode-10.3.0}/varcode/ucsc_reference_names.py +0 -0
  183. {varcode-10.2.1 → varcode-10.3.0}/varcode/util.py +0 -0
  184. {varcode-10.2.1 → varcode-10.3.0}/varcode/variant.py +0 -0
  185. {varcode-10.2.1 → varcode-10.3.0}/varcode/variant_collection.py +0 -0
  186. {varcode-10.2.1 → varcode-10.3.0}/varcode/vcf.py +0 -0
  187. {varcode-10.2.1 → varcode-10.3.0}/varcode/vcf_output.py +0 -0
  188. {varcode-10.2.1 → varcode-10.3.0}/varcode/vcf_parsing.py +0 -0
  189. {varcode-10.2.1 → varcode-10.3.0}/varcode.egg-info/SOURCES.txt +0 -0
  190. {varcode-10.2.1 → varcode-10.3.0}/varcode.egg-info/dependency_links.txt +0 -0
  191. {varcode-10.2.1 → varcode-10.3.0}/varcode.egg-info/entry_points.txt +0 -0
  192. {varcode-10.2.1 → varcode-10.3.0}/varcode.egg-info/requires.txt +0 -0
  193. {varcode-10.2.1 → varcode-10.3.0}/varcode.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: varcode
3
- Version: 10.2.1
3
+ Version: 10.3.0
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
@@ -19,31 +19,49 @@ the ref alleles fail loudly rather than silently mis-classifying.
19
19
  """
20
20
  from __future__ import annotations
21
21
 
22
+ import copy
23
+ import dataclasses
24
+ import math
22
25
  import os
26
+ import pickle
23
27
  import tempfile
24
28
  import warnings
25
29
 
30
+ import numpy as np
26
31
  import pytest
27
32
 
28
33
  from pyensembl import cached_release
29
34
 
30
35
  from varcode import (
31
36
  Completeness,
37
+ EffectCollection,
32
38
  GenomeBuildMismatchError,
33
39
  GermlineContext,
40
+ HypothesisLimit,
41
+ HypothesisLimitError,
42
+ PhasePartition,
43
+ Unresolved,
34
44
  Variant,
35
45
  VariantCollection,
36
46
  apply_germline_to_transcript,
37
47
  detect_loh,
38
48
  detect_germline_overlap,
49
+ effect_priority,
39
50
  enumerate_phase_hypotheses,
40
51
  load_vcf,
52
+ partition_germline_by_phase,
41
53
  predict_germline_aware_effect,
42
54
  )
43
55
  from varcode.annotators.registry import get_default_annotator
56
+ from varcode.effects.effect_ordering import (
57
+ select_between_exonic_splice_site_and_alternate_effect,
58
+ )
59
+ from varcode.splice_outcomes import SpliceOutcomeSet
44
60
  from varcode.effects.effect_classes import (
61
+ IncompleteTranscript,
45
62
  PhaseCandidateSet,
46
63
  Substitution,
64
+ ThreePrimeUTR,
47
65
  )
48
66
 
49
67
 
@@ -403,41 +421,296 @@ class TestHemizygous:
403
421
  # --------------------------------------------------------------------
404
422
 
405
423
 
406
- class TestHypothesisCap:
407
- """When 2^n exceeds the cap, emit a single
408
- too_many_hypotheses placeholder. Default cap is 8 ⇒ up to 3
409
- germline variants in window fully unphased."""
424
+ def _germline_at(pos, contig="7"):
425
+ return Variant(contig=contig, start=pos, ref="A", alt="T",
426
+ genome=ensembl_grch38)
427
+
428
+
429
+ def _somatic_at(pos=100, contig="7"):
430
+ return Variant(contig=contig, start=pos, ref="A", alt="T",
431
+ genome=ensembl_grch38)
432
+
433
+
434
+ class _PartialPhaseResolver:
435
+ """Answers somatic-germline phase by germline position and
436
+ germline-germline phase by position pair; everything else is unknown."""
410
437
 
411
- def _germline(self, pos):
412
- return Variant(contig="7", start=pos, ref="A", alt="T",
413
- genome=ensembl_grch38)
438
+ def __init__(self, answers, links=None):
439
+ self._answers = answers
440
+ self._links = links or {}
414
441
 
442
+ def in_cis(self, v1, v2):
443
+ if v1.start == 100:
444
+ return self._answers.get(v2.start)
445
+ return self._links.get((v1.start, v2.start))
446
+
447
+
448
+ def _germline_vcf(genotype):
449
+ return _write_vcf(
450
+ "##fileformat=VCFv4.2\n"
451
+ "##contig=<ID=7>\n"
452
+ '##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">\n'
453
+ "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tNORMAL\n"
454
+ "7\t%d\t.\t%s\t%s\t.\tPASS\t.\tGT\t%s\n" % (
455
+ GERMLINE_POS, GERMLINE_REF, GERMLINE_ALT, genotype))
456
+
457
+
458
+ class TestPartitionGermlineByPhase:
459
+ def test_without_resolver_everything_is_unphased(self):
460
+ germ = [_germline_at(101), _germline_at(102)]
461
+ phase = partition_germline_by_phase(_somatic_at(), germ)
462
+ assert phase == PhasePartition(germline=tuple(germ))
463
+ assert phase.unphased == tuple(germ)
464
+
465
+ def test_resolver_answers_split_cis_trans_and_unphased(self):
466
+ germ = [_germline_at(p) for p in (101, 102, 103)]
467
+ phase = partition_germline_by_phase(
468
+ _somatic_at(), germ,
469
+ _PartialPhaseResolver({101: True, 102: False, 103: "maybe"}))
470
+ assert phase.cis == (germ[0],)
471
+ assert phase.trans == (germ[1],)
472
+ assert phase.unphased == (germ[2],)
473
+
474
+ def test_hemizygous_contig_is_implicitly_cis(self):
475
+ germ = [_germline_at(101, contig="MT")]
476
+ phase = partition_germline_by_phase(_somatic_at(contig="MT"), germ)
477
+ assert phase == PhasePartition(
478
+ germline=tuple(germ), cis=tuple(germ), implicit=True)
479
+
480
+ def test_homozygous_germline_is_cis_without_evidence(self):
481
+ germ = (_germline_at(101), _germline_at(102))
482
+ phase = partition_germline_by_phase(
483
+ _somatic_at(), germ, homozygous=germ[:1])
484
+ assert phase.cis == germ[:1]
485
+ assert phase.unphased == germ[1:]
486
+
487
+ def test_germline_to_germline_phase_links_unphased_variants(self):
488
+ germ = tuple(_germline_at(p) for p in range(101, 105))
489
+ links = {(101, 102): True, (101, 103): False, (103, 104): True}
490
+ phase = partition_germline_by_phase(
491
+ _somatic_at(), germ, _PartialPhaseResolver({}, links))
492
+ assert phase.linked == ((germ[:2], germ[2:]),)
493
+ assert phase.hypothesis_count == 2
494
+ assert {h.cis for h in phase.hypotheses()} == {germ[:2], germ[2:]}
495
+
496
+ def test_phase_follows_through_another_germline_variant(self):
497
+ germ = (_germline_at(101), _germline_at(102))
498
+ phase = partition_germline_by_phase(
499
+ _somatic_at(), germ,
500
+ _PartialPhaseResolver({101: True}, {(101, 102): False}))
501
+ assert (phase.cis, phase.trans) == (germ[:1], germ[1:])
502
+
503
+ def test_contradicting_answer_is_ignored_with_warning(self, caplog):
504
+ germ = (_germline_at(101), _germline_at(102))
505
+ resolver = _PartialPhaseResolver(
506
+ {101: True, 102: True}, {(101, 102): False})
507
+ phase = partition_germline_by_phase(_somatic_at(), germ, resolver)
508
+ assert phase.cis == germ
509
+ assert "contradicts" in caplog.text
510
+
511
+ def test_resolver_errors_are_logged_as_unknown(self, caplog):
512
+ class Broken:
513
+ def in_cis(self, v1, v2):
514
+ raise KeyError("contig naming mismatch")
515
+
516
+ phase = partition_germline_by_phase(
517
+ _somatic_at(), [_germline_at(101)], Broken())
518
+ assert phase.unphased == (_germline_at(101),)
519
+ assert "contig naming mismatch" in caplog.text
520
+
521
+
522
+ class TestPhasePartitionHypotheses:
523
+ def test_known_phase_gives_one_hypothesis(self):
524
+ g1, g2 = _germline_at(101), _germline_at(102)
525
+ (h,) = PhasePartition(
526
+ germline=(g1, g2), cis=(g1,), trans=(g2,)).hypotheses()
527
+ assert (h.cis, h.trans, h.phase_state) == ((g1,), (g2,), "phased")
528
+ assert h.haplotype == "A_mixed_1"
529
+ (h,) = PhasePartition(
530
+ germline=(g1,), cis=(g1,), implicit=True).hypotheses()
531
+ assert h.phase_state == "implicit"
532
+
533
+ def test_enumerates_only_unphased_variants(self):
534
+ g1, g2, g3 = (_germline_at(p) for p in (101, 102, 103))
535
+ phase = PhasePartition(germline=(g1, g2, g3), cis=(g1,), trans=(g2,))
536
+ hyps = phase.hypotheses()
537
+ assert phase.hypothesis_count == len(hyps) == 2
538
+ assert all(g1 in h.cis and g2 in h.trans for h in hyps)
539
+ assert {g3 in h.cis for h in hyps} == {True, False}
540
+ assert {h.phase_state for h in hyps} == {"unknown"}
541
+
542
+ def test_labels_depend_only_on_the_cis_set(self):
543
+ germ = tuple(_germline_at(p) for p in (101, 102, 103))
544
+ unknown = {h.cis: h.haplotype
545
+ for h in PhasePartition(germline=germ).hypotheses()}
546
+ partly_known = PhasePartition(germline=germ, trans=germ[:1])
547
+ for h in partly_known.hypotheses():
548
+ assert h.haplotype == unknown[h.cis]
549
+
550
+ def test_exceeding_the_cap_raises(self):
551
+ germ = tuple(_germline_at(p) for p in range(101, 105))
552
+ with pytest.raises(HypothesisLimitError) as error:
553
+ PhasePartition(germline=germ).hypotheses()
554
+ assert error.value.max_hypotheses == 8
555
+ assert len(PhasePartition(germline=germ).hypotheses(16)) == 16
556
+
557
+ def test_numpy_integer_cap_is_accepted(self):
558
+ phase = PhasePartition(germline=(_germline_at(101),))
559
+ assert len(phase.hypotheses(np.int64(2))) == 2
560
+ ctx = dataclasses.replace(
561
+ GermlineContext.empty(), max_phase_hypotheses=np.int64(2))
562
+ assert type(ctx.max_phase_hypotheses) is int
563
+
564
+ def test_limit_error_survives_pickle_and_copy(self):
565
+ error = pickle.loads(pickle.dumps(HypothesisLimitError(8)))
566
+ assert error.max_hypotheses == copy.deepcopy(error).max_hypotheses == 8
567
+ assert "max_hypotheses=8" in str(error)
568
+
569
+ @pytest.mark.parametrize("cap", [0, -1, True, 2.0, math.inf, "8", None])
570
+ def test_invalid_cap_is_rejected(self, cap):
571
+ with pytest.raises(ValueError, match="max_hypotheses"):
572
+ PhasePartition().hypotheses(cap)
573
+ with pytest.raises(ValueError, match="max_phase_hypotheses"):
574
+ dataclasses.replace(
575
+ GermlineContext.empty(), max_phase_hypotheses=cap)
576
+
577
+
578
+ class TestEnumeratePhaseHypotheses:
415
579
  def test_under_cap_enumerates(self):
416
- somatic = Variant(contig="7", start=100, ref="A", alt="T",
417
- genome=ensembl_grch38)
418
- germ = [self._germline(101), self._germline(102)]
419
- # 2 germline → 4 hypotheses, under default cap of 8.
420
- hyps = enumerate_phase_hypotheses(somatic, germ)
580
+ germ = [_germline_at(101), _germline_at(102)]
581
+ assert len(enumerate_phase_hypotheses(_somatic_at(), germ)) == 4
582
+
583
+ def test_partial_resolver_answers_avoid_the_cap(self):
584
+ germ = [_germline_at(p) for p in range(101, 105)]
585
+ with pytest.raises(HypothesisLimitError):
586
+ enumerate_phase_hypotheses(_somatic_at(), germ)
587
+ resolver = _PartialPhaseResolver({101: True, 102: False})
588
+ hyps = enumerate_phase_hypotheses(
589
+ _somatic_at(), germ, phase_resolver=resolver)
421
590
  assert len(hyps) == 4
422
591
 
423
- def test_over_cap_returns_placeholder(self):
424
- somatic = Variant(contig="7", start=100, ref="A", alt="T",
425
- genome=ensembl_grch38)
426
- # 4 germline → 16 hypotheses, over default cap.
427
- germ = [self._germline(p) for p in range(101, 105)]
428
- hyps = enumerate_phase_hypotheses(somatic, germ)
429
- assert len(hyps) == 1
430
- assert hyps[0].phase_state == "too_many_hypotheses"
431
- # Conservatively marks all germline as cis (the worst-case).
432
- assert len(hyps[0].cis) == len(germ)
433
592
 
434
- def test_caller_can_raise_cap(self):
435
- somatic = Variant(contig="7", start=100, ref="A", alt="T",
436
- genome=ensembl_grch38)
437
- germ = [self._germline(p) for p in range(101, 105)]
438
- # Raise the cap to 32 → 16 hypotheses now fit.
439
- hyps = enumerate_phase_hypotheses(somatic, germ, max_hypotheses=32)
440
- assert len(hyps) == 16
593
+ class TestHypothesisLimit:
594
+ """Unenumerated phase stays unresolved instead of becoming the cis
595
+ consequence (#503). The CFTR pair has differing alternatives:
596
+ p.L159M in trans and p.S159T in cis."""
597
+
598
+ def _ctx(self, max_phase_hypotheses=8):
599
+ return dataclasses.replace(
600
+ GermlineContext.from_variants(
601
+ [_same_codon_germline()], reference_name="GRCh38"),
602
+ max_phase_hypotheses=max_phase_hypotheses)
603
+
604
+ def _predict(self, ctx, transcript=None, **kwargs):
605
+ return predict_germline_aware_effect(
606
+ _somatic(), transcript or _cftr(), ctx, get_default_annotator(),
607
+ **kwargs)
608
+
609
+ def test_under_cap_keeps_both_alternatives(self):
610
+ e = self._predict(self._ctx())
611
+ assert isinstance(e, PhaseCandidateSet)
612
+ assert {c.effect.short_description for c in e.candidates} == {
613
+ "p.L159M", "p.S159T"}
614
+
615
+ def test_exceeded_cap_records_phase_and_reference(self):
616
+ e = self._predict(self._ctx(max_phase_hypotheses=1))
617
+ assert isinstance(e, HypothesisLimit)
618
+ assert isinstance(e, Unresolved)
619
+ assert e.short_description == "unresolved-hypothesis-limit"
620
+ assert e.modifies_protein_sequence is None
621
+ assert e.mutant_protein_sequence is None
622
+ assert e.max_hypotheses == 1
623
+ assert e.phase == PhasePartition(germline=(_same_codon_germline(),))
624
+ assert e.reference_effect.short_description == "p.L159M"
625
+
626
+ def test_effects_uses_the_context_cap(self):
627
+ variant = _somatic()
628
+ (e,) = [e for e in variant.effects(germline=self._ctx(1))
629
+ if e.transcript.id == CFTR_ID]
630
+ assert isinstance(e, HypothesisLimit)
631
+
632
+ def test_explicit_cap_overrides_the_context(self):
633
+ e = self._predict(self._ctx(max_phase_hypotheses=1), max_hypotheses=2)
634
+ assert isinstance(e, PhaseCandidateSet)
635
+
636
+ def test_known_phase_under_small_cap_still_classifies(self):
637
+ e = self._predict(
638
+ self._ctx(max_phase_hypotheses=1),
639
+ phase_resolver=_StubPhaseResolver(in_cis_answer=True))
640
+ assert e.short_description == "p.S159T"
641
+ assert e.germline_phase_state == "phased"
642
+
643
+ def test_phase_independent_transcript_ignores_the_cap(self):
644
+ incomplete = ensembl_grch38.transcript_by_id("ENST00000426809")
645
+ e = self._predict(self._ctx(max_phase_hypotheses=1), incomplete)
646
+ assert isinstance(e, IncompleteTranscript)
647
+
648
+ def test_four_unphased_variants_exceed_default_cap(self):
649
+ germline = [
650
+ Variant(contig="7", start=pos, ref="A", alt="G",
651
+ genome=ensembl_grch38)
652
+ for pos in (117_480_100, 117_500_100, 117_540_100, 117_600_100)]
653
+ ctx = GermlineContext.from_variants(germline, reference_name="GRCh38")
654
+
655
+ def whole_transcript(variant, transcript):
656
+ return transcript.contig, transcript.start, transcript.end
657
+
658
+ e = self._predict(ctx, window_fn=whole_transcript)
659
+ assert isinstance(e, HypothesisLimit)
660
+ assert e.phase.unphased == tuple(germline)
661
+
662
+ def test_ranks_like_the_reference_effect(self):
663
+ e = self._predict(self._ctx(max_phase_hypotheses=1))
664
+ assert effect_priority(e) == effect_priority(e.reference_effect)
665
+ sibling_utr = ThreePrimeUTR(
666
+ _somatic(), ensembl_grch38.transcript_by_id("ENST00000426809"))
667
+ effects = EffectCollection([sibling_utr, e])
668
+ assert effects.top_priority_effect_per_variant()[_somatic()] is e
669
+
670
+ def test_phase_candidate_set_ranks_as_its_most_severe_candidate(self):
671
+ e = self._predict(self._ctx())
672
+ assert effect_priority(e) == effect_priority(e.highest_priority_effect)
673
+ sibling = IncompleteTranscript(
674
+ _somatic(), ensembl_grch38.transcript_by_id("ENST00000426809"))
675
+ assert EffectCollection([sibling, e]).top_priority_effect() is e
676
+
677
+ def test_splice_reference_is_wrapped_and_ranked_as_selected(self):
678
+ splice_variant = Variant(
679
+ "7", 117_531_114, "G", "T", genome=ensembl_grch38)
680
+ germline = Variant("7", 117_531_113, "A", "G", genome=ensembl_grch38)
681
+ ctx = dataclasses.replace(
682
+ GermlineContext.from_variants([germline], reference_name="GRCh38"),
683
+ max_phase_hypotheses=1)
684
+ e = predict_germline_aware_effect(
685
+ splice_variant, _cftr(), ctx, get_default_annotator())
686
+ assert isinstance(e, HypothesisLimit)
687
+ assert isinstance(e.reference_effect, SpliceOutcomeSet)
688
+ assert effect_priority(e) == effect_priority(
689
+ select_between_exonic_splice_site_and_alternate_effect(
690
+ e.reference_effect))
691
+
692
+ def test_homozygous_germline_resolves_phase(self):
693
+ ctx = GermlineContext.from_germline_vcf(
694
+ _germline_vcf("1/1"), genome=ensembl_grch38)
695
+ assert ctx.homozygous(ctx.variants) == tuple(ctx.variants)
696
+ e = self._predict(dataclasses.replace(ctx, max_phase_hypotheses=1))
697
+ assert e.short_description == "p.S159T"
698
+ assert e.germline_phase_state == "phased"
699
+
700
+ def test_heterozygous_germline_is_not_homozygous(self):
701
+ ctx = GermlineContext.from_germline_vcf(
702
+ _germline_vcf("0/1"), genome=ensembl_grch38)
703
+ assert ctx.homozygous(ctx.variants) == ()
704
+
705
+ def test_json_round_trip(self):
706
+ e = self._predict(self._ctx(max_phase_hypotheses=1))
707
+ restored = EffectCollection.from_json(
708
+ EffectCollection([e]).to_json())[0]
709
+ assert restored == e
710
+ assert hash(restored) == hash(e)
711
+ assert restored.phase == e.phase
712
+ assert restored.reason == e.reason
713
+ assert restored.reference_effect == e.reference_effect
441
714
 
442
715
 
443
716
  # --------------------------------------------------------------------
@@ -19,6 +19,7 @@ openvax/isovar) — verifying the plumbing without tying the test suite
19
19
  to any one upstream's release cadence.
20
20
  """
21
21
 
22
+ import numpy as np
22
23
  from pyensembl import cached_release
23
24
 
24
25
  from varcode import (
@@ -30,6 +31,7 @@ from varcode import (
30
31
  Variant,
31
32
  VariantCollection,
32
33
  apply_phase_resolver_to_effects,
34
+ query_in_cis,
33
35
  )
34
36
 
35
37
 
@@ -110,6 +112,18 @@ def test_in_cis_false_when_observed_on_different_molecules():
110
112
  assert resolver.in_cis(v1, v2, transcript=transcript) is False
111
113
 
112
114
 
115
+ def test_in_cis_false_when_only_one_variant_has_evidence():
116
+ """Without its own ``in_cis``, a source's reads are assumed to span
117
+ nearby variants, so absence from the partners is read as trans."""
118
+ transcript = _cftr()
119
+ v1 = Variant("7", 117531100, "T", "A", ensembl_grch38)
120
+ v2 = Variant("7", 117531114, "G", "T", ensembl_grch38)
121
+ source = StubReadPhasingSource(phasing={v1: (v1,)})
122
+ resolver = ReadPhaseResolver(source)
123
+ assert resolver.in_cis(v1, v2, transcript=transcript) is False
124
+ assert resolver.in_cis(v2, v1, transcript=transcript) is False
125
+
126
+
113
127
  def test_in_cis_none_when_no_evidence():
114
128
  transcript = _cftr()
115
129
  v1 = Variant("7", 117531100, "T", "A", ensembl_grch38)
@@ -276,3 +290,51 @@ def test_user_example_shape_works():
276
290
  found_protein = e.mutant_transcript.mutant_protein_sequence
277
291
  break
278
292
  assert found_protein == stub_mt.mutant_protein_sequence
293
+
294
+
295
+ # --------------------------------------------------------------------
296
+ # query_in_cis: one policy for asking any resolver
297
+ # --------------------------------------------------------------------
298
+
299
+
300
+ class _Answer:
301
+ def __init__(self, answer):
302
+ self.answer = answer
303
+
304
+ def in_cis(self, v1, v2):
305
+ return self.answer
306
+
307
+
308
+ def test_query_in_cis_normalizes_answers():
309
+ v1 = Variant("7", 117531100, "T", "A", ensembl_grch38)
310
+ v2 = Variant("7", 117531114, "G", "T", ensembl_grch38)
311
+ assert query_in_cis(_Answer(np.True_), v1, v2) is True
312
+ assert query_in_cis(_Answer(np.False_), v1, v2) is False
313
+ assert query_in_cis(_Answer("maybe"), v1, v2) is None
314
+ assert query_in_cis(None, v1, v2) is None
315
+
316
+
317
+ def test_query_in_cis_passes_transcript_only_when_given():
318
+ seen = []
319
+
320
+ class WithTranscript:
321
+ def in_cis(self, v1, v2, transcript=None):
322
+ seen.append(transcript)
323
+ return True
324
+
325
+ v1 = Variant("7", 117531100, "T", "A", ensembl_grch38)
326
+ v2 = Variant("7", 117531114, "G", "T", ensembl_grch38)
327
+ assert query_in_cis(_Answer(True), v1, v2) is True
328
+ assert query_in_cis(WithTranscript(), v1, v2, transcript=_cftr()) is True
329
+ assert seen == [_cftr()]
330
+
331
+
332
+ def test_query_in_cis_logs_resolver_errors(caplog):
333
+ class Broken:
334
+ def in_cis(self, v1, v2):
335
+ raise KeyError("chr prefix")
336
+
337
+ v1 = Variant("7", 117531100, "T", "A", ensembl_grch38)
338
+ v2 = Variant("7", 117531114, "G", "T", ensembl_grch38)
339
+ assert query_in_cis(Broken(), v1, v2) is None
340
+ assert "chr prefix" in caplog.text
@@ -1,18 +1,24 @@
1
1
  """End-to-end tests for the experimental transcript model."""
2
2
 
3
+ import dataclasses
3
4
  import pickle
4
5
  import subprocess
5
6
  import sys
6
7
 
8
+ import numpy as np
7
9
  import pytest
8
10
  from pyensembl import cached_release
9
11
 
10
12
  from varcode import (
11
13
  Completeness,
14
+ EffectCollection,
12
15
  GermlineContext,
16
+ HypothesisLimit,
17
+ PhasePartition,
13
18
  StructuralVariant,
14
19
  TranscriptModelEffectAnnotator,
15
20
  Variant,
21
+ effect_priority,
16
22
  get_default_annotator,
17
23
  get_annotator,
18
24
  predict_transcript_model_effect,
@@ -184,10 +190,94 @@ def test_combined_phase_and_splice_hypotheses_obey_global_cap():
184
190
  somatic = point(11, "G", "A")
185
191
  germline = point(9, "A", "G")
186
192
 
187
- with pytest.raises(ValueError, match="Combined phase/splice"):
188
- predict_transcript_model_effect(
189
- (somatic,), transcript, germline_variants=(germline,),
190
- sequence_provider=provider(), max_hypotheses=7)
193
+ result = predict_transcript_model_effect(
194
+ (somatic,), transcript, germline_variants=(germline,),
195
+ sequence_provider=provider(), max_hypotheses=7)
196
+
197
+ assert isinstance(result, HypothesisLimit)
198
+ assert result.max_hypotheses == 7
199
+ assert result.phase == PhasePartition(germline=(germline,))
200
+ assert result.reference_effect == predict_transcript_model_effect(
201
+ (somatic,), transcript, sequence_provider=provider(), max_hypotheses=7)
202
+
203
+
204
+ def test_phase_cap_gives_hypothesis_limit_ranked_like_reference():
205
+ transcript = ensembl_grch38.transcript_by_id(CFTR_TRANSCRIPT_ID)
206
+ somatic = Variant("7", 117531100, "T", "A", ensembl_grch38)
207
+ germline = Variant("7", 117531101, "T", "C", ensembl_grch38)
208
+
209
+ result = predict_transcript_model_effect(
210
+ (somatic,), transcript, germline_variants=(germline,),
211
+ max_phase_hypotheses=1)
212
+
213
+ assert isinstance(result, HypothesisLimit)
214
+ assert result.max_hypotheses == 1
215
+ assert result.reference_effect.short_description == "p.L159M"
216
+ assert effect_priority(result) == effect_priority(result.reference_effect)
217
+
218
+
219
+ def test_transcript_model_uses_context_phase_cap():
220
+ transcript = ensembl_grch38.transcript_by_id(CFTR_TRANSCRIPT_ID)
221
+ somatic = Variant("7", 117531100, "T", "A", ensembl_grch38)
222
+ ctx = dataclasses.replace(
223
+ GermlineContext.from_variants(
224
+ [Variant("7", 117531101, "T", "C", ensembl_grch38)],
225
+ reference_name="GRCh38"),
226
+ max_phase_hypotheses=1)
227
+
228
+ result = TranscriptModelEffectAnnotator().annotate_with_context(
229
+ somatic, transcript, ctx)
230
+
231
+ assert isinstance(result, HypothesisLimit)
232
+
233
+
234
+ def test_direct_phase_cap_defaults_to_max_hypotheses():
235
+ transcript = ensembl_grch38.transcript_by_id(CFTR_TRANSCRIPT_ID)
236
+ somatic = Variant("7", 117531100, "T", "A", ensembl_grch38)
237
+ germline = Variant("7", 117531101, "T", "C", ensembl_grch38)
238
+
239
+ capped = predict_transcript_model_effect(
240
+ (somatic,), transcript, germline_variants=(germline,), max_hypotheses=1)
241
+ enumerated = predict_transcript_model_effect(
242
+ (somatic,), transcript, germline_variants=(germline,))
243
+
244
+ assert isinstance(capped, HypothesisLimit)
245
+ assert not isinstance(enumerated, HypothesisLimit)
246
+
247
+
248
+ def test_splice_limit_without_germline_leaves_no_reference():
249
+ transcript = Transcript()
250
+ somatic = point(11, "G", "A")
251
+ germline = point(9, "A", "G")
252
+
253
+ result = predict_transcript_model_effect(
254
+ (somatic,), transcript, germline_variants=(germline,),
255
+ sequence_provider=provider(), max_hypotheses=1)
256
+
257
+ assert isinstance(result, HypothesisLimit)
258
+ assert result.reference_effect is None
259
+
260
+
261
+ def test_numpy_cap_result_exports_to_json():
262
+ transcript = ensembl_grch38.transcript_by_id(CFTR_TRANSCRIPT_ID)
263
+ somatic = Variant("7", 117531100, "T", "A", ensembl_grch38)
264
+ germline = Variant("7", 117531101, "T", "C", ensembl_grch38)
265
+
266
+ result = predict_transcript_model_effect(
267
+ (somatic,), transcript, germline_variants=(germline,),
268
+ max_hypotheses=np.int64(1))
269
+
270
+ assert type(result.max_hypotheses) is int
271
+ restored = EffectCollection.from_json(EffectCollection([result]).to_json())
272
+ assert restored[0] == result
273
+
274
+
275
+ @pytest.mark.parametrize("cap", ["max_hypotheses", "max_phase_hypotheses"])
276
+ def test_transcript_model_rejects_invalid_caps(cap):
277
+ transcript = ensembl_grch38.transcript_by_id(CFTR_TRANSCRIPT_ID)
278
+ somatic = Variant("7", 117531100, "T", "A", ensembl_grch38)
279
+ with pytest.raises(ValueError, match=cap):
280
+ predict_transcript_model_effect((somatic,), transcript, **{cap: 0})
191
281
 
192
282
 
193
283
  def test_real_cftr_missense_matches_existing_varcode_result():
@@ -24,7 +24,11 @@ from .annotators import (
24
24
  set_default_annotator,
25
25
  use_annotator,
26
26
  )
27
- from .errors import ReferenceMismatchError, SampleNotFoundError
27
+ from .errors import (
28
+ HypothesisLimitError,
29
+ ReferenceMismatchError,
30
+ SampleNotFoundError,
31
+ )
28
32
  from .genome import Genome
29
33
  from .genome_sequence import reference_base, reference_range
30
34
  from .germline import (
@@ -32,11 +36,13 @@ from .germline import (
32
36
  GermlineContext,
33
37
  Completeness,
34
38
  PhaseHypothesis,
39
+ PhasePartition,
35
40
  apply_germline_to_transcript,
36
41
  default_germline_window,
37
42
  detect_loh,
38
43
  detect_germline_overlap,
39
44
  enumerate_phase_hypotheses,
45
+ partition_germline_by_phase,
40
46
  predict_germline_aware_effect,
41
47
  )
42
48
  from .genotype import Genotype, Zygosity
@@ -61,6 +67,7 @@ from .phasing import (
61
67
  ReadPhasingSource,
62
68
  VCFPhaseResolver,
63
69
  apply_phase_resolver_to_effects,
70
+ query_in_cis,
64
71
  )
65
72
  from .rna_read_phasing import RNAReadPhasingSource
66
73
  from .rna_evidence import (
@@ -104,6 +111,7 @@ from .effects import (
104
111
  MultiOutcomeEffect,
105
112
  MutationEffect,
106
113
  NonsilentCodingMutation,
114
+ HypothesisLimit,
107
115
  Unresolved,
108
116
  GermlineAlleleOverlap,
109
117
  )
@@ -179,6 +187,7 @@ __all__ = [
179
187
  "RNAReadPhasingSource",
180
188
  "VCFPhaseResolver",
181
189
  "apply_phase_resolver_to_effects",
190
+ "query_in_cis",
182
191
 
183
192
  # RNA-evidence resolver (openvax/varcode#259)
184
193
  "RNAEvidenceResolver",
@@ -206,6 +215,7 @@ __all__ = [
206
215
  "top_priority_effect",
207
216
  "MultiOutcomeEffect",
208
217
  "MutationEffect",
218
+ "HypothesisLimit",
209
219
  "Unresolved",
210
220
  "NonsilentCodingMutation",
211
221
 
@@ -213,17 +223,20 @@ __all__ = [
213
223
  "ReferenceMismatchError",
214
224
  "SampleNotFoundError",
215
225
  "GenomeBuildMismatchError",
226
+ "HypothesisLimitError",
216
227
 
217
228
  # Germline-aware annotation (openvax/varcode#268)
218
229
  "GermlineContext",
219
230
  "Completeness",
220
231
  "PhaseHypothesis",
232
+ "PhasePartition",
221
233
  "apply_germline_to_transcript",
222
234
  "default_germline_window",
223
235
  "detect_loh",
224
236
  "detect_germline_overlap",
225
237
  "GermlineAlleleOverlap",
226
238
  "enumerate_phase_hypotheses",
239
+ "partition_germline_by_phase",
227
240
  "predict_germline_aware_effect",
228
241
 
229
242
  # Genome wrapper + tiered reference lookup (openvax/varcode#372)