From d788212928fbabbdb4618bf31437b9cd52281dbb Mon Sep 17 00:00:00 2001 From: Marco Biasini <mvbiasini@gmail.com> Date: Sat, 13 Jul 2013 19:43:21 +0200 Subject: [PATCH] improve GuessAtomElement It seems, just looking at the number of atoms is not enough, we also have to look at the hetatm flag. The whole element guessing code is still quite shaky and should be improved. --- modules/conop/src/heuristic.cc | 2 +- modules/conop/src/processor.cc | 4 ++-- modules/conop/src/processor.hh | 3 ++- modules/conop/src/rule_based.cc | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/conop/src/heuristic.cc b/modules/conop/src/heuristic.cc index 8c5277206..a2f931848 100644 --- a/modules/conop/src/heuristic.cc +++ b/modules/conop/src/heuristic.cc @@ -37,7 +37,7 @@ void HeuristicProcessor::ProcessUnkResidue(DiagnosticsPtr diags, i = atoms.begin(), e = atoms.end(); i != e; ++i) { mol::AtomHandle a = *i; if (!Conopology::Instance().IsValidElement(a.GetElement())) - a.SetElement(GuessAtomElement(a.GetName(), atoms.size())); + a.SetElement(GuessAtomElement(a.GetName(), a.IsHetAtom(), atoms.size())); } res.SetChemClass(GuessChemClass(res)); diff --git a/modules/conop/src/processor.cc b/modules/conop/src/processor.cc index 4ce93eba6..a2e32c0bf 100644 --- a/modules/conop/src/processor.cc +++ b/modules/conop/src/processor.cc @@ -133,7 +133,7 @@ mol::ChemClass GuessChemClass(mol::ResidueHandle res) return mol::ChemClass(); } -String GuessAtomElement(const String& aname, int atom_count) +String GuessAtomElement(const String& aname, bool hetatm, int atom_count) { static String l1[] = { "H","C","N","O","P","S","K" @@ -158,7 +158,7 @@ String GuessAtomElement(const String& aname, int atom_count) if(ele[0]=='H') { return "H"; } - if (atom_count > 1) { + if (!hetatm || atom_count > 1) { if (ele=="CA" || ele=="CB") { return "C"; } diff --git a/modules/conop/src/processor.hh b/modules/conop/src/processor.hh index d66f6ccbc..1283fd863 100644 --- a/modules/conop/src/processor.hh +++ b/modules/conop/src/processor.hh @@ -126,7 +126,8 @@ String DLLEXPORT_OST_CONOP StringFromConopAction(ConopAction action); /// \brief guess element of atom based on name and hetatm flag -String DLLEXPORT_OST_CONOP GuessAtomElement(const String& atom_name, int atom_count); +String DLLEXPORT_OST_CONOP GuessAtomElement(const String& atom_name, bool hetatm, + int atom_count); /// \brief guess chemclass based on atoms of residue mol::ChemClass DLLEXPORT_OST_CONOP GuessChemClass(mol::ResidueHandle res); diff --git a/modules/conop/src/rule_based.cc b/modules/conop/src/rule_based.cc index c4c870005..902aec33d 100644 --- a/modules/conop/src/rule_based.cc +++ b/modules/conop/src/rule_based.cc @@ -102,7 +102,7 @@ void RuleBasedProcessor::ProcessUnkResidue(DiagnosticsPtr diags, e = atoms.end(); i !=e; ++i) { remaining_atoms.push_back(*i); if (!Conopology::Instance().IsValidElement(i->GetElement())) - i->SetElement(GuessAtomElement(i->GetName(), atoms.size())); + i->SetElement(GuessAtomElement(i->GetName(), i->IsHetAtom(), atoms.size())); } } // Don't do anything if treatment is set to SILENT @@ -139,7 +139,7 @@ void RuleBasedProcessor::ProcessUnkAtoms(DiagnosticsPtr diags, e = unks.end(); i !=e; ++i) { remaining_atoms.push_back(*i); if (!Conopology::Instance().IsValidElement(i->GetElement())) - i->SetElement(GuessAtomElement(i->GetName(), res.GetAtomCount())); + i->SetElement(GuessAtomElement(i->GetName(), i->IsHetAtom(), res.GetAtomCount())); } } -- GitLab