Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/commons/SubstitutionMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// If a probabilities file is given, it calculates a biased matrix (produces shorter = more precise alignments).
//

#include <climits>
#include <cstddef>
#include "BaseMatrix.h"
#include "ProfileStates.h"
Expand Down Expand Up @@ -51,10 +52,15 @@ class SubstitutionMatrix : public BaseMatrix {
{}
};

// build matrix from ~ (=0) to ~(=122)
// Build a table covering every byte value that aa2num maps (0..UCHAR_MAX-1), not just
// the printable-ASCII range up to 'z'. DistanceCalculator.h's ungapped scoring functions
// index this table directly with raw, untranslated byte values (not routed through
// aa2num first), so any byte the table doesn't cover reads past the end of `matrix` and
// crashes on dereference. aa2num's own mapping (see SubstitutionMatrix::setupLetterMapping)
// already sends every unmapped byte to the 'X' index, so widening this table is safe.
static FastMatrix createAsciiSubMat(BaseMatrix & submat){
const size_t asciiStart = 0;
const size_t asciiEnd = 'z'+1;
const size_t asciiEnd = UCHAR_MAX;
const size_t range = asciiEnd-asciiStart;
char ** matrix = new char *[range];
char * matrixData = new char[range*range];
Expand Down