Source code for ensembl.vep.common.containers

# See the NOTICE file distributed with this work for additional information
# regarding copyright ownership.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Common containers.

Containers are for collection data (generally without any behavior).
"""

from __future__ import annotations

from attrs import frozen


[docs] @frozen(kw_only=True, auto_attribs=True) class Locus: """Container for a genomic position and (optionally) alleles. Attributes: seq_region_name (str | None): Name of the sequence region. start (int): Start position of the locus. end (int): End position of the locus. allele_string (str | None): String representation of the alleles. It could be in the format "{reference_allele}/{alternate_allele}", or just "allele" where allele could be either reference or alternate. """ seq_region_name: str | None = None start: int end: int allele_string: str | None = None
[docs] @frozen(kw_only=True, auto_attribs=True) class Attribute: """Container for an attribute of a feature. Attributes: name (str): Name of the attribute. value (str): Value of the attribute. code (str | None): Code of the attribute. description (str | None): Description of the attribute. """ name: str value: str code: str | None = None description: str | None = None
[docs] @frozen(kw_only=True, auto_attribs=True) class ExternalDB: """Container for external database information. Attributes: id (str): Unique identifier for the external database. name (str): Name of the external database. description (str | None): Description of the external database. url (str | None): URL where this external database can be accessed. release (str | None): Release version of the external database. """ id: str name: str description: str | None = None url: str | None = None release: str | None = None
[docs] @frozen(kw_only=True, auto_attribs=True) class ExternalReference: """Container for external reference information. Attributes: accession_id (str): Accession ID of the external reference. name (str): Name of the external reference. description (str | None): Description of the external reference. assignment_method (str | None): Method used to assign this reference, e.g., DIRECT. url (str | None): URL where this external reference can be accessed. source (ExternalDB): Source database for this reference. """ accession_id: str name: str description: str | None = None assignment_method: str | None = None url: str | None = None source: ExternalDB | None = None
[docs] @frozen(kw_only=True, auto_attribs=True) class PredictionResult: """Container for a prediction result of a program. Attributes: plugin_name (str): Name of the plugin that generated this prediction. consequence (str): Consequence term predicted by the plugin. score (float | None): Score associated with the prediction, if applicable. description (str | None): Description of the prediction. """ tool: str # Need something more generic and can be used for both plugins and custom annotation # plugin gets attached to FeatureOverlap and works on FeatureOverlap after overlap computation is done # custom annotation after doing overlap computation gets attached to VFA # The data shape varies widely, e.g. SpliceAI, SIFT/PolyPhen; # Should we use a dict? the values can be int/str/tuple. score: int result: str classification: float | None = None version: str | None = None modes: tuple[str] | tuple[()] = () reference_data: tuple[ExternalDB] | tuple[()] = ()
[docs] @frozen(kw_only=True, auto_attribs=True) class SequenceEdit: """Container for edit caused by a variant on a spliced sequence. Offsets are relative to whatever ``Mapper`` produced them, for example, same variant yields a different ``SequenceEdit`` against a CDS mapper than against a cDNA mapper. Attributes: footprint (tuple[int, int]): ``(low, high)`` inclusive offsets the variant covers. start (int): Start of the half-open range to replace. end (int): End of that range, exclusive. Equal to ``start`` for a pure insertion. replacement (str): The allele string to replace with. Generally the alternate allele, strand-corrected to transcript sense and empty for a pure deletion. """ footprint: tuple[int, int] start: int end: int replacement: str @property def length_change(self) -> int: """Net change in sequence length this edit makes. The change in sequence length is calculated as (replaced allele length - edited allele length). Derived here rather than at each call site so the arithmetic lives next to the geometry it comes from. Returns: int: The net length change. """ return len(self.replacement) - (self.end - self.start)