Skip to content
Snippets Groups Projects
Commit 52945733 authored by Juergen Haas's avatar Juergen Haas
Browse files

Merge branch 'develop' into qt5_port

parents 80b72f6d f503f663
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,7 @@ test:centos7.3: ...@@ -38,6 +38,7 @@ test:centos7.3:
- module load Perl/5.22.2-goolf-1.7.20 - module load Perl/5.22.2-goolf-1.7.20
- module load HH-suite/2.0.16-goolf-1.7.20-Boost-1.53.0-Python-2.7.11 - module load HH-suite/2.0.16-goolf-1.7.20-Boost-1.53.0-Python-2.7.11
- module load OpenMM/6.1-goolf-1.7.20-Python-2.7.11 - module load OpenMM/6.1-goolf-1.7.20-Python-2.7.11
- module load SQLite/3.9.2-goolf-1.7.20
- echo "... done running centos7.3 'before_script'." - echo "... done running centos7.3 'before_script'."
script: script:
- echo "Testing on CentOS 7..." - echo "Testing on CentOS 7..."
...@@ -57,6 +58,8 @@ test:centos7.3: ...@@ -57,6 +58,8 @@ test:centos7.3:
-DEIGEN3_INCLUDE_DIR=$EBROOTEIGEN/include -DEIGEN3_INCLUDE_DIR=$EBROOTEIGEN/include
-DFFTW_LIBRARY=$EBROOTFFTW/lib/libfftw3f.a -DFFTW_LIBRARY=$EBROOTFFTW/lib/libfftw3f.a
-DFFTW_INCLUDE_DIR=$EBROOTFFTW/include -DFFTW_INCLUDE_DIR=$EBROOTFFTW/include
-DSQLITE3_LIBRARY=$EBROOTSQLITE/lib/libsqlite3.so
-DSQLITE3_INCLUDE_DIR=$EBROOTSQLITE/include
-DBOOST_ROOT=$EBROOTBOOST -DBOOST_ROOT=$EBROOTBOOST
-DQT_QMAKE_EXECUTABLE=$EBROOTQT5/bin/qmake -DQT_QMAKE_EXECUTABLE=$EBROOTQT5/bin/qmake
-DPNG_LIBRARY=$EBROOTLIBPNG/lib/libpng.so -DPNG_LIBRARY=$EBROOTLIBPNG/lib/libpng.so
......
Changes in Release 1.x.x
--------------------------------------------------------------------------------
* Use system provided SQLite3 library
Changes in Release 1.9.0 Changes in Release 1.9.0
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
......
...@@ -234,7 +234,8 @@ else() ...@@ -234,7 +234,8 @@ else()
endif() endif()
find_package(Eigen 3.2.0 REQUIRED) find_package(Eigen 3.2.0 REQUIRED)
find_package(Python 2.7 REQUIRED) find_package(Python 2.4 REQUIRED)
find_package(SQLite3 3.7.13 REQUIRED)
if(USE_NUMPY) if(USE_NUMPY)
find_package(Numpy REQUIRED) find_package(Numpy REQUIRED)
...@@ -307,6 +308,7 @@ include_directories(${Boost_INCLUDE_DIRS} ...@@ -307,6 +308,7 @@ include_directories(${Boost_INCLUDE_DIRS}
${TIFF_INCLUDE_DIR} ${TIFF_INCLUDE_DIR}
${PNG_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS}
${OPEN_MM_INCLUDE_DIRS} ${OPEN_MM_INCLUDE_DIRS}
${SQLITE3_INCLUDE_DIRS}
) )
if(USE_NUMPY) if(USE_NUMPY)
include_directories(${PYTHON_NUMPY_INCLUDE_DIR}) include_directories(${PYTHON_NUMPY_INCLUDE_DIR})
......
# Once done this will define
# - Find SQLite3
# Find the native SQLite3 includes and library
#
# SQLITE3_INCLUDE_DIRS - SQLite3 include dir.
# SQLITE3_LIBRARIES - List of libraries when using SQLite3.
# SQLITE3_FOUND - True if SQLite3 found.
find_path(SQLITE3_INCLUDE_DIR sqlite3.h)
find_library(SQLITE3_LIBRARY NAMES sqlite3)
# handle the QUIETLY and REQUIRED arguments and set SQLITE3_FOUND to TRUE if
# all listed variables are TRUE
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (SQLITE3 DEFAULT_MSG SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR)
mark_as_advanced(SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR)
SET(SQLITE3_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIR})
SET(SQLITE3_LIBRARIES ${SQLITE3_LIBRARY})
...@@ -47,6 +47,7 @@ RUN apt-get update -y && apt-get install -y cmake \ ...@@ -47,6 +47,7 @@ RUN apt-get update -y && apt-get install -y cmake \
swig \ swig \
clustalw \ clustalw \
python-virtualenv \ python-virtualenv \
libsqlite3-dev \
locales && \ locales && \
# CLEANUP # CLEANUP
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "compound_lib.hh" #include "compound_lib.hh"
#include <ost/version.hh> #include <ost/version.hh>
#include <ost/string_ref.hh> #include <ost/string_ref.hh>
#include <sqlite3.h>
using boost::format; using boost::format;
...@@ -105,13 +106,32 @@ const char* INSERT_CHEMLIB_INFO_STATEMENT="insert into chemlib_info ...@@ -105,13 +106,32 @@ const char* INSERT_CHEMLIB_INFO_STATEMENT="insert into chemlib_info
} }
struct CompoundLib::Database {
Database(): ptr(NULL) { }
Database(sqlite3* p): ptr(p) { }
~Database() {
if (ptr) {
int retval = sqlite3_close(ptr);
if (retval != SQLITE_OK) {
LOG_ERROR("Problem while closing SQLite db for CompoundLib: "
<< sqlite3_errmsg(ptr));
}
}
}
sqlite3* ptr;
};
void CompoundLib::SetChemLibInfo(void){ void CompoundLib::SetChemLibInfo(void){
sqlite3_stmt* stmt=NULL; sqlite3_stmt* stmt=NULL;
//~ if (!conn_) { //~ if (!db_->ptr) {
//~ LOG_ERROR(sqlite3_errmsg("Connection to DB not made")); //~ LOG_ERROR(sqlite3_errmsg("Connection to DB not made"));
//~ } //~ }
int retval=sqlite3_prepare_v2(conn_, INSERT_CHEMLIB_INFO_STATEMENT, int retval=sqlite3_prepare_v2(db_->ptr, INSERT_CHEMLIB_INFO_STATEMENT,
strlen(INSERT_CHEMLIB_INFO_STATEMENT), &stmt, NULL); strlen(INSERT_CHEMLIB_INFO_STATEMENT), &stmt, NULL);
time_t rawtime; time_t rawtime;
struct tm * timeinfo; struct tm * timeinfo;
...@@ -131,10 +151,10 @@ void CompoundLib::SetChemLibInfo(void){ ...@@ -131,10 +151,10 @@ void CompoundLib::SetChemLibInfo(void){
} }
retval=sqlite3_step(stmt); retval=sqlite3_step(stmt);
if (SQLITE_DONE!=retval) { if (SQLITE_DONE!=retval) {
if (sqlite3_errcode(conn_)==SQLITE_CONSTRAINT) { if (sqlite3_errcode(db_->ptr)==SQLITE_CONSTRAINT) {
LOG_ERROR("chemlib info already exists"); LOG_ERROR("chemlib info already exists");
} else { } else {
LOG_ERROR(sqlite3_errmsg(conn_)); LOG_ERROR(sqlite3_errmsg(db_->ptr));
} }
} }
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
...@@ -144,7 +164,7 @@ Date CompoundLib::GetCreationDate(void){ ...@@ -144,7 +164,7 @@ Date CompoundLib::GetCreationDate(void){
String query="SELECT creation_date FROM chemlib_info"; String query="SELECT creation_date FROM chemlib_info";
sqlite3_stmt* stmt; sqlite3_stmt* stmt;
int retval=sqlite3_prepare_v2(conn_, query.c_str(), int retval=sqlite3_prepare_v2(db_->ptr, query.c_str(),
static_cast<int>(query.length()), static_cast<int>(query.length()),
&stmt, NULL); &stmt, NULL);
if (SQLITE_OK==retval) { if (SQLITE_OK==retval) {
...@@ -174,7 +194,7 @@ String CompoundLib::GetOSTVersionUsed() { ...@@ -174,7 +194,7 @@ String CompoundLib::GetOSTVersionUsed() {
sqlite3_stmt* stmt; sqlite3_stmt* stmt;
String version; String version;
int retval=sqlite3_prepare_v2(conn_, query.c_str(), int retval=sqlite3_prepare_v2(db_->ptr, query.c_str(),
static_cast<int>(query.length()), static_cast<int>(query.length()),
&stmt, NULL); &stmt, NULL);
if (SQLITE_OK==retval) { if (SQLITE_OK==retval) {
...@@ -202,7 +222,7 @@ String CompoundLib::GetOSTVersionUsed() { ...@@ -202,7 +222,7 @@ String CompoundLib::GetOSTVersionUsed() {
void CompoundLib::AddCompound(const CompoundPtr& compound) void CompoundLib::AddCompound(const CompoundPtr& compound)
{ {
sqlite3_stmt* stmt=NULL; sqlite3_stmt* stmt=NULL;
int retval=sqlite3_prepare_v2(conn_, INSERT_COMPOUND_STATEMENT, int retval=sqlite3_prepare_v2(db_->ptr, INSERT_COMPOUND_STATEMENT,
strlen(INSERT_COMPOUND_STATEMENT), &stmt, NULL); strlen(INSERT_COMPOUND_STATEMENT), &stmt, NULL);
String crea_date_str, modi_date_str; String crea_date_str, modi_date_str;
if (SQLITE_OK==retval) { if (SQLITE_OK==retval) {
...@@ -233,27 +253,27 @@ void CompoundLib::AddCompound(const CompoundPtr& compound) ...@@ -233,27 +253,27 @@ void CompoundLib::AddCompound(const CompoundPtr& compound)
sqlite3_bind_text(stmt, 11, compound->GetInchiKey().c_str(), sqlite3_bind_text(stmt, 11, compound->GetInchiKey().c_str(),
compound->GetInchiKey().length(), NULL); compound->GetInchiKey().length(), NULL);
} else { } else {
LOG_ERROR(sqlite3_errmsg(conn_)); LOG_ERROR(sqlite3_errmsg(db_->ptr));
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
return; return;
} }
retval=sqlite3_step(stmt); retval=sqlite3_step(stmt);
if (SQLITE_DONE!=retval) { if (SQLITE_DONE!=retval) {
if (sqlite3_errcode(conn_)==SQLITE_CONSTRAINT) { if (sqlite3_errcode(db_->ptr)==SQLITE_CONSTRAINT) {
LOG_ERROR("Compound '" << compound->GetID() << "' already exists for the " LOG_ERROR("Compound '" << compound->GetID() << "' already exists for the "
<< compound->GetDialectAsString() << " dialect."); << compound->GetDialectAsString() << " dialect.");
} else { } else {
LOG_ERROR(sqlite3_errmsg(conn_)); LOG_ERROR(sqlite3_errmsg(db_->ptr));
} }
} }
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
sqlite3_int64 compound_id=sqlite3_last_insert_rowid(conn_); sqlite3_int64 compound_id=sqlite3_last_insert_rowid(db_->ptr);
// insert atoms // insert atoms
const AtomSpecList& al=compound->GetAtomSpecs(); const AtomSpecList& al=compound->GetAtomSpecs();
std::vector<sqlite3_int64> atom_ids(al.size(), 0); std::vector<sqlite3_int64> atom_ids(al.size(), 0);
for (AtomSpecList::const_iterator i=al.begin(), e=al.end(); i!=e; ++i) { for (AtomSpecList::const_iterator i=al.begin(), e=al.end(); i!=e; ++i) {
const AtomSpec& a=*i; const AtomSpec& a=*i;
retval=sqlite3_prepare_v2(conn_, INSERT_ATOM_STATEMENT, retval=sqlite3_prepare_v2(db_->ptr, INSERT_ATOM_STATEMENT,
strlen(INSERT_ATOM_STATEMENT), &stmt, NULL); strlen(INSERT_ATOM_STATEMENT), &stmt, NULL);
if (SQLITE_OK==retval) { if (SQLITE_OK==retval) {
sqlite3_bind_int64(stmt, 1, compound_id); sqlite3_bind_int64(stmt, 1, compound_id);
...@@ -267,16 +287,16 @@ void CompoundLib::AddCompound(const CompoundPtr& compound) ...@@ -267,16 +287,16 @@ void CompoundLib::AddCompound(const CompoundPtr& compound)
sqlite3_bind_int(stmt, 8, a.ordinal); sqlite3_bind_int(stmt, 8, a.ordinal);
retval=sqlite3_step(stmt); retval=sqlite3_step(stmt);
assert(retval==SQLITE_DONE); assert(retval==SQLITE_DONE);
atom_ids[a.ordinal]=sqlite3_last_insert_rowid(conn_); atom_ids[a.ordinal]=sqlite3_last_insert_rowid(db_->ptr);
} else { } else {
LOG_ERROR(sqlite3_errmsg(conn_)); LOG_ERROR(sqlite3_errmsg(db_->ptr));
} }
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
} }
const BondSpecList& bl=compound->GetBondSpecs(); const BondSpecList& bl=compound->GetBondSpecs();
for (BondSpecList::const_iterator i=bl.begin(), e=bl.end(); i!=e; ++i) { for (BondSpecList::const_iterator i=bl.begin(), e=bl.end(); i!=e; ++i) {
const BondSpec& b=*i; const BondSpec& b=*i;
retval=sqlite3_prepare_v2(conn_, INSERT_BOND_STATEMENT, retval=sqlite3_prepare_v2(db_->ptr, INSERT_BOND_STATEMENT,
strlen(INSERT_BOND_STATEMENT), &stmt, NULL); strlen(INSERT_BOND_STATEMENT), &stmt, NULL);
if (SQLITE_OK==retval) { if (SQLITE_OK==retval) {
sqlite3_bind_int64(stmt, 1, compound_id); sqlite3_bind_int64(stmt, 1, compound_id);
...@@ -287,7 +307,7 @@ void CompoundLib::AddCompound(const CompoundPtr& compound) ...@@ -287,7 +307,7 @@ void CompoundLib::AddCompound(const CompoundPtr& compound)
retval=sqlite3_step(stmt); retval=sqlite3_step(stmt);
assert(retval==SQLITE_DONE); assert(retval==SQLITE_DONE);
} else { } else {
LOG_ERROR(sqlite3_errmsg(conn_)); LOG_ERROR(sqlite3_errmsg(db_->ptr));
} }
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
} }
...@@ -296,23 +316,23 @@ void CompoundLib::AddCompound(const CompoundPtr& compound) ...@@ -296,23 +316,23 @@ void CompoundLib::AddCompound(const CompoundPtr& compound)
CompoundLibPtr CompoundLib::Copy(const String& filename) const CompoundLibPtr CompoundLib::Copy(const String& filename) const
{ {
CompoundLibPtr clone=CompoundLibPtr(new CompoundLib); CompoundLibPtr clone=CompoundLibPtr(new CompoundLib);
int retval=sqlite3_open(filename.c_str(), &clone->conn_); int retval=sqlite3_open(filename.c_str(), &clone->db_->ptr);
if (SQLITE_OK==retval) { if (SQLITE_OK==retval) {
sqlite3_backup* backup; sqlite3_backup* backup;
backup=sqlite3_backup_init(clone->conn_, "main", conn_, "main"); backup=sqlite3_backup_init(clone->db_->ptr, "main", db_->ptr, "main");
if (backup){ if (backup){
sqlite3_backup_step(backup, -1); sqlite3_backup_step(backup, -1);
sqlite3_backup_finish(backup); sqlite3_backup_finish(backup);
} }
int rc=sqlite3_errcode(clone->conn_); int rc=sqlite3_errcode(clone->db_->ptr);
if (rc!=SQLITE_OK) { if (rc!=SQLITE_OK) {
LOG_ERROR(sqlite3_errmsg(clone->conn_)); LOG_ERROR(sqlite3_errmsg(clone->db_->ptr));
return CompoundLibPtr(); return CompoundLibPtr();
} }
return clone; return clone;
} }
LOG_ERROR(sqlite3_errmsg(clone->conn_)); LOG_ERROR(sqlite3_errmsg(clone->db_->ptr));
return CompoundLibPtr(); return CompoundLibPtr();
} }
...@@ -321,18 +341,18 @@ CompoundLibPtr CompoundLib::Copy(const String& filename) const ...@@ -321,18 +341,18 @@ CompoundLibPtr CompoundLib::Copy(const String& filename) const
CompoundLibPtr CompoundLib::Create(const String& database) CompoundLibPtr CompoundLib::Create(const String& database)
{ {
CompoundLibPtr lib(new CompoundLib); CompoundLibPtr lib(new CompoundLib);
int retval=sqlite3_open(database.c_str(), &lib->conn_); int retval=sqlite3_open(database.c_str(), &lib->db_->ptr);
if (SQLITE_OK==retval) { if (SQLITE_OK==retval) {
const char** cmd=CREATE_CMD; const char** cmd=CREATE_CMD;
while (*cmd) { while (*cmd) {
sqlite3_stmt* stmt; sqlite3_stmt* stmt;
retval=sqlite3_prepare_v2(lib->conn_, *cmd, strlen(*cmd), &stmt, NULL); retval=sqlite3_prepare_v2(lib->db_->ptr, *cmd, strlen(*cmd), &stmt, NULL);
if (SQLITE_OK==retval) { if (SQLITE_OK==retval) {
retval=sqlite3_step(stmt); retval=sqlite3_step(stmt);
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
assert(SQLITE_DONE==retval); assert(SQLITE_DONE==retval);
} else { } else {
LOG_ERROR(sqlite3_errmsg(lib->conn_)); LOG_ERROR(sqlite3_errmsg(lib->db_->ptr));
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
return CompoundLibPtr(); return CompoundLibPtr();
} }
...@@ -340,7 +360,7 @@ CompoundLibPtr CompoundLib::Create(const String& database) ...@@ -340,7 +360,7 @@ CompoundLibPtr CompoundLib::Create(const String& database)
} }
return lib; return lib;
} }
LOG_ERROR(sqlite3_errmsg(lib->conn_)); LOG_ERROR(sqlite3_errmsg(lib->db_->ptr));
return CompoundLibPtr(); return CompoundLibPtr();
} }
...@@ -349,28 +369,28 @@ CompoundLibPtr CompoundLib::Load(const String& database, bool readonly) ...@@ -349,28 +369,28 @@ CompoundLibPtr CompoundLib::Load(const String& database, bool readonly)
{ {
int flags=readonly ? SQLITE_OPEN_READONLY : SQLITE_OPEN_READWRITE; int flags=readonly ? SQLITE_OPEN_READONLY : SQLITE_OPEN_READWRITE;
CompoundLibPtr lib(new CompoundLib); CompoundLibPtr lib(new CompoundLib);
int retval=sqlite3_open_v2(database.c_str(), &lib->conn_, flags, NULL); int retval=sqlite3_open_v2(database.c_str(), &lib->db_->ptr, flags, NULL);
if (SQLITE_OK!=retval) { if (SQLITE_OK!=retval) {
LOG_ERROR(sqlite3_errmsg(lib->conn_)); LOG_ERROR(sqlite3_errmsg(lib->db_->ptr));
return CompoundLibPtr(); return CompoundLibPtr();
} }
// check if column chem_type exists in database // check if column chem_type exists in database
String aq="SELECT chem_type FROM chem_compounds LIMIT 1"; String aq="SELECT chem_type FROM chem_compounds LIMIT 1";
sqlite3_stmt* stmt; sqlite3_stmt* stmt;
retval=sqlite3_prepare_v2(lib->conn_, aq.c_str(), retval=sqlite3_prepare_v2(lib->db_->ptr, aq.c_str(),
static_cast<int>(aq.length()), static_cast<int>(aq.length()),
&stmt, NULL); &stmt, NULL);
lib->chem_type_available_ = retval==SQLITE_OK; lib->chem_type_available_ = retval==SQLITE_OK;
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
aq="SELECT name FROM chem_compounds LIMIT 1"; aq="SELECT name FROM chem_compounds LIMIT 1";
retval=sqlite3_prepare_v2(lib->conn_, aq.c_str(), retval=sqlite3_prepare_v2(lib->db_->ptr, aq.c_str(),
static_cast<int>(aq.length()), static_cast<int>(aq.length()),
&stmt, NULL); &stmt, NULL);
lib->name_available_ = retval==SQLITE_OK; lib->name_available_ = retval==SQLITE_OK;
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
// check if InChIs are available // check if InChIs are available
aq="SELECT inchi_code FROM chem_compounds LIMIT 1"; aq="SELECT inchi_code FROM chem_compounds LIMIT 1";
retval=sqlite3_prepare_v2(lib->conn_, aq.c_str(), retval=sqlite3_prepare_v2(lib->db_->ptr, aq.c_str(),
static_cast<int>(aq.length()), static_cast<int>(aq.length()),
&stmt, NULL); &stmt, NULL);
lib->inchi_available_ = retval==SQLITE_OK; lib->inchi_available_ = retval==SQLITE_OK;
...@@ -386,7 +406,7 @@ void CompoundLib::LoadAtomsFromDB(CompoundPtr comp, int pk) const { ...@@ -386,7 +406,7 @@ void CompoundLib::LoadAtomsFromDB(CompoundPtr comp, int pk) const {
"FROM atoms WHERE compound_id=%d " "FROM atoms WHERE compound_id=%d "
"ORDER BY ordinal ASC") % pk); "ORDER BY ordinal ASC") % pk);
sqlite3_stmt* stmt; sqlite3_stmt* stmt;
int retval=sqlite3_prepare_v2(conn_, aq.c_str(), int retval=sqlite3_prepare_v2(db_->ptr, aq.c_str(),
static_cast<int>(aq.length()), static_cast<int>(aq.length()),
&stmt, NULL); &stmt, NULL);
if (SQLITE_OK==retval) { if (SQLITE_OK==retval) {
...@@ -401,7 +421,7 @@ void CompoundLib::LoadAtomsFromDB(CompoundPtr comp, int pk) const { ...@@ -401,7 +421,7 @@ void CompoundLib::LoadAtomsFromDB(CompoundPtr comp, int pk) const {
comp->AddAtom(atom_sp); comp->AddAtom(atom_sp);
} }
} else { } else {
LOG_ERROR(sqlite3_errmsg(conn_)); LOG_ERROR(sqlite3_errmsg(db_->ptr));
} }
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
} }
...@@ -416,7 +436,7 @@ void CompoundLib::LoadBondsFromDB(CompoundPtr comp, int pk) const { ...@@ -416,7 +436,7 @@ void CompoundLib::LoadBondsFromDB(CompoundPtr comp, int pk) const {
"LEFT JOIN atoms AS a1 ON b.atom_one=a1.id " "LEFT JOIN atoms AS a1 ON b.atom_one=a1.id "
"LEFT JOIN atoms as a2 ON b.atom_two=a2.id " "LEFT JOIN atoms as a2 ON b.atom_two=a2.id "
"WHERE b.compound_id=%d") % pk); "WHERE b.compound_id=%d") % pk);
int retval=sqlite3_prepare_v2(conn_, aq.c_str(), int retval=sqlite3_prepare_v2(db_->ptr, aq.c_str(),
static_cast<int>(aq.length()), static_cast<int>(aq.length()),
&stmt, NULL); &stmt, NULL);
if (SQLITE_OK==retval) { if (SQLITE_OK==retval) {
...@@ -429,7 +449,7 @@ void CompoundLib::LoadBondsFromDB(CompoundPtr comp, int pk) const { ...@@ -429,7 +449,7 @@ void CompoundLib::LoadBondsFromDB(CompoundPtr comp, int pk) const {
comp->AddBond(bond_sp); comp->AddBond(bond_sp);
} }
} else { } else {
LOG_ERROR(sqlite3_errmsg(conn_)); LOG_ERROR(sqlite3_errmsg(db_->ptr));
} }
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
} }
...@@ -457,7 +477,7 @@ CompoundPtr CompoundLib::FindCompound(const String& id, ...@@ -457,7 +477,7 @@ CompoundPtr CompoundLib::FindCompound(const String& id,
query+=" FROM chem_compounds" query+=" FROM chem_compounds"
" WHERE tlc='"+id+"' AND dialect='"+String(1, char(dialect))+"'"; " WHERE tlc='"+id+"' AND dialect='"+String(1, char(dialect))+"'";
sqlite3_stmt* stmt; sqlite3_stmt* stmt;
int retval=sqlite3_prepare_v2(conn_, query.c_str(), int retval=sqlite3_prepare_v2(db_->ptr, query.c_str(),
static_cast<int>(query.length()), static_cast<int>(query.length()),
&stmt, NULL); &stmt, NULL);
if (SQLITE_OK==retval) { if (SQLITE_OK==retval) {
...@@ -503,7 +523,7 @@ CompoundPtr CompoundLib::FindCompound(const String& id, ...@@ -503,7 +523,7 @@ CompoundPtr CompoundLib::FindCompound(const String& id,
} }
assert(SQLITE_DONE==sqlite3_step(stmt)); assert(SQLITE_DONE==sqlite3_step(stmt));
} else { } else {
LOG_ERROR("ERROR: " << sqlite3_errmsg(conn_)); LOG_ERROR("ERROR: " << sqlite3_errmsg(db_->ptr));
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
return CompoundPtr(); return CompoundPtr();
} }
...@@ -513,23 +533,16 @@ CompoundPtr CompoundLib::FindCompound(const String& id, ...@@ -513,23 +533,16 @@ CompoundPtr CompoundLib::FindCompound(const String& id,
CompoundLib::CompoundLib(): CompoundLib::CompoundLib():
CompoundLibBase(), CompoundLibBase(),
db_(new Database),
compound_cache_(), compound_cache_(),
conn_(NULL),
chem_type_available_(false), chem_type_available_(false),
name_available_(), name_available_(),
inchi_available_(), inchi_available_(),
creation_date_(), creation_date_(),
ost_version_used_() ost_version_used_() { }
{
}
CompoundLib::~CompoundLib() { CompoundLib::~CompoundLib() {
if (conn_) { delete db_;
int retval = sqlite3_close(conn_);
if (retval != SQLITE_OK) {
LOG_ERROR("Problem while closing SQLite db for CompoundLib: "
<< sqlite3_errmsg(conn_));
}
}
} }
}} }}
...@@ -22,9 +22,6 @@ ...@@ -22,9 +22,6 @@
#include <map> #include <map>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
// our own local copy of sqlite3
#include <ost/db/sqlite3.h>
#include "module_config.hh" #include "module_config.hh"
#include "compound.hh" #include "compound.hh"
#include "compound_lib_base.hh" #include "compound_lib_base.hh"
...@@ -55,8 +52,9 @@ private: ...@@ -55,8 +52,9 @@ private:
void LoadAtomsFromDB(CompoundPtr comp, int pk) const; void LoadAtomsFromDB(CompoundPtr comp, int pk) const;
void LoadBondsFromDB(CompoundPtr comp, int pk) const; void LoadBondsFromDB(CompoundPtr comp, int pk) const;
private: private:
struct Database;
Database* db_;
mutable CompoundMap compound_cache_; mutable CompoundMap compound_cache_;
sqlite3* conn_;
bool chem_type_available_; // wether pdbx_type is available in db bool chem_type_available_; // wether pdbx_type is available in db
bool name_available_; // wether name is available in db bool name_available_; // wether name is available in db
bool inchi_available_; //whether inchi is available in db bool inchi_available_; //whether inchi is available in db
......
set(OST_DB_HEADERS set(OST_DB_HEADERS
sqlite_wrap.hh sqlite_wrap.hh
sqlite3.h
sqlite_conv.hh sqlite_conv.hh
module_config.hh module_config.hh
) )
set(OST_DB_SOURCES set(OST_DB_SOURCES
sqlite_wrap.cc sqlite_wrap.cc
sqlite3.c
) )
module(NAME db SOURCES ${OST_DB_SOURCES} HEADERS ${OST_DB_HEADERS} module(NAME db SOURCES ${OST_DB_SOURCES} HEADERS ${OST_DB_HEADERS}
DEPENDS_ON ost_base) DEPENDS_ON ost_base sqlite3)
if(WIN32) if(WIN32)
set_target_properties(ost_db PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_SOURCE_DIR}/sqlite3.def") set_target_properties(ost_db PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_SOURCE_DIR}/sqlite3.def")
add_definitions(/DSQLITE_ENABLE_COLUMN_METADATA) add_definitions(/DSQLITE_ENABLE_COLUMN_METADATA)
......
This diff is collapsed.
This diff is collapsed.
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#ifndef OST_IO_SQLITE_CONV_HH #ifndef OST_IO_SQLITE_CONV_HH
#define OST_IO_SQLITE_CONV_HH #define OST_IO_SQLITE_CONV_HH
#include "sqlite3.h" #include <sqlite3.h>
#include <ost/db/module_config.hh> #include <ost/db/module_config.hh>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <ost/base.hh> #include <ost/base.hh>
#include <ost/message.hh> #include <ost/message.hh>
#include "sqlite3.h" #include <sqlite3.h>
#include "sqlite_conv.hh" #include "sqlite_conv.hh"
namespace ost { namespace db { namespace ost { namespace db {
......
...@@ -33,6 +33,7 @@ required version is given in parentheses. ...@@ -33,6 +33,7 @@ required version is given in parentheses.
* `Boost <http://boost.org>`_ (1.53) * `Boost <http://boost.org>`_ (1.53)
* `zlib <https://zlib.net/>`_ (usually comes with Boost or system) * `zlib <https://zlib.net/>`_ (usually comes with Boost or system)
* `Eigen3 <http://eigen.tuxfamily.org>`_ (3.2.0) * `Eigen3 <http://eigen.tuxfamily.org>`_ (3.2.0)
* `SQLite3 <https://www3.sqlite.org>`_ (3.7.13)
When you enable support for image processing, you will need: When you enable support for image processing, you will need:
...@@ -215,6 +216,10 @@ can influence it. ...@@ -215,6 +216,10 @@ can influence it.
starting with `libtiff`) starting with `libtiff`)
* `TIFF_INCLUDE_DIR` defines the include folder of libtiff (contains include * `TIFF_INCLUDE_DIR` defines the include folder of libtiff (contains include
files directly) files directly)
* `SQLITE3_LIBRARY` defines the location of the SQLite3 library (file name starting
with `libsqlite3`)
* `SQLITE3_INCLUDE_DIR` defines the include folder of SQLite3 (contains include
files directly)
* Usually, you will receive errors for those variables when executing `cmake` * Usually, you will receive errors for those variables when executing `cmake`
and set them accordingly as needed. and set them accordingly as needed.
...@@ -300,7 +305,7 @@ All the dependencies can be installed from the package manager as follows: ...@@ -300,7 +305,7 @@ All the dependencies can be installed from the package manager as follows:
sudo apt-get install cmake sip-dev libtiff-dev libfftw3-dev libeigen3-dev \ sudo apt-get install cmake sip-dev libtiff-dev libfftw3-dev libeigen3-dev \
libpng-dev python-all python2.7 python-qt4 libboost-all-dev \ libpng-dev python-all python2.7 python-qt4 libboost-all-dev \
qt4-qtconfig qt4-qmake libqt4-dev libpng-dev qt4-qtconfig qt4-qmake libqt4-dev libpng-dev libsqlite3-dev
Now, all dependencies are located in standard locations and cmake will Now, all dependencies are located in standard locations and cmake will
automatically find them without the need to pass any additional parameters. The automatically find them without the need to pass any additional parameters. The
...@@ -314,22 +319,6 @@ version of OpenStructure. ...@@ -314,22 +319,6 @@ version of OpenStructure.
-DOPTIMIZE=ON -DOPTIMIZE=ON
**Fedora 26 without GUI**
All the dependencies can be installed from the package manager as follows:
.. code-block:: bash
sudo dnf install cmake eigen3-devel boost-devel libpng-devel python2-devel \
fftw-devel libtiff-devel
Here, we compile a version without GUI as follows:
.. code-block:: bash
cmake . -DOPTIMIZE=ON -DENABLE_INFO=OFF
**macOS with Homebrew without GUI** **macOS with Homebrew without GUI**
`Homebrew <https://brew.sh/>`_ can be used to conveniently install all packages `Homebrew <https://brew.sh/>`_ can be used to conveniently install all packages
......
...@@ -55,8 +55,9 @@ apt-get update -y && apt-get install -y cmake \ ...@@ -55,8 +55,9 @@ apt-get update -y && apt-get install -y cmake \
doxygen \ doxygen \
swig \ swig \
clustalw \ clustalw \
python-virtualenv \ python-virtualenv \
locales libsqlite3-dev \
locales
# SET LOCALE # SET LOCALE
############ ############
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment