From 82af1808a0d8f74a0bde897acff2e352f889584e Mon Sep 17 00:00:00 2001
From: Marco Biasini <marco.biasini@unibas.ch>
Date: Mon, 2 May 2011 19:31:16 +0200
Subject: [PATCH] fix AddCompound for residues with atoms not listed in order
 of increasing ordinals

The issues manifests when importing large "composite" compounds,
e.g. a ligand derived from several amino acids with the atoms not
listed in order of increasing ordinals. This was not a problem up
until now, since the components.cif dictionary was always (as
far as I know) listing the atoms ordered by ordinal.
---
 modules/conop/src/compound_lib.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/conop/src/compound_lib.cc b/modules/conop/src/compound_lib.cc
index 03435ff2c..c16c8505a 100644
--- a/modules/conop/src/compound_lib.cc
+++ b/modules/conop/src/compound_lib.cc
@@ -156,10 +156,10 @@ void CompoundLib::AddCompound(const CompoundPtr& compound)
       sqlite3_bind_int(stmt, 5, a.is_aromatic);
       sqlite3_bind_int(stmt, 6, 0);                  
       sqlite3_bind_int(stmt, 7, a.is_leaving);
-      sqlite3_bind_int(stmt, 8, i-al.begin());      
+      sqlite3_bind_int(stmt, 8, a.ordinal);
       retval=sqlite3_step(stmt);
       assert(retval==SQLITE_DONE);
-      atom_ids[i-al.begin()]=sqlite3_last_insert_rowid(conn_);
+      atom_ids[a.ordinal]=sqlite3_last_insert_rowid(conn_);
     } else {
       LOG_ERROR(sqlite3_errmsg(conn_));
     }
-- 
GitLab