diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a566df25067c9bb4c29189f432be9f5a380a111..4032c98398459f76e46ca43a81562b531adaa856 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ include(PROMOD3) set(PROMOD3_VERSION_MAJOR 1) set(PROMOD3_VERSION_MINOR 0) -set(PROMOD3_VERSION_PATCH 0) +set(PROMOD3_VERSION_PATCH 1) set(PROMOD3_VERSION_STRING ${PROMOD3_VERSION_MAJOR}.${PROMOD3_VERSION_MINOR}) set(PROMOD3_VERSION_STRING ${PROMOD3_VERSION_STRING}.${PROMOD3_VERSION_PATCH}) diff --git a/modelling/pymod/_pipeline.py b/modelling/pymod/_pipeline.py index 9fe9f49bbda5c4083226401b894c2fddf3bb2f00..53d6bfd33a5e9b1ddcee2ef3be709f6acf6b0ccf 100644 --- a/modelling/pymod/_pipeline.py +++ b/modelling/pymod/_pipeline.py @@ -13,7 +13,7 @@ from _ring_punches import * import ost from ost import mol from ost.mol import mm -import os +import os, math def BuildSidechains(mhandle, merge_distance=4, scorer=None, fragment_db=None, structure_db=None, torsion_sampler=None): @@ -140,6 +140,11 @@ def MinimizeModelEnergy(mhandle, max_iterations=12, max_iter_sd=20, settings.platform = mm.Platform.Reference sim = mm.Simulation(mhandle.model, settings) ost.LogWarning("Switched to slower reference platform of OpenMM!") + # check for certain failure -> we get NaN if atoms are on top each other + if math.isnan(sim.GetEnergy()): + ost.LogError("OpenMM could not minimize energy as atoms are on top of " + "each other!") + return # settings to check for stereochemical problems clashing_distances = mol.alg.DefaultClashingDistances() bond_stereo_chemical_param = mol.alg.DefaultBondStereoChemicalParams() diff --git a/modelling/src/model.cc b/modelling/src/model.cc index 404b5b13ae813bd9701227448ef45db6fdcc3cd6..95fbcc63dc6b07911af96073061d3d1d7495e4fd 100644 --- a/modelling/src/model.cc +++ b/modelling/src/model.cc @@ -46,8 +46,25 @@ bool CheckBackboneAtoms(ResidueView res) return true; } +void CleanupAtomConflicts(ResidueView& res) { + // remove atoms which are on top of any other atoms in the tpl entity + EntityView tpl = res.GetEntity(); + AtomViewList atom_views = res.GetAtomList(); + for (uint i = 0; i < atom_views.size(); ++i) { + AtomViewList on_top_atoms = tpl.FindWithin(atom_views[i].GetPos(), 0.0); + if (on_top_atoms.size() > 1) { + res.RemoveAtom(atom_views[i]); + // report + std::stringstream ss; + ss << "residue " << res.GetQualifiedName() << " has conflicting atom " + << atom_views[i].GetName() << " - skipping atom."; + LOG_WARNING(ss.str()); + } + } } +} // anon ns + int CountEnclosedGaps(ModellingHandle& mhandle, const StructuralGap& gap, bool insertions_only) { @@ -541,6 +558,8 @@ void BuildRawChain(const ost::seq::AlignmentHandle& aln, src_res.GetOneLetterCode() << "'"; throw promod3::Error(ss.str()); } + // remove atoms with conflicting positions (i.e. on top of each other) + CleanupAtomConflicts(src_res); // check for complete backbone, or in case of Calpha only model building, // if the src_res has a Calpha atom if(!CheckBackboneAtoms(src_res)){