From 409005942429428162837ae66ceacb0de69181f3 Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Tue, 1 Nov 2022 11:48:34 +0100 Subject: [PATCH] Ensure correct elements for terminal oxygens when using AMBER forcefield --- modules/mol/mm/src/topology_creator.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/mol/mm/src/topology_creator.cc b/modules/mol/mm/src/topology_creator.cc index dede191f8..00ba0738d 100644 --- a/modules/mol/mm/src/topology_creator.cc +++ b/modules/mol/mm/src/topology_creator.cc @@ -164,6 +164,21 @@ TopologyPtr TopologyCreator::Create(ost::mol::EntityHandle& ent, if(hc){ hc->ApplyOnBuildingBlock(block); hc->ApplyOnResidue(*i,ed); + // hack for AMBER forcefield + // GROMACS hijacks the hydrogen constructor to construct terminal oxygens + // in the case of the AMBER forcefield, their elements are thus set to H. + // Forcefields in general don't care about elements, they just care for + // atom types and their respective masses. There is no easy way to tell + // the hydrogen constructor that the element is not H. I just hardcode the + // AMBER case here. Please forgive me... + ost::mol::AtomHandle at = i->FindAtom("OC1"); + if(at.IsValid()) { + at.SetElement("O"); + } + at = i->FindAtom("OC2"); + if(at.IsValid()) { + at.SetElement("O"); + } } //check for n terminus if(i->HasProp("n_ter")){ -- GitLab