-
Notifications
You must be signed in to change notification settings - Fork 0
/
AlignmentFragment.cpp
executable file
·51 lines (42 loc) · 1.22 KB
/
AlignmentFragment.cpp
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
#include "AlignmentFragment.h"
#include <algorithm>
int AlignmentFragment::NumOfIdenticalBases() const
{
//std::cout << alignedS1 << std::endl;
//std::cout << alignedS2 << std::endl;
return NumOfIdenticalChars(alignedS1, alignedS2);
}
void AlignmentFragment::PrintAlignment() const
{
std::cout << match1 << " to " << match2 << std::endl;
std::cout << alignedS1 << std::endl;
std::cout << alignedS2 << std::endl;
}
void AlignmentFragment::Flip(int origLength1, int origLength2)
{
std::reverse(alignedS1.begin(), alignedS1.end());
std::reverse(alignedS2.begin(), alignedS2.end());
match1.Flip(origLength1);
match2.Flip(origLength2);
}
bool AlignmentFragment::operator ==(const AlignmentFragment &other) const
{
return alignedS1 == other.alignedS1 &&
alignedS2 == other.alignedS2 &&
match1 == other.match1 &&
match2 == other.match2;
}
int NumOfIdenticalChars(const std::string &v, const std::string &w)
{
assert(v.length() == w.length());
int s = 0;
for (size_t i = 0; i < v.length(); ++i)
{
if (v[i] == w[i]) s++;
}
return s;
}
bool IsLastCharIdentical(const std::string &v, const std::string &w)
{
return v.back() == w.back();
}