-
Notifications
You must be signed in to change notification settings - Fork 0
/
dna_sequence.h
62 lines (44 loc) · 1.55 KB
/
dna_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
*
*
*/
#ifndef DNA_SEQUENCE_H_
#define DNA_SEQUENCE_H_
#include <string>
//-----------------------------------------------------------------------------
enum class Nucleotide {
kA = 0 /* Adenine */,
kC = 1 /* Cytosine */,
kG = 2 /* Guanine */,
kT = 3 /* Thymine */,
kNumNucleotides = 4
};
//-----------------------------------------------------------------------------
Nucleotide CharToNucleotide(const char c);
char NucleotideToChar(Nucleotide n);
//-----------------------------------------------------------------------------
class DNASequence {
public:
// Constructor.
DNASequence();
// Construct sequence based on given 'sequence' and 'identifier'.
DNASequence(const std::string& sequence, const std::string& identifier);
// Accesors.
const std::string& sequence() const { return sequence_; }
const std::string& identifier() const { return identifier_; }
// Prints the DNA sequence out in columns.
void PrintWithColumns() const;
// Substitutes all unknown characters in 'line' with a T.
static std::string MakeValidDNASequence(const std::string& line);
// Returns true if 'sequence' is a a valid DNA sequence.
static bool IsValidDNASequence(const std::string& sequence);
// Whether 'c' translates to a valid nucleotide {A, C, G, T}.
static bool IsValidNucleotide(char c);
private:
// Name or identifier for this sequence.
std::string identifier_;
// Vector containing a sequence of nucleotides.
std::string sequence_;
};
//-----------------------------------------------------------------------------
#endif