Skip to content

Commit 4b7cb32

Browse files
committed
checkpoint
1 parent 6172dd8 commit 4b7cb32

File tree

11 files changed

+53
-5
lines changed

11 files changed

+53
-5
lines changed

bin/app

67.4 KB
Binary file not shown.

makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
2424
clean:
2525
rm -rf $(OBJDIR)/* $(BINDIR)/*
2626

27-
run: $(TARGET)
27+
run-sample: $(TARGET)
2828
@if [ -f $(TARGET) ]; then \
29-
./$(TARGET) inputs/alphabets/English_alphabet.txt inputs/genes/banana.txt; \
29+
./$(TARGET) input/base-sample.fasta; \
3030
else \
3131
echo "Error: Executable $(TARGET) not found. Please build it first."; \
3232
exit 1; \

obj/alignment/alignment.o

32 KB
Binary file not shown.

obj/alignment/de_cell.o

7.52 KB
Binary file not shown.

obj/io/io_utils.o

120 KB
Binary file not shown.

obj/wrapper/program_wrapper.o

2.94 KB
Binary file not shown.

src/alignment/alignment.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
#include "./alignment.hpp"
22

33
namespace alignment {
4+
int64_t execute_global_alignment(const std::string& string_one, const std::string& string_two) {
5+
const size_t row_size = string_one.size() + 1;
6+
const size_t col_size = string_two.size() + 1;
7+
std::vector<dp_cell> cur_dp_row(col_size);
8+
std::vector<dp_cell> prev_dp_row(col_size);
49

10+
for (size_t i = 1; i < col_size; ++i) {
11+
prev_dp_row[i].set_top_row(i);
12+
}
13+
14+
for (size_t row_idx = 1; row_idx < row_size; ++row_idx) {
15+
cur_dp_row[0].set_left_col(row_idx);
16+
for (size_t col_idx = 1; col_idx < col_size; ++col_idx) {
17+
cur_dp_row[col_idx].score_cell(prev_dp_row[col_idx-1], prev_dp_row[col_idx], cur_dp_row[col_idx-1], string_one[col_idx-1], string_two[row_idx-1]);
18+
}
19+
std::swap(prev_dp_row, cur_dp_row);
20+
}
21+
22+
return prev_dp_row.back().get_max_score();
23+
}
24+
25+
int32_t execute_modified_global_alignment(const std::string& string_one, const std::string& string_two) {
26+
throw std::runtime_error("not implemented");
27+
}
528
}

src/alignment/alignment.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
#ifndef __ALIGNMENT_HPP__
2+
#define __ALIGNMENT_HPP__
3+
4+
#include <string>
5+
#include <vector>
6+
#include <cstdint>
7+
#include <stdexcept>
8+
#include "./dp_cell.hpp"
9+
110
namespace alignment {
2-
3-
}
11+
int64_t execute_global_alignment(const std::string&, const std::string&);
12+
int32_t execute_modified_global_alignment(const std::string&, const std::string&);
13+
}
14+
15+
#endif

src/alignment/dp_cell.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class dp_cell {
2929
public:
3030
dp_cell();
3131
~dp_cell();
32+
3233
int64_t get_max_score(void) const;
3334
int32_t get_max_score_matches(void) const;
3435
void score_cell(const dp_cell&, const dp_cell&, const dp_cell&, const char, const char);

src/wrapper/program_wrapper.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,14 @@ program_wrapper& program_wrapper::get_instance(void) {
1313
}
1414

1515
void program_wrapper::run_program(const int arg_count, const char* const* arg_vector) {
16-
std::cout << "here" << std::endl;
16+
if (arg_count != 2) {
17+
throw std::runtime_error("error, not enough command line args");
18+
}
19+
std::string gene_one;
20+
std::string gene_two;
21+
std::string gene_one_name;
22+
std::string gene_two_name;
23+
if (!io_utils::load_two_genes(arg_vector[1], gene_one, gene_two, gene_one_name, gene_two_name)) {
24+
throw std::runtime_error("error, not able to load genes from file");
25+
}
1726
}

0 commit comments

Comments
 (0)