From 7d6fdf3af706129846ba1a11b450a41d63a2cf92 Mon Sep 17 00:00:00 2001 From: Marco Biasini <marco.biasini@unibas.ch> Date: Mon, 4 Apr 2011 00:15:54 +0200 Subject: [PATCH] added RuleBasedBuilder::GetUnknownAtoms --- modules/conop/doc/connectivity.rst | 7 +++++++ modules/conop/pymod/export_builder.cc | 1 + modules/conop/src/chemdict_tool.cc | 4 +++- modules/conop/src/rule_based_builder.cc | 24 ++++++++++++++++++++++++ modules/conop/src/rule_based_builder.hh | 5 ++++- 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/modules/conop/doc/connectivity.rst b/modules/conop/doc/connectivity.rst index 1b0610770..9b56d6566 100644 --- a/modules/conop/doc/connectivity.rst +++ b/modules/conop/doc/connectivity.rst @@ -250,4 +250,11 @@ The RuleBasedBuilder class :param atom: The missing atom's name :type atom: string + + .. method:: GetUnknownAtoms(residue) + + Returns the unknown atoms of this residue, that is all atoms that + are not part of the compound lib definition. + + :rtype: list of :class:`~ost.mol.AtomHandle` instances diff --git a/modules/conop/pymod/export_builder.cc b/modules/conop/pymod/export_builder.cc index 871329a47..4bd468f36 100644 --- a/modules/conop/pymod/export_builder.cc +++ b/modules/conop/pymod/export_builder.cc @@ -55,5 +55,6 @@ void export_Builder() { class_<RuleBasedBuilder, bases<Builder> >("RuleBasedBuilder", init<const CompoundLibPtr&>()) .add_property("compound_lib", &RuleBasedBuilder::GetCompoundLib) + .def("GetUnknownAtoms", &RuleBasedBuilder::GetUnknownAtoms) ; } diff --git a/modules/conop/src/chemdict_tool.cc b/modules/conop/src/chemdict_tool.cc index 21ff69293..6e5720675 100644 --- a/modules/conop/src/chemdict_tool.cc +++ b/modules/conop/src/chemdict_tool.cc @@ -80,7 +80,9 @@ int main(int argc, char const *argv[]) PrintUsage(); return 0; } - + if (!compound_lib) { + return 0; + } assert(compound_lib); conop::CompoundLibPtr in_mem_lib=compound_lib->Copy(":memory:"); compound_lib.reset(); diff --git a/modules/conop/src/rule_based_builder.cc b/modules/conop/src/rule_based_builder.cc index 9cd65b269..9a0e87851 100644 --- a/modules/conop/src/rule_based_builder.cc +++ b/modules/conop/src/rule_based_builder.cc @@ -82,6 +82,30 @@ bool RuleBasedBuilder::HasUnknownAtoms(mol::ResidueHandle res) return false; } +mol::AtomHandleList RuleBasedBuilder::GetUnknownAtoms(mol::ResidueHandle res) +{ + mol::AtomHandleList unknown; + this->LookupCompound(res); + if (!last_compound_) { + return unknown; + } + this->ReorderAtoms(res, last_compound_); + AtomSpecList::const_iterator j=last_compound_->GetAtomSpecs().begin(); + mol::AtomHandleList atoms=res.GetAtomList(); + mol::AtomHandleList::iterator i=atoms.begin(); + for (mol::AtomHandleList::iterator + i=atoms.begin(), e=atoms.end(); i!=e; ++i) { + if ((*i).Impl()->GetState()==std::numeric_limits<unsigned int>::max()) { + if (((*i).GetElement()=="H" || (*i).GetElement()=="D") && + this->GetStrictHydrogenMode()==false) { + continue; + } + unknown.push_back(*i); + } + } + return unknown; +} + void RuleBasedBuilder::FillAtomProps(mol::AtomHandle atom, const AtomSpec& spec) { Conopology& conop_inst=Conopology::Instance(); diff --git a/modules/conop/src/rule_based_builder.hh b/modules/conop/src/rule_based_builder.hh index 5eea4b42e..9adcc6747 100644 --- a/modules/conop/src/rule_based_builder.hh +++ b/modules/conop/src/rule_based_builder.hh @@ -117,7 +117,10 @@ public: virtual void FillResidueProps(mol::ResidueHandle residue); /// \brief whether the residue has unknown atoms - bool HasUnknownAtoms(mol::ResidueHandle res); + bool HasUnknownAtoms(mol::ResidueHandle res); + + mol::AtomHandleList GetUnknownAtoms(mol::ResidueHandle res); + /// \brief Check whether the residue has all required atoms. This does not /// include hydrogens and leaving atoms such as the terminal OXT. virtual bool IsResidueComplete(const mol::ResidueHandle& residue); -- GitLab