Skip to content
Snippets Groups Projects
Commit 4958e18d authored by Marco Biasini's avatar Marco Biasini
Browse files

added minimal compound library

parent 0f8c4f19
No related branches found
No related tags found
No related merge requests found
......@@ -127,7 +127,7 @@ void export_Compound() {
class_<BondSpec>("BondSpec", no_init)
.def_readonly("atom_one", &BondSpec::atom_one)
.def_readonly("atom_two", &BondSpec::atom_two)
.def_readonly("border", &BondSpec::order)
.def_readonly("order", &BondSpec::order)
;
......
set(OST_CONOP_HEADERS
#builder.hh
#builder_fw.hh
conop.hh
processor.hh
#heuristic_builder.hh
amino_acids.hh
diag.hh
model_check.hh
......@@ -13,24 +10,24 @@ compound_lib.hh
module_config.hh
rule_based.hh
nonstandard.hh
#rule_based_builder.hh
minimal_compound_lib.hh
compound_lib_base.hh
ring_finder.hh
)
set(OST_CONOP_SOURCES
# builder.cc
processor.cc
amino_acids.cc
conop.cc
minimal_compound_lib.cc
compound_lib_base.cc
heuristic.cc
diag.cc
rule_based.cc
model_check.cc
#heuristic_builder.cc
compound.cc
compound_lib.cc
nonstandard.cc
#rule_based_builder.cc
ring_finder.cc
)
......
......@@ -20,6 +20,7 @@
#define OST_CONOP_COMPOUND_HH
#include <vector>
#include <map>
#include <boost/shared_ptr.hpp>
#include <ost/string_ref.hh>
#include <ost/conop/module_config.hh>
......@@ -72,6 +73,9 @@ struct DLLEXPORT_OST_CONOP AtomSpec {
AtomSpec()
: ordinal(0), is_leaving(false) {
}
AtomSpec(int o, const String& n, const String& a, const String& e,
bool l, bool r): ordinal(o), name(n), alt_name(a), element(e),
is_leaving(l), is_aromatic(r) {}
int ordinal;
String name;
String alt_name;
......@@ -93,7 +97,7 @@ struct DLLEXPORT_OST_CONOP BondSpec {
: atom_one(0), atom_two(0), order(1) {
}
BondSpec(int a, int b, int o): atom_one(a), atom_two(b), order(o) {}
bool operator==(const BondSpec& rhs) const {
return atom_one==rhs.atom_one && atom_two==rhs.atom_two;
}
......@@ -247,6 +251,8 @@ private:
Date mod_date_;
};
typedef std::map<String, CompoundPtr> CompoundMap;
}}
#endif
......@@ -363,7 +363,7 @@ CompoundLibPtr CompoundLib::Load(const String& database, bool readonly)
return lib;
}
void CompoundLib::LoadAtomsFromDB(CompoundPtr comp, int pk) {
void CompoundLib::LoadAtomsFromDB(CompoundPtr comp, int pk) const {
String aq=str(format("SELECT name, alt_name, element, ordinal, is_leaving "
"FROM atoms WHERE compound_id=%d "
"ORDER BY ordinal ASC") % pk);
......@@ -392,7 +392,7 @@ void CompoundLib::ClearCache()
compound_cache_.clear();
}
void CompoundLib::LoadBondsFromDB(CompoundPtr comp, int pk) {
void CompoundLib::LoadBondsFromDB(CompoundPtr comp, int pk) const {
sqlite3_stmt* stmt;
String aq=str(format("SELECT a1.ordinal, a2.ordinal, b.bond_order FROM bonds AS b "
"LEFT JOIN atoms AS a1 ON b.atom_one=a1.id "
......@@ -417,8 +417,8 @@ void CompoundLib::LoadBondsFromDB(CompoundPtr comp, int pk) {
}
CompoundPtr CompoundLib::FindCompound(const String& id,
Compound::Dialect dialect) {
CompoundMap::iterator i=compound_cache_.find(id);
Compound::Dialect dialect) const {
CompoundMap::const_iterator i=compound_cache_.find(id);
if (i!=compound_cache_.end()) {
return i->second;
}
......
......@@ -25,41 +25,42 @@
// our own local copy of sqlite3
#include <ost/db/sqlite3.h>
#include <ost/conop/module_config.hh>
#include <ost/conop/compound.hh>
#include "module_config.hh"
#include "compound.hh"
#include "compound_lib_base.hh"
namespace ost { namespace conop {
class CompoundLib;
typedef boost::shared_ptr<CompoundLib> CompoundLibPtr;
typedef std::map<String, CompoundPtr> CompoundMap;
class DLLEXPORT_OST_CONOP CompoundLib {
class DLLEXPORT_OST_CONOP CompoundLib : public CompoundLibBase {
public:
static CompoundLibPtr Load(const String& database, bool readonly=true);
static CompoundLibPtr Create(const String& database);
~CompoundLib();
CompoundPtr FindCompound(const String& id, Compound::Dialect dialect);
Date GetCreationDate(void);
String GetOSTVersionUsed(void);
virtual CompoundPtr FindCompound(const String& id,
Compound::Dialect dialect) const;
void AddCompound(const CompoundPtr& compound);
CompoundLibPtr Copy(const String& filename) const;
void ClearCache();
Date GetCreationDate(void);
String GetOSTVersionUsed(void);
void SetChemLibInfo(void);
private:
CompoundLib();
void LoadAtomsFromDB(CompoundPtr comp, int pk);
void LoadBondsFromDB(CompoundPtr comp, int pk);
void LoadAtomsFromDB(CompoundPtr comp, int pk) const;
void LoadBondsFromDB(CompoundPtr comp, int pk) const;
private:
CompoundMap compound_cache_;
sqlite3* conn_;
bool chem_type_available_; // weather pdbx_type is available in db
bool name_available_; // weather name is available in db
Date creation_date_;
String ost_version_used_;
mutable CompoundMap compound_cache_;
sqlite3* conn_;
bool chem_type_available_; // weather pdbx_type is available in db
bool name_available_; // weather name is available in db
Date creation_date_;
String ost_version_used_;
};
}}
......
#ifndef OST_CONOP_COMPOUND_LIB_BASE_HH
#define OST_CONOP_COMPOUND_LIB_BASE_HH
#include "compound.hh"
namespace ost { namespace conop {
class CompoundLibBase;
typedef boost::shared_ptr<CompoundLibBase> CompoundLibBasePtr;
class DLLEXPORT_OST_CONOP CompoundLibBase {
virtual CompoundPtr FindCompound(const String& id,
Compound::Dialect dialect) const = 0;
};
}}
#endif
......@@ -16,6 +16,7 @@
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#include <ost/log.hh>
#include <ost/profile.hh>
#include <ost/mol/xcs_editor.hh>
......@@ -28,7 +29,6 @@
namespace ost { namespace conop {
void HeuristicProcessor::DoProcess(DiagnosticsPtr diags,
mol::EntityHandle ent) const {
}
......
......@@ -46,5 +46,6 @@ private:
}}
#endif
#include "minimal_compound_lib.hh"
namespace ost { namespace conop {
#include "standard_compounds.cc"
CompoundMap MinimalCompoundLib::compounds_ = MinimalCompoundLib::InitCompounds();
CompoundMap MinimalCompoundLib::InitCompounds() {
CompoundMap c;
c["ALA"] = MakeALACompound();
c["CYS"] = MakeCYSCompound();
c["ASP"] = MakeASPCompound();
c["GLU"] = MakeGLUCompound();
c["PHE"] = MakePHECompound();
c["GLY"] = MakeGLYCompound();
c["HIS"] = MakeHISCompound();
c["ILE"] = MakeILECompound();
c["LYS"] = MakeLYSCompound();
c["LEU"] = MakeLEUCompound();
c["MET"] = MakeMETCompound();
c["ASN"] = MakeASNCompound();
c["PRO"] = MakePROCompound();
c["GLN"] = MakeGLNCompound();
c["ARG"] = MakeARGCompound();
c["SER"] = MakeSERCompound();
c["THR"] = MakeTHRCompound();
c["VAL"] = MakeVALCompound();
c["TRP"] = MakeTRPCompound();
c["TYR"] = MakeTYRCompound();
c["G"] = MakeGCompound();
c["T"] = MakeTCompound();
c["A"] = MakeACompound();
c["C"] = MakeCCompound();
c["U"] = MakeUCompound();
c["DG"] = MakeDGCompound();
c["DT"] = MakeDTCompound();
c["DU"] = MakeDUCompound();
c["DC"] = MakeDCCompound();
c["DA"] = MakeDACompound();
return c;
}
CompoundPtr MinimalCompoundLib::FindCompound(const String& id,
Compound::Dialect dialect) const
{
CompoundMap::const_iterator i = MinimalCompoundLib::compounds_.find(id);
if (i != MinimalCompoundLib::compounds_.end()) {
return i->second;
}
return CompoundPtr();
}
}}
#ifndef OST_CONOP_MINIMAL_COMPOUND_LIB_HH
#define OST_CONOP_MINIMAL_COMPOUND_LIB_HH
#include "compound_lib_base.hh"
namespace ost { namespace conop {
class MinimalCompoundLib;
typedef boost::shared_ptr<MinimalCompoundLib> MinimalCompoundLibPtr;
// a minimal compound lib containing the definitions of the 20 standard
// amino acids and standard nucleotides
class MinimalCompoundLib : public CompoundLibBase {
public:
MinimalCompoundLib() {}
virtual CompoundPtr FindCompound(const String& id,
Compound::Dialect dialect) const;
private:
static CompoundMap InitCompounds();
// since this information is never going to change, it is shared
// between instances of minimal compound lib.
static CompoundMap compounds_;
};
}}
#endif
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment