1 #ifndef BFG_UNITIGMAP_HPP 2 #define BFG_UNITIGMAP_HPP 13 template<
typename U>
class Unitig;
15 template<
typename U,
typename G,
bool is_const>
class BackwardCDBG;
16 template<
typename U,
typename G,
bool is_const>
class ForwardCDBG;
48 UnitigMapBase(
const size_t start,
const size_t length,
const size_t unitig_sz,
const bool strand);
91 template<
typename Unitig_data_t =
void,
typename Graph_data_t =
void,
bool is_const = false>
94 typedef Unitig_data_t U;
95 typedef Graph_data_t G;
97 template<
typename U,
typename G>
friend class CompactedDBG;
98 template<
typename U,
typename G,
bool C>
friend class BackwardCDBG;
99 template<
typename U,
typename G,
bool C>
friend class ForwardCDBG;
100 template<
typename U,
typename G,
bool C>
friend class unitigIterator;
101 template<
typename U,
typename G,
bool C>
friend class UnitigMap;
103 typedef typename std::conditional<is_const, const CompactedDBG<U, G>*,
CompactedDBG<U, G>*>::type CompactedDBG_ptr_t;
104 typedef typename std::conditional<is_const, const U*, U*>::type Unitig_data_ptr_t;
116 UnitigMap(
size_t length = 1, CompactedDBG_ptr_t cdbg_ =
nullptr);
126 UnitigMap(
const size_t start,
const size_t length,
const size_t unitig_sz,
const bool strand);
162 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;
217 Unitig_data_ptr_t
getData()
const;
238 inline CompactedDBG_ptr_t
getGraph()
const {
return cdbg; }
249 void setFullCoverage()
const;
250 void increaseCoverage()
const;
251 void decreaseCoverage()
const;
253 bool isCoverageFull()
const;
254 size_t getCoverage(
const size_t pos)
const;
258 UnitigMap(
size_t p_unitig,
size_t i,
size_t l,
size_t sz,
bool short_,
bool abundance,
bool strd, CompactedDBG_ptr_t cdbg_);
266 template<
bool is_
void>
typename std::enable_if<!is_void, Unitig<U>>::type splitData_(
const bool last_split)
const;
267 template<
bool is_
void>
typename std::enable_if<is_void, Unitig<U>>::type splitData_(
const bool last_split)
const;
269 Unitig<U> splitData(
const bool last_split)
const;
271 template<
bool is_
void>
typename std::enable_if<!is_void, Unitig_data_ptr_t>::type getData_()
const;
272 template<
bool is_
void>
typename std::enable_if<is_void, Unitig_data_ptr_t>::type getData_()
const;
281 CompactedDBG_ptr_t cdbg;
284 template<
typename Unitig_data_t =
void,
typename Graph_data_t =
void,
bool is_const = false>
287 typedef Unitig_data_t U;
288 typedef Graph_data_t G;
292 struct UnitigMapTMP {
309 isAbundant(um.isAbundant), cdbg(static_cast<const void*>(um.cdbg)) {};
312 UnitigMapTMP tmp(um);
314 return static_cast<size_t>(XXH64(static_cast<const void*>(&tmp),
sizeof(UnitigMapTMP), 0));
318 #include "UnitigMap.tcc" string mappedSequenceToString() const
Create a string containing the sequence corresponding to the mapping.
Iterator for the neighbors (predecessors or successors) of a reference unitig used in a UnitigMap obj...
Definition: NeighborIterator.hpp:34
Iterator for the unitigs of a Compacted de Bruijn graph.
Definition: UnitigIterator.hpp:36
size_t len
Length of the mapping on the reference unitig, in k-mers.
Definition: UnitigMap.hpp:61
Kmer getUnitigKmer(const size_t pos) const
Get the k-mer starting at position pos in the reference unitig used for the mapping.
Unitig_data_ptr_t getData() const
Get a pointer to the data associated with the reference unitig used in the mapping.
bool operator!=(const UnitigMapBase &o) const
Inequality operator: check if two UnitigMapBase are different.
UnitigMap_FW getSuccessors() const
Create a UnitigMap_FW object that can create iterators (through UnitigMap_FW::begin() and UnitigMap_F...
Represent a Compacted de Bruijn graph.
Definition: CompactedDBG.hpp:297
UnitigMap_BW getPredecessors() const
Create a UnitigMap_BW object that can create iterators (through UnitigMap_BW::begin() and UnitigMap_B...
Definition: UnitigMap.hpp:285
Kmer getMappedTail() const
Get the tail k-mer of the mapped sequence.
size_t size
Length of the reference unitig.
Definition: UnitigMap.hpp:62
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 use...
CompactedDBG_ptr_t getGraph() const
Get a pointer to the CompactedDBG containing the reference unitig used in the mapping.
Definition: UnitigMap.hpp:238
Interface to store and manipulate k-mers.
Definition: Kmer.hpp:40
Contain all the information for the mapping of a k-mer or a sequence to a unitig of a Compacted de Br...
Definition: NeighborIterator.hpp:12
Wrapper for class neighborIterator to iterate over the predecessors of a reference unitig used in a U...
Definition: NeighborIterator.hpp:116
Interface for the class Kmer:
Kmer getUnitigTail() const
Get the tail k-mer of the reference unitig used for the mapping.
bool strand
True if the mapped k-mer or sequence matches the forward strand, false if it matches its reverse-comp...
Definition: UnitigMap.hpp:64
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.
Kmer getUnitigHead() const
Get the head k-mer of the reference unitig used for the mapping.
Kmer getMappedHead() const
Get the head k-mer of the mapped sequence.
size_t dist
Start position of the mapping (0-based distance) from the start of the reference unitig.
Definition: UnitigMap.hpp:60
Kmer getMappedKmer(const size_t pos) const
Get the k-mer starting at position pos in the mapped sequence.
UnitigMapBase(const size_t length=1)
UnitigMapBase constructor (isEmpty = true).
Wrapper for class neighborIterator to iterate over the predecessors of a reference unitig used in a U...
Definition: NeighborIterator.hpp:162
Structure containing the basic information of a unitig mapping.
Definition: UnitigMap.hpp:33
Represent a unitig which is a vertex of the Compacted de Bruijn graph.
Definition: Unitig.hpp:22
string referenceUnitigToString() const
Create a string containing the sequence of the reference unitig used the mapping. ...
bool isEmpty
True if there is no mapping.
Definition: UnitigMap.hpp:65
bool operator==(const UnitigMapBase &o) const
Equality operator: check if two UnitigMapBase are the same.