Skip to content

Commit

Permalink
Fix truncated profile sequences in convertalis #567
Browse files Browse the repository at this point in the history
  • Loading branch information
milot-mirdita committed Jun 2, 2022
1 parent 96b2009 commit b0b8e85
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/commons/Sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,18 +375,18 @@ void Sequence::print() {
std::cout << std::endl;
}

void extractProfileData(const char* data, const BaseMatrix &subMat, const int offset, std::string &result) {
void extractProfileData(const char* data, size_t dataSize, const BaseMatrix &subMat, const int offset, std::string &result) {
size_t i = 0;
while (data[i] != '\0'){
while (i < dataSize){
result.append(1, subMat.num2aa[(int)data[i + Sequence::PROFILE_AA_SIZE + offset]]);
i += Sequence::PROFILE_READIN_SIZE;
}
}

void Sequence::extractProfileSequence(const char* data, const BaseMatrix &submat, std::string &result) {
extractProfileData(data, submat, 0, result);
void Sequence::extractProfileSequence(const char* data, size_t dataSize, const BaseMatrix &submat, std::string &result) {
extractProfileData(data, dataSize, submat, 0, result);
}

void Sequence::extractProfileConsensus(const char* data, const BaseMatrix &submat, std::string &result) {
extractProfileData(data, submat, 1, result);
void Sequence::extractProfileConsensus(const char* data, size_t dataSize, const BaseMatrix &submat, std::string &result) {
extractProfileData(data, dataSize, submat, 1, result);
}
4 changes: 2 additions & 2 deletions src/commons/Sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ class Sequence {

void print(); // for debugging

static void extractProfileSequence(const char* data, const BaseMatrix &submat, std::string &result);
static void extractProfileConsensus(const char* data, const BaseMatrix &submat, std::string &result);
static void extractProfileSequence(const char* data, size_t dataSize, const BaseMatrix &submat, std::string &result);
static void extractProfileConsensus(const char* data, size_t dataSize, const BaseMatrix &submat, std::string &result);

int getId() const { return id; }

Expand Down
9 changes: 6 additions & 3 deletions src/util/convertalignments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ int convertalignments(int argc, const char **argv, const Command &command) {
querySeqData = (char*) queryBuffer.c_str();
}
if (queryProfile) {
Sequence::extractProfileConsensus(querySeqData, *subMat, queryProfData);
size_t queryEntryLen = qDbr.sequenceReader->getEntryLen(qId);
Sequence::extractProfileConsensus(querySeqData, queryEntryLen, *subMat, queryProfData);
}
}

Expand Down Expand Up @@ -481,7 +482,8 @@ int convertalignments(int argc, const char **argv, const Command &command) {
size_t tId = tDbr->sequenceReader->getId(res.dbKey);
targetSeqData = tDbr->sequenceReader->getData(tId, thread_idx);
if (targetProfile) {
Sequence::extractProfileConsensus(targetSeqData, *subMat, targetProfData);
size_t targetEntryLen = tDbr->sequenceReader->getEntryLen(tId);
Sequence::extractProfileConsensus(targetSeqData, targetEntryLen, *subMat, targetProfData);
}
}
for(size_t i = 0; i < outcodes.size(); i++) {
Expand Down Expand Up @@ -723,7 +725,8 @@ int convertalignments(int argc, const char **argv, const Command &command) {
size_t tId = tDbr->sequenceReader->getId(res.dbKey);
char* targetSeqData = tDbr->sequenceReader->getData(tId, thread_idx);
if (targetProfile) {
Sequence::extractProfileConsensus(targetSeqData, *subMat, targetProfData);
size_t targetEntryLen = tDbr->sequenceReader->getEntryLen(tId);
Sequence::extractProfileConsensus(targetSeqData, targetEntryLen, *subMat, targetProfData);
printSeqBasedOnAln(result, targetProfData.c_str(), res.dbStartPos,
Matcher::uncompressAlignment(res.backtrace), true,
(res.dbStartPos > res.dbEndPos),
Expand Down

0 comments on commit b0b8e85

Please sign in to comment.