Bifrost
Unitig.hpp
Go to the documentation of this file.
1 #ifndef BIFROST_UNITIG_HPP
2 #define BIFROST_UNITIG_HPP
3 
4 #include "Common.hpp"
5 #include "Kmer.hpp"
6 #include "CompressedSequence.hpp"
7 #include "CompressedCoverage.hpp"
8 
21 template<typename T = void>
22 class Unitig {
23 
24  public:
25 
26  Unitig() {}
27  Unitig(const CompressedSequence& s, const CompressedCoverage& c) : seq(s), cov(c) {}
28  Unitig(CompressedSequence&& s, CompressedCoverage&& c) : seq(move(s)), cov(move(c)) {}
29  Unitig(const char* s, bool full = false) : seq(s), cov(seq.size() - Kmer::k + 1, full) {}
30 
31  BFG_INLINE size_t numKmers() const {
32 
33  return seq.size( ) - Kmer::k + 1;
34  }
35 
36  BFG_INLINE size_t length() const {
37 
38  return seq.size();
39  }
40 
41  BFG_INLINE const CompressedSequence& getSeq() const {
42 
43  return seq;
44  }
45 
46  BFG_INLINE CompressedSequence& getSeq() {
47 
48  return seq;
49  }
50 
51  BFG_INLINE const CompressedCoverage& getCov() const {
52 
53  return cov;
54  }
55 
56  BFG_INLINE CompressedCoverage& getCov() {
57 
58  return cov;
59  }
60 
61  BFG_INLINE const T* getData() const {
62 
63  return &data;
64  }
65 
66  BFG_INLINE T* getData() {
67 
68  return &data;
69  }
70 
71  private:
72 
73  CompressedSequence seq;
74  CompressedCoverage cov;
75 
76  T data;
77 };
78 
80 template<>
81 class Unitig<void> {
82 
83  public:
84 
85  Unitig() {}
86  Unitig(const CompressedSequence& s, const CompressedCoverage& c) : seq(s), cov(c) {}
87  Unitig(CompressedSequence&& s, CompressedCoverage&& c) : seq(move(s)), cov(move(c)) {}
88  Unitig(const char* s, bool full = false) : seq(s), cov(seq.size() - Kmer::k + 1, full) {}
89 
90  BFG_INLINE size_t numKmers() const {
91 
92  return seq.size( ) - Kmer::k + 1;
93  }
94 
95  BFG_INLINE size_t length() const {
96 
97  return seq.size();
98  }
99 
100  BFG_INLINE const CompressedSequence& getSeq() const {
101 
102  return seq;
103  }
104 
105  BFG_INLINE CompressedSequence& getSeq() {
106 
107  return seq;
108  }
109 
110  BFG_INLINE const CompressedCoverage& getCov() const {
111 
112  return cov;
113  }
114 
115  BFG_INLINE CompressedCoverage& getCov() {
116 
117  return cov;
118  }
119 
120  BFG_INLINE const void* getData() const {
121 
122  return nullptr;
123  }
124 
125  BFG_INLINE void* getData() {
126 
127  return nullptr;
128  }
129 
130  private:
131 
132  CompressedSequence seq;
133  CompressedCoverage cov;
134 };
136 
137 #endif // BFG_CONTIG_HPP
Kmer
Interface to store and manipulate k-mers.
Definition: Kmer.hpp:42
Unitig
Represent a unitig which is a vertex of the Compacted de Bruijn graph.
Definition: Unitig.hpp:22
Kmer.hpp
Interface for the class Kmer: