PyG graph to Smiles #9313
Love123github
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Can anyone help me, thank you very much.
code:
from torch_geometric.datasets import ZINC
from rdkit import Chem
from rdkit.Chem import AllChem
import torch_geometric.utils.smiles as tosmiles
dataset = ZINC(root='/content/data')
data = dataset[0]
print(data)
SMILES_0 = tosmiles.to_smiles(data)
output:
Data(x=[33, 1], edge_index=[2, 72], edge_attr=[72], y=[1])
error:
IndexError Traceback (most recent call last)
in <cell line: 1>()
----> 1 SMILES_0 = tosmiles.to_smiles(data)
/usr/local/lib/python3.10/dist-packages/torch_geometric/utils/smiles.py in to_smiles(data, kekulize)
166 for i in range(data.num_nodes):
167 atom = Chem.Atom(int(data.x[i, 0]))
--> 168 atom.SetChiralTag(Chem.rdchem.ChiralType.values[int(data.x[i, 1])])
169 atom.SetFormalCharge(x_map['formal_charge'][int(data.x[i, 3])])
170 atom.SetNumExplicitHs(x_map['num_hs'][int(data.x[i, 4])])
IndexError: index 1 is out of bounds for dimension 1 with size 1
Beta Was this translation helpful? Give feedback.
All reactions