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

Pre-condition Violation - Failed Expression: dir == Bond::ENDUPRIGHT || dir == Bond::ENDDOWNRIGHT #5433

Closed
bjonnh-work opened this issue Jul 19, 2022 · 4 comments
Labels
Milestone

Comments

@bjonnh-work
Copy link
Contributor

Describe the bug
Trying to open a specific molfile (with sanitize=True) raises:

****
Pre-condition Violation
bad dir
Violation occurred on line 382 in file /project/build/temp.linux-x86_64-cpython-310/rdkit/Code/GraphMol/Chirality.cpp
Failed Expression: dir == Bond::ENDUPRIGHT || dir == Bond::ENDDOWNRIGHT
****

To Reproduce
I simplified the failing molecule. This python code should trigger the error:

from rdkit import Chem
mol_file = """
  SomeFailingMolFile

  8  8  0  0  1  0            999 V2000
   -0.7145    1.2375    0.0000 C   0  0  2  0  0  0  0  0  0  0  0  0
    0.0000    0.8250    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.7145   -0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.7145   -1.2375    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000   -1.6500    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    0.7145   -1.2375    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.7145   -0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  6  0  0  0
  2  3  2  0  0  0  0
  3  4  1  4  0  0  0
  3  8  1  0  0  0  0
  4  5  2  0  0  0  0
  5  6  1  0  0  0  0
  6  7  1  0  0  0  0
  7  8  2  0  0  0  0
M  END
"""

Chem.MolFromMolBlock(mol_file, sanitize=False)  # This works

Chem.MolFromMolBlock(mol_file, sanitize=True) # This doesn't

Expected behavior
Expecting a specific error if the molfile is invalid (which is possible), but not an un-catchable error.

Configuration (please complete the following information):

  • RDKit version: Master and 2022.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • OS: Ubuntu 20.04 and 22.04
  • Python version (if relevant): Not relevant, seen the bug both in c++ and Python 3.10
  • Are you using conda? No
  • If you are not using conda: how did you install the RDKit? Pip, but same error with c++ code using rdkit from master
@bjonnh-work
Copy link
Contributor Author

(I have other examples if needed)

@bjonnh-work
Copy link
Contributor Author

The error in c++ code is the same:

terminate called after throwing an instance of 'Invar::Invariant'
  what():  bad dir

@greglandrum
Copy link
Member

I can reproduce this.
The mol block is not particularly sensible, but I agree that it shouldn't be throwing an exception here.

@greglandrum greglandrum added this to the 2022_03_5 milestone Jul 20, 2022
greglandrum added a commit to greglandrum/rdkit that referenced this issue Jul 26, 2022
Also a minor bit of refactoring
@bjonnh-work
Copy link
Contributor Author

Appreciate the quick fix! Thanks.

greglandrum added a commit that referenced this issue Aug 4, 2022
* Fixes #5433
Also a minor bit of refactoring

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

No branches or pull requests

2 participants