Skip to content

Commit

Permalink
Fix issue #312
Browse files Browse the repository at this point in the history
alntmscore is now normalized by the backtrace length
  • Loading branch information
martin-steinegger committed Aug 29, 2024
1 parent 69d397b commit b40729c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
7 changes: 4 additions & 3 deletions src/strucclustutils/aln2tmscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ int aln2tmscore(int argc, const char **argv, const Command& command) {
float* tdata = tcoords.read(tcadata, targetLen, tCaLength);

// Matching residue index collection
unsigned int normLen = std::min(res.dbLen, res.qLen);
TMaligner::TMscoreResult tmres = tmaln.computeTMscore(tdata, &tdata[targetLen], &tdata[targetLen + targetLen], targetLen,
res.qStartPos, res.dbStartPos, res.backtrace,
std::min(static_cast<unsigned int>(res.backtrace.length()), std::min(res.dbLen, res.qLen)));

res.qStartPos, res.dbStartPos, res.backtrace, normLen);
tmres.tmscore = (tmres.tmscore / static_cast<double>(normLen))
* static_cast<double>(res.backtrace.size());
//std::cout << TMalnScore << std::endl;
resultsStr.append(SSTR(dbKey));
resultsStr.push_back(' ');
Expand Down
5 changes: 4 additions & 1 deletion src/strucclustutils/structurealign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ int structurealign(int argc, const char **argv, const Command& command) {
size_t tCaLength = tcadbr->sequenceReader->getEntryLen(tId);
float* targetCaData = tcoords.read(tcadata, res.dbLen, tCaLength);
if(needTMaligner) {
unsigned int normLen = std::min(res.dbLen, res.qLen);
tmres = tmaligner->computeTMscore(targetCaData,
&targetCaData[res.dbLen],
&targetCaData[res.dbLen +
Expand All @@ -388,7 +389,9 @@ int structurealign(int argc, const char **argv, const Command& command) {
res.qStartPos,
res.dbStartPos,
res.backtrace,
std::min(static_cast<unsigned int>(res.backtrace.size()), std::min(res.dbLen, res.qLen)));
normLen);
tmres.tmscore = (tmres.tmscore / static_cast<double>(normLen))
* static_cast<double>(res.backtrace.size());
if (tmres.tmscore < par.tmScoreThr) {
continue;
}
Expand Down
18 changes: 6 additions & 12 deletions src/strucclustutils/structureconvertalis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,12 @@ R"html(<!DOCTYPE html>
}
if(needTMaligner){
tmaligner->initQuery(queryCaData, &queryCaData[res.qLen], &queryCaData[res.qLen+res.qLen], NULL, res.qLen);
unsigned int normlen= std::min(res.qLen, res.dbLen);
tmpBt = Matcher::uncompressAlignment(res.backtrace);
tmres = tmaligner->computeTMscore(targetCaData, &targetCaData[res.dbLen], &targetCaData[res.dbLen+res.dbLen], res.dbLen,
res.qStartPos, res.dbStartPos, tmpBt,
std::min(std::min(res.dbLen, res.qLen), static_cast<unsigned int>(tmpBt.size())));
res.qStartPos, res.dbStartPos, tmpBt,normlen);
tmres.tmscore = tmres.tmscore / normlen;
rmsd = tmres.rmsd;

}
LDDTCalculator::LDDTScoreResult lddtres;
if(needLDDT) {
Expand Down Expand Up @@ -885,19 +885,13 @@ R"html(<!DOCTYPE html>
result.append(SSTR(tmres.t[2]));
break;
case LocalParameters::OUTFMT_ALNTMSCORE:
result.append(SSTR(tmres.tmscore));
result.append(SSTR(tmres.tmscore * tmpBt.size()));
break;
case LocalParameters::OUTFMT_QTMSCORE:
tmres = tmaligner->computeTMscore(targetCaData, &targetCaData[res.dbLen], &targetCaData[res.dbLen+res.dbLen], res.dbLen,
res.qStartPos, res.dbStartPos, Matcher::uncompressAlignment(res.backtrace),
res.qLen);
result.append(SSTR(tmres.tmscore));
result.append(SSTR(tmres.tmscore * res.qLen));
break;
case LocalParameters::OUTFMT_TTMSCORE:
tmres = tmaligner->computeTMscore(targetCaData, &targetCaData[res.dbLen], &targetCaData[res.dbLen+res.dbLen], res.dbLen,
res.qStartPos, res.dbStartPos, Matcher::uncompressAlignment(res.backtrace),
res.dbLen);
result.append(SSTR(tmres.tmscore));
result.append(SSTR(tmres.tmscore * res.dbLen));
break;
case LocalParameters::OUTFMT_RMSD:
result.append(SSTR(rmsd));
Expand Down
5 changes: 4 additions & 1 deletion src/strucclustutils/structurerescorediagonal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,12 @@ int structureungappedalign(int argc, const char **argv, const Command& command)
char *tcadata = tcadbr->sequenceReader->getData(tId, thread_idx);
size_t tCaLength = tcadbr->sequenceReader->getEntryLen(tId);
float* targetCaData = tcoords.read(tcadata, res.dbLen, tCaLength);
unsigned int normLen = std::min(res.dbLen, res.qLen);
TMaligner::TMscoreResult tmres = tmaligner->computeTMscore(targetCaData, &targetCaData[res.dbLen], &targetCaData[res.dbLen+res.dbLen], res.dbLen,
res.qStartPos, res.dbStartPos, Matcher::uncompressAlignment(res.backtrace),
std::min(static_cast<unsigned int>(res.backtrace.length()), std::min(res.dbLen, res.qLen)));
normLen);
tmres.tmscore = (tmres.tmscore / static_cast<double>(normLen))
* static_cast<double>(res.backtrace.size());
if(tmres.tmscore < par.tmScoreThr){
continue;
}
Expand Down

0 comments on commit b40729c

Please sign in to comment.