From 5ccfb4e91ea8c0db69a3c135de165ed0ecee1dfb Mon Sep 17 00:00:00 2001
From: Tobias Schmidt <tobias.schmidt@unibas.ch>
Date: Tue, 19 Jul 2011 17:02:18 +0200
Subject: [PATCH] fixed builder.GetUnknownAtoms for calling it multiple times
 with the same residue

---
 modules/conop/src/rule_based_builder.cc | 4 +++-
 modules/conop/src/rule_based_builder.hh | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/conop/src/rule_based_builder.cc b/modules/conop/src/rule_based_builder.cc
index 2a0a50010..57c8f5154 100644
--- a/modules/conop/src/rule_based_builder.cc
+++ b/modules/conop/src/rule_based_builder.cc
@@ -89,9 +89,10 @@ mol::AtomHandleList RuleBasedBuilder::GetUnknownAtoms(mol::ResidueHandle res)
   if (!last_compound_) {
     return unknown;
   }
+  mol::AtomHandleList atoms=res.GetAtomList();
+  last_residue_=mol::ResidueHandle();
   this->ReorderAtoms(res, last_compound_);
   AtomSpecList::const_iterator j=last_compound_->GetAtomSpecs().begin();
-  mol::AtomHandleList atoms=res.GetAtomList();
   mol::AtomHandleList::iterator i=atoms.begin();
   for (mol::AtomHandleList::iterator 
        i=atoms.begin(), e=atoms.end(); i!=e; ++i) {
@@ -153,6 +154,7 @@ void RuleBasedBuilder::ReorderAtoms(mol::ResidueHandle residue,
   mol::impl::AtomImplList::iterator i=impl->GetAtomList().begin();
   for (; i!=impl->GetAtomList().end(); ++i) {
     mol::impl::AtomImplPtr atom=*i;
+    atom->SetState(std::numeric_limits<unsigned int>::max());
     int index=compound->GetAtomSpecIndex(atom->GetName());
     if (index==-1) {
       if (!this->OnUnknownAtom(mol::AtomHandle(atom))) {
diff --git a/modules/conop/src/rule_based_builder.hh b/modules/conop/src/rule_based_builder.hh
index 9adcc6747..9ecc45c10 100644
--- a/modules/conop/src/rule_based_builder.hh
+++ b/modules/conop/src/rule_based_builder.hh
@@ -116,9 +116,6 @@ public:
   /// \brief Set residue properties such as chemical class
   virtual void FillResidueProps(mol::ResidueHandle residue);
 
-  /// \brief whether the residue has unknown atoms
-  bool HasUnknownAtoms(mol::ResidueHandle res);
-  
   mol::AtomHandleList GetUnknownAtoms(mol::ResidueHandle res);
   
   /// \brief Check whether the residue has all required atoms. This does not
@@ -131,6 +128,9 @@ private:
   CompoundPtr         last_compound_;
   mol::ResidueHandle  last_residue_;
   bool                unknown_atoms_;
+  /// \brief whether the residue has unknown atoms
+  bool HasUnknownAtoms(mol::ResidueHandle res);
+
   void LookupCompound(const mol::ResidueHandle& rh);
   /// Change internal order of atoms in residue to the order given by compound
   void ReorderAtoms(mol::ResidueHandle residue, CompoundPtr compound);
-- 
GitLab