Closed lvkd84 closed 2 years ago
When I execute the following block of code:
from rdkit.Chem import MolFromSmiles from dgllife.utils import mol_to_bigraph, mol_to_graph from dgllife.utils.featurizers import CanonicalAtomFeaturizer, CanonicalBondFeaturizer mol = MolFromSmiles('CCO') mol_to_bigraph(mol, node_featurizer=CanonicalAtomFeaturizer, edge_featurizer=CanonicalBondFeaturizer)
I got the following error:
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-72-f95cc3af6dcb> in <module>() 6 mol_to_bigraph(mol, 7 node_featurizer=CanonicalAtomFeaturizer, ----> 8 edge_featurizer=CanonicalBondFeaturizer) 2 frames /usr/local/lib/python3.7/site-packages/dgllife/utils/mol_to_graph.py in mol_to_bigraph(mol, add_self_loop, node_featurizer, edge_featurizer, canonical_atom_order, explicit_hydrogens, num_virtual_nodes) 269 return mol_to_graph(mol, partial(construct_bigraph_from_mol, add_self_loop=add_self_loop), 270 node_featurizer, edge_featurizer, --> 271 canonical_atom_order, explicit_hydrogens, num_virtual_nodes) 272 273 def smiles_to_bigraph(smiles, add_self_loop=False, /usr/local/lib/python3.7/site-packages/dgllife/utils/mol_to_graph.py in mol_to_graph(mol, graph_constructor, node_featurizer, edge_featurizer, canonical_atom_order, explicit_hydrogens, num_virtual_nodes) 83 84 if node_featurizer is not None: ---> 85 g.ndata.update(node_featurizer(mol)) 86 87 if edge_featurizer is not None: /usr/lib/python3.7/_collections_abc.py in update(*args, **kwds) 844 self[key] = other[key] 845 else: --> 846 for key, value in other: 847 self[key] = value 848 for key, value in kwds.items(): TypeError: 'CanonicalAtomFeaturizer' object is not iterable
Environment: python=3.7 rdkit=2020.09.02
CanonicalAtomFeaturizer is a class and you need to create an object of it.
CanonicalAtomFeaturizer
That makes sense. Closing.
When I execute the following block of code:
I got the following error:
Environment: python=3.7 rdkit=2020.09.02