From 52e9c14891d77fb08f1dc3efbccee9a16705facf Mon Sep 17 00:00:00 2001
From: Gerardo Tauriello <gerardo.tauriello@unibas.ch>
Date: Mon, 13 Aug 2018 20:18:10 +0200
Subject: [PATCH] SCHWED-3566: Fixed inconsistent handling of sidechain and
 backbone issues.

---
 modules/mol/alg/src/filter_clashes.cc | 17 +++++++++++------
 modules/mol/alg/src/lddt.cc           | 22 +++++++++++-----------
 2 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/modules/mol/alg/src/filter_clashes.cc b/modules/mol/alg/src/filter_clashes.cc
index 18ffc17ba..e0d2bee05 100644
--- a/modules/mol/alg/src/filter_clashes.cc
+++ b/modules/mol/alg/src/filter_clashes.cc
@@ -421,10 +421,15 @@ std::pair<EntityView,StereoChemistryInfo> CheckStereoChemistry(const EntityView&
               remove_sc=true;
               if (always_remove_bb==true) {
                 remove_bb=true;
-              }
-              String name=atom.GetName();
-              if (name=="CA" || name=="N" || name=="O" || name=="C") {
-                remove_bb=true;
+              } else {
+                // we need to check both atom names since the order is random!
+                // -> for angles and clashes this is not needed
+                String name1 = atom.GetName();
+                String name2 = other_atom.GetName();
+                if (name1=="CA" || name1=="N" || name1=="O" || name1=="C" ||
+                    name2=="CA" || name2=="N" || name2=="O" || name2=="C") {
+                  remove_bb=true;
+                }
               }
             } else {
               LOG_VERBOSE("BOND:" << " " << res.GetChain() << " " << res.GetName() << " " << res.GetNumber() << " " << bond_str << " " << min_length << " " << max_length << " " << blength << " " << zscore << " " << "PASS")
@@ -629,7 +634,7 @@ std::pair<EntityView,ClashingInfo> FilterClashes(const EntityView& ent, const Cl
     
     if (remove_bb) {
       LOG_VERBOSE("ACTION: removing whole residue " << res);
-      res.SetBoolProp("steric_clash",true);
+      res.SetBoolProp("steric_clash_backbone", true);
       continue;
     }
     if (remove_sc) {
@@ -642,7 +647,7 @@ std::pair<EntityView,ClashingInfo> FilterClashes(const EntityView& ent, const Cl
          filtered.AddAtom(atom);
        }
       }
-      res.SetBoolProp("steric_clash",true);
+      res.SetBoolProp("steric_clash_sidechain", true);
       continue;
     }
     filtered.AddResidue(res, ViewAddFlag::INCLUDE_ATOMS);
diff --git a/modules/mol/alg/src/lddt.cc b/modules/mol/alg/src/lddt.cc
index 4a9c095f5..a64f5bb19 100644
--- a/modules/mol/alg/src/lddt.cc
+++ b/modules/mol/alg/src/lddt.cc
@@ -361,17 +361,17 @@ int main (int argc, char **argv)
     }
 
     // Check consistency
-  for (std::vector<EntityView>::const_iterator ref_list_it = ref_list.begin();
-       ref_list_it != ref_list.end(); ++ref_list_it) {
-    bool cons_check = ResidueNamesMatch(model_view,*ref_list_it, ignore_consistency_checks);
-    if (cons_check==false) {
-      if (ignore_consistency_checks==false) {
-        throw std::runtime_error("Residue names in model and in reference structure(s) are inconsistent.");            
-      } else {
-        LOG_WARNING("Residue names in model and in reference structure(s) are inconsistent.");
-      }   
-    } 
-  }
+    for (std::vector<EntityView>::const_iterator ref_list_it = ref_list.begin();
+         ref_list_it != ref_list.end(); ++ref_list_it) {
+      bool cons_check = ResidueNamesMatch(model_view,*ref_list_it, ignore_consistency_checks);
+      if (cons_check==false) {
+        if (ignore_consistency_checks==false) {
+          throw std::runtime_error("Residue names in model and in reference structure(s) are inconsistent.");
+        } else {
+          LOG_WARNING("Residue names in model and in reference structure(s) are inconsistent.");
+        }
+      }
+    }
 
     // computes the lddt score   
     LocalDistDiffTest(model_view, ref_list, glob_dist_list, settings);
-- 
GitLab