You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I know this repo is under few maintenance, but I'm still wondering how to support dative bonds in it.
The version of RDKIT used by the author, namely 2019.03.4, does not support dative bonds when it comes to Chem.MolFromSmiles(smiles). Therefore, I edit the codes and have successfully made this repo available to much newer versions of RDKIT such as version 2024.3.6, and the total process works quite fine under basic settings.
That's quite easy. All you need is python 3.11.9 and install these versions of python libraries above. You may also need to change line 17 of hgraph/chemutils.py into the following codes.
if mol is not None: Chem.Kekulize(mol, clearAromaticFlags=True)
When I try to deal with molecular with dative bonds, I add 'Chem.rdchem.BondType.DATIVE' to BOND_LIST in file hgraph/mol_graph. The get_vocab and preprocessing process works fine, however in train_generator, the training process raise error in line 284 of hgraph/decoder.py, saying that dimension does not match between cand_vecs and icls_vecs. A simple python slice kindly fixes the problem, and the following training process works well. (I have no answer on how to fix it, so I just use a python slice to skip it).
However, when I try to use the models trained from the process above to generate new ones, the code cannot work anymore.
(chem) root@autodl-container-06a3468bc2-0b38bd02:~/autodl-tmp/chem/hgraph2graph# python generate.py --vocab pt_vocab.txt --model ckpt/tmp/model.ckpt.12 --nsample 100 > output.txt
/root/miniconda3/envs/chem/lib/python3.11/site-packages/torch/nn/_reduction.py:51: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.
warnings.warn(warning.format(ret))
/root/autodl-tmp/chem/hgraph2graph/generate.py:44: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
model.load_state_dict(torch.load(args.model)[0])
0%| | 0/2 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/root/autodl-tmp/chem/hgraph2graph/generate.py", line 52, in <module>
smiles_list = model.sample(args.batch_size, greedy=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/autodl-tmp/chem/hgraph2graph/hgraph/hgnn.py", line 42, in sample
return self.decoder.decode((root_vecs, root_vecs, root_vecs), greedy=greedy, max_decode_step=150)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/autodl-tmp/chem/hgraph2graph/hgraph/decoder.py", line 410, in decode
new_atoms, new_bonds, attached = graph_batch.add_mol(bid, ismiles, inter_label, nth_child)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/autodl-tmp/chem/hgraph2graph/hgraph/inc_graph.py", line 144, in add_mol
self.add_edge(a1, a2, self.get_mess_feature(bond.GetBeginAtom(), bond_type, nth_child if a2 in attached else 0) ) #only child to father node (in intersection) have non-zero nth_child
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/autodl-tmp/chem/hgraph2graph/hgraph/inc_graph.py", line 41, in add_edge
self.agraph[j, self.graph.in_degree(j) - 1] = idx
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: index 10 is out of bounds for dimension 1 with size 10
I cannot figure out where this IndexError comes from and how to fix it, but I know datasets without dative bonds will never encounter this error.
Could anyone help me out? Any suggestions would be really appreciated!
The text was updated successfully, but these errors were encountered:
Hi, I know this repo is under few maintenance, but I'm still wondering how to support dative bonds in it.
The version of RDKIT used by the author, namely 2019.03.4, does not support dative bonds when it comes to Chem.MolFromSmiles(smiles). Therefore, I edit the codes and have successfully made this repo available to much newer versions of RDKIT such as version 2024.3.6, and the total process works quite fine under basic settings.
That's quite easy. All you need is python 3.11.9 and install these versions of python libraries above. You may also need to change line 17 of hgraph/chemutils.py into the following codes.
When I try to deal with molecular with dative bonds, I add 'Chem.rdchem.BondType.DATIVE' to BOND_LIST in file hgraph/mol_graph. The get_vocab and preprocessing process works fine, however in train_generator, the training process raise error in line 284 of hgraph/decoder.py, saying that dimension does not match between cand_vecs and icls_vecs. A simple python slice kindly fixes the problem, and the following training process works well. (I have no answer on how to fix it, so I just use a python slice to skip it).
Here is a part of my vocab, you can see there's DATIVE BONDS in it.
However, when I try to use the models trained from the process above to generate new ones, the code cannot work anymore.
I cannot figure out where this IndexError comes from and how to fix it, but I know datasets without dative bonds will never encounter this error.
Could anyone help me out? Any suggestions would be really appreciated!
The text was updated successfully, but these errors were encountered: