Bifrost
Public Member Functions
UnitigMap< Unitig_data_t, Graph_data_t, is_const > Class Template Reference

Contain all the information for the mapping of a k-mer or a sequence to a unitig of a Compacted de Bruijn graph. More...

Public Member Functions

 UnitigMap (size_t length=1, CompactedDBG_ptr_t cdbg_=nullptr)
 UnitigMap constructor. More...
 
 UnitigMap (const size_t start, const size_t length, const size_t unitig_sz, const bool strand)
 UnitigMap constructor. More...
 
bool operator== (const UnitigMap &o) const
 Equality operator: check if two UnitigMap are the same. More...
 
bool operator!= (const UnitigMap &o) const
 Inequality operator: check if two UnitigMap are different. More...
 
bool isSameReferenceUnitig (const UnitigMap &o) const
 check if two UnitigMap have the same unitig as reference. More...
 
string mappedSequenceToString () const
 Create a string containing the sequence corresponding to the mapping. More...
 
string referenceUnitigToString () const
 Create a string containing the sequence of the reference unitig used the mapping. More...
 
size_t lcp (const char *s, const size_t pos_s=0, const size_t pos_um_seq=0, const bool um_reversed=false) const
 Compute the length of the longest common prefix between a given sequence and the reference unitig used in the mapping. More...
 
Kmer getUnitigHead () const
 Get the head k-mer of the reference unitig used for the mapping. More...
 
Kmer getUnitigTail () const
 Get the tail k-mer of the reference unitig used for the mapping. More...
 
Kmer getUnitigKmer (const size_t pos) const
 Get the k-mer starting at position pos in the reference unitig used for the mapping. More...
 
Kmer getMappedHead () const
 Get the head k-mer of the mapped sequence. More...
 
Kmer getMappedTail () const
 Get the tail k-mer of the mapped sequence. More...
 
Kmer getMappedKmer (const size_t pos) const
 Get the k-mer starting at position pos in the mapped sequence. More...
 
UnitigMap< U, G, is_const > getKmerMapping (const size_t pos) const
 Create a new UnitigMap object which is the mapping of a k-mer on a reference unitig. More...
 
Unitig_data_ptr_t getData () const
 Get a pointer to the data associated with the reference unitig used in the mapping. More...
 
UnitigMap_BW getPredecessors () const
 Create a UnitigMap_BW object that can create iterators (through UnitigMap_BW::begin() and UnitigMap_BW::end()) over the predecessors of the reference unitig used in the mapping. More...
 
UnitigMap_FW getSuccessors () const
 Create a UnitigMap_FW object that can create iterators (through UnitigMap_FW::begin() and UnitigMap_FW::end()) over the successors of the reference unitig used in the mapping. More...
 
CompactedDBG_ptr_t getGraph () const
 Get a pointer to the CompactedDBG containing the reference unitig used in the mapping. More...
 

Detailed Description

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
class UnitigMap< Unitig_data_t, Graph_data_t, is_const >

Contain all the information for the mapping of a k-mer or a sequence to a unitig of a Compacted de Bruijn graph.

A UnitigMap object has 3 template parameters: the type of data associated with the unitigs of the graph, the type of data associated with the graph and a boolean indicating if this is a constant UnitigMap (const_UnitigMap) or not. A const_UnitigMap can be modified but you can't modify the CompactedDBG you can access using UnitigMap::getCompactedDBG. The unitig data and graph data types should be the same as the ones used for the CompactedDBG.

UnitigMap<> um_1; // No unitig data, no graph data, NOT constant and its content IS NOT constant
UnitigMap<void, void, false> um_2; // Equivalent to previous notation
const UnitigMap<> um_3; // No unitig data, no graph data, constant BUT its content IS NOT constant
UnitigMap<void, void, true> um_4; // No unitig data, no graph data, NOT constant BUT its content IS constant
const UnitigMap<void, void, true> um_5; // No unitig data, no graph data, constant AND its content IS constant
UnitigMap<myUnitigData, myGraphData> um_6; // Unitig data of type myUnitigData for each unitig, graph data of type myGraphData, not constant
CompactedDBG<>* cdbg_ptr_1 = um_1.getGraph(); // Associated CompactedDBG can be modified from the UnitigMap
CompactedDBG<>* cdbg_ptr_2 = um_2.getGraph(); // Associated CompactedDBG can be modified from the UnitigMap
CompactedDBG<>* cdbg_ptr_3 = um_3.getGraph(); // Associated CompactedDBG can be modified from the UnitigMap
const CompactedDBG<>* cdbg_ptr_4 = um_4.getGraph(); // Associated CompactedDBG cannot be modified from the UnitigMap
const CompactedDBG<>* cdbg_ptr_5 = um_5.getGraph(); // Associated CompactedDBG cannot be modified from the UnitigMap
CompactedDBG<myUnitigData, myGraphData>* cdbg_ptr_6 = um_6.getGraph(); // Associated CompactedDBG can be modified from the UnitigMap

Constructor & Destructor Documentation

◆ UnitigMap() [1/2]

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
UnitigMap< Unitig_data_t, Graph_data_t, is_const >::UnitigMap ( size_t  length = 1,
CompactedDBG_ptr_t  cdbg_ = nullptr 
)

UnitigMap constructor.

Parameters
lengthis the length of the mapping in k-mers (default is 1 k-mer).
cdbg_is a pointer to the CompactedDBG containing the reference unitig used for the mapping (default is nullptr).
Returns
an empty UnitigMap.

◆ UnitigMap() [2/2]

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
UnitigMap< Unitig_data_t, Graph_data_t, is_const >::UnitigMap ( const size_t  start,
const size_t  length,
const size_t  unitig_sz,
const bool  strand 
)

UnitigMap constructor.

This constructor is used to create temporary mappings and must not be used to extract information from the graph.

Parameters
startis the start position of the mapping (0-based distance) from the start of the reference unitig.
lengthis the length of the mapping in k-mers.
unitig_szis the length of the reference unitig used for the mapping.
strandindicates if the mapped k-mer or sequence matches the forward strand (true) or the reverse-complement (false).
Returns
a UnitigMap.

Member Function Documentation

◆ getData()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
Unitig_data_ptr_t UnitigMap< Unitig_data_t, Graph_data_t, is_const >::getData ( ) const

Get a pointer to the data associated with the reference unitig used in the mapping.

Returns
a pointer to the data associated with the reference unitig used in the mapping or a nullptr pointer if:
  • there is no mapping (UnitigMap::isEmpty = true)
  • there is no data associated with the unitigs (U = void). The returned pointer is constant if the UnitigMap is constant (UnitigMap<U, G, true>).

◆ getGraph()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
CompactedDBG_ptr_t UnitigMap< Unitig_data_t, Graph_data_t, is_const >::getGraph ( ) const
inline

Get a pointer to the CompactedDBG containing the reference unitig used in the mapping.

Returns
a pointer to the CompactedDBG containing the reference unitig used in the mapping. If the mapping is empty, a nullptr pointer is returned. The pointer is a constant pointer if the UnitigMap is constant (UnitigMap<U, G, true>).

◆ getKmerMapping()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
UnitigMap<U, G, is_const> UnitigMap< Unitig_data_t, Graph_data_t, is_const >::getKmerMapping ( const size_t  pos) const

Create a new UnitigMap object which is the mapping of a k-mer on a reference unitig.

Parameters
posis the start position of the k-mer to map in the reference unitig used for the current mapping.
Returns
a UnitigMap object which is the mapping.

◆ getMappedHead()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
Kmer UnitigMap< Unitig_data_t, Graph_data_t, is_const >::getMappedHead ( ) const

Get the head k-mer of the mapped sequence.

Returns
a Kmer object which is either the head k-mer of the mapped sequence or an empty k-mer if there is no mapping (UnitigMap::isEmpty = true).

◆ getMappedKmer()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
Kmer UnitigMap< Unitig_data_t, Graph_data_t, is_const >::getMappedKmer ( const size_t  pos) const

Get the k-mer starting at position pos in the mapped sequence.

Parameters
posis the start position of the k-mer to extract within the mapped sequence.
Returns
a Kmer object which is either the k-mer starting at position pos in the mapped sequence or an empty k-mer if there is either no mapping (UnitigMap::isEmpty = true) or the position is greater than length(unitig)-k.

◆ getMappedTail()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
Kmer UnitigMap< Unitig_data_t, Graph_data_t, is_const >::getMappedTail ( ) const

Get the tail k-mer of the mapped sequence.

Returns
a Kmer object which is either the tail k-mer of the mapped sequence or an empty k-mer if there is no mapping (UnitigMap::isEmpty = true).

◆ getPredecessors()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
UnitigMap_BW UnitigMap< Unitig_data_t, Graph_data_t, is_const >::getPredecessors ( ) const

Create a UnitigMap_BW object that can create iterators (through UnitigMap_BW::begin() and UnitigMap_BW::end()) over the predecessors of the reference unitig used in the mapping.

Returns
a UnitigMap_BW object that can create iterators (through UnitigMap_BW::begin() and UnitigMap_BW::end()) over the predecessors of the reference unitig used in the mapping.

◆ getSuccessors()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
UnitigMap_FW UnitigMap< Unitig_data_t, Graph_data_t, is_const >::getSuccessors ( ) const

Create a UnitigMap_FW object that can create iterators (through UnitigMap_FW::begin() and UnitigMap_FW::end()) over the successors of the reference unitig used in the mapping.

Returns
a UnitigMap_FW object that can create iterators (through UnitigMap_FW::begin() and UnitigMap_FW::end()) over the successors of the reference unitig used in the mapping.

◆ getUnitigHead()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
Kmer UnitigMap< Unitig_data_t, Graph_data_t, is_const >::getUnitigHead ( ) const

Get the head k-mer of the reference unitig used for the mapping.

Returns
a Kmer object which is either the head k-mer of the mapped unitig or an empty k-mer if there is no mapping (UnitigMap::isEmpty = true).

◆ getUnitigKmer()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
Kmer UnitigMap< Unitig_data_t, Graph_data_t, is_const >::getUnitigKmer ( const size_t  pos) const

Get the k-mer starting at position pos in the reference unitig used for the mapping.

Parameters
posis the start position of the k-mer to extract.
Returns
a Kmer object which is either the k-mer starting at position pos in the mapped unitig or an empty k-mer if there is either no mapping (UnitigMap::isEmpty = true) or the position is greater than length(unitig)-k.

◆ getUnitigTail()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
Kmer UnitigMap< Unitig_data_t, Graph_data_t, is_const >::getUnitigTail ( ) const

Get the tail k-mer of the reference unitig used for the mapping.

Returns
a Kmer object which is either the tail k-mer of the mapped unitig or an empty k-mer if there is no mapping (UnitigMap::isEmpty = true).

◆ isSameReferenceUnitig()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
bool UnitigMap< Unitig_data_t, Graph_data_t, is_const >::isSameReferenceUnitig ( const UnitigMap< Unitig_data_t, Graph_data_t, is_const > &  o) const

check if two UnitigMap have the same unitig as reference.

Returns
a boolean indicating if two UnitigMap have the same unitig as reference.

◆ lcp()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
size_t UnitigMap< Unitig_data_t, Graph_data_t, is_const >::lcp ( const char *  s,
const size_t  pos_s = 0,
const size_t  pos_um_seq = 0,
const bool  um_reversed = false 
) const

Compute the length of the longest common prefix between a given sequence and the reference unitig used in the mapping.

Parameters
sis a pointer to an array of characters representing the sequence from which the length of the longest common prefix must be computed.
pos_sis the start position in s from which the longest common prefix must be computed.
pos_um_seqis the start position in the reference unitig of the mapping from which the longest common prefix must be computed.
um_reversedindicates if the longest common prefix must be computed from the reverse-complement of the reference unitig used in the mapping (true) or not (false).
Returns
the length of the longest common prefix

◆ mappedSequenceToString()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
string UnitigMap< Unitig_data_t, Graph_data_t, is_const >::mappedSequenceToString ( ) const

Create a string containing the sequence corresponding to the mapping.

Returns
a string containing the sequence corresponding to the mapping or an empty string if there is no mapping (UnitigMap::isEmpty = true).

◆ operator!=()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
bool UnitigMap< Unitig_data_t, Graph_data_t, is_const >::operator!= ( const UnitigMap< Unitig_data_t, Graph_data_t, is_const > &  o) const

Inequality operator: check if two UnitigMap are different.

Returns
a boolean indicating if the two UnitigMap are different.

◆ operator==()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
bool UnitigMap< Unitig_data_t, Graph_data_t, is_const >::operator== ( const UnitigMap< Unitig_data_t, Graph_data_t, is_const > &  o) const

Equality operator: check if two UnitigMap are the same.

Returns
a boolean indicating if two UnitigMap are the same.

◆ referenceUnitigToString()

template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
string UnitigMap< Unitig_data_t, Graph_data_t, is_const >::referenceUnitigToString ( ) const

Create a string containing the sequence of the reference unitig used the mapping.

Returns
a string containing the sequence of the reference unitig used the mapping or an empty string if there is no mapping (UnitigMap::isEmpty = true).

The documentation for this class was generated from the following files:
UnitigMap
Contain all the information for the mapping of a k-mer or a sequence to a unitig of a Compacted de Br...
Definition: UnitigMap.hpp:92
UnitigMap::getGraph
CompactedDBG_ptr_t getGraph() const
Get a pointer to the CompactedDBG containing the reference unitig used in the mapping.
Definition: UnitigMap.hpp:243
CompactedDBG
Represent a Compacted de Bruijn graph.
Definition: CompactedDBG.hpp:313