Skip to content

Commit

Permalink
Revise alignment TMscore computation
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-steinegger committed Sep 14, 2024
1 parent 2256e21 commit 7e6be60
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/commons/LocalParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class LocalParameters : public Parameters {
static const int TMSCORE_THRESHOLD_MODE_ALIGNMENT = 0;
static const int TMSCORE_THRESHOLD_MODE_QUERY = 1;
static const int TMSCORE_THRESHOLD_MODE_TARGET = 2;
static const int TMSCORE_THRESHOLD_MODE_MIN = 3;

static const int PREF_MODE_KMER = 0;
static const int PREF_MODE_UNGAPPED = 1;
Expand Down
4 changes: 3 additions & 1 deletion src/commons/TMaligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,14 @@ Matcher::result_t TMaligner::align(unsigned int dbKey, float *x, float *y, float
}

unsigned int TMaligner::normalization(int mode, unsigned int alignmentLen, unsigned int queryLen, unsigned int targetLen) {
if(mode == LocalParameters::TMSCORE_THRESHOLD_MODE_ALIGNMENT){
if(mode == LocalParameters::TMSCORE_THRESHOLD_MODE_ALIGNMENT) {
return alignmentLen;
} else if(mode == LocalParameters::TMSCORE_THRESHOLD_MODE_QUERY){
return queryLen;
} else if(mode == LocalParameters::TMSCORE_THRESHOLD_MODE_TARGET){
return targetLen;
} else if(mode == LocalParameters::TMSCORE_THRESHOLD_MODE_MIN){
return std::min(queryLen, targetLen);
}
return 0;
}
4 changes: 2 additions & 2 deletions src/strucclustutils/aln2tmscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int aln2tmscore(int argc, const char **argv, const Command& command) {
// Matching residue index collection
TMaligner::TMscoreResult tmres = tmaln.computeTMscore(tdata, &tdata[targetLen], &tdata[targetLen + targetLen], targetLen,
res.qStartPos, res.dbStartPos, res.backtrace,
TMaligner::normalization(par.tmScoreThrMode, res.backtrace.size(), res.qLen, res.dbLen));
TMaligner::normalization(par.tmScoreThrMode, std::min(res.qEndPos - res.qStartPos, res.dbEndPos - res.dbStartPos ), res.qLen, res.dbLen));
//std::cout << TMalnScore << std::endl;
resultsStr.append(SSTR(dbKey));
resultsStr.push_back(' ');
Expand Down Expand Up @@ -152,4 +152,4 @@ int aln2tmscore(int argc, const char **argv, const Command& command) {
}

return EXIT_SUCCESS;
}
}
3 changes: 2 additions & 1 deletion src/strucclustutils/structurealign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ int structurealign(int argc, const char **argv, const Command& command) {
res.qStartPos,
res.dbStartPos,
res.backtrace,
TMaligner::normalization(par.tmScoreThrMode, res.backtrace.size(), res.qLen, res.dbLen));
TMaligner::normalization(par.tmScoreThrMode, std::min(res.qEndPos - res.qStartPos, res.dbEndPos - res.dbStartPos ), res.qLen, res.dbLen));

if (tmres.tmscore < par.tmScoreThr) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/strucclustutils/structurerescorediagonal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ int structureungappedalign(int argc, const char **argv, const Command& command)
float* targetCaData = tcoords.read(tcadata, res.dbLen, tCaLength);
TMaligner::TMscoreResult tmres = tmaligner->computeTMscore(targetCaData, &targetCaData[res.dbLen], &targetCaData[res.dbLen+res.dbLen], res.dbLen,
res.qStartPos, res.dbStartPos, Matcher::uncompressAlignment(res.backtrace),
TMaligner::normalization(par.tmScoreThrMode, res.backtrace.size(), res.qLen, res.dbLen));
TMaligner::normalization(par.tmScoreThrMode, std::min(res.qEndPos - res.qStartPos, res.dbEndPos - res.dbStartPos ), res.qLen, res.dbLen));
if(tmres.tmscore < par.tmScoreThr){
continue;
}
Expand Down

0 comments on commit 7e6be60

Please sign in to comment.