Skip to content

Commit

Permalink
fix: check for length being a multiple of 3 before codon aware stripping
Browse files Browse the repository at this point in the history
  • Loading branch information
rneher committed Feb 11, 2021
1 parent 9a457c3 commit a33dd6b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/nextalign/src/align/getGapOpenCloseScores.cpp
Expand Up @@ -33,7 +33,7 @@ std::vector<int> getGapOpenCloseScoresCodonAware(//
for (const auto& [geneName, gene] : geneMap) {

// TODO: might use std::fill()
for (int i = gene.start; i <= gene.end-2; i += 3) {
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;
Expand Down
5 changes: 4 additions & 1 deletion packages/nextalign/src/translate/extractGene.cpp
Expand Up @@ -9,7 +9,6 @@
#include "../utils/safe_cast.h"
#include "./removeGaps.h"


NucleotideSequenceView extractGeneRef(const NucleotideSequenceView& ref, const Gene& gene) {
precondition_less(gene.length, ref.size());
precondition_less_equal(gene.length, ref.size());
Expand Down Expand Up @@ -86,6 +85,10 @@ NucleotideSequence extractGeneQuery(


auto result = NucleotideSequence(query.substr(start, length));
const auto resultLengthPreStrip = safe_cast<int>(result.size());
if (resultLengthPreStrip % 3 != 0) {
throw ErrorExtractGeneLengthInvalid(gene.geneName, resultLengthPreStrip);
}
stripGeneInPlace(result);

const auto resultLength = safe_cast<int>(result.size());
Expand Down
4 changes: 0 additions & 4 deletions packages/nextalign/src/translate/translateGenes.cpp
Expand Up @@ -44,10 +44,6 @@ PeptidesInternal translateGenes( //

const auto coordMap = mapCoordinates(ref);

// Each position in the raw ref sequence should have a corresponding mapped position in aligned ref sequence
invariant_equal(coordMap.size(), ref.size());


std::vector<PeptideInternal> queryPeptides;
queryPeptides.reserve(geneMap.size());

Expand Down

0 comments on commit a33dd6b

Please sign in to comment.