From ec7489455d592d21912c2cca2c804f565f61a748 Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Fri, 26 Apr 2024 18:09:25 +0200 Subject: [PATCH] find membrane: guard against cases with zero solvent accessibilities There are structures with only atoms that lie on top of each other. This is typically a fuckup but hey, better a nice error than the segfault that would be caused by this... --- modules/mol/alg/src/find_membrane.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/mol/alg/src/find_membrane.cc b/modules/mol/alg/src/find_membrane.cc index 8669efd8a..d3ebede1b 100644 --- a/modules/mol/alg/src/find_membrane.cc +++ b/modules/mol/alg/src/find_membrane.cc @@ -986,6 +986,21 @@ FindMemParam FindMembrane(ost::mol::EntityView& ent, "of heavy atoms!"); } + // number of atom position with non-zero accessibility is relevant too + int n_nonzero_asa = 0; + for(Real acc: asas) { + if(acc != 0.0) { + ++n_nonzero_asa; + } + } + if(n_nonzero_asa < 10) { + throw ost::Error("Cannot detect membrane with such a low number of " + "atoms with non-zero accessibility. Potential failure " + "mode: Atoms on top of each other result in zero " + "solvent accessibility (yes this happens)."); + } + + // we always optimizer along the z-axis. // We therefore have to transform the positions. We use a rotation // around the z-axis with subsequent rotation around the x-axis for this task -- GitLab