Skip to content
Snippets Groups Projects
Commit 71cffd9a authored by Bienchen's avatar Bienchen
Browse files

Also load InChI key into the compoundslib, ment to be machine readable

parent dce93795
Branches
Tags
No related merge requests found
......@@ -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_;
......
......@@ -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);
......
......@@ -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());
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment