From 3eba172e2bfde50fc2e7ec70027159682f62abf7 Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@stud.unibas.ch> Date: Mon, 27 May 2013 18:51:50 +0200 Subject: [PATCH] added checker function for residue completeness in compound lib. not tested yet. --- modules/conop/pymod/export_compound.cc | 3 +++ modules/conop/src/compound_lib_base.cc | 26 ++++++++++++++++++++++++++ modules/conop/src/compound_lib_base.hh | 5 +++++ 3 files changed, 34 insertions(+) diff --git a/modules/conop/pymod/export_compound.cc b/modules/conop/pymod/export_compound.cc index 33cbe0536..4ed7248f4 100644 --- a/modules/conop/pymod/export_compound.cc +++ b/modules/conop/pymod/export_compound.cc @@ -135,6 +135,9 @@ void export_Compound() { .def("Load", &CompoundLib::Load, arg("readonly")=true).staticmethod("Load") .def("FindCompound", &find_compound, (arg("tlc"), arg("dialect")="PDB")) + .def("IsResidueComplete",&CompoundLib::IsResidueComplete, (arg("residue"), + arg("check_hydrogens")=false, + arg("dialect")="PDB")) .def("ClearCache", &CompoundLib::ClearCache) .def("GetOSTVersionUsed", &CompoundLib::GetOSTVersionUsed) .def("GetCreationDate", &get_creation_date, (arg("comp_lib"))) diff --git a/modules/conop/src/compound_lib_base.cc b/modules/conop/src/compound_lib_base.cc index e69de29bb..b5071e00f 100644 --- a/modules/conop/src/compound_lib_base.cc +++ b/modules/conop/src/compound_lib_base.cc @@ -0,0 +1,26 @@ +#include "compound_lib_base.hh" + +namespace ost { namespace conop { + +bool CompoundLibBase::IsResidueComplete(const ost::mol::ResidueHandle& res, bool check_hydrogens, Compound::Dialect dialect) const{ + + CompoundPtr compound = this->FindCompound(res.GetName(), dialect); + + AtomSpecList a_spec = compound->GetAtomSpecs(); + + for(AtomSpecList::const_iterator it=a_spec.begin(); it!=a_spec.end();++it){ + if(it->element=="H" || it->element=="D"){ + if(check_hydrogens){ + if(!res.FindAtom(it->name).IsValid()){ + return false; + } + } + } + if(!res.FindAtom(it->name).IsValid()){ + return false; + } + } + return true; +} + +}}//namespace diff --git a/modules/conop/src/compound_lib_base.hh b/modules/conop/src/compound_lib_base.hh index 350307eb5..aee5215b9 100644 --- a/modules/conop/src/compound_lib_base.hh +++ b/modules/conop/src/compound_lib_base.hh @@ -2,6 +2,7 @@ #define OST_CONOP_COMPOUND_LIB_BASE_HH #include "compound.hh" +#include <ost/mol/residue_handle.hh> namespace ost { namespace conop { @@ -13,6 +14,10 @@ public: virtual ~CompoundLibBase() {} virtual CompoundPtr FindCompound(const String& id, Compound::Dialect dialect) const = 0; + + bool IsResidueComplete(const ost::mol::ResidueHandle& res, + bool check_hydrogens, + Compound::Dialect) const; }; }} -- GitLab