Commit 918e5588 authored by Martin Larralde's avatar Martin Larralde
Browse files

Expose `TRANSLATION_TABLES` and `METAGENOMIC_BINS` constants in `pyrodigal` module

parent 96b6e2ce
......@@ -17,6 +17,8 @@ from ._pyrodigal import (
Sequence,
TrainingInfo,
MetagenomicBin,
TRANSLATION_TABLES,
METAGENOMIC_BINS,
)
__doc__ = _pyrodigal.__doc__
......@@ -30,7 +32,9 @@ __all__ = [
"OrfFinder",
"Sequence",
"TrainingInfo",
"MetagenomicBin"
"MetagenomicBin",
"METAGENOMIC_BINS",
"TRANSLATION_TABLES",
]
__author__ = "Martin Larralde <martin.larralde@embl.de>"
......
......@@ -17,7 +17,7 @@ cdef int MIN_SINGLE_GENOME
cdef int IDEAL_SINGLE_GENOME
cdef size_t MIN_GENES_ALLOC
cdef size_t MIN_NODES_ALLOC
cdef public set TRANSLATION_TABLES
cdef public set _TRANSLATION_TABLES
# --- Sequence mask ----------------------------------------------------------
......
......@@ -12,7 +12,7 @@ _AVX2_BUILD_SUPPORT : bool
_NEON_BUILD_SUPPORT : bool
_SSE2_BUILD_SUPPORT : bool
_TRANSLATION_TABLES : FrozenSet[int]
TRANSLATION_TABLES : FrozenSet[int]
METAGENOMIC_BINS : Tuple[MetagenomicBin]
......
......@@ -118,9 +118,9 @@ cdef int WINDOW = 120
cdef size_t MIN_MASKS_ALLOC = 8
cdef size_t MIN_GENES_ALLOC = 8
cdef size_t MIN_NODES_ALLOC = 8 * MIN_GENES_ALLOC
cdef set TRANSLATION_TABLES = set(range(1, 7)) | set(range(9, 17)) | set(range(21, 26))
cdef set _TRANSLATION_TABLES = set(range(1, 7)) | set(range(9, 17)) | set(range(21, 26))
_TRANSLATION_TABLES = frozenset(TRANSLATION_TABLES)
TRANSLATION_TABLES = frozenset(_TRANSLATION_TABLES)
# --- Sequence mask ----------------------------------------------------------
......@@ -2934,7 +2934,7 @@ cdef class Gene:
# table would be read from in the fields of the struct
if translation_table is None:
tt = self.owner.training_info.tinf.trans_table
elif translation_table not in TRANSLATION_TABLES:
elif translation_table not in _TRANSLATION_TABLES:
raise ValueError(f"{translation_table} is not a valid translation table index")
else:
tt = translation_table
......@@ -3393,7 +3393,7 @@ cdef class Genes:
cdef int i
cdef ssize_t n = 0
if translation_table is not None and translation_table not in TRANSLATION_TABLES:
if translation_table is not None and translation_table not in _TRANSLATION_TABLES:
raise ValueError(f"{translation_table} is not a valid translation table index")
for i, gene in enumerate(self):
......@@ -3687,7 +3687,7 @@ cdef class TrainingInfo:
@translation_table.setter
def translation_table(self, int table):
assert self.tinf != NULL
if table not in TRANSLATION_TABLES:
if table not in _TRANSLATION_TABLES:
raise ValueError(f"{table} is not a valid translation table index")
self.raw.trans_table = table
......@@ -4879,7 +4879,7 @@ cdef class OrfFinder:
# Check arguments
if self.meta:
raise RuntimeError("cannot use training sequence in metagenomic mode")
if translation_table not in TRANSLATION_TABLES:
if translation_table not in _TRANSLATION_TABLES:
raise ValueError(f"{translation_table} is not a valid translation table index")
# extract sequence
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment