diff --git a/src/UnitigMap.hpp b/src/UnitigMap.hpp index 7aaf3ba..da41df9 100644 --- a/src/UnitigMap.hpp +++ b/src/UnitigMap.hpp @@ -15,6 +15,7 @@ template class CompactedDBG; template class BackwardCDBG; template class ForwardCDBG; template class neighborIterator; +template struct UnitigMapHash; /** @class UnitigMapBase * @brief Structure containing the basic information of a unitig mapping. This structure is independent @@ -99,6 +100,7 @@ class UnitigMap : public UnitigMapBase { template friend class ForwardCDBG; template friend class unitigIterator; template friend class UnitigMap; + template friend class UnitigMapHash; typedef typename std::conditional*, CompactedDBG*>::type CompactedDBG_ptr_t; typedef typename std::conditional::type Unitig_data_ptr_t; @@ -108,6 +110,9 @@ class UnitigMap : public UnitigMapBase { typedef BackwardCDBG UnitigMap_BW; typedef ForwardCDBG UnitigMap_FW; + using hasher = UnitigMapHash; + using neighbor_iterator = neighborIterator; + /** UnitigMap constructor. * @param length is the length of the mapping in k-mers (default is 1 k-mer). * @param cdbg_ is a pointer to the CompactedDBG containing the reference unitig used for the mapping (default is nullptr). @@ -152,6 +157,14 @@ class UnitigMap : public UnitigMapBase { */ string referenceUnitigToString() const; + /** + * By default, cdbg->find returns a mapping of a single k-mer on a unitig. This function makes a copy of this + * object, but where the mapping represents the full unitig. + */ + UnitigMap mappingToFullUnitig() const; + + bool isFullMapping() const; + /** Compute the length of the longest common prefix between a given sequence and * the reference unitig used in the mapping. * @param s is a pointer to an array of characters representing the sequence from @@ -262,11 +275,11 @@ class UnitigMap : public UnitigMapBase { UnitigMap(size_t p_unitig, size_t i, size_t l, size_t sz, bool short_, bool abundance, bool strd, CompactedDBG_ptr_t cdbg_); - neighborIterator bw_begin() const; - neighborIterator bw_end() const; + neighbor_iterator bw_begin() const; + neighbor_iterator bw_end() const; - neighborIterator fw_begin() const; - neighborIterator fw_end() const; + neighbor_iterator fw_begin() const; + neighbor_iterator fw_end() const; template typename std::enable_if>::type splitData_(const bool last_split) const; template typename std::enable_if>::type splitData_(const bool last_split) const; diff --git a/src/UnitigMap.tcc b/src/UnitigMap.tcc index 25d7cd6..a923be9 100644 --- a/src/UnitigMap.tcc +++ b/src/UnitigMap.tcc @@ -64,6 +64,20 @@ string UnitigMap::referenceUnitigToString() const { return cdbg->v_unitigs[pos_unitig]->getSeq().toString(); } +template +UnitigMap UnitigMap::mappingToFullUnitig() const { + UnitigMap cpy(*this); + cpy.dist = 0; + cpy.len = size - cdbg->getK() + 1; + + return cpy; +} + +template +bool UnitigMap::isFullMapping() const { + return !isEmpty && dist == 0 && len == size - getGraph()->getK() + 1; +} + template size_t UnitigMap::lcp(const char* s, const size_t pos_s, const size_t pos_um_seq, const bool um_reversed) const {