dgllife.utils.CanonicalAtomFeaturizer¶
-
class
dgllife.utils.
CanonicalAtomFeaturizer
(atom_data_field='h')[source]¶ A default featurizer for atoms.
The atom features include:
One hot encoding of the atom type. The supported atom types include
C
,N
,O
,S
,F
,Si
,P
,Cl
,Br
,Mg
,Na
,Ca
,Fe
,As
,Al
,I
,B
,V
,K
,Tl
,Yb
,Sb
,Sn
,Ag
,Pd
,Co
,Se
,Ti
,Zn
,H
,Li
,Ge
,Cu
,Au
,Ni
,Cd
,In
,Mn
,Zr
,Cr
,Pt
,Hg
,Pb
.One hot encoding of the atom degree. The supported possibilities include
0 - 10
.One hot encoding of the number of implicit Hs on the atom. The supported possibilities include
0 - 6
.Formal charge of the atom.
Number of radical electrons of the atom.
One hot encoding of the atom hybridization. The supported possibilities include
SP
,SP2
,SP3
,SP3D
,SP3D2
.Whether the atom is aromatic.
One hot encoding of the number of total Hs on the atom. The supported possibilities include
0 - 4
.
We assume the resulting DGLGraph will not contain any virtual nodes.
- Parameters
atom_data_field (str) – Name for storing atom features in DGLGraphs, default to ‘h’.
Examples
>>> from rdkit import Chem >>> from dgllife.utils import CanonicalAtomFeaturizer
>>> mol = Chem.MolFromSmiles('CCO') >>> atom_featurizer = CanonicalAtomFeaturizer(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., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 1., 0.], [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., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 1., 0., 0.], [0., 0., 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., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1., 0., 0., 0.]])}
>>> # Get feature size for nodes >>> print(atom_featurizer.feat_size('feat')) 74
See also
BaseAtomFeaturizer
,WeaveAtomFeaturizer
,PretrainAtomFeaturizer
,AttentiveFPAtomFeaturizer
,PAGTNAtomFeaturizer
-
__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
.