Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/UnitigMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ template<typename U, typename G> class CompactedDBG;
template<typename U, typename G, bool is_const> class BackwardCDBG;
template<typename U, typename G, bool is_const> class ForwardCDBG;
template<typename U, typename G, bool is_const> class neighborIterator;
template<typename U, typename G, bool is_const> struct UnitigMapHash;

/** @class UnitigMapBase
* @brief Structure containing the basic information of a unitig mapping. This structure is independent
Expand Down Expand Up @@ -99,6 +100,7 @@ class UnitigMap : public UnitigMapBase {
template<typename U, typename G, bool C> friend class ForwardCDBG;
template<typename U, typename G, bool C> friend class unitigIterator;
template<typename U, typename G, bool C> friend class UnitigMap;
template<typename U, typename G, bool C> friend class UnitigMapHash;

typedef typename std::conditional<is_const, const CompactedDBG<U, G>*, CompactedDBG<U, G>*>::type CompactedDBG_ptr_t;
typedef typename std::conditional<is_const, const U*, U*>::type Unitig_data_ptr_t;
Expand All @@ -108,6 +110,9 @@ class UnitigMap : public UnitigMapBase {
typedef BackwardCDBG<U, G, is_const> UnitigMap_BW;
typedef ForwardCDBG<U, G, is_const> UnitigMap_FW;

using hasher = UnitigMapHash<U, G, is_const>;
using neighbor_iterator = neighborIterator<U, G, is_const>;

/** 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).
Expand Down Expand Up @@ -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<U, G, is_const> 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
Expand Down Expand Up @@ -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<U, G, is_const> bw_begin() const;
neighborIterator<U, G, is_const> bw_end() const;
neighbor_iterator bw_begin() const;
neighbor_iterator bw_end() const;

neighborIterator<U, G, is_const> fw_begin() const;
neighborIterator<U, G, is_const> fw_end() const;
neighbor_iterator fw_begin() const;
neighbor_iterator fw_end() const;

template<bool is_void> typename std::enable_if<!is_void, Unitig<U>>::type splitData_(const bool last_split) const;
template<bool is_void> typename std::enable_if<is_void, Unitig<U>>::type splitData_(const bool last_split) const;
Expand Down
14 changes: 14 additions & 0 deletions src/UnitigMap.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ string UnitigMap<U, G, is_const>::referenceUnitigToString() const {
return cdbg->v_unitigs[pos_unitig]->getSeq().toString();
}

template<typename U, typename G, bool is_const>
UnitigMap<U, G, is_const> UnitigMap<U, G, is_const>::mappingToFullUnitig() const {
UnitigMap<U, G, is_const> cpy(*this);
cpy.dist = 0;
cpy.len = size - cdbg->getK() + 1;

return cpy;
}

template<typename U, typename G, bool is_const>
bool UnitigMap<U, G, is_const>::isFullMapping() const {
return !isEmpty && dist == 0 && len == size - getGraph()->getK() + 1;
}

template<typename U, typename G, bool is_const>
size_t UnitigMap<U, G, is_const>::lcp(const char* s, const size_t pos_s, const size_t pos_um_seq, const bool um_reversed) const {

Expand Down