Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating point exception in OpenBabel::OBGroupContrib::Predict for logP with PA0 #2088

Open
1 task
jlkjr opened this issue Nov 19, 2019 · 2 comments
Open
1 task

Comments

@jlkjr
Copy link

jlkjr commented Nov 19, 2019

  • [ x] I believe this to be a bug with Open Babel
  • This is a feature request

Environment Information

Open Babel version: 3.0.0
Operating system and version: Ubuntu 18.04

Expected Behavior

No floating point exception. I think there needs to be a check in vector3::normalize() for zero vectors since it is very hard to guarantee that no callers ever have a zero vector.

Actual Behavior

vector3::normalize() gets a zero vector.

Thread 3 "bfd-server-debu" received signal SIGFPE, Arithmetic exception.
[Switching to Thread 0x7ffff5fc2700 (LWP 9010)]
0x0000000000dc98c9 in OpenBabel::vector3::normalize() ()
(gdb) bt
#0 0x0000000000dc98c9 in OpenBabel::vector3::normalize() ()
#1 0x0000000000e0543f in OpenBabel::OBBuilder::GetNewBondVector(OpenBabel::OBAtom*, double) ()
#2 0x0000000000b4723b in OpenBabel::OBMol::AddNewHydrogens(OpenBabel::HydrogenType, bool, double)
()
#3 0x0000000000d1b06f in OpenBabel::OBGroupContrib::Predict(OpenBabel::OBBase*, std::__cxx11::basic_string<char, std::char_traits, std::allocator >*) ()

Steps to Reproduce

This happens with any PDB structure containing the PA0 ligand (e.g. 3E3Z), a phenyl ring with arsenic attached. Getting the logP property. Example code (the 'content' string contains a mol format string with the PA0 compound:

std::ios_base::openmode imode = std::ios_base::in|std::ios_base::binary;
std::ios_base::openmode omode = std::ios_base::out|std::ios_base::binary;
std::stringstream ssi(content, imode);
std::stringstream sso("", omode);
OpenBabel::OBConversion conv(&ssi, &sso);
OpenBabel::OBFormat* molformat = conv.FindFormat("mol");
conv.SetInFormat(molformat);
OpenBabel::OBMol mol;
molformat->ReadMolecule(&mol, &conv);
json js;
OpenBabel::OBDescriptor* pDesc = OpenBabel::OBDescriptor::FindType("logP");
if(pDesc) js["LogP"] = pDesc->Predict(&mol);

mol string for PA0.178:A:
PA0
JL BFD1119190613
Written by the BioLeap Fragment Displayer(TM)[BioLeap, Inc.]
12 12 0 0 0 0 0 0 0 0999 V2000
7.2100 -10.0520 2.6110 As 0 3 0 0 0 0 0 0 0 1 0 0
7.1560 -10.0390 1.2400 C 0 0 0 0 0 0 0 0 0 2 0 0
6.2490 -9.2320 0.5650 C 0 0 0 0 0 0 0 0 0 3 0 0
6.2170 -9.2220 -0.8210 C 0 0 0 0 0 0 0 0 0 4 0 0
7.0890 -10.0140 -1.5640 C 0 0 0 0 0 0 0 0 0 5 0 0
8.0000 -10.8330 -0.9030 C 0 0 0 0 0 0 0 0 0 6 0 0
8.0240 -10.8420 0.4890 C 0 0 0 0 0 0 0 0 0 7 0 0
8.6560 -11.4170 0.9490 H 0 0 0 0 0 0 0 0 0 8 0 0
8.6120 -11.3920 -1.4070 H 0 0 0 0 0 0 0 0 0 9 0 0
7.0620 -9.9950 -2.5330 H 0 0 0 0 0 0 0 0 0 10 0 0
5.5780 -8.6550 -1.2800 H 0 0 0 0 0 0 0 0 0 11 0 0
5.6350 -8.6730 1.0660 H 0 0 0 0 0 0 0 0 0 12 0 0
1 2 1 0 0 0 0
2 3 2 0 0 0 0
2 7 1 0 0 0 0
3 4 1 0 0 0 0
4 5 2 0 0 0 0
5 6 1 0 0 0 0
7 6 2 0 0 0 0
3 12 1 0 0 0 0
4 11 1 0 0 0 0
5 10 1 0 0 0 0
6 9 1 0 0 0 0
7 8 1 0 0 0 0
M END

@e-kwsm
Copy link
Contributor

e-kwsm commented Nov 19, 2019

vector3& vector3 :: normalize ()
{
#ifdef OB_OLD_MATH_CHECKS
if( CanBeNormalized() )
(*this) /= length();
#else
(*this) /= length();
#endif
return(*this);
}

Should always check if the norm is not zero.

e-kwsm added a commit to e-kwsm/openbabel that referenced this issue Nov 21, 2019
@e-kwsm e-kwsm mentioned this issue Nov 21, 2019
@ghutchis
Copy link
Member

ghutchis commented Dec 2, 2019

Thanks for the detailed report.

Based on the backtrace, the bug is not in the vector code but in AddNewHydrogens / GetNewBondVector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants