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

IndexError when trying to construct Graph for single-atom molecule #224

Closed
rwxayheee opened this issue Jan 16, 2025 · 1 comment
Closed

Comments

@rwxayheee
Copy link

rwxayheee commented Jan 16, 2025

Hi,

Thank you for developing and maintaining espaloma. It has been a very valuable source of the parameters to our project, Meeko, interface for AutoDock and molecule parameterization. Our user (forlilab/Meeko#310) encountered an issue when trying to construct Graph for single-atom molecules. Initially, the issue was raised for Zn2+. Please see a non-metal example:

Input

from openff.toolkit.topology import Molecule
import espaloma as esp
from espaloma import Graph
mol = Molecule.from_smiles("[O-2]", allow_undefined_stereo=True)
Graph(mol)

Output

/Users/amyhe/micromamba/envs/has_espaloma/lib/python3.10/site-packages/dgl/heterograph.py:92: DGLWarning: Recommend creating graphs by `dgl.graph(data)` instead of `dgl.DGLGraph(data)`.
  dgl_warning(
Traceback (most recent call last):
  File "/Users/amyhe/Downloads/single_atom_graph.py", line 5, in <module>
    Graph(mol)
  File "/Users/amyhe/micromamba/envs/has_espaloma/lib/python3.10/site-packages/espaloma-0.3.2+3.g907d183-py3.10.egg/espaloma/graphs/graph.py", line 63, in __init__
    heterograph = self.get_heterograph_from_graph_and_mol(
  File "/Users/amyhe/micromamba/envs/has_espaloma/lib/python3.10/site-packages/espaloma-0.3.2+3.g907d183-py3.10.egg/espaloma/graphs/graph.py", line 137, in get_heterograph_from_graph_and_mol
    heterograph = esp.graphs.utils.read_heterogeneous_graph.from_homogeneous_and_mol(
  File "/Users/amyhe/micromamba/envs/has_espaloma/lib/python3.10/site-packages/espaloma-0.3.2+3.g907d183-py3.10.egg/espaloma/graphs/utils/read_heterogeneous_graph.py", line 150, in from_homogeneous_and_mol
    for x in idxs["n%s" % big_idx][
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

espaloma version:

'0.3.2+3.g907d183'

We understand that not all elements are supported, but would very much appreciate it if you could point us to a possible workaround or clarify the definition of graph - does it still make sense to single-atom molecules to have graph, or should we avoid constructing it at all?

Thank you for your time and kind advice in advance.

@rwxayheee
Copy link
Author

Just saw #191 and think it's the same issue. Closing to avoid duplicates

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

1 participant