Coverage for src/python/ensembl/vep/matcher/base.py: 100%

18 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"""Matcher contracts and policies.""" 

15 

16from __future__ import annotations 

17 

18from enum import Enum 

19from typing import Protocol 

20 

21__all__ = ["AlleleLike", "InsertionMatchPolicy", "IntervalLike"] 

22 

23 

24class IntervalLike(Protocol): 

25 """Inclusive coordinates used for interval matching.""" 

26 

27 @property 

28 def start(self) -> int: 

29 """Return the inclusive start coordinate.""" 

30 raise NotImplementedError 

31 

32 @property 

33 def end(self) -> int: 

34 """Return the inclusive end coordinate.""" 

35 raise NotImplementedError 

36 

37 

38class AlleleLike(IntervalLike, Protocol): 

39 """Coordinates and allele strings used for colocation.""" 

40 

41 @property 

42 def reference_allele(self) -> str | None: 

43 """Return the reference allele string.""" 

44 raise NotImplementedError 

45 

46 @property 

47 def alternate_allele(self) -> str | None: 

48 """Return the alternate allele string.""" 

49 raise NotImplementedError 

50 

51 

52class InsertionMatchPolicy(str, Enum): 

53 """Policy for associating an interbase insertion with a feature.""" 

54 

55 CONTAINED = "contained" 

56 TOUCHING = "touching" 

57 THREE_PRIME = "three_prime"