-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSeqSet.cpp
More file actions
90 lines (79 loc) · 2.55 KB
/
SeqSet.cpp
File metadata and controls
90 lines (79 loc) · 2.55 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include<seq_view.h>
namespace SeqView {
std::vector<std::string> SeqSet::_slice(int64_t beg, int64_t end,
int64_t first, int64_t last,
DisplayMode mode) {
std::vector<std::string> ret;
ret.reserve(last - first + 1);
for(int64_t i = first; i < last; i++) {
if(i > (nseqs - 1)) {
ret.push_back(std::string(end - beg + 1, ' '));
} else {
ret.push_back(seqs[i].getSeq(beg, end, mode, frame));
}
}
std::vector<bool> comps;
return ret;
}
SeqSet::SeqSet() {
maxlen = 0;
nseqs = 0;
frame = 1;
std::vector<SeqRecord> seqs;
}
void SeqSet::set_frame(int f) {
if(f < 1 || f > 3) {
} else {
frame = f;
}
}
int SeqSet::get_frame() {
return frame;
}
int64_t SeqSet::numseqs() {
return nseqs;
}
int64_t SeqSet::length() {
return maxlen;
}
std::vector<std::string> SeqSet::nameSlice(int64_t first,
int64_t last) {
std::vector<std::string> ret;
ret.reserve(last - first + 1);
for(int64_t i = first; i < last; i++) {
if(i >= nseqs) {
ret.push_back(" ");
} else {
ret.push_back(seqs[i].getName());
}
}
return ret;
}
// TODO: Implement additional comparison options.
// Note that frame is a SeqSet variable - so no need to include
// it as a function argument. SeqWindow also has a few places that
// need to be changed.
//
// Also: could be more efficient by using _slice only once and then
// slicing on the slice; but that might be complicated.
std::pair< std::vector<std::string>, std::vector<bool> >
SeqSet::slice(int64_t beg, int64_t end, int64_t first, int64_t last,
DisplayMode mode, ComparisonMode compare) {
std::vector<std::string> ret = _slice(beg, end, first, last, mode);
ret.reserve(last - first + 1);
std::vector<bool> comps;
if(compare == NUCAMB) {
comps = nuc_compare(_slice(beg, end, 0, numseqs(), mode));
} else if(compare == PLAIN) {
comps = simple_compare(_slice(beg, end, 0, numseqs(), mode));
}
return std::make_pair(ret, comps);
}
void SeqSet::append(SeqRecord rec) {
seqs.push_back(rec);
if(rec.length() > maxlen) {
maxlen = rec.length();
}
nseqs += 1;
}
}