From 8fc60a0c3345cb0557f81410b04effc902a4142a Mon Sep 17 00:00:00 2001 From: Marco Biasini <marco.biasini@unibas.ch> Date: Fri, 6 Sep 2013 15:51:50 +0200 Subject: [PATCH] fix rule-based conop with strict_hydrogens=false --- modules/conop/src/processor.cc | 27 ++++++++------------------- modules/conop/src/rule_based.cc | 12 +++++++++++- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/modules/conop/src/processor.cc b/modules/conop/src/processor.cc index a2e32c0bf..141003c65 100644 --- a/modules/conop/src/processor.cc +++ b/modules/conop/src/processor.cc @@ -290,15 +290,6 @@ void Processor::ConnectAtomsOfResidue(mol::ResidueHandle rh, CompoundPtr compound, bool strict_hydrogens) const { - - //if (!compound) { - // dist_connect(this, rh.GetAtomList()); - // return; - //} - //if (unknown_atoms_) { - // dist_connect(this, rh.GetAtomList()); - // return; - //} mol::XCSEditor e=rh.GetEntity().EditXCS(mol::BUFFERED_EDIT); BondSpecList::const_iterator j=compound->GetBondSpecs().begin(); mol::AtomHandleList atoms=rh.GetAtomList(); @@ -307,18 +298,16 @@ void Processor::ConnectAtomsOfResidue(mol::ResidueHandle rh, mol::AtomHandle a1=this->LocateAtom(atoms, bond.atom_one); mol::AtomHandle a2=this->LocateAtom(atoms, bond.atom_two); if (a1.IsValid() && a2.IsValid()) { + if (!strict_hydrogens && (a1.GetElement()=="H" || + a1.GetElement()=="D" || + a2.GetElement()=="H" || + a2.GetElement()=="D")) { + continue; + } if (!this->GetCheckBondFeasibility()) { - if (strict_hydrogens && (a1.GetElement()=="H" || - a2.GetElement()=="D")) { - continue; - } e.Connect(a1, a2, bond.order); } else { if (IsBondFeasible(a1, a2)) { - if (strict_hydrogens && (a1.GetElement()=="H" || - a2.GetElement()=="D")) { - continue; - } e.Connect(a1, a2, bond.order); } } @@ -405,8 +394,8 @@ void Processor::DistanceBasedConnect(mol::AtomHandle atom) const e=alist.end();it!=e;++it) { if (*it!=atom) { if (IsBondFeasible(atom, *it)) { - if (Processor::AreResiduesConsecutive(res_a, it->GetResidue()) || - it->GetResidue()==res_a) { + if (it->GetResidue()==res_a || + Processor::AreResiduesConsecutive(res_a, it->GetResidue())) { editor.Connect(*it, atom); } } diff --git a/modules/conop/src/rule_based.cc b/modules/conop/src/rule_based.cc index 902aec33d..6e8b712fe 100644 --- a/modules/conop/src/rule_based.cc +++ b/modules/conop/src/rule_based.cc @@ -47,7 +47,7 @@ void RuleBasedProcessor::DoProcess(DiagnosticsPtr diags, mol::ResidueHandle residue = *j; mol::AtomHandleList atoms_to_connect; CompoundPtr compound = lib_->FindCompound(residue.GetName(), Compound::PDB); - if (!compound) { + if (!compound && this->GetConnect()) { // process unknown residue... this->ProcessUnkResidue(diags, residue, atoms_to_connect); for (mol::AtomHandleList::iterator k = atoms_to_connect.begin(), @@ -79,6 +79,16 @@ void RuleBasedProcessor::DoProcess(DiagnosticsPtr diags, e3=atoms_to_connect.end(); k!= e3; ++k) { this->DistanceBasedConnect(*k); } + if (!this->GetStrictHydrogens()) { + mol::AtomHandleList atoms = residue.GetAtomList(); + for (mol::AtomHandleList::iterator k = atoms.begin(), + e3 = atoms.end(); k != e3; ++k) { + const String& ele = k->GetElement(); + if ((ele == "D" || ele == "H") && k->GetBondCount() == 0) { + this->DistanceBasedConnect(*k); + } + } + } } prev = residue; } -- GitLab