ensembl.vep.annotators.consequence.facts package#
Cost-tagged facts used by consequence rules.
Importing this package populates REGISTRY through register_fact decorators.
FactContext remains in consequence.context beside AnnotatorContext because the two
types differ by lifetime rather than by responsibility.
Submodules#
ensembl.vep.annotators.consequence.facts.base module#
Lazy, memoised, cost-tagged facts for consequence annotation.
Facts form a dependency graph and are computed at most once per FactContext. Declared costs
allow strategies to order work and measure avoided computation.
Registered functions have two forms:
Boolean facts have public names and may appear in catalogue formulas.
Internal value facts have private names and share non-Boolean intermediate values between facts.
Internal value facts must not declare requires because a failed guard returns False.
Keep single-use calculations as plain helpers; registration only benefits values shared by
multiple facts.
- class ensembl.vep.annotators.consequence.facts.base.Fact(*, name, cost, compute, unguarded_compute=<factory>, deps=(), requires=(), documentation='')[source]#
Bases:
objectRepresent a named, cost-tagged property derived from a context.
depsnames values the implementation reads.requiresnames Boolean preconditions; these are also dependencies and allow evaluation to returnFalsebefore running the fact.- Variables:
name (str) – Registry key and rule atom name.
cost (int) – Marginal evaluation cost, excluding dependencies.
compute (Callable[[FactContext[Any]], object]) – Guarded computation called by
get_fact.unguarded_compute (Callable[[FactContext[Any]], object]) – Original computation used to validate
requiresdeclarations.deps (tuple[str, ...]) – Facts read by the computation.
requires (tuple[str, ...]) – Boolean preconditions that gate the computation.
documentation (str) – Description copied from the registered function.
- compute: Callable[[FactContext[Any]], object]#
- cost: int#
- deps: tuple[str, ...]#
- documentation: str#
- name: str#
- requires: tuple[str, ...]#
- unguarded_compute: Callable[[FactContext[Any]], object]#
- ensembl.vep.annotators.consequence.facts.base.REGISTRY: dict[str, Fact] = {'_cds_footprint': Fact(name='_cds_footprint', cost=<CostTier.MAPPING: 20>, compute=<function _cds_footprint>, unguarded_compute=<function _cds_footprint>, deps=(), requires=(), documentation="Return the zero-based CDS offset span touched by the variant.\n\n Delegates to Mapper.genomic_span_to_cds_offsets, which intersects the variant span against the\n CDS's genomic spans directly (O(exon count)) rather than mapping every individual genomic\n position in the variant's span (O(span length)) which can be very large for a large structural variant.\n\n No accelerator needed here: the block-overlap approach is already O(exon count), which the O(1)\n per-position MapperIndex cannot improve on further.\n\n NOTE: It is important to check overlap with every coding span, not just the two endpoints of the variant's\n genomic span. A variant can have both endpoints outside of coding exons but still overlap the CDS.\n "), '_codon_alleles': Fact(name='_codon_alleles', cost=<CostTier.SEQUENCE: 60>, compute=<function _codon_alleles>, unguarded_compute=<function _codon_alleles>, deps=(), requires=(), documentation='Return reference and alternate codon windows around the variant.\n\n The overlap cases its codons for display; every comparison here is on the bases alone.\n '), '_full_cds_peptide_alleles': Fact(name='_full_cds_peptide_alleles', cost=<CostTier.TRANSCRIPT_SEQUENCE: 200>, compute=<function _full_cds_peptide_alleles>, unguarded_compute=<function _full_cds_peptide_alleles>, deps=(), requires=(), documentation="Return peptides translated from the complete reference and alternate CDS.\n\n ``data/fact_costs.json`` (the opt-in measured-cost override, see facts/base.py) has no entry\n for this fact, so its declared ``CostTier.TRANSCRIPT_SEQUENCE`` applies whenever that override\n is enabled too -- not regenerated here since ``vep catalogue costs`` profiles against a live\n corpus and picking one is a judgement call outside this change's scope.\n "), '_nearby_introns': Fact(name='_nearby_introns', cost=<CostTier.INTERVAL: 5>, compute=<function _nearby_introns>, unguarded_compute=<function _nearby_introns>, deps=(), requires=(), documentation='Return every intron within 20 bases of the variant.'), '_peptide_alleles': Fact(name='_peptide_alleles', cost=<CostTier.SEQUENCE: 60>, compute=<function _peptide_alleles>, unguarded_compute=<function _peptide_alleles>, deps=(), requires=(), documentation='Return peptides translated from the reference and alternate codon windows.'), 'alt_matches_ref_codon_edge': Fact(name='alt_matches_ref_codon_edge', cost=<CostTier.SEQUENCE: 60>, compute=<function alt_matches_ref_codon_edge>, unguarded_compute=<function alt_matches_ref_codon_edge>, deps=('_codon_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds'), requires=('is_transcript', 'overlap_feature', 'overlap_cds'), documentation="Return whether a deletion removes whole codons while preserving a window edge.\n\n VEP's own test for an inframe deletion (``VariationEffect::inframe_deletion``): see\n ``_matches_codon_edge`` for its two branches.\n "), 'alt_peptide_has_ter': Fact(name='alt_peptide_has_ter', cost=<CostTier.SEQUENCE: 60>, compute=<function alt_peptide_has_ter>, unguarded_compute=<function alt_peptide_has_ter>, deps=('_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation='Return whether the alternate peptide window contains a stop codon.'), 'alt_peptide_is_ter': Fact(name='alt_peptide_is_ter', cost=<CostTier.SEQUENCE: 60>, compute=<function alt_peptide_is_ter>, unguarded_compute=<function alt_peptide_is_ter>, deps=('_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation='Return whether the alternate peptide is exactly one stop codon.'), 'alt_peptide_matches_ref_edge': Fact(name='alt_peptide_matches_ref_edge', cost=<CostTier.SEQUENCE: 60>, compute=<function alt_peptide_matches_ref_edge>, unguarded_compute=<function alt_peptide_matches_ref_edge>, deps=('_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation="Return whether the alternate peptide preserves a reference-window edge.\n\n VEP's test for an inframe insertion (``VariationEffect::inframe_insertion``), which it makes on\n the peptides rather than the codons: residues added at one end of the window leave the\n reference residues intact at the other. The alternate window is cut at its first stop first, so\n that an insertion which also introduces a stop is judged on what precedes it.\n "), 'biotype_miRNA': Fact(name='biotype_miRNA', cost=<CostTier.FREE: 0>, compute=<function biotype_miRNA>, unguarded_compute=<function biotype_miRNA>, deps=('is_transcript',), requires=('is_transcript',), documentation='Return whether the transcript has a microRNA biotype.'), 'biotype_nmd': Fact(name='biotype_nmd', cost=<CostTier.FREE: 0>, compute=<function biotype_nmd>, unguarded_compute=<function biotype_nmd>, deps=('is_transcript',), requires=('is_transcript',), documentation='Return whether the transcript has a nonsense-mediated-decay biotype.'), 'biotype_non_coding': Fact(name='biotype_non_coding', cost=<CostTier.FREE: 0>, compute=<function biotype_non_coding>, unguarded_compute=<function biotype_non_coding>, deps=('is_transcript',), requires=('is_transcript',), documentation='Return whether the transcript is non-coding.'), 'biotype_protein_coding': Fact(name='biotype_protein_coding', cost=<CostTier.FREE: 0>, compute=<function biotype_protein_coding>, unguarded_compute=<function biotype_protein_coding>, deps=('is_transcript',), requires=('is_transcript',), documentation='Return whether the transcript has a protein-coding biotype.'), 'cds_length_change_inframe': Fact(name='cds_length_change_inframe', cost=<CostTier.MAPPING: 20>, compute=<function cds_length_change_inframe>, unguarded_compute=<function cds_length_change_inframe>, deps=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation="Return whether the coding-length change is in frame.\n\n False when the variant does not overlap the CDS. There is then no coding length change to be in\n frame, and reporting True would contradict this fact's own ``requires``.\n "), 'cds_start_lost': Fact(name='cds_start_lost', cost=<CostTier.FREE: 0>, compute=<function cds_start_lost>, unguarded_compute=<function cds_start_lost>, deps=('_full_cds_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation', 'overlap_start_codon'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation', 'overlap_start_codon'), documentation='Return whether the alternate CDS loses the start codon.'), 'cds_start_retained': Fact(name='cds_start_retained', cost=<CostTier.FREE: 0>, compute=<function cds_start_retained>, unguarded_compute=<function cds_start_retained>, deps=('_full_cds_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation', 'overlap_start_codon'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation', 'overlap_start_codon'), documentation='Return whether the alternate CDS retains the initiator methionine.\n\n Computed from the peptides directly rather than as ``not cds_start_lost``. Negating a *guarded*\n fact is unsound: when a required atom is false, ``cds_start_lost`` short-circuits to False, and\n ``not False`` claims the start codon is retained for a variant that never touches it -- which\n is exactly what ``verify_requires`` catches by running this body unguarded. Deriving it here\n also returns False (not True) when the peptides are unavailable, matching ``cds_stop_retained``.\n Caching is unaffected: ``_full_cds_peptide_alleles`` is the memoised dep both facts read.\n '), 'cds_stop_gain': Fact(name='cds_stop_gain', cost=<CostTier.FREE: 0>, compute=<function cds_stop_gain>, unguarded_compute=<function cds_stop_gain>, deps=('_full_cds_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation='Return whether the alternate CDS introduces a premature stop codon.'), 'cds_stop_lost': Fact(name='cds_stop_lost', cost=<CostTier.FREE: 0>, compute=<function cds_stop_lost>, unguarded_compute=<function cds_stop_lost>, deps=('_full_cds_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation="Return whether the alternate CDS loses the stop codon.\n\n Requires the alternate peptide to match the reference up to (but not including) the reference's own stop\n position, so a frameshift several codons upstream that happens to remove the stop incidentally doesn't\n get conflated with an edit that actually changes the stop codon itself.\n "), 'cds_stop_retained': Fact(name='cds_stop_retained', cost=<CostTier.FREE: 0>, compute=<function cds_stop_retained>, unguarded_compute=<function cds_stop_retained>, deps=('_full_cds_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation='Return whether the alternate CDS retains the stop codon.\n\n Requires stop at the exact same reading-frame position, with the same prefix leading up to it.'), 'contain_feature': Fact(name='contain_feature', cost=<CostTier.BOUNDS: 1>, compute=<function contain_feature>, unguarded_compute=<function contain_feature>, deps=(), requires=(), documentation='Return whether the variant contains the feature\'s genomic span.\n\n Not zone-mappable: a zone-map union answers "does the span touch this interval", not\n "is the span fully inside one specific interval".\n '), 'has_translation': Fact(name='has_translation', cost=<CostTier.FREE: 0>, compute=<function has_translation>, unguarded_compute=<function has_translation>, deps=('is_transcript',), requires=('is_transcript',), documentation='Return whether the transcript has a translation.'), 'insertion_after_start': Fact(name='insertion_after_start', cost=<CostTier.SEQUENCE: 60>, compute=<function insertion_after_start>, unguarded_compute=<function insertion_after_start>, deps=('_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation='Return whether an insertion occurs after and preserves the start codon.'), 'insertion_before_start': Fact(name='insertion_before_start', cost=<CostTier.SEQUENCE: 60>, compute=<function insertion_before_start>, unguarded_compute=<function insertion_before_start>, deps=('_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation='Return whether an insertion occurs before and preserves the start codon.\n\n Because variant overlaps start codon (verified by overlap_start_codon fact requirement) the reference\n peptide should include the start peptide. If the alternate peptide window ends with the reference peptide\n then it also include the start codon with inserted amino acids before it.\n\n An empty reference peptide is excluded because ``str.endswith("")`` is trivially True for any string,\n which would make this fact vacuously True for every overlap.\n '), 'is_chromosomal_breakpoint': Fact(name='is_chromosomal_breakpoint', cost=<CostTier.FREE: 0>, compute=<function is_chromosomal_breakpoint>, unguarded_compute=<function is_chromosomal_breakpoint>, deps=('is_structural',), requires=('is_structural',), documentation='Return whether the variant represents a chromosomal breakpoint.'), 'is_copy_number_gain': Fact(name='is_copy_number_gain', cost=<CostTier.FREE: 0>, compute=<function is_copy_number_gain>, unguarded_compute=<function is_copy_number_gain>, deps=('is_structural',), requires=('is_structural',), documentation='Return whether the variant represents a copy-number gain.'), 'is_copy_number_loss': Fact(name='is_copy_number_loss', cost=<CostTier.FREE: 0>, compute=<function is_copy_number_loss>, unguarded_compute=<function is_copy_number_loss>, deps=('is_structural',), requires=('is_structural',), documentation='Return whether the variant represents a copy-number loss.'), 'is_deletion': Fact(name='is_deletion', cost=<CostTier.FREE: 0>, compute=<function is_deletion>, unguarded_compute=<function is_deletion>, deps=('is_short_deletion', 'is_structural_deletion'), requires=(), documentation='Return whether the variant removes sequence.'), 'is_downstream': Fact(name='is_downstream', cost=<CostTier.BOUNDS: 1>, compute=<function is_downstream>, unguarded_compute=<function is_downstream>, deps=(), requires=(), documentation='Return whether the variant lies within the downstream pairing distance.'), 'is_duplication': Fact(name='is_duplication', cost=<CostTier.FREE: 0>, compute=<function is_duplication>, unguarded_compute=<function is_duplication>, deps=('is_structural',), requires=('is_structural',), documentation='Return whether the variant represents a duplicated segment.'), 'is_indel': Fact(name='is_indel', cost=<CostTier.FREE: 0>, compute=<function is_indel>, unguarded_compute=<function is_indel>, deps=('is_short_indel', 'is_structural_indel'), requires=(), documentation='Return whether the variant changes sequence length.'), 'is_insertion': Fact(name='is_insertion', cost=<CostTier.FREE: 0>, compute=<function is_insertion>, unguarded_compute=<function is_insertion>, deps=('is_short_insertion', 'is_structural_insertion'), requires=(), documentation='Return whether the variant adds sequence.'), 'is_motif': Fact(name='is_motif', cost=<CostTier.FREE: 0>, compute=<function is_motif>, unguarded_compute=<function is_motif>, deps=(), requires=(), documentation='Return whether the overlapped feature is a motif.'), 'is_regulatory': Fact(name='is_regulatory', cost=<CostTier.FREE: 0>, compute=<function is_regulatory>, unguarded_compute=<function is_regulatory>, deps=(), requires=(), documentation='Return whether the overlapped feature is regulatory.'), 'is_short': Fact(name='is_short', cost=<CostTier.FREE: 0>, compute=<function is_short>, unguarded_compute=<function is_short>, deps=(), requires=(), documentation='Return whether the overlapping allele is a short variant.'), 'is_short_deletion': Fact(name='is_short_deletion', cost=<CostTier.FREE: 0>, compute=<function is_short_deletion>, unguarded_compute=<function is_short_deletion>, deps=('is_short',), requires=('is_short',), documentation='Return whether the variant is a short deletion.'), 'is_short_indel': Fact(name='is_short_indel', cost=<CostTier.FREE: 0>, compute=<function is_short_indel>, unguarded_compute=<function is_short_indel>, deps=('is_short_insertion', 'is_short_deletion', 'is_short'), requires=('is_short',), documentation='Return whether the short variant changes allele length.'), 'is_short_insertion': Fact(name='is_short_insertion', cost=<CostTier.FREE: 0>, compute=<function is_short_insertion>, unguarded_compute=<function is_short_insertion>, deps=('is_short',), requires=('is_short',), documentation='Return whether the variant is a short insertion.'), 'is_snv': Fact(name='is_snv', cost=<CostTier.FREE: 0>, compute=<function is_snv>, unguarded_compute=<function is_snv>, deps=('is_short',), requires=('is_short',), documentation='Return whether the variant is a single-nucleotide substitution.'), 'is_structural': Fact(name='is_structural', cost=<CostTier.FREE: 0>, compute=<function is_structural>, unguarded_compute=<function is_structural>, deps=(), requires=(), documentation='Return whether the overlapping allele is structural.'), 'is_structural_deletion': Fact(name='is_structural_deletion', cost=<CostTier.FREE: 0>, compute=<function is_structural_deletion>, unguarded_compute=<function is_structural_deletion>, deps=('is_structural',), requires=('is_structural',), documentation='Return whether the structural variant removes sequence.'), 'is_structural_indel': Fact(name='is_structural_indel', cost=<CostTier.FREE: 0>, compute=<function is_structural_indel>, unguarded_compute=<function is_structural_indel>, deps=('is_structural_insertion', 'is_structural_deletion', 'is_structural'), requires=('is_structural',), documentation='Return whether the structural variant changes sequence length.'), 'is_structural_insertion': Fact(name='is_structural_insertion', cost=<CostTier.FREE: 0>, compute=<function is_structural_insertion>, unguarded_compute=<function is_structural_insertion>, deps=('is_structural',), requires=('is_structural',), documentation='Return whether the structural variant adds sequence.'), 'is_transcript': Fact(name='is_transcript', cost=<CostTier.FREE: 0>, compute=<function is_transcript>, unguarded_compute=<function is_transcript>, deps=(), requires=(), documentation='Return whether the overlapped feature is a transcript.'), 'is_upstream': Fact(name='is_upstream', cost=<CostTier.BOUNDS: 1>, compute=<function is_upstream>, unguarded_compute=<function is_upstream>, deps=(), requires=(), documentation='Return whether the variant lies within the upstream pairing distance.'), 'overlap_acceptor_site': Fact(name='overlap_acceptor_site', cost=<CostTier.INTERVAL: 5>, compute=<function overlap_acceptor_site>, unguarded_compute=<function overlap_acceptor_site>, deps=('_nearby_introns', 'is_transcript', 'overlap_feature', 'overlap_intron_boundary'), requires=('is_transcript', 'overlap_feature', 'overlap_intron_boundary'), documentation='Return whether the variant overlaps acceptor-site bases -1 or -2.'), 'overlap_cds': Fact(name='overlap_cds', cost=<CostTier.MAPPING: 20>, compute=<function overlap_cds>, unguarded_compute=<function overlap_cds>, deps=('_cds_footprint', 'is_transcript', 'overlap_feature', 'overlap_exon', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_exon', 'has_translation'), documentation='Return whether the variant overlaps the coding sequence.'), 'overlap_donor_5th_base': Fact(name='overlap_donor_5th_base', cost=<CostTier.INTERVAL: 5>, compute=<function overlap_donor_5th_base>, unguarded_compute=<function overlap_donor_5th_base>, deps=('_nearby_introns', 'is_transcript', 'overlap_feature', 'overlap_intron_boundary'), requires=('is_transcript', 'overlap_feature', 'overlap_intron_boundary'), documentation='Return whether the variant overlaps donor base +5.'), 'overlap_donor_region': Fact(name='overlap_donor_region', cost=<CostTier.INTERVAL: 5>, compute=<function overlap_donor_region>, unguarded_compute=<function overlap_donor_region>, deps=('_nearby_introns', 'is_transcript', 'overlap_feature', 'overlap_intron_boundary'), requires=('is_transcript', 'overlap_feature', 'overlap_intron_boundary'), documentation='Return whether the variant overlaps donor-region bases +3 to +6.'), 'overlap_donor_site': Fact(name='overlap_donor_site', cost=<CostTier.INTERVAL: 5>, compute=<function overlap_donor_site>, unguarded_compute=<function overlap_donor_site>, deps=('_nearby_introns', 'is_transcript', 'overlap_feature', 'overlap_intron_boundary'), requires=('is_transcript', 'overlap_feature', 'overlap_intron_boundary'), documentation='Return whether the variant overlaps donor-site bases +1 or +2.'), 'overlap_exon': Fact(name='overlap_exon', cost=<CostTier.INTERVAL: 5>, compute=<function overlap_exon>, unguarded_compute=<function overlap_exon>, deps=('is_transcript', 'overlap_feature'), requires=('is_transcript', 'overlap_feature'), documentation='Return whether the variant overlaps an exon.'), 'overlap_feature': Fact(name='overlap_feature', cost=<CostTier.BOUNDS: 1>, compute=<function overlap_feature>, unguarded_compute=<function overlap_feature>, deps=(), requires=(), documentation="Return whether the variant overlaps the feature's genomic span.\n\n The variant can\n - just intersect the feature's span\n - be fully contained in the feature's span\n - or, fully contain the feature's span\n "), 'overlap_five_prime_utr': Fact(name='overlap_five_prime_utr', cost=<CostTier.INTERVAL: 5>, compute=<function overlap_five_prime_utr>, unguarded_compute=<function overlap_five_prime_utr>, deps=('is_transcript', 'overlap_feature', 'overlap_exon'), requires=('is_transcript', 'overlap_feature', 'overlap_exon'), documentation="Return whether the variant overlaps the transcript's 5' UTR.\n\n Tested against genomic spans of the five_prime_utr instead of just the span(start, end) as a UTR can\n contain introns (non-UTR region) and therefore, can give inaccurate results.\n "), 'overlap_intron': Fact(name='overlap_intron', cost=<CostTier.INTERVAL: 5>, compute=<function overlap_intron>, unguarded_compute=<function overlap_intron>, deps=('is_transcript', 'overlap_feature'), requires=('is_transcript', 'overlap_feature'), documentation='Return whether the variant overlaps an intron.'), 'overlap_intron_boundary': Fact(name='overlap_intron_boundary', cost=<CostTier.INTERVAL: 5>, compute=<function overlap_intron_boundary>, unguarded_compute=<function overlap_intron_boundary>, deps=('is_transcript', 'overlap_feature'), requires=('is_transcript', 'overlap_feature'), documentation='Return whether the variant overlaps an intron boundary window.'), 'overlap_intron_interior': Fact(name='overlap_intron_interior', cost=<CostTier.INTERVAL: 5>, compute=<function overlap_intron_interior>, unguarded_compute=<function overlap_intron_interior>, deps=('is_transcript', 'overlap_feature'), requires=('is_transcript', 'overlap_feature'), documentation="Return whether the variant overlaps an intron away from its splice sites.\n\n VEP's ``intronic`` test (``BaseTranscriptVariationAllele::_intron_effects``): overlap with\n ``intron.start + 2 .. intron.end - 2``. An insertion's span is its two flanking bases, so one\n at either end of that window counts, as VEP's own insertion special case has it.\n "), 'overlap_polypyrimidine_tract': Fact(name='overlap_polypyrimidine_tract', cost=<CostTier.INTERVAL: 5>, compute=<function overlap_polypyrimidine_tract>, unguarded_compute=<function overlap_polypyrimidine_tract>, deps=('_nearby_introns', 'is_transcript', 'overlap_feature', 'overlap_intron'), requires=('is_transcript', 'overlap_feature', 'overlap_intron'), documentation='Return whether the variant overlaps polypyrimidine-tract bases -3 to -17.'), 'overlap_splice_region': Fact(name='overlap_splice_region', cost=<CostTier.INTERVAL: 5>, compute=<function overlap_splice_region>, unguarded_compute=<function overlap_splice_region>, deps=('_nearby_introns', 'is_transcript', 'overlap_feature', 'overlap_intron_boundary'), requires=('is_transcript', 'overlap_feature', 'overlap_intron_boundary'), documentation='Return whether the variant overlaps an exonic or intronic splice region.'), 'overlap_start_codon': Fact(name='overlap_start_codon', cost=<CostTier.MAPPING: 20>, compute=<function overlap_start_codon>, unguarded_compute=<function overlap_start_codon>, deps=('is_transcript', 'overlap_feature', 'overlap_exon', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_exon', 'has_translation'), documentation='Return whether the variant overlaps the start codon.\n\n Similar to UTRs a start codon can split across an exon-exon junction and therefore should be tested\n against all its genomic spans.\n '), 'overlap_stop_codon': Fact(name='overlap_stop_codon', cost=<CostTier.MAPPING: 20>, compute=<function overlap_stop_codon>, unguarded_compute=<function overlap_stop_codon>, deps=('is_transcript', 'overlap_feature', 'overlap_exon', 'overlap_cds'), requires=('is_transcript', 'overlap_feature', 'overlap_exon', 'overlap_cds'), documentation='Return whether the variant overlaps the stop codon.'), 'overlap_three_prime_utr': Fact(name='overlap_three_prime_utr', cost=<CostTier.INTERVAL: 5>, compute=<function overlap_three_prime_utr>, unguarded_compute=<function overlap_three_prime_utr>, deps=('is_transcript', 'overlap_feature', 'overlap_exon'), requires=('is_transcript', 'overlap_feature', 'overlap_exon'), documentation="Return whether the variant overlaps the transcript's 3' UTR."), 'partial_last_codon': Fact(name='partial_last_codon', cost=<CostTier.MAPPING: 20>, compute=<function partial_last_codon>, unguarded_compute=<function partial_last_codon>, deps=('_cds_footprint', 'is_transcript', 'overlap_feature', 'overlap_exon'), requires=('is_transcript', 'overlap_feature', 'overlap_exon'), documentation='Return whether the variant falls in an incomplete terminal codon.'), 'peptide_changed': Fact(name='peptide_changed', cost=<CostTier.SEQUENCE: 60>, compute=<function peptide_changed>, unguarded_compute=<function peptide_changed>, deps=('_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation='Return whether the reference and alternate peptide windows differ.'), 'peptide_has_X': Fact(name='peptide_has_X', cost=<CostTier.SEQUENCE: 60>, compute=<function peptide_has_X>, unguarded_compute=<function peptide_has_X>, deps=('_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation='Return whether either peptide window contains an ambiguous residue.\n\n "X" comes from an unresolvable codon (incomplete, or an ambiguity code).\n '), 'peptide_same_length': Fact(name='peptide_same_length', cost=<CostTier.SEQUENCE: 60>, compute=<function peptide_same_length>, unguarded_compute=<function peptide_same_length>, deps=('_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation='Return whether the peptide windows have the same length.'), 'ref_peptide_has_ter': Fact(name='ref_peptide_has_ter', cost=<CostTier.SEQUENCE: 60>, compute=<function ref_peptide_has_ter>, unguarded_compute=<function ref_peptide_has_ter>, deps=('_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation='Return whether the reference peptide window contains a stop codon.'), 'ref_peptide_is_ter': Fact(name='ref_peptide_is_ter', cost=<CostTier.SEQUENCE: 60>, compute=<function ref_peptide_is_ter>, unguarded_compute=<function ref_peptide_is_ter>, deps=('_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation='Return whether the reference peptide is exactly one stop codon.'), 'ref_peptide_startswith_ter': Fact(name='ref_peptide_startswith_ter', cost=<CostTier.SEQUENCE: 60>, compute=<function ref_peptide_startswith_ter>, unguarded_compute=<function ref_peptide_startswith_ter>, deps=('_peptide_alleles', 'is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), requires=('is_transcript', 'overlap_feature', 'overlap_cds', 'has_translation'), documentation='Return whether the reference peptide window begins with a stop codon.'), 'within_any_exon': Fact(name='within_any_exon', cost=<CostTier.INTERVAL: 5>, compute=<function within_any_exon>, unguarded_compute=<function within_any_exon>, deps=('is_transcript', 'overlap_feature'), requires=('is_transcript', 'overlap_feature'), documentation='Return whether the variant lies within one exon.\n\n Not zone-mappable.\n '), 'within_feature': Fact(name='within_feature', cost=<CostTier.BOUNDS: 1>, compute=<function within_feature>, unguarded_compute=<function within_feature>, deps=(), requires=(), documentation="Return whether the variant lies within the feature's genomic span.\n\n Not zone-mappable.\n ")}#
Every registered fact, keyed by name. Populated by importing the
factssubpackage via the decorator.
- ensembl.vep.annotators.consequence.facts.base.apply_fact_cost_overrides(overrides)[source]#
Override REGISTRY entries’
costin place from a measured fact-cost table.Declared cost tiers are untouched for any fact not present in
overrides. Also closure_cost’s memoisation cache is cleared so subsequent calls reflect the new costs rather than a stale value computed before the override was applied.- Parameters:
overrides (
Mapping[str,int]) – Fact name -> cost unit, typically loaded fromannotators/consequence/data/fact_costs.json.
- ensembl.vep.annotators.consequence.facts.base.apply_packaged_fact_cost_overrides()[source]#
Apply the packaged measured-cost table, if the package ships one.
Call after every fact submodule has registered, since REGISTRY is empty before that. Costs change evaluation order only, never the terms emitted.
- ensembl.vep.annotators.consequence.facts.base.atom_names()[source]#
Return the Boolean facts a rule may reference.
- Returns:
Sorted names of every registered fact that does not start with
_.- Return type:
list[str]
- ensembl.vep.annotators.consequence.facts.base.build_requires_guard(compute, requires)[source]#
Wrap
Fact.computeso it short-circuits to False when any required atom is False.- Parameters:
compute (
Callable[[FactContext[Any]],object]) – The fact’s raw computation.requires (
tuple[str,...]) – Atoms that must all be true forcomputeto run.
- Returns:
computeitself whenrequiresis empty,else a guarded wrapper around it.
- Return type:
Callable[[FactContext[Any]],object]
- ensembl.vep.annotators.consequence.facts.base.closure_cost(name)[source]#
Return the cost of a fact and its dependencies.
- Parameters:
name (
str) – The name of a registered fact.- Returns:
- The total cost of computing
nameand every fact it (transitively) depends on, counting each shared dependency once.
- The total cost of computing
- Return type:
int
- ensembl.vep.annotators.consequence.facts.base.get_fact(fact_context, name)[source]#
Fetch a fact’s value for this context, computing it at most once.
The hottest function in the system, so it does the least it can when tracing is off: one
is not Nonecheck, shared by both paths, whose body is a single dict bump. Everything else a derivation trace shows – origins, costs, forced-False facts – is reconstructed afterwards from the memo table (ensembl.vep.trace.reconstruct), because it can be. The read count is the one thing that cannot: a replay sees only memo hits, so it never observes the original read pattern. Making the counter unconditional to drop the branch measures 1.30x here.- Parameters:
fact_context (
FactContext) – The per-overlap memoisation context to read from and populate.name (
str) – The name of a registered fact.
- Returns:
The fact’s value, from the memo table if already computed.
- Return type:
object
- ensembl.vep.annotators.consequence.facts.base.implied_false(known)[source]#
Extend known facts that are implied False by the current assignment.
The result also explains itself later: a name this added is False here and absent from the memo, which is how
trace.reconstruct.forced_false_eventsrecovers the forced-False set and its cause without this function recording anything, and without the explanation duplicating the propagation.- Parameters:
known (
Mapping[str,bool]) – A partial assignment of fact names to boolean values.- Returns:
knownextended with every fact thatrequiresproves False giventhe input, iterated to a fixed point.
- Return type:
dict[str,bool]
- ensembl.vep.annotators.consequence.facts.base.load_fact_cost_overrides_from_package()[source]#
Read the checked-in measured fact-cost table, if any, without applying it.
- Returns:
- The
{fact_name: cost_units}table from annotators/data/fact_costs.json, or an empty dict if that resource does not exist.
- The
- Return type:
dict[str,int]
- ensembl.vep.annotators.consequence.facts.base.register_fact(cost, deps=(), requires=())[source]#
Register a function as a named Fact in REGISTRY.
requiresnames are folded intodepsautomatically because an atom that has to be true first necessarily has to be computed first, so declaring it twice was only ever an opportunity to declare it inconsistently.- Parameters:
cost (
int) – The fact’s marginal cost.deps (
tuple[str,...], default:()) – Names of facts that must be computed before this one.requires (
tuple[str,...], default:()) – Atoms this fact is gated on.
- Returns:
- A
decorator that registers the wrapped function and returns the original function unchanged, so a module-level reference to it still calls the unguarded body.
- Return type:
Callable[[Callable[[FactContext[Any]],object]],Callable[[FactContext[Any]],object]]
- ensembl.vep.annotators.consequence.facts.base.total_cost(names)[source]#
Return the cost of facts and their shared dependencies.
- Parameters:
names (
Iterable[str]) – Names of registered facts.- Returns:
The total cost, with every shared dependency (transitively) counted exactly once.
- Return type:
int
- ensembl.vep.annotators.consequence.facts.base.verify_requires(fact_contexts)[source]#
Check every
requiresclaim against real contexts.A wrong declaration would silently produce wrong consequences. This is a sanity check to make sure that never happens.
Checks a fact by running a fact’s compute function without its requires guard, and then checking when the result is True all of its required atoms are True. if one required atom is False, the claim is false and the fact’s compute function is mis-declared.
Running the unguarded body is the whole point: a guarded call can never disprove its own guard, since the guard returns False whenever a required atom is False. Checking through
get_factwould therefore pass for every declaration, correct or not.A body that raises when its required atoms are false is reported too. That is the same class of defect seen from the other side: the body is relying on the guard having already short-circuited, rather than being independently consistent with what it declares.
- Parameters:
fact_contexts (
Iterable[FactContext[Any]]) – Contexts to check the claims against. Each is reset before use.- Returns:
- A description of every
requiresclaim found to be false, or an empty list if every claim held.
- A description of every
- Return type:
list[str]
ensembl.vep.annotators.consequence.facts.costs module#
Measure fact evaluation costs.
Declared tiers provide relative ordering rather than wall-clock timings. Profiling measures each
fact’s self-time and normalises it to the BOUNDS = 1 scale used by declared costs.
Profiling temporarily replaces registered compute functions with timing wrappers and therefore belongs only in explicit measurement runs.
- ensembl.vep.annotators.consequence.facts.costs.declared_vs_measured(measured_self_nanoseconds)[source]#
Return one row per fact comparing its declared tier against what was measured.
- Return type:
list[tuple[str,str,float,int]]- Returns:
(fact name, declared tier label, measured ns, measured cost in BOUNDS units),ordered by declared cost then name.
- ensembl.vep.annotators.consequence.facts.costs.fact_costs_path()[source]#
Return the filesystem path of the packaged measured-cost table.
Resolved the same way
load_fact_cost_overrides_from_packagereads it, so--writeand the loader can no longer disagree about where the table lives.- Return type:
Path
- ensembl.vep.annotators.consequence.facts.costs.normalised_cost_table(measured_self_nanoseconds)[source]#
Normalise every fact’s measured self-time to BOUNDS = 1 and write it to
output_path.The inverse of
apply_fact_cost_overrides: BOUNDS = 1 is the same normalisation the declared tier constants use, so a measured table is interchangeable with the declared ones.- Parameters:
measured_self_nanoseconds (
dict[str,float]) – Fact name -> mean self-time in nanoseconds.- Returns:
Fact name -> cost in BOUNDS units.
- Return type:
dict[str,int]- Raises:
RuntimeError – If no BOUNDS-tier fact was measured, leaving nothing to normalise against.
- ensembl.vep.annotators.consequence.facts.costs.profile_self_nanoseconds(fact_contexts)[source]#
Profile every registered fact’s mean self-time, in nanoseconds, over
fact_contexts.Temporarily wraps every Fact in REGISTRY with a timing shim (restored in a
finallyblock, so a failure partway through still leaves the registry as it found it), then computes every fact for every context.- Parameters:
fact_contexts (
list[FactContext]) – Contexts to compute every fact over. Each is reset first.- Returns:
- Fact name -> mean self-time in nanoseconds, over every context in which
that fact was computed (every fact is computed for every context here, so the divisor is
len(fact_contexts)for all of them).
- Return type:
dict[str,float]
- ensembl.vep.annotators.consequence.facts.costs.write_cost_table(cost_table, output_path=None)[source]#
Write a measured cost table as JSON, and return where it was written.
- Parameters:
cost_table (
dict[str,int]) – Fact name -> cost in BOUNDS units.output_path (
Path|None, default:None) – Where to write, or None for the packaged table.
- Returns:
The path written to.
- Return type:
Path
ensembl.vep.annotators.consequence.facts.helper module#
Unregistered helper functions used by consequence facts.
- ensembl.vep.annotators.consequence.facts.helper.UPSTREAM_DISTANCE = 5000#
The distances a run uses when it configures none, matching Perl VEP’s
--distancedefault.
- ensembl.vep.annotators.consequence.facts.helper.allele_length_difference(fact_context)[source]#
Return the length change from reference to alternate allele.
- Return type:
int
- ensembl.vep.annotators.consequence.facts.helper.alternate_allele(fact_context)[source]#
Return the alternate allele, treating
Noneas empty.- Return type:
str
- ensembl.vep.annotators.consequence.facts.helper.alternate_allele_length(fact_context)[source]#
Return the alternate-allele length, treating empty spellings as zero.
- Return type:
int
- ensembl.vep.annotators.consequence.facts.helper.downstream_distance(fact_context)[source]#
Return the run’s downstream pairing distance, or the default outside a run.
- Return type:
int
- ensembl.vep.annotators.consequence.facts.helper.genomic_overlap(range_start, range_end, other_start, other_end)[source]#
Return whether two closed genomic intervals share a position.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.helper.intron_offsets_to_genomic_span(intron, strand, low, high, from_donor)[source]#
Return the genomic span of transcript-relative intron offsets.
As usual the genomic span is ascending.
Offsets are 1-based, transcript sense, measured from the intron’s 5’ end (donor) when
from_donoris True, else from its 3’ end (acceptor). The donor isintron.starton the forward strand andintron.endon the reverse strand (the intron’s 5’ end in transcript sense is the high genomic coordinate there). Positions are clipped to the start and end of the intron so that they are never outside an intron.- Return type:
tuple[int,int]
- ensembl.vep.annotators.consequence.facts.helper.reference_allele(fact_context)[source]#
Return the reference allele, treating
Noneas empty.- Return type:
str
- ensembl.vep.annotators.consequence.facts.helper.reference_allele_length(fact_context)[source]#
Return the reference-allele length, treating empty spellings as zero.
- Return type:
int
- ensembl.vep.annotators.consequence.facts.helper.upstream_distance(fact_context)[source]#
Return the run’s upstream pairing distance, or the default outside a run.
Read from the annotator context because
--distanceis per run, and a fact evaluated standalone (a unit test, say) has no context to read.- Return type:
int
- ensembl.vep.annotators.consequence.facts.helper.variant_genomic_span(fact_context)[source]#
Return the variant’s genomic
(minimum, maximum)span.Thin wrapper over
FactContext.variant_span, which memoises the result for the whole overlap – kept as a free function because every position/sequence fact calls it by this name.- Return type:
tuple[int,int]
ensembl.vep.annotators.consequence.facts.kind module#
Facts describing variant and feature kinds.
- ensembl.vep.annotators.consequence.facts.kind.biotype_miRNA(fact_context)[source]#
Return whether the transcript has a microRNA biotype.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.biotype_nmd(fact_context)[source]#
Return whether the transcript has a nonsense-mediated-decay biotype.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.biotype_non_coding(fact_context)[source]#
Return whether the transcript is non-coding.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.biotype_protein_coding(fact_context)[source]#
Return whether the transcript has a protein-coding biotype.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.has_translation(fact_context)[source]#
Return whether the transcript has a translation.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_chromosomal_breakpoint(fact_context)[source]#
Return whether the variant represents a chromosomal breakpoint.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_copy_number_gain(fact_context)[source]#
Return whether the variant represents a copy-number gain.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_copy_number_loss(fact_context)[source]#
Return whether the variant represents a copy-number loss.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_deletion(fact_context)[source]#
Return whether the variant removes sequence.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_duplication(fact_context)[source]#
Return whether the variant represents a duplicated segment.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_indel(fact_context)[source]#
Return whether the variant changes sequence length.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_insertion(fact_context)[source]#
Return whether the variant adds sequence.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_motif(fact_context)[source]#
Return whether the overlapped feature is a motif.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_regulatory(fact_context)[source]#
Return whether the overlapped feature is regulatory.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_short(fact_context)[source]#
Return whether the overlapping allele is a short variant.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_short_deletion(fact_context)[source]#
Return whether the variant is a short deletion.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_short_indel(fact_context)[source]#
Return whether the short variant changes allele length.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_short_insertion(fact_context)[source]#
Return whether the variant is a short insertion.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_snv(fact_context)[source]#
Return whether the variant is a single-nucleotide substitution.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_structural(fact_context)[source]#
Return whether the overlapping allele is structural.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_structural_deletion(fact_context)[source]#
Return whether the structural variant removes sequence.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.kind.is_structural_indel(fact_context)[source]#
Return whether the structural variant changes sequence length.
- Return type:
bool
ensembl.vep.annotators.consequence.facts.position module#
Facts describing a variant’s position relative to its feature.
- ensembl.vep.annotators.consequence.facts.position.contain_feature(fact_context)[source]#
Return whether the variant contains the feature’s genomic span.
Not zone-mappable: a zone-map union answers “does the span touch this interval”, not “is the span fully inside one specific interval”.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.is_downstream(fact_context)[source]#
Return whether the variant lies within the downstream pairing distance.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.is_upstream(fact_context)[source]#
Return whether the variant lies within the upstream pairing distance.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_acceptor_site(fact_context)[source]#
Return whether the variant overlaps acceptor-site bases -1 or -2.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_cds(fact_context)[source]#
Return whether the variant overlaps the coding sequence.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_donor_5th_base(fact_context)[source]#
Return whether the variant overlaps donor base +5.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_donor_region(fact_context)[source]#
Return whether the variant overlaps donor-region bases +3 to +6.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_donor_site(fact_context)[source]#
Return whether the variant overlaps donor-site bases +1 or +2.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_exon(fact_context)[source]#
Return whether the variant overlaps an exon.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_feature(fact_context)[source]#
Return whether the variant overlaps the feature’s genomic span.
- The variant can
just intersect the feature’s span
be fully contained in the feature’s span
or, fully contain the feature’s span
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_five_prime_utr(fact_context)[source]#
Return whether the variant overlaps the transcript’s 5’ UTR.
Tested against genomic spans of the five_prime_utr instead of just the span(start, end) as a UTR can contain introns (non-UTR region) and therefore, can give inaccurate results.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_intron(fact_context)[source]#
Return whether the variant overlaps an intron.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_intron_boundary(fact_context)[source]#
Return whether the variant overlaps an intron boundary window.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_intron_interior(fact_context)[source]#
Return whether the variant overlaps an intron away from its splice sites.
VEP’s
intronictest (BaseTranscriptVariationAllele::_intron_effects): overlap withintron.start + 2 .. intron.end - 2. An insertion’s span is its two flanking bases, so one at either end of that window counts, as VEP’s own insertion special case has it.- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_polypyrimidine_tract(fact_context)[source]#
Return whether the variant overlaps polypyrimidine-tract bases -3 to -17.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_splice_region(fact_context)[source]#
Return whether the variant overlaps an exonic or intronic splice region.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_start_codon(fact_context)[source]#
Return whether the variant overlaps the start codon.
Similar to UTRs a start codon can split across an exon-exon junction and therefore should be tested against all its genomic spans.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_stop_codon(fact_context)[source]#
Return whether the variant overlaps the stop codon.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.overlap_three_prime_utr(fact_context)[source]#
Return whether the variant overlaps the transcript’s 3’ UTR.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.position.partial_last_codon(fact_context)[source]#
Return whether the variant falls in an incomplete terminal codon.
- Return type:
bool
ensembl.vep.annotators.consequence.facts.sequence module#
Facts derived from allele, codon, CDS, and peptide sequences.
Internal codon and peptide facts perform sequence editing and translation. Public facts reuse those values or perform length arithmetic.
- ensembl.vep.annotators.consequence.facts.sequence.alt_matches_ref_codon_edge(fact_context)[source]#
Return whether a deletion removes whole codons while preserving a window edge.
VEP’s own test for an inframe deletion (
VariationEffect::inframe_deletion): see_matches_codon_edgefor its two branches.- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.alt_peptide_has_ter(fact_context)[source]#
Return whether the alternate peptide window contains a stop codon.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.alt_peptide_is_ter(fact_context)[source]#
Return whether the alternate peptide is exactly one stop codon.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.alt_peptide_matches_ref_edge(fact_context)[source]#
Return whether the alternate peptide preserves a reference-window edge.
VEP’s test for an inframe insertion (
VariationEffect::inframe_insertion), which it makes on the peptides rather than the codons: residues added at one end of the window leave the reference residues intact at the other. The alternate window is cut at its first stop first, so that an insertion which also introduces a stop is judged on what precedes it.- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.cds_length_change_inframe(fact_context)[source]#
Return whether the coding-length change is in frame.
False when the variant does not overlap the CDS. There is then no coding length change to be in frame, and reporting True would contradict this fact’s own
requires.- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.cds_start_lost(fact_context)[source]#
Return whether the alternate CDS loses the start codon.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.cds_start_retained(fact_context)[source]#
Return whether the alternate CDS retains the initiator methionine.
Computed from the peptides directly rather than as
not cds_start_lost. Negating a guarded fact is unsound: when a required atom is false,cds_start_lostshort-circuits to False, andnot Falseclaims the start codon is retained for a variant that never touches it – which is exactly whatverify_requirescatches by running this body unguarded. Deriving it here also returns False (not True) when the peptides are unavailable, matchingcds_stop_retained. Caching is unaffected:_full_cds_peptide_allelesis the memoised dep both facts read.- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.cds_stop_gain(fact_context)[source]#
Return whether the alternate CDS introduces a premature stop codon.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.cds_stop_lost(fact_context)[source]#
Return whether the alternate CDS loses the stop codon.
Requires the alternate peptide to match the reference up to (but not including) the reference’s own stop position, so a frameshift several codons upstream that happens to remove the stop incidentally doesn’t get conflated with an edit that actually changes the stop codon itself.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.cds_stop_retained(fact_context)[source]#
Return whether the alternate CDS retains the stop codon.
Requires stop at the exact same reading-frame position, with the same prefix leading up to it.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.insertion_after_start(fact_context)[source]#
Return whether an insertion occurs after and preserves the start codon.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.insertion_before_start(fact_context)[source]#
Return whether an insertion occurs before and preserves the start codon.
Because variant overlaps start codon (verified by overlap_start_codon fact requirement) the reference peptide should include the start peptide. If the alternate peptide window ends with the reference peptide then it also include the start codon with inserted amino acids before it.
An empty reference peptide is excluded because
str.endswith("")is trivially True for any string, which would make this fact vacuously True for every overlap.- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.peptide_changed(fact_context)[source]#
Return whether the reference and alternate peptide windows differ.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.peptide_has_X(fact_context)[source]#
Return whether either peptide window contains an ambiguous residue.
“X” comes from an unresolvable codon (incomplete, or an ambiguity code).
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.peptide_same_length(fact_context)[source]#
Return whether the peptide windows have the same length.
- Return type:
bool
- ensembl.vep.annotators.consequence.facts.sequence.ref_peptide_has_ter(fact_context)[source]#
Return whether the reference peptide window contains a stop codon.
- Return type:
bool