From 8d75a95e32e52efc198900d0e0038642d6fcbb57 Mon Sep 17 00:00:00 2001 From: "[AldhairMedico]" Date: Mon, 14 Oct 2024 12:20:36 -0400 Subject: [PATCH] Oct 14, 2024: -p IUPAC and -c working --- include/tools.h | 9 +++++++++ src/tools.cpp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 include/tools.h create mode 100644 src/tools.cpp diff --git a/include/tools.h b/include/tools.h new file mode 100644 index 0000000..1260028 --- /dev/null +++ b/include/tools.h @@ -0,0 +1,9 @@ +#ifndef TOOLS_H +#define TOOLS_H + +#include +#include + +void generate_combinations(const std::string &pattern, std::string ¤t, size_t index, std::vector &combinations); + +#endif // TOOLS_H diff --git a/src/tools.cpp b/src/tools.cpp new file mode 100644 index 0000000..8dfec88 --- /dev/null +++ b/src/tools.cpp @@ -0,0 +1,36 @@ +#include "tools.h" +#include + +std::unordered_map> 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 ¤t, size_t index, std::vector &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); + } +} + +