Coverage for src/python/ensembl/vep/common/enums.py: 98%
85 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-18 14:41 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-18 14:41 +0000
1# See the NOTICE file distributed with this work for additional information
2# regarding copyright ownership.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""Common enums."""
16from enum import Enum, IntEnum
19class Strand(Enum):
20 """Genomic strand."""
22 FORWARD = 1
23 REVERSE = -1
24 UNKNOWN = 0
27class CoordSystemLevel(Enum):
28 """Coordinate system level."""
30 CHROMOSOME = 1
31 TOPLEVEL = 2
32 CONTIG = 3
35class ExonPhase(Enum):
36 """Phase of an exon."""
38 ZERO = 0
39 ONE = 1
40 TWO = 2
41 UNKNOWN = -1
44class ClassSOTerm(Enum):
45 """Sequence Ontology term describing the class of a variation.
47 The first block is what ``infer_variant_so_term`` can derive from an allele string alone --
48 the classes a short variant can have. The second block is structural-variant only which may
49 may need INFO/SVTYPE to be derived.
50 """
52 SEQUENCE_ALTERATION = "sequence_alteration"
53 SNV = "SNV"
54 INSERTION = "insertion"
55 DELETION = "deletion"
56 INDEL = "indel"
57 SUBSTITUTION = "substitution"
58 INVERSION = "inversion"
59 COPY_NUMBER_VARIATION = "copy_number_variation"
60 TANDEM_REPEAT = "tandem_repeat"
62 # Structural-variant classes. Never produced by infer_variant_so_term.
63 DUPLICATION = "duplication"
64 TANDEM_DUPLICATION = "tandem_duplication"
65 COPY_NUMBER_GAIN = "copy_number_gain"
66 COPY_NUMBER_LOSS = "copy_number_loss"
67 MOBILE_ELEMENT_INSERTION = "mobile_element_insertion"
68 ALU_INSERTION = "Alu_insertion"
69 HERV_INSERTION = "HERV_insertion"
70 LINE1_INSERTION = "LINE1_insertion"
71 SVA_INSERTION = "SVA_insertion"
72 MOBILE_ELEMENT_DELETION = "mobile_element_deletion"
73 ALU_DELETION = "Alu_deletion"
74 HERV_DELETION = "HERV_deletion"
75 LINE1_DELETION = "LINE1_deletion"
76 SVA_DELETION = "SVA_deletion"
77 NOVEL_SEQUENCE_INSERTION = "novel_sequence_insertion"
78 TRANSLOCATION = "translocation"
79 INTERCHROMOSOMAL_BREAKPOINT = "interchromosomal_breakpoint"
80 INTRACHROMOSOMAL_BREAKPOINT = "intrachromosomal_breakpoint"
81 CHROMOSOME_BREAKPOINT = "chromosome_breakpoint"
82 LOSS_OF_HETEROZYGOSITY = "loss_of_heterozygosity"
83 PROBE = "probe"
86class ConsequenceImpact(Enum):
87 """Impact of a consequence."""
89 HIGH = "HIGH"
90 MODERATE = "MODERATE"
91 LOW = "LOW"
92 MODIFIER = "MODIFIER"
95class SourceType(Enum):
96 """Type of annotation/input source."""
98 FILE = "file"
99 DB = "db"
100 CACHE = "cache"
103class StartMethod(str, Enum):
104 """Multiprocessing worker start methods."""
106 AUTO = "auto"
107 SPAWN = "spawn"
108 FORK = "fork"
109 FORKSERVER = "forkserver"
112class Readthrough(IntEnum):
113 """How far translation may run when a variant destroys the stop codon.
115 Opt-in, and ``NONE`` by default. An ``IntEnum`` because the levels are ordered rather
116 than independent, each one extends the previous.
117 """
119 NONE = 0
120 """Stop at the (possibly shifted) CDS end. Translation never enters the UTR."""
122 UTR = 1
123 """Continue into the 3' UTR, looking for the next in-frame stop. Stays entirely within the
124 transcript's own spliced sequence."""
126 BEYOND_TRANSCRIPT = 2
127 """As ``UTR``, and if that still yields no stop, continue into raw genomic sequence past the
128 transcript's own boundary, read directly from the attached slice (bounded by
129 ``MAX_READTHROUGH_BASES``). Trusts that the attached slice already covers the flank."""
132class CostTier(IntEnum):
133 """The declared cost tiers a fact can be registered with, cheapest first.
135 An ``IntEnum`` rather than a plain ``int`` alias, so a tier is both a real integer (comparable,
136 summable, sortable) and a self-naming, enumerable value: ``CostTier.MAPPING.name`` instead of
137 a hand-maintained ``{20: "MAPPING"}`` lookup, and ``list(CostTier)`` for anything that wants
138 every tier without duplicating this declaration.
140 The numbers are relative in magnitude and not absolute. The declared relative magnitudes do
141 not match measured wall-clock time. Treat the tier ordering as load-bearing and the numeric
142 ratios as illustrative only.
143 """
145 FREE = 0
146 """Arithmetic on the variant alone."""
147 BOUNDS = 1
148 """Comparing against a single bound (e.g. transcript start/end)."""
149 INTERVAL = 5
150 """Scanning exon/intron interval lists."""
151 MAPPING = 20
152 """Genomic -> CDS coordinate mapping."""
153 SEQUENCE = 60
154 """Extracting sequence, splicing in the alt allele, translating."""
155 TRANSCRIPT_SEQUENCE = 200
156 """Rebuilding or translating the whole CDS or cDNA, not just the touched codon window."""
158 @classmethod
159 def label(cls, cost: int) -> str:
160 """Return the name of the tier ``cost`` belongs to, or the number itself.
162 A declared cost is a member, so this is ``cost.name``. The measured-cost override
163 (``data/fact_costs.json``, opt-in) sets arbitrary profiled integers that match no tier, so
164 the numeric fallback is the normal case there rather than an error.
165 """
166 try:
167 return cls(cost).name
168 except ValueError:
169 return str(cost)