Coverage for src/python/ensembl/vep/models/variation/structural_variation_allele.py: 100%

26 statements  

« 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"""StructuralVariationAllele class.""" 

15 

16from __future__ import annotations 

17 

18import logging 

19from attrs import define, field 

20 

21from ensembl.vep.models.variation.variation_allele import VariationAllele 

22 

23logger = logging.getLogger(__name__) 

24 

25 

26@define(kw_only=True, auto_attribs=True) 

27class StructuralVariationAllele(VariationAllele): 

28 """Represents a specific allele of a structural variation. 

29 

30 Attributes: 

31 svlen (int | None): 

32 The length of the structural variant 

33 """ 

34 

35 svlen: int | None = field(default=None) 

36 

37 def minimise(self, force: bool = False) -> None: 

38 """Minimises the variation allele by computing the minimal representation of the variant. 

39 

40 Structural variants are not minimised, so this method simply returns the current representation 

41 of the structural variant. 

42 """ 

43 msg = "Structural Variation alleles are currently not minimised. " 

44 if force: 

45 msg += "force=True doesn't change this behaviour. " 

46 msg += "Returning the original representation" 

47 logger.warning(msg) 

48 

49 setattr(self, "_original_locus", self._locus) 

50 setattr(self, "_minimised_locus", self._locus) 

51 setattr(self, "_minimised", True) 

52 

53 def shift(self, force: bool = False) -> None: 

54 """Shifts the variation allele to the leftmost position in the sequence. 

55 

56 Currently, this method simply returns the current representation of the structural variant. 

57 """ 

58 msg = "Structural Variation alleles are currently not shifted. " 

59 if force: 

60 msg += "force=True doesn't change this behaviour. " 

61 msg += "Returning the original representation" 

62 logger.warning(msg) 

63 

64 setattr(self, "_original_locus", self._locus) 

65 setattr(self, "_shifted_locus", self._locus) 

66 setattr(self, "_shifted", True)