From 71cffd9a965aad906245ac1c1bfe4e003e378200 Mon Sep 17 00:00:00 2001 From: Stefan Bienert <stefan.bienert@unibas.ch> Date: Fri, 26 Feb 2016 15:14:56 +0100 Subject: [PATCH] Also load InChI key into the compoundslib, ment to be machine readable --- modules/conop/src/compound.hh | 6 ++++++ modules/conop/src/compound_lib.cc | 9 ++++++--- modules/io/src/mol/chemdict_parser.cc | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/conop/src/compound.hh b/modules/conop/src/compound.hh index c64e5d120..9e2547bbf 100644 --- a/modules/conop/src/compound.hh +++ b/modules/conop/src/compound.hh @@ -148,6 +148,7 @@ public: formula_(), name_(), inchi_(), + inchi_key_(), atom_specs_(), bond_specs_(), chem_class_(), @@ -247,6 +248,10 @@ public: const String& GetInchi() { return inchi_; } + void SetInchiKey(const String& inchikey) { inchi_key_=inchikey; } + + const String& GetInchiKey() { return inchi_key_; } + const BondSpecList& GetBondSpecs() const { return bond_specs_; } @@ -275,6 +280,7 @@ private: String formula_; String name_; String inchi_; + String inchi_key_; AtomSpecList atom_specs_; BondSpecList bond_specs_; mol::ChemClass chem_class_; diff --git a/modules/conop/src/compound_lib.cc b/modules/conop/src/compound_lib.cc index 09b667b77..508c31bd6 100644 --- a/modules/conop/src/compound_lib.cc +++ b/modules/conop/src/compound_lib.cc @@ -50,7 +50,8 @@ const char* CREATE_CMD[]={ " pdb_initial TIMESTAMP, " " pdb_modified TIMESTAMP, " " name VARCHAR(256), " -" inchi_code TEXT " +" inchi_code TEXT, " +" inchi_key TEXT " ");", " CREATE UNIQUE INDEX IF NOT EXISTS commpound_tlc_index ON chem_compounds " " (tlc, dialect)", @@ -86,8 +87,8 @@ const char* CREATE_CMD[]={ const char* INSERT_COMPOUND_STATEMENT="INSERT INTO chem_compounds " -" (tlc, olc, dialect, chem_class, chem_type, formula, pdb_initial, pdb_modified, name, inchi_code) " -" VALUES (?, ?, ?, ?, ?, ?, DATE(?), DATE(?), ?, ?)"; +" (tlc, olc, dialect, chem_class, chem_type, formula, pdb_initial, pdb_modified, name, inchi_code, inchi_key) " +" VALUES (?, ?, ?, ?, ?, ?, DATE(?), DATE(?), ?, ?, ?)"; const char* INSERT_ATOM_STATEMENT="INSERT INTO atoms " " (compound_id, name, alt_name, element, is_aromatic, stereo_conf, " @@ -229,6 +230,8 @@ void CompoundLib::AddCompound(const CompoundPtr& compound) compound->GetName().length(), NULL); sqlite3_bind_text(stmt, 10, compound->GetInchi().c_str(), compound->GetInchi().length(), NULL); + sqlite3_bind_text(stmt, 11, compound->GetInchiKey().c_str(), + compound->GetInchiKey().length(), NULL); } else { LOG_ERROR(sqlite3_errmsg(conn_)); sqlite3_finalize(stmt); diff --git a/modules/io/src/mol/chemdict_parser.cc b/modules/io/src/mol/chemdict_parser.cc index 841beb4b7..47f7f6f2d 100644 --- a/modules/io/src/mol/chemdict_parser.cc +++ b/modules/io/src/mol/chemdict_parser.cc @@ -83,6 +83,8 @@ void ChemdictParser::OnDataRow(const StarLoopDesc& header, return; } compound_->SetInchi(columns[indices_[DESC]].substr(6).str()); + } else if (columns[indices_[DESC_TYPE]] == StringRef("InChIKey", 8)) { + compound_->SetInchiKey(columns[indices_[DESC]].str()); } } } -- GitLab