Coverage for src/python/ensembl/vep/overlaps/colocated.py: 100%
15 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"""Colocated-variant overlap finding."""
16from __future__ import annotations
18from attrs import define
20from ensembl.vep.models.overlap import FeatureOverlap
21from ensembl.vep.models.variation import Variation, VariationAllele
22from ensembl.vep.overlaps.base import CandidateLookup, FeatureMatcher
23from ensembl.vep.overlaps.feature import FeatureOverlapFinder
25__all__ = ["ColocatedVariantOverlapFinder", "colocated_variant_overlap"]
28def colocated_variant_overlap(variation: Variation, variation_allele: VariationAllele) -> FeatureOverlap:
29 """Construct an overlap between a known variation and an input allele."""
30 return FeatureOverlap(feature=variation, overlapping_feature=variation_allele)
33@define(kw_only=True, auto_attribs=True)
34class ColocatedVariantOverlapFinder(FeatureOverlapFinder[Variation, FeatureOverlap]):
35 """Known-variant colocation finder for input alleles.
37 Attributes:
38 candidates (CandidateLookup[Variation]): Lookup for known variation candidates.
39 matcher (FeatureMatcher): Rule for associating a candidate with an input allele.
40 """
42 candidates: CandidateLookup[Variation]
43 matcher: FeatureMatcher
45 def __attrs_post_init__(self) -> None:
46 """Use the colocated-variant overlap factory."""
47 self.overlap_factory = colocated_variant_overlap