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

AbstractIDContainer

Abstract base class for new identifier container

IndexIDContainer

For 0-based indices identifiers

HashableIDContainer

For hashable identifiers

Type#

IdT#
Value:

Hashable

Identifier 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.

Parameters:

read_id (IndexT) – Read’s identifier

Returns:

Is read’s identifier in container?

Return type:

bool

__iter__()#

Iterate on reads’ identifier.

Yields:

IndexT – Reads’ identifier

__len__()#

Return the number of recorded read’s identifiers.

Returns:

Number of reads’ identifiers

Return type:

int

add(read_id)#

Add an entry if identifier not yet recorded.

Parameters:

read_id (IndexT) – Read’s identifier

Returns:

Associated vertex index

Return type:

IndexT

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 identifier

  • orientation (OrT, default FORWARD_INT) – Read orientation

Returns:

Oriented vertex

Return type:

IndOrT

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:

IndexT

Raises:

NoVertexIndex – There is no read’s identifier corresponding to given vertex

pop(read_id)#

Remove read’s identifier.

Parameters:

read_id (int) – Read’s identifier

Returns:

Index corresponding to read’s identifier

Return type:

IndexT

Raises:

NoReadId – If there is no read’s identifier in container

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:

bool

__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:

int

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:

IndexT

id_to_indor(read_id, orientation=FORWARD_INT)#

Return the oriented vertex associated to the id.

Parameters:
  • read_id (Hashable) – Read’s identifier

  • orientation (OrT, default FORWARD_INT) – Read orientation

Returns:

Oriented vertex

Return type:

IndOrT

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

pop(read_id)#

Remove read’s identifier.

Parameters:

read_id (Hashable) – Read’s identifier

Returns:

Index corresponding to read’s identifier

Return type:

IndexT

Raises:

NoReadId – If there is no read’s identifier in container

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:

bool

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:

int

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:

IndexT

abstract id_to_indor(read_id, orientation=FORWARD_INT)#

Return the oriented vertex associated to the id.

Parameters:
  • read_id (IdT) – Read’s identifier

  • orientation (OrT, default FORWARD_INT) – Read orientation

Returns:

Oriented vertex

Return type:

IndOrT

Raises:

NoReadId – If there is no read’s identifier in container

abstract indor_to_id(vertex)#

Return the id from vertices.

Parameters:

vertex (IndOrT) – Oriented vertex

Returns:

The associated read’s identifier

Return type:

IdT

Raises:

NoVertex – There is no read’s identifier corresponding to given vertex

abstract pop(read_id)#

Remove read’s identifier.

Parameters:

read_id (IdT) – Read’s identifier

Returns:

Index corresponding to read’s identifier

Return type:

IndexT

Raises:

NoReadId – If there is no read’s identifier in container