From 8a4bc5f06abf97e466a3887c89445d12886ac6d9 Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@stud.unibas.ch>
Date: Thu, 30 May 2013 23:37:36 +0200
Subject: [PATCH] nicify IsResidueComplete function

---
 modules/conop/src/compound_lib_base.cc | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/modules/conop/src/compound_lib_base.cc b/modules/conop/src/compound_lib_base.cc
index 708c630bb..7fbb5520d 100644
--- a/modules/conop/src/compound_lib_base.cc
+++ b/modules/conop/src/compound_lib_base.cc
@@ -5,23 +5,20 @@ namespace ost { namespace conop {
 bool CompoundLibBase::IsResidueComplete(const ost::mol::ResidueHandle& res, bool check_hydrogens, Compound::Dialect dialect) const{
 
   CompoundPtr compound = this->FindCompound(res.GetName(), dialect);
-
   AtomSpecList a_spec = compound->GetAtomSpecs();
 
   for(AtomSpecList::const_iterator it=a_spec.begin(); it!=a_spec.end();++it){
-    if(it->element=="H" || it->element=="D"){
-      if(check_hydrogens){
-        if(!res.FindAtom(it->name).IsValid()){
-          return false;
-        }
-      }
-    }
-    else{
-      if(!res.FindAtom(it->name).IsValid()){
-        return false;
-      }
-    }
+
+    if (it->is_leaving) continue;
+
+    if((it->element=="H" || it->element=="D") && (!check_hydrogens)) continue;
+
+    if(res.FindAtom(it->name).IsValid() || res.FindAtom(it->alt_name)) continue;
+
+    return false; 
+
   }
+
   return true;
 }
 
-- 
GitLab