-
Notifications
You must be signed in to change notification settings - Fork 58
/
getGapOpenCloseScores.cpp
44 lines (35 loc) · 1.36 KB
/
getGapOpenCloseScores.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "getGapOpenCloseScores.h"
#include <fmt/format.h>
#include <nextalign_private.h>
#include <vector>
class ErrorGeneMapGeneNotFound : std::runtime_error {
static std::string formatError(const std::string& geneName) {
return fmt::format("Error: gene '{:s}' not found in gene map", geneName);
}
public:
explicit ErrorGeneMapGeneNotFound(const std::string& geneName) : std::runtime_error(formatError(geneName)) {}
};
std::vector<int> getGapOpenCloseScoresFlat(//
/* in */ const NucleotideSequence& ref, //
/* in */ const NextalignOptions& options //
) {
std::vector<int> gapOpenClose(ref.size() + 2);
std::fill(gapOpenClose.begin(), gapOpenClose.end(), options.alignment.scoreGapOpen);
return gapOpenClose;
}
std::vector<int> getGapOpenCloseScoresCodonAware(//
/* in */ const NucleotideSequence& ref, //
/* in */ const GeneMap& geneMap, //
/* in */ const NextalignOptions& options //
) {
auto gapOpenClose = getGapOpenCloseScoresFlat(ref, options);
for (const auto& [geneName, gene] : geneMap) {
// TODO: might use std::fill()
for (int i = gene.start; i < gene.end-2; i += 3) {
gapOpenClose[i] = options.alignment.scoreGapOpenInFrame;
gapOpenClose[i+1] = options.alignment.scoreGapOpenOutOfFrame;
gapOpenClose[i+2] = options.alignment.scoreGapOpenOutOfFrame;
}
}
return gapOpenClose;
}