Commit 90b51ea1 authored by Martin Larralde's avatar Martin Larralde
Browse files

Document methods of `ConnectionScorer` and add `__sizeof__` method

parent da417ab6
......@@ -51,6 +51,7 @@ cdef class Masks:
cpdef Masks copy(self)
cpdef void clear(self)
# --- Input sequence ---------------------------------------------------------
cdef class Sequence:
......@@ -127,6 +128,8 @@ cdef class ConnectionScorer:
cdef uint8_t* node_frames
cdef uint8_t* node_frames_raw
cpdef size_t __sizeof__(self)
cdef int _index(self, Nodes nodes) nogil except -1
cdef int _compute_skippable(
......@@ -912,6 +912,8 @@ cdef enum simd_backend:
cdef class ConnectionScorer:
"""A dedicated class for the fast scoring of nodes.
# --- Magic methods ------------------------------------------------------
......@@ -923,6 +925,17 @@ cdef class ConnectionScorer:
self.node_frames = self.node_frames_raw = NULL
def __init__(self, str backend="detect"):
"""__init__(self, backend="detect")\n--
Create a new connection score.
backend (`str`): The SIMD backend to use for the heuristic filter.
Use ``"detect"`` to use the best available one depending on
the CPU capabilities of the local machine. Other available
values are: ``"generic"``, ``"sse"``, ``"avx"``, ``neon``.
IF TARGET_CPU == "x86":
if backend =="detect":
self.backend = simd_backend.NONE
......@@ -987,6 +1000,9 @@ cdef class ConnectionScorer:
cpdef size_t __sizeof__(self):
return sizeof(self) + (self.capacity * sizeof(uint8_t) + 0x1F) * 4
# --- C interface --------------------------------------------------------
cdef int _index(self, Nodes nodes) nogil except -1:
......@@ -1079,10 +1095,25 @@ cdef class ConnectionScorer:
# --- Python interface ---------------------------------------------------
def index(self, Nodes nodes not None):
"""index(self, nodes)\n--
Index the nodes in preparation for the heuristic SIMD filter.
with nogil:
def compute_skippable(self, int min, int i):
"""compute_skippable(self, min, i)\n--
Find which connections to node *i* are invalid, starting from *min*.
min (`int`): The index of the first node from which to start
scoring connections.
i (`int`): The index of the node to score.
assert (self.skip_connection != NULL) | (self.backend == simd_backend.NONE)
assert (i < <int> self.capacity) | (self.backend == simd_backend.NONE)
assert min <= i
......@@ -1097,6 +1128,21 @@ cdef class ConnectionScorer:
TrainingInfo tinf not None,
bint final=False
"""score_connections(self, nodes, min, i, tinf, final=False)\n--
Score all connections to node *i*, starting from node *min*.
nodes (`~pyrodigal.Nodes`): The array of nodes to score.
min (`int`): The index of the first node from which to start
scoring connections.
i (`int`): The index of the node to score.
tinf (`~pyrodigal.TrainingInfo`): The training info from which
to read the start codon weights.
final (`bool`): ``False`` when the scoring occurs during training,
``True`` otherwise.
assert (self.skip_connection != NULL) | (self.backend == simd_backend.NONE)
assert (i < <int> nodes.length) | (self.backend == simd_backend.NONE)
assert min <= i
Markdown is supported
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