@@ -245,7 +245,8 @@ std::tuple<std::vector<float>, std::vector<int>, float, int> calculate_lddt(
245245 std::vector<size_t > &subset,
246246 std::vector<size_t > &keys,
247247 DBReader<unsigned int > * seqDbrCA,
248- float pairThreshold
248+ float pairThreshold,
249+ bool onlyScoringCols
249250) {
250251 // mapping:
251252 // cigar vectors can be any size
@@ -375,6 +376,7 @@ std::tuple<std::vector<float>, std::vector<int>, float, int> calculate_lddt(
375376 std::vector<int > colCounts = countColumns (cigars, subset, alnLength);
376377 float scaledSum = 0.0 ;
377378 int numCols = 0 ;
379+ int numColsScoring = 0 ;
378380 for (size_t i = 0 ; i < perColumnCount.size (); i++) {
379381 // float pairSupport = perColumnCount[i] / static_cast<float>(numPairs);
380382 float residuesInColumn = colCounts[i];
@@ -392,13 +394,16 @@ std::tuple<std::vector<float>, std::vector<int>, float, int> calculate_lddt(
392394 // perColumnScore[i] /= perColumnCount[i]; // get mean LDDT for this column
393395 perColumnScore[i] = (2 * score * occupancy) / (score + occupancy);
394396 scaledSum += perColumnScore[i];
397+ numColsScoring++;
395398 } else {
396399 perColumnScore[i] = 0.0 ;
397400 }
398401 // scaledSum += colscore;
399402 numCols++;
400403 }
401- float lddtScore = (numCols > 0 ) ? scaledSum / static_cast <float >(numCols) : 0.0 ;
404+ float lddtScore = onlyScoringCols
405+ ? ((numColsScoring > 0 ) ? scaledSum / static_cast <float >(numColsScoring) : 0 .0f )
406+ : ((numCols > 0 ) ? scaledSum / static_cast <float >(numCols) : 0 .0f );
402407 return std::make_tuple (perColumnScore, perColumnCount, lddtScore, numCols);
403408}
404409
@@ -464,7 +469,8 @@ float getLDDTScore(
464469 DBReader<unsigned int > &seqDbr3Di,
465470 DBReader<unsigned int > &seqDbrCA,
466471 std::string msa,
467- float pairThreshold
472+ float pairThreshold,
473+ bool onlyScoringCols
468474) {
469475 KSeqWrapper* kseq = new KSeqBuffer (msa.c_str (), msa.length ());
470476 int alnLength = 0 ;
@@ -479,7 +485,7 @@ float getLDDTScore(
479485 std::vector<int > perColumnCount;
480486 float lddtScore;
481487 int numCols;
482- std::tie (perColumnScore, perColumnCount, lddtScore, numCols) = calculate_lddt (cigars_aa, inds, inds, &seqDbrCA, pairThreshold);
488+ std::tie (perColumnScore, perColumnCount, lddtScore, numCols) = calculate_lddt (cigars_aa, inds, inds, &seqDbrCA, pairThreshold, onlyScoringCols );
483489
484490 return lddtScore;
485491}
@@ -531,7 +537,7 @@ int msa2lddt(int argc, const char **argv, const Command& command, int makeReport
531537 std::iota (subset.begin (), subset.end (), 0 );
532538
533539 if (caExist) {
534- std::tie (perColumnScore, perColumnCount, lddtScore, numCols) = calculate_lddt (cigars_aa, subset, indices, seqDbrCA, par.pairThreshold );
540+ std::tie (perColumnScore, perColumnCount, lddtScore, numCols) = calculate_lddt (cigars_aa, subset, indices, seqDbrCA, par.pairThreshold , par. onlyScoringCols );
535541 std::string scores;
536542 for (float score : perColumnScore) {
537543 if (scores.length () > 0 ) scores += " ," ;
0 commit comments