diff --git a/modules/conop/doc/connectivity.rst b/modules/conop/doc/connectivity.rst index 1b06107701568178e3810f1fab5341c8fba620f8..9b56d65662df21b3350d7ce7cdb080bb984263a8 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 871329a47a14bce969e952e5710581b274902946..4bd468f36b23180c726f661f34a89227ee7168c0 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 21ff69293d0994d53c1c93eab9d2e7da62e4a732..6e5720675c912198e53fb0c0260d3514ecb91004 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 9cd65b269fe978a6d6c279ecd52cfe7928f578b4..9a0e8785175242a4a5e559ff719ae1e81a06f7d1 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 5eea4b42ed959185fb885067454e28595ac2c8a1..9adcc67479a6e7282721051c246217e4abec38bd 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);