-
Notifications
You must be signed in to change notification settings - Fork 3
/
Sequence.h
38 lines (33 loc) · 919 Bytes
/
Sequence.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef SEQ
#define SEQ
#include <string>
#include <algorithm>
#include "nthash.hpp"
class Sequence
{
public:
Sequence(const std::string& kmer);
bool operator==(const Sequence& seq) const;
bool operator==(const std::string& s) const;
bool operator!=(const Sequence& seq) const;
bool operator!=(const std::string& s) const;
friend std::ostream& operator<<(std::ostream& os, const Sequence& s){return os << s.get_kmer();};
const std::string get_kmer() const;
std::string rc() const;
private:
inline static char complement(char c){switch(c){ case 'A': return 'T'; case 'C': return 'G'; case 'G': return 'C'; case 'T' : return 'A'; default : return 'N';};}
std::string kmer_;
};
namespace std
{
template <>
struct hash<Sequence>
{
size_t operator()(const Sequence& k) const
{
std::string toHash = k.get_kmer();
return NTC64(toHash.c_str(), toHash.size());
}
};
}
#endif