Coverage for src/python/ensembl/vep/common/constants.py: 100%

22 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"""Common constants.""" 

15 

16from ensembl.vep.common.enums import ExonPhase, Strand, ClassSOTerm 

17 

18__all__ = [ 

19 "DEFAULT_DISTANCE", 

20 "INPUT_FORMAT_EXTENSIONS", 

21 "COMPRESSION_SUFFIXES", 

22 "CANONICAL_DNA_BASES", 

23 "EMPTY_ALLELE", 

24 "UNKNOWN_VALUE", 

25 "VCF_BASES", 

26 "VCF_PLAIN_ALLELE_CHARACTERS", 

27 "CLASS_SO_TERM_ABBRV_TO_ENUM", 

28 "STRAND_SYMBOL_TO_ENUM", 

29 "GFF_TO_ENSEMBL_PHASE", 

30] 

31 

32DEFAULT_DISTANCE = 5000 

33"""Bases either side of a feature that still pair with it, as Perl VEP's ``--distance`` defaults. 

34 

35One home for a value three layers have to agree on: the pairing window the overlap finder expands 

36by, the ``is_upstream``/``is_downstream`` facts, and the zone map that prefills them. 

37""" 

38INPUT_FORMAT_EXTENSIONS = { 

39 "vcf": (".vcf", ".bcf"), 

40} 

41"""The input formats a run reads, and the file extensions each one owns. 

42 

43Here rather than beside the sources because ``--format`` offers these names and the configuration 

44package cannot import the sources, which import it. 

45""" 

46 

47COMPRESSION_SUFFIXES = (".gz", ".bgz", ".bz2", ".zst") 

48"""Suffixes that name how a file is compressed rather than what it holds.""" 

49 

50CANONICAL_DNA_BASES = "ACGT" 

51"""Unambiguous DNA bases used when generating synthetic sequence.""" 

52 

53EMPTY_ALLELE = "-" 

54"""VEP's spelling of an empty allele.""" 

55 

56UNKNOWN_VALUE = "?" 

57"""Placeholder printed where a label's field is not available.""" 

58 

59VCF_BASES = frozenset("ACGTN") 

60"""Base characters accepted in a plain VCF allele, including the unknown base ``N``.""" 

61 

62VCF_PLAIN_ALLELE_CHARACTERS = frozenset("ACGTN.") 

63"""Characters accepted in a non-symbolic VCF allele.""" 

64 

65CLASS_SO_TERM_ABBRV_TO_ENUM: dict[str, ClassSOTerm] = { 

66 "INS": ClassSOTerm.INSERTION, 

67 "INS_ME": ClassSOTerm.MOBILE_ELEMENT_INSERTION, 

68 "INS_ALU": ClassSOTerm.ALU_INSERTION, 

69 "INS_HERV": ClassSOTerm.HERV_INSERTION, 

70 "INS_LINE1": ClassSOTerm.LINE1_INSERTION, 

71 "INS_SVA": ClassSOTerm.SVA_INSERTION, 

72 "DEL": ClassSOTerm.DELETION, 

73 "DEL_ME": ClassSOTerm.MOBILE_ELEMENT_DELETION, 

74 "DEL_ALU": ClassSOTerm.ALU_DELETION, 

75 "DEL_HERV": ClassSOTerm.HERV_DELETION, 

76 "DEL_LINE1": ClassSOTerm.LINE1_DELETION, 

77 "DEL_SVA": ClassSOTerm.SVA_DELETION, 

78 "TREP": ClassSOTerm.TANDEM_REPEAT, 

79 "TDUP": ClassSOTerm.TANDEM_DUPLICATION, 

80 "DUP": ClassSOTerm.DUPLICATION, 

81 "CNV": ClassSOTerm.COPY_NUMBER_VARIATION, 

82 "INV": ClassSOTerm.INVERSION, 

83 "BND": ClassSOTerm.CHROMOSOME_BREAKPOINT, 

84} 

85 

86# for . (non-strandedness) we treat it as forward strand 

87STRAND_SYMBOL_TO_ENUM = { 

88 "+": Strand.FORWARD, 

89 "-": Strand.REVERSE, 

90 ".": Strand.FORWARD, 

91 "?": Strand.UNKNOWN, 

92} 

93 

94GFF_TO_ENSEMBL_PHASE = { 

95 0: ExonPhase.ZERO, 

96 2: ExonPhase.ONE, 

97 1: ExonPhase.TWO, 

98} 

99"""A CDS row's GFF phase (bases to skip to reach a codon) as an Ensembl exon phase (bases of the 

100first codon on what came before), converted as ``Bio::EnsEMBL::VEP::AnnotationSource::File:: 

101BaseGXF::_convert_phase`` does."""