Skip to content

Commit

Permalink
Oct 14, 2024: -p IUPAC and -c working
Browse files Browse the repository at this point in the history
  • Loading branch information
AldhairMedico committed Oct 14, 2024
1 parent 694dfb6 commit 8d75a95
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/tools.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef TOOLS_H
#define TOOLS_H

#include <vector>
#include <string>

void generate_combinations(const std::string &pattern, std::string &current, size_t index, std::vector<std::string> &combinations);

#endif // TOOLS_H
36 changes: 36 additions & 0 deletions src/tools.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "tools.h"
#include <unordered_map>

std::unordered_map<char, std::vector<char>> IUPAC_DNA_map = {
{'A', {'A'}},
{'C', {'C'}},
{'G', {'G'}},
{'T', {'T'}},
{'R', {'A', 'G'}},
{'Y', {'C', 'T'}},
{'M', {'A', 'C'}},
{'K', {'G', 'T'}},
{'S', {'C', 'G'}},
{'W', {'A', 'T'}},
{'H', {'A', 'C', 'T'}},
{'B', {'C', 'G', 'T'}},
{'V', {'A', 'C', 'G'}},
{'D', {'A', 'G', 'T'}},
{'N', {'A', 'C', 'G', 'T'}}
};


void generate_combinations(const std::string &pattern, std::string &current, size_t index, std::vector<std::string> &combinations) {
if (index == pattern.size()) {
combinations.push_back(current);
return;
}

char base = pattern[index];
for (char c : IUPAC_DNA_map[base]) {
current[index] = c;
generate_combinations(pattern, current, index + 1, combinations);
}
}


0 comments on commit 8d75a95

Please sign in to comment.