Coverage for src/python/ensembl/vep/models/variation/structural_variation.py: 100%
21 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"""StructuralVariation class."""
16from functools import cached_property
17from typing import Sequence
18from attrs import define, field
20from ensembl.vep.common import ClassSOTerm, infer_symbolic_variant_so_term, invalidates
21from ensembl.vep.models.variation.variation import Variation
22from ensembl.vep.models.variation.structural_variation_allele import StructuralVariationAllele
25@define(kw_only=True, auto_attribs=True)
26class StructuralVariation(Variation):
27 """Represents a structural variation to genomic sequences in a specific locus.
29 Attributes:
30 sv_type (str | None):
31 Type of the structural variant.
32 copy_number (float | None):
33 Number of sequence copies of a structural variant classified as "copy number variant" (CNV) when
34 available.
35 inner_start (int | None):
36 The inner bound on the start position when the variant is imprecise
37 outer_start (int | None):
38 The outer bound on the start position when the variant is imprecise
39 inner_end (int | None):
40 The inner bound on the end position when the variant is imprecise
41 outer_end (int | None):
42 The outer bound on the end position when the variant is imprecise
43 variation_alleles (Sequence[StructuralVariationAllele]):
44 List of VariationAllele objects describing the alleles of the variation.
45 """
47 sv_type: str | None = field(default=None, on_setattr=invalidates("_class_so_term"))
48 copy_number: int | None = field(default=None)
49 inner_start: int | None = field(default=None)
50 outer_start: int | None = field(default=None)
51 inner_end: int | None = field(default=None)
52 outer_end: int | None = field(default=None)
53 variation_alleles: Sequence[StructuralVariationAllele] = field(
54 factory=list,
55 init=False,
56 on_setattr=invalidates("_most_severe_consequence"),
57 )
59 @cached_property
60 def _class_so_term(self) -> ClassSOTerm | None:
61 """Return the inferred SO term for this structural variation."""
62 allele_string = self.allele_string or ""
63 _, separator, alternate_alleles = allele_string.partition("/")
64 raw_type = alternate_alleles if separator else allele_string
65 return infer_symbolic_variant_so_term(raw_type, svtype=self.sv_type)