Skip to content

Commit 9f40c83

Browse files
committed
hydrogen bond donor/acceptor prop for fg
1 parent 751f63e commit 9f40c83

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

chebai_graph/preprocessing/properties/augmented_properties.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
from rdkit import Chem
55

6-
from chebai_graph.preprocessing.property_encoder import OneHotEncoder, PropertyEncoder
6+
from chebai_graph.preprocessing.property_encoder import (
7+
BoolEncoder,
8+
OneHotEncoder,
9+
PropertyEncoder,
10+
)
711

812
from . import constants as k
913
from . import properties as pr
@@ -104,6 +108,43 @@ def _check_modify_atom_prop_value(self, atom: Chem.rdchem.Atom | Dict, prop: str
104108
return 0
105109

106110

111+
class IsHydrogenBondDonorFG(AugmentedAtomProperty):
112+
def __init__(self, encoder: Optional[PropertyEncoder] = None):
113+
super().__init__(encoder or BoolEncoder(self))
114+
# fmt: off
115+
# https://github.com/thaonguyen217/farm_molecular_representation/blob/main/src/(6)gen_FG_KG.py#L26-L31
116+
self._hydrogen_bond_donor: set[str] = {
117+
'hydroxyl', 'hydroperoxy', 'primary_amine', 'secondary_amine',
118+
'hydrazone', 'primary_ketimine', 'secondary_ketimine', 'primary_aldimine',
119+
'amide', 'sulfhydryl', 'sulfonic_acid', 'thiolester', 'hemiacetal',
120+
'hemiketal', 'carboxyl', 'aldoxime', 'ketoxime'
121+
}
122+
# fmt: on
123+
124+
def get_atom_value(self, atom: Chem.rdchem.Atom | Dict):
125+
fg = self._check_modify_atom_prop_value(atom, "FG")
126+
return fg in self._hydrogen_bond_donor
127+
128+
129+
class IsHydrogenBondAcceptorFG(AugmentedAtomProperty):
130+
def __init__(self, encoder: Optional[PropertyEncoder] = None):
131+
super().__init__(encoder or BoolEncoder(self))
132+
# fmt: off
133+
# https://github.com/thaonguyen217/farm_molecular_representation/blob/main/src/(6)gen_FG_KG.py#L33-L39
134+
self._hydrogen_bond_acceptor: set[str] = {
135+
'ether', 'peroxy', 'haloformyl', 'ketone', 'aldehyde', 'carboxylate',
136+
'carboxyl', 'ester', 'ketal', 'carbonate_ester', 'carboxylic_anhydride',
137+
'primary_amine', 'secondary_amine', 'tertiary_amine', '4_ammonium_ion',
138+
'hydrazone', 'primary_ketimine', 'secondary_ketimine', 'primary_aldimine',
139+
'amide', 'sulfhydryl', 'sulfonic_acid', 'thiolester', 'aldoxime', 'ketoxime'
140+
}
141+
# fmt: on
142+
143+
def get_atom_value(self, atom: Chem.rdchem.Atom | Dict):
144+
fg = self._check_modify_atom_prop_value(atom, "FG")
145+
return fg in self._hydrogen_bond_acceptor
146+
147+
107148
class AugNodeValueDefaulter(AugmentedAtomProperty, FrozenPropertyAlias, ABC):
108149
def get_atom_value(self, atom: Chem.rdchem.Atom | Dict):
109150
if isinstance(atom, Chem.rdchem.Atom):

0 commit comments

Comments
 (0)