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

Cannot create InChi of large molecule #1977

Open
mattwthompson opened this issue Dec 9, 2024 · 0 comments
Open

Cannot create InChi of large molecule #1977

mattwthompson opened this issue Dec 9, 2024 · 0 comments
Labels

Comments

@mattwthompson
Copy link
Member

Describe the bug

The toolkit fails to generate InChi for molecules with more than 1024 atoms.

To Reproduce

In this example, C340 passes but C341 errors. This is where the number of atoms crosses 1024.

from openff.toolkit import ForceField, Molecule
from openff.toolkit.utils.exceptions import EmptyInChiError


for n in [340, 341]:
    molecule = Molecule.from_smiles(n * "C")

    try:
        molecule.to_inchi()
    except EmptyInChiError as error:
        print(f"failed with {n=}")
        print(f"{error=}")
        continue

    print(f"passed with {n=}")

    # double-check that the SMILES conversion doesn't crash, and is probably correct
    assert n == len(molecule.to_smiles(explicit_hydrogens=False))

Output

With OpenEye installed and licensed:

passed with n=340
Warning: OECreateInChI: InChI only supports molecules with between 1 and 1023 atoms! (note: large molecule support is experimental)
failed with n=341
error=EmptyInChiError('OEChem failed to generate an InChI for the molecule.')

Without the license accessible:

passed with n=340
[14:27:42] ERROR: Too many atoms [did you forget 'LargeMolecules' switch?]

failed with n=341
error=EmptyInChiError('RDKit failed to generate an InChI for the molecule.')

Computing environment (please complete the following information):

Additional context

InChi versions prior to 1.05 (2017) were limited to 1024 atoms. OpenEye says they use version 1.06, so their error message is outdated in saying that InChi only supports molecules up to 1023 atoms and, as far as the release notes indices, that large molecule support is experimental.

I can't find what version of InChi is used by RDKit, but its error message indicates it uses 1.05+ and does support it with a flag being passed through.

https://docs.eyesopen.com/toolkits/python/oechemtk/OEChemFunctions/OEMolToInChI.html?highlight=inchi#OEChem::OEMolToInChI

https://github.com/IUPAC-InChI/InChI/blob/v1.07.1/INCHI-1-DOC/CHANGELOG.md#v105-release-2017-02-04

@mattwthompson mattwthompson changed the title Cannot create INCHI of large molecule Cannot create InChi of large molecule Dec 9, 2024
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

1 participant