Coverage for src/python/ensembl/vep/models/sequence/coord_system.py: 100%
23 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"""CoordSystem class."""
16from __future__ import annotations
18from attrs import define, field
20from ensembl.vep.common import CoordSystemLevel
23@define(kw_only=True, auto_attribs=True)
24class CoordSystem:
25 """
26 Represents a coordinate system in the Ensembl database.
28 Attributes:
29 name (str): Name of the coordinate system.
30 level (CoordSystemLevel): Level of the coordinate system (e.g. chromosome, contig, toplevel).
31 default (bool): Whether this is the default coordinate system.
32 alias_to (str | None): Name of another coordinate system this is an alias to, if applicable.
33 rank (int | None): Rank of the coordinate system.
34 """
36 name: str
37 level: CoordSystemLevel
38 default: bool = field(default=False)
39 alias_to: str | None = field(default=None)
40 rank: int | None = field(default=None)
42 @property
43 def is_sequence_level(self) -> bool:
44 """
45 Returns True if the coordinate system is sequence-level (e.g. contig), False otherwise.
47 Returns:
48 bool: True if sequence-level, False otherwise.
49 """
50 return self.level == CoordSystemLevel.CONTIG
52 @property
53 def is_chromosome_level(self) -> bool:
54 """
55 Returns True if the coordinate system is chromosome-level, False otherwise.
57 Returns:
58 bool: True if chromosome-level, False otherwise.
59 """
60 return self.level == CoordSystemLevel.CHROMOSOME
62 @property
63 def is_toplevel(self) -> bool:
64 """
65 Returns True if the coordinate system is toplevel, False otherwise.
67 Returns:
68 bool: True if toplevel, False otherwise.
69 """
70 return self.level == CoordSystemLevel.TOPLEVEL
72 def __eq__(self, other: object) -> bool:
73 """Compare two CoordSystem objects for equality.
75 Args:
76 other (object): Another object to compare against.
78 Returns:
79 bool: True if equal, False otherwise.
80 """
81 if type(self) is not type(other):
82 return False
84 return self.name == other.name and self.level == other.level and self.rank == other.rank