From 753718368fb35293c32e2671ea099cf8c87406c3 Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Wed, 29 Apr 2015 10:58:15 +0200
Subject: [PATCH] avoid the buildup of several disulfid bridges with the same
 sulfur

not only check for the number of bond partners, but also whether
there is an atom called SG in the bonded atoms.
---
 modules/mol/mm/src/modeller.cc | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/modules/mol/mm/src/modeller.cc b/modules/mol/mm/src/modeller.cc
index 9e87752bf..fafdf5b74 100644
--- a/modules/mol/mm/src/modeller.cc
+++ b/modules/mol/mm/src/modeller.cc
@@ -13,7 +13,22 @@ void Modeller::GenerateDisulfidBonds(ost::mol::EntityHandle& handle){
     if(i->GetName() == "CYS" || i->GetName() == "CYX" || i->GetName() == "CYS2" || i->GetName() == "CYM"){
       ost::mol::AtomHandle s = i->FindAtom("SG");
       if(s.IsValid()){
+        //quick check, whether max bond partners is already reached
         if(s.GetBondCount() >= 2) continue;
+        //check, whether SG is already bound to a SG
+        ost::mol::AtomHandleList bonded_atoms = s.GetBondPartners();
+        bool already_bound = false;
+        for(ost::mol::AtomHandleList::iterator bound_it = bonded_atoms.begin();
+            bound_it != bonded_atoms.end(); ++bound_it){
+          if(bound_it->GetName() == "SG"){
+            if(bound_it->GetResidue().GetName() == "CYS" || bound_it->GetResidue().GetName() == "CYX" ||
+               bound_it->GetResidue().GetName() == "CYS2" || bound_it->GetResidue().GetName() == "CYM"){
+              already_bound = true;
+              break;
+            }
+          }
+        }
+        if(already_bound) continue;
         ost::mol::AtomHandleList in_reach = handle.FindWithin(s.GetPos(),2.5);
         for(ost::mol::AtomHandleList::iterator j = in_reach.begin();
             j != in_reach.end(); ++j){
-- 
GitLab