Identifier Containers#
An identifier container is an object which hashes identifiers.
e.g. it associates a read’s identifier to an index.
So \(\forall r \in \mathcal{R}\) we define:
\(r_{rid}\) the read’s identifier
\(r_{ind}\) the read’s index
You can write your own identifier container class using the abstract base class.
Class |
Description |
---|---|
Abstract base class for new identifier container |
|
For 0-based indices identifiers |
|
For hashable identifiers |
Type#
Indices Identifier Container#
- class IndexIDContainer#
Reads identifier container for 0-based indentifiers.
Methods:
__contains__
(read_id)Return True if read's identifier in container.
__iter__
()Iterate on reads' identifier.
__len__
()Return the number of recorded read's identifiers.
add
(read_id)Add an entry if identifier not yet recorded.
id_to_indor
(read_id[, orientation])Return the oriented vertex associated to the id.
indor_to_id
(vertex)Return the id from vertices.
pop
(read_id)Remove read's identifier.
- __contains__(read_id)#
Return True if read’s identifier in container.
- __len__()#
Return the number of recorded read’s identifiers.
- Returns:
Number of reads’ identifiers
- Return type:
- add(read_id)#
Add an entry if identifier not yet recorded.
- Parameters:
read_id (
IndexT
) – Read’s identifier- Returns:
Associated vertex index
- Return type:
Notes
It considers bijective-property respected (read’s identifiers are 0-base indices), thus it adds all read’s identifiers between the \(max(r_{id} \in \mathcal{R_{id}}\) and new \(r_{id}\)
If the property was violated, only new \(r_{id}\) is added.
- id_to_indor(read_id, orientation=FORWARD_INT)#
Return the oriented vertex associated to the id.
- Parameters:
read_id (
IdT
) – Read’s identifierorientation (
OrT
, defaultFORWARD_INT
) – Read orientation
- Returns:
Oriented vertex
- Return type:
- Raises:
NoReadId – If there is no read’s identifier in container
- indor_to_id(vertex)#
Return the id from vertices.
- Parameters:
vertex (
IndOrT
) – Oriented vertex- Returns:
The associated read’s identifier
- Return type:
- Raises:
NoVertexIndex – There is no read’s identifier corresponding to given vertex
Hashable Identifier Container#
- class HashableIDContainer#
Reads identifier container for hashable identifiers.
Methods:
__contains__
(read_id)Return True if read's identifier in container.
__iter__
()Iterate on reads' identifier.
__len__
()Return the number of recorded read's identifiers.
add
(read_id)Add an entry if identifier not yet recorded else corresponding index.
id_to_indor
(read_id[, orientation])Return the oriented vertex associated to the id.
indor_to_id
(vertex)Return the id from vertices.
pop
(read_id)Remove read's identifier.
- __contains__(read_id)#
Return True if read’s identifier in container.
- Parameters:
read_id (
Hashable
) – Read’s identifier- Returns:
Is read’s identifier in container?
- Return type:
- __iter__()#
Iterate on reads’ identifier.
- Yields:
Hashable
– Reads’ identifier
- __len__()#
Return the number of recorded read’s identifiers.
- Returns:
Number of reads’ identifiers
- Return type:
- add(read_id)#
Add an entry if identifier not yet recorded else corresponding index.
- Parameters:
read_id (
Hasable
) – Read’s identifier- Returns:
Associated vertex index
- Return type:
- id_to_indor(read_id, orientation=FORWARD_INT)#
Return the oriented vertex associated to the id.
- Parameters:
read_id (
Hashable
) – Read’s identifierorientation (
OrT
, defaultFORWARD_INT
) – Read orientation
- Returns:
Oriented vertex
- Return type:
- Raises:
NoReadId – If there is no read’s identifier in container
- indor_to_id(vertex)#
Return the id from vertices.
- Parameters:
vertex (
IndOrT
) – Oriented vertex- Returns:
The associated read’s identifier
- Return type:
Hashable
- Raises:
NoVertexIndex – There is no read’s identifier corresponding to given vertex
Identifier Container Abstract Base Class#
- class AbstractIDContainer#
Abstract class for reads identifiers container.
Methods:
__contains__
(read_id)Return True if read's identifier in container.
__iter__
()Iterate on reads' identifier.
__len__
()Return the number of recorded read's identifiers.
add
(read_id)Add an entry if identifier not yet recorded else corresponding index.
id_to_indor
(read_id[, orientation])Return the oriented vertex associated to the id.
indor_to_id
(vertex)Return the id from vertices.
pop
(read_id)Remove read's identifier.
- abstract __contains__(read_id)#
Return True if read’s identifier in container.
- Parameters:
read_id (
IdT
) – Read’s identifier- Returns:
Is read’s identifier in container?
- Return type:
- abstract __iter__()#
Iterate on reads’ identifier.
- Yields:
IdT
– Reads’ identifier
- abstract __len__()#
Return the number of recorded read’s identifiers.
- Returns:
Number of reads’ identifiers
- Return type:
- abstract add(read_id)#
Add an entry if identifier not yet recorded else corresponding index.
- Parameters:
read_id (
IdT
) – Read’s identifier- Returns:
Associated vertex index
- Return type:
- abstract id_to_indor(read_id, orientation=FORWARD_INT)#
Return the oriented vertex associated to the id.
- Parameters:
read_id (
IdT
) – Read’s identifierorientation (
OrT
, defaultFORWARD_INT
) – Read orientation
- Returns:
Oriented vertex
- Return type:
- Raises:
NoReadId – If there is no read’s identifier in container