DeepGraphLearning / torchdrug

A powerful and flexible machine learning platform for drug discovery
https://torchdrug.ai/
Apache License 2.0
1.43k stars 199 forks source link

The error when run tutorial of retrosynthesis #28

Closed Drlittlelab closed 3 years ago

Drlittlelab commented 3 years ago

Dear everyone,

I have install torchdrug correctly, and then follow the tutorial https://torchdrug.ai/docs/tutorials/retrosynthesis.html When I run the code as below:

from torchdrug import datasets

reaction_dataset = datasets.USPTO50k("D:/test/molecule-datasets/",
                                     node_feature="reaction_reaction_identification",
                                     kekulize=True)
synthon_dataset = datasets.USPTO50k("D:/test/molecule-dataset/", as_synthon=True,
                                    node_feature="synthon_completion",
                                    kekulize=True)

It happens error as follows:

Loading D:/test/molecule-datasets/data_processed.csv: 100%|██████████| 50017/50017 [00:00<00:00, 92358.37it/s]
Constructing molecules from SMILES:   0%|          | 0/50016 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "F:/workdir/pycharm/Retrosynthesis/main.py", line 5, in <module>
    kekulize=True)
  File "D:\soft\Anaconda3\envs\py37\lib\site-packages\decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "D:\soft\Anaconda3\envs\py37\lib\site-packages\torchdrug-0.1.0-py3.7.egg\torchdrug\core\core.py", line 282, in wrapper
    return init(self, *args, **kwargs)
  File "D:\soft\Anaconda3\envs\py37\lib\site-packages\torchdrug-0.1.0-py3.7.egg\torchdrug\datasets\uspto50k.py", line 63, in __init__
    **kwargs)
  File "D:\soft\Anaconda3\envs\py37\lib\site-packages\torchdrug-0.1.0-py3.7.egg\torchdrug\data\dataset.py", line 112, in load_csv
    self.load_smiles(smiles, targets, verbose=verbose, **kwargs)
  File "D:\soft\Anaconda3\envs\py37\lib\site-packages\torchdrug-0.1.0-py3.7.egg\torchdrug\data\dataset.py", line 232, in load_smiles
    mol = data.Molecule.from_molecule(mol, **kwargs)
  File "D:\soft\Anaconda3\envs\py37\lib\site-packages\torchdrug-0.1.0-py3.7.egg\torchdrug\data\molecule.py", line 183, in from_molecule
    func = R.get("features.atom.%s" % name)
  File "D:\soft\Anaconda3\envs\py37\lib\site-packages\torchdrug-0.1.0-py3.7.egg\torchdrug\core\core.py", line 208, in get
    raise KeyError("Can't find `%s` in `%s`" % (key, ".".join(keys[:i])))
KeyError: "Can't find `reaction_reaction_identification` in `features.atom`"

what is the problem? could you help me to solve it? Thanks.

KiddoZhu commented 3 years ago

Hi! I found this is a typo in our tutorial. Could you try to modify node_feature to "center_identification"?

Drlittlelab commented 3 years ago

Hi! I found this is a typo in our tutorial. Could you try to modify node_feature to "center_identification"?

I follow your suggestion, it still have an error as follows:


Loading D:/test/molecule-datasets/data_processed.csv: 100%|██████████| 50017/50017 [00:00<00:00, 90032.80it/s]
Constructing molecules from SMILES:   0%|          | 0/50016 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "F:/workdir/pycharm/Retrosynthesis/main.py", line 5, in <module>
    kekulize=True)
  File "D:\soft\Anaconda3\envs\py37\lib\site-packages\decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "D:\soft\Anaconda3\envs\py37\lib\site-packages\torchdrug-0.1.0-py3.7.egg\torchdrug\core\core.py", line 282, in wrapper
    return init(self, *args, **kwargs)
  File "D:\soft\Anaconda3\envs\py37\lib\site-packages\torchdrug-0.1.0-py3.7.egg\torchdrug\datasets\uspto50k.py", line 63, in __init__
    **kwargs)
  File "D:\soft\Anaconda3\envs\py37\lib\site-packages\torchdrug-0.1.0-py3.7.egg\torchdrug\data\dataset.py", line 112, in load_csv
    self.load_smiles(smiles, targets, verbose=verbose, **kwargs)
  File "D:\soft\Anaconda3\envs\py37\lib\site-packages\torchdrug-0.1.0-py3.7.egg\torchdrug\data\dataset.py", line 232, in load_smiles
    mol = data.Molecule.from_molecule(mol, **kwargs)
TypeError: from_molecule() got an unexpected keyword argument 'center_identification'
KiddoZhu commented 3 years ago

Sorry for the ambiguity. Could you set the argument as node_feature="center_identification"?

Drlittlelab commented 3 years ago

Sorry for the ambiguity. Could you set the argument as node_feature="center_identification"?

Thanks, it is ok now.

KiddoZhu commented 3 years ago

Fixed in a12bbd3.