openforcefield / openff-toolkit

The Open Forcefield Toolkit provides implementations of the SMIRNOFF format, parameterization engine, and other tools. Documentation available at http://open-forcefield-toolkit.readthedocs.io
http://openforcefield.org
MIT License
311 stars 90 forks source link

Make RDKitToolkitWrapper.from_file throw an exception if an rdmol fails to load #184

Open j-wags opened 5 years ago

j-wags commented 5 years ago

https://github.com/openforcefield/openforcefield/blob/topology/openforcefield/utils/toolkits.py#L1500

mattwthompson commented 2 years ago

Do we still want this? It is not the current behavior, i.e. if i try to sneak in an obviously-garbage SMILES string in a .smi file it just skips over it and proceeds:


In [1]: from openff.toolkit.utils.rdkit_wrapper import RDKitToolkitWrapper

In [2]: from openff.toolkit import Molecule

In [3]: wrapper = RDKitToolkitWrapper()

In [4]: !cat smiles.smi
CC
CCO
C#C#C#C#C

In [5]: Molecule.from_file("smiles.smi", toolkit_registry=wrapper)
[11:28:02] WARNING: no name column found on line 0
[11:28:02] WARNING: no name column found on line 1
[11:28:02] Explicit valence for atom # 1 C, 6, is greater than permitted
[11:28:02] ERROR: Could not sanitize molecule on line 2
[11:28:02] ERROR: Explicit valence for atom # 1 C, 6, is greater than permitted
Out[5]:
[Molecule with name '' and SMILES '[H]C([H])([H])C([H])([H])[H]',
 Molecule with name '' and SMILES '[H]C([H])([H])C([H])([H])O[H]']