66from torchdrug .core import Registry as R
77
88
9+ # orderd by perodic table
910atom_vocab = ["H" , "B" , "C" , "N" , "O" , "F" , "Mg" , "Si" , "P" , "S" , "Cl" , "Cu" , "Zn" , "Se" , "Br" , "Sn" , "I" ]
1011atom_vocab = {a : i for i , a in enumerate (atom_vocab )}
1112degree_vocab = range (7 )
@@ -45,7 +46,6 @@ def onehot(x, vocab, allow_unknown=False):
4546 return feature
4647
4748
48- # TODO: this one is too slow
4949@R .register ("features.atom.default" )
5050def atom_default (atom ):
5151 """Default atom feature.
@@ -68,8 +68,6 @@ def atom_default(atom):
6868 GetIsAromatic(): whether the atom is aromatic
6969
7070 IsInRing(): whether the atom is in a ring
71-
72- atom_position(): the 3D position of the atom
7371 """
7472 return onehot (atom .GetSymbol (), atom_vocab , allow_unknown = True ) + \
7573 onehot (atom .GetChiralTag (), chiral_tag_vocab ) + \
@@ -78,8 +76,7 @@ def atom_default(atom):
7876 onehot (atom .GetTotalNumHs (), num_hs_vocab ) + \
7977 onehot (atom .GetNumRadicalElectrons (), num_radical_vocab ) + \
8078 onehot (atom .GetHybridization (), hybridization_vocab ) + \
81- [atom .GetIsAromatic (), atom .IsInRing ()] + \
82- atom_position (atom )
79+ [atom .GetIsAromatic (), atom .IsInRing ()]
8380
8481
8582@R .register ("features.atom.center_identification" )
@@ -192,8 +189,10 @@ def atom_property_prediction(atom):
192189@R .register ("features.atom.position" )
193190def atom_position (atom ):
194191 """
195- Atom position.
192+ Atom position in the molecular conformation .
196193 Return 3D position if available, otherwise 2D position is returned.
194+
195+ Note it takes much time to compute the conformation for large molecules.
197196 """
198197 mol = atom .GetOwningMol ()
199198 if mol .GetNumConformers () == 0 :
@@ -228,19 +227,20 @@ def bond_default(bond):
228227 GetStereo(): one-hot embedding for the stereo configuration of the bond
229228
230229 GetIsConjugated(): whether the bond is considered to be conjugated
231-
232- bond_length: the length of the bond
233230 """
234231 return onehot (bond .GetBondType (), bond_type_vocab ) + \
235232 onehot (bond .GetBondDir (), bond_dir_vocab ) + \
236233 onehot (bond .GetStereo (), bond_stereo_vocab ) + \
237- [int (bond .GetIsConjugated ())] + \
238- bond_length (bond )
234+ [int (bond .GetIsConjugated ())]
239235
240236
241237@R .register ("features.bond.length" )
242238def bond_length (bond ):
243- """Bond length"""
239+ """
240+ Bond length in the molecular conformation.
241+
242+ Note it takes much time to compute the conformation for large molecules.
243+ """
244244 mol = bond .GetOwningMol ()
245245 if mol .GetNumConformers () == 0 :
246246 mol .Compute2DCoords ()
0 commit comments