Debian Codegraph @

src/get_masked_amplicons.cpp

raw symbols SCIP
1 #include "get_masked_amplicons.h"
2
3 int get_primers_with_mismatches(std::string bed, std::string vpath,
4 std::string out, std::string primer_pair_file) {
5 std::vector<primer> primers = populate_from_file(bed);
6 std::vector<primer> mismatches_primers;
7 std::vector<primer> tmp;
8 if (primers.size() == 0) {
9 return 0;
10 }
11 populate_pair_indices(primers, primer_pair_file);
12 std::string line, cell;
13 std::ifstream fin(vpath.c_str());
14 out += ".txt";
15 std::ofstream fout(out.c_str());
16 unsigned int ctr, pos;
17 std::stringstream line_stream;
18 while (std::getline(fin, line)) {
19 line_stream << line;
20 ctr = 0;
21 pos = 0;
22 while (std::getline(line_stream, cell, '\t')) {
23 switch (ctr) {
24 case 1:
25 if (cell != "POS") pos = stoi(cell);
26 break;
27 default:
28 break;
29 }
30 ctr++;
31 }
32 if (pos == 0) {
33 line_stream.clear();
34 continue;
35 }
36 pos--; // 1 based to 0 based
37 tmp = get_primers(primers, pos);
38 // mismatches_primers.insert(mismatches_primers.end(), tmp.begin(),
39 // tmp.end());
40 std::vector<primer>::iterator tmp_it;
41 for (std::vector<primer>::iterator it = tmp.begin(); it != tmp.end();
42 ++it) {
43 tmp_it =
44 std::find(mismatches_primers.begin(), mismatches_primers.end(), *it);
45 if (tmp_it == mismatches_primers.end()) {
46 std::cout << it->get_name() << std::endl;
47 mismatches_primers.push_back(*it);
48 }
49 // Look for primer pair
50 if (it->get_pair_indice() != -1) {
51 tmp_it = std::find(mismatches_primers.begin(), mismatches_primers.end(),
52 primers.at(it->get_pair_indice()));
53 if (tmp_it == mismatches_primers.end()) {
54 mismatches_primers.push_back(primers.at(it->get_pair_indice()));
55 }
56 }
57 }
58 line_stream.clear();
59 tmp.clear();
60 }
61 for (std::vector<primer>::iterator it = mismatches_primers.begin();
62 it != mismatches_primers.end(); ++it) {
63 fout << it->get_name();
64 std::cout << it->get_name();
65 if (it != mismatches_primers.end() - 1) {
66 fout << "\t";
67 std::cout << "\t";
68 }
69 }
70 std::cout << std::endl;
71 return 0;
72 }