dgllife.utils.PAGTNAtomFeaturizer

class dgllife.utils.PAGTNAtomFeaturizer(atom_data_field='h')[source]

The atom featurizer used in PAGTN

PAGTN is introduced in Path-Augmented Graph Transformer Network.

The atom features include:

  • One hot encoding of the atom type.

  • One hot encoding of formal charge of the atom.

  • One hot encoding of the atom degree

  • One hot encoding of explicit valence of an atom. The supported possibilities include 0 - 6.

  • One hot encoding of implicit valence of an atom. The supported possibilities include 0 - 5.

  • Whether the atom is aromatic.

Parameters

atom_data_field (str) – Name for storing atom features in DGLGraphs, default to ‘h’.

Examples

>>> from rdkit import Chem
>>> from dgllife.utils import PAGTNAtomFeaturizer
>>> mol = Chem.MolFromSmiles('C')
>>> atom_featurizer = PAGTNAtomFeaturizer(atom_data_field='feat')
>>> atom_featurizer(mol)
{'feat': tensor([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
                  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
                  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
                  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 1., 0., 0.,
                  0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
                  0., 1., 0., 0.]])}
>>> # Get feature size for nodes
>>> print(atom_featurizer.feat_size())
94
__init__(atom_data_field='h')[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([atom_data_field])

Initialize self.

feat_size([feat_name])

Get the feature size for feat_name.