Coverage for src/python/ensembl/vep/overlaps/custom.py: 100%

16 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"""Custom-feature overlap finding.""" 

15 

16from __future__ import annotations 

17 

18from attrs import define 

19 

20from ensembl.vep.models.custom_feature import CustomFeature 

21from ensembl.vep.models.overlap import CustomVariationAllele 

22from ensembl.vep.models.variation import VariationAllele 

23from ensembl.vep.overlaps.base import CandidateLookup, FeatureMatcher 

24from ensembl.vep.overlaps.feature import FeatureOverlapFinder 

25 

26__all__ = ["CustomOverlapFinder", "custom_overlap"] 

27 

28 

29def custom_overlap(custom_feature: CustomFeature, variation_allele: VariationAllele) -> CustomVariationAllele: 

30 """Construct a typed custom-feature overlap.""" 

31 return CustomVariationAllele(feature=custom_feature, overlapping_feature=variation_allele) 

32 

33 

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

35class CustomOverlapFinder(FeatureOverlapFinder[CustomFeature, CustomVariationAllele]): 

36 """Custom-feature overlap finder for a variation-allele buffer. 

37 

38 Attributes: 

39 candidates (CandidateLookup[CustomFeature]): Lookup for custom-feature candidates. 

40 matcher (FeatureMatcher): Rule for associating a candidate with an input allele. 

41 """ 

42 

43 candidates: CandidateLookup[CustomFeature] 

44 matcher: FeatureMatcher 

45 

46 def __attrs_post_init__(self) -> None: 

47 """Use the typed custom-overlap factory.""" 

48 self.overlap_factory = custom_overlap