Skip to content

Commit a181a17

Browse files
committed
added dp cell logic
1 parent 6330537 commit a181a17

File tree

5 files changed

+200
-0
lines changed

5 files changed

+200
-0
lines changed

.vscode/settings.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"files.associations": {
3+
"algorithm": "cpp",
4+
"atomic": "cpp",
5+
"bit": "cpp",
6+
"cctype": "cpp",
7+
"charconv": "cpp",
8+
"clocale": "cpp",
9+
"cmath": "cpp",
10+
"compare": "cpp",
11+
"concepts": "cpp",
12+
"cstddef": "cpp",
13+
"cstdint": "cpp",
14+
"cstdio": "cpp",
15+
"cstdlib": "cpp",
16+
"cstring": "cpp",
17+
"ctime": "cpp",
18+
"cwchar": "cpp",
19+
"exception": "cpp",
20+
"format": "cpp",
21+
"fstream": "cpp",
22+
"initializer_list": "cpp",
23+
"ios": "cpp",
24+
"iosfwd": "cpp",
25+
"iostream": "cpp",
26+
"istream": "cpp",
27+
"iterator": "cpp",
28+
"limits": "cpp",
29+
"list": "cpp",
30+
"locale": "cpp",
31+
"memory": "cpp",
32+
"new": "cpp",
33+
"optional": "cpp",
34+
"ostream": "cpp",
35+
"stdexcept": "cpp",
36+
"streambuf": "cpp",
37+
"string": "cpp",
38+
"system_error": "cpp",
39+
"tuple": "cpp",
40+
"type_traits": "cpp",
41+
"typeinfo": "cpp",
42+
"unordered_set": "cpp",
43+
"utility": "cpp",
44+
"vector": "cpp",
45+
"xfacet": "cpp",
46+
"xhash": "cpp",
47+
"xiosbase": "cpp",
48+
"xlocale": "cpp",
49+
"xlocbuf": "cpp",
50+
"xlocinfo": "cpp",
51+
"xlocmes": "cpp",
52+
"xlocmon": "cpp",
53+
"xlocnum": "cpp",
54+
"xloctime": "cpp",
55+
"xmemory": "cpp",
56+
"xstring": "cpp",
57+
"xtr1common": "cpp",
58+
"xutility": "cpp"
59+
}
60+
}

src/alignment/alignment.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "./alignment.hpp"
2+
3+
namespace alignment {
4+
5+
}

src/alignment/alignment.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace alignment {
2+
3+
}

src/alignment/de_cell.cpp

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#include "./dp_cell.hpp"
2+
3+
// MARK: public methods
4+
5+
dp_cell::dp_cell() :
6+
m_s_score(0),
7+
m_d_score(0),
8+
m_i_score(0),
9+
m_s_matches(0),
10+
m_d_matches(0),
11+
m_i_matches(0) {
12+
}
13+
14+
int64_t dp_cell::get_max_score(void) {
15+
return std::max(this->m_s_score, std::max(this->m_d_score, this->m_i_score));
16+
}
17+
18+
int32_t dp_cell::get_max_score_matches(void) {
19+
const int64_t max_score = std::max(this->m_s_score, std::max(this->m_d_score, this->m_i_score));
20+
if (max_score == this->m_s_score) {
21+
return this->m_s_matches;
22+
} else if (max_score == this->m_d_score) {
23+
return this->m_d_matches;
24+
}
25+
return this->m_i_matches;
26+
}
27+
28+
void dp_cell::score_cell(const dp_cell& cell_s, const dp_cell& cell_d, const dp_cell& cell_i) {
29+
throw std::runtime_error("not implemented");
30+
}
31+
32+
void dp_cell::reset_cell(void) {
33+
this->m_s_score = 0;
34+
this->m_d_score = 0;
35+
this->m_i_score = 0;
36+
this->m_s_matches = 0;
37+
this->m_d_matches = 0;
38+
this->m_i_matches = 0;
39+
}
40+
41+
// MARK: getters
42+
43+
int64_t dp_cell::get_s_score(void) const {
44+
return this->m_s_score;
45+
}
46+
47+
int64_t dp_cell::get_d_score(void) const {
48+
return this->m_d_score;
49+
}
50+
51+
int64_t dp_cell::get_i_score(void) const {
52+
return this->m_i_score;
53+
}
54+
55+
int32_t dp_cell::get_s_matches(void) const {
56+
return this->m_s_matches;
57+
}
58+
59+
int32_t dp_cell::get_d_matches(void) const {
60+
return this->m_d_matches;
61+
}
62+
63+
int32_t dp_cell::get_i_matches(void) const {
64+
return this->m_i_matches;
65+
}
66+
67+
// MARK: setters
68+
69+
void dp_cell::set_s_score(int64_t _s_score) {
70+
this->m_s_score = _s_score;
71+
}
72+
73+
void dp_cell::set_d_score(int64_t _d_score) {
74+
this->m_d_score = _d_score;
75+
}
76+
77+
void dp_cell::set_i_score(int64_t _i_score) {
78+
this->m_i_score = _i_score;
79+
}
80+
81+
void dp_cell::set_s_matches(int32_t _s_matches) {
82+
this->m_s_matches = _s_matches;
83+
}
84+
85+
void dp_cell::set_d_matches(int32_t _d_matches) {
86+
this->m_d_matches = _d_matches;
87+
}
88+
89+
void dp_cell::set_i_matches(int32_t _i_matches) {
90+
this->m_i_matches = _i_matches;
91+
}

src/alignment/dp_cell.hpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#ifndef __DP_CELL_HPP__
2+
#define __DP_CELL_HPP__
3+
4+
#include <cstdint>
5+
#include <algorithm>
6+
#include <stdexcept>
7+
8+
class dp_cell {
9+
private:
10+
int64_t m_s_score;
11+
int64_t m_d_score;
12+
int64_t m_i_score;
13+
14+
int32_t m_s_matches;
15+
int32_t m_d_matches;
16+
int32_t m_i_matches;
17+
public:
18+
dp_cell();
19+
int64_t get_max_score(void);
20+
int32_t get_max_score_matches(void);
21+
void score_cell(const dp_cell&, const dp_cell&, const dp_cell&);
22+
void reset_cell(void);
23+
24+
int64_t get_s_score(void) const;
25+
int64_t get_d_score(void) const;
26+
int64_t get_i_score(void) const;
27+
28+
int32_t get_s_matches(void) const;
29+
int32_t get_d_matches(void) const;
30+
int32_t get_i_matches(void) const;
31+
32+
void set_s_score(int64_t _s_score);
33+
void set_d_score(int64_t _d_score);
34+
void set_i_score(int64_t _i_score);
35+
36+
void set_s_matches(int32_t _s_matches);
37+
void set_d_matches(int32_t _d_matches);
38+
void set_i_matches(int32_t _i_matches);
39+
};
40+
41+
#endif

0 commit comments

Comments
 (0)