From 3cb6b129c7a3b545ff7dfe07643eafc4a1425765 Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Wed, 14 May 2025 09:47:40 +0200
Subject: [PATCH] bugfix in deprecated DRMSD implementation

Penalties for missing residues also included values for distances
within the same residue => the penalty logic did not consider
the specified sequence separation.
---
 modules/mol/alg/src/distance_rmsd_test.cc | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/modules/mol/alg/src/distance_rmsd_test.cc b/modules/mol/alg/src/distance_rmsd_test.cc
index 6bb500e36..95d09e062 100644
--- a/modules/mol/alg/src/distance_rmsd_test.cc
+++ b/modules/mol/alg/src/distance_rmsd_test.cc
@@ -129,8 +129,17 @@ void fill_values(const GlobalRDMap& glob_dist_list,
     rnum_one = i->first;
     res_positions_one = positions.find(rnum_one);
     if(res_positions_one == positions.end()){
-      //this residue is missing, so we give it the full penalty
-      drmsd_values[rnum_one] = std::make_pair(i->second.size()*squared_cap_distance,i->second.size());
+      // this residue is missing, count how many interactions there are
+      // towards residues that fulfill sequence separation threshold
+      int n = 0;
+      for(ResidueRDMap::const_iterator j = i->second.begin(); j != i->second.end(); ++j){
+        //check sequence separation
+        rnum_two = j->first.second.GetResNum();
+        if(std::abs(rnum_one.GetNum() - rnum_two.GetNum()) > sequence_separation){
+          ++n;
+        }
+      }
+      drmsd_values[rnum_one] = std::make_pair(n*squared_cap_distance,n);
       continue;
     }
 
-- 
GitLab