Bifrost
DataAccessor.hpp
Go to the documentation of this file.
1 #ifndef BFG_DATAACCESSOR_HPP
2 #define BFG_DATAACCESSOR_HPP
3 
4 #include "CompactedDBG.hpp"
5 #include "ColorSet.hpp"
6 
13 template<typename U> using UnitigColorMap = UnitigMap<DataAccessor<U>, DataStorage<U>>;
14 template<typename U> using const_UnitigColorMap = const_UnitigMap<DataAccessor<U>, DataStorage<U>>;
15 
20 template<typename Unitig_data_t = void>
21 class DataAccessor : public CDBG_Data_t<DataAccessor<Unitig_data_t>, DataStorage<Unitig_data_t>> {
22 
23  typedef Unitig_data_t U;
24 
25  template<typename U> friend class DataStorage;
26 
27  public:
28 
31  DataAccessor(const uint8_t id = 0);
32 
38  void clear(const UnitigColorMap<U>& um);
39 
45  const U* getData(const const_UnitigColorMap<U>& um) const;
46 
52  U* getData(const UnitigColorMap<U>& um) const;
53 
61 
68 
77 
82  vector<string> getSubUnitigColorNames(const const_UnitigColorMap<U>& um) const;
83 
95  void concat(const UnitigColorMap<U>& um_dest, const UnitigColorMap<U>& um_src);
96 
107  void merge(const UnitigColorMap<U>& um_dest, const const_UnitigColorMap<U>& um_src);
108 
122  void extract(const UnitigColorMap<U>& um_src, const bool last_extraction);
123 
131  string serialize(const const_UnitigColorMap<U>& um_src) const;
132 
133  private:
134 
135  inline uint8_t get() const { return da_id; }
136 
137  inline void set(const uint8_t id) { da_id = id; }
138 
139  uint8_t da_id;
140 };
141 
142 #endif
string serialize(const const_UnitigColorMap< U > &um_src) const
Serialize the data to a GFA-formatted string.
void extract(const UnitigColorMap< U > &um_src, const bool last_extraction)
Extract data and colors corresponding to a sub-unitig of a unitig A.
Represent the k-mer color sets of a unitig.
Definition: ColorSet.hpp:21
void clear(const UnitigColorMap< U > &um)
Clear the colors and data associated with a colored unitig.
DataAccessor(const uint8_t id=0)
Constructor (set up an empty DataAccessor).
const UnitigColors * getUnitigColors(const const_UnitigColorMap< U > &um) const
Get the colors of the reference unitig.
Definition: ColorSet.hpp:16
Interface for UnitigColors, the unitig container of k-mer color sets used in ColoredCDBG.
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
If data are to be associated with the unitigs of the compacted de Bruijn graph, those data must be wr...
Definition: CompactedDBG.hpp:204
Interface to access the colors and the data associated with a unitig of a ColoredCDBG.
Definition: ColorSet.hpp:15
void concat(const UnitigColorMap< U > &um_dest, const UnitigColorMap< U > &um_src)
Join data and colors of two colored unitigs which are going to be concatenated.
void merge(const UnitigColorMap< U > &um_dest, const const_UnitigColorMap< U > &um_src)
Merge the data and colors of a sub-unitig B to the data and colors of a sub-unitig A...
Interface for the Compacted de Bruijn graph API.
UnitigColors getSubUnitigColors(const const_UnitigColorMap< U > &um) const
Create a new UnitigColors object for a unitig B corresponding to a unitig mapping to a reference unit...
vector< string > getSubUnitigColorNames(const const_UnitigColorMap< U > &um) const
Obtain the name of the colors present on AT LEAST one k-mer of a unitig mapping.
const U * getData(const const_UnitigColorMap< U > &um) const
Get the unitig data.