|
3 | 3 |
|
4 | 4 | from rdkit import Chem |
5 | 5 |
|
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 | +) |
7 | 11 |
|
8 | 12 | from . import constants as k |
9 | 13 | from . import properties as pr |
@@ -104,6 +108,43 @@ def _check_modify_atom_prop_value(self, atom: Chem.rdchem.Atom | Dict, prop: str |
104 | 108 | return 0 |
105 | 109 |
|
106 | 110 |
|
| 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 | + |
107 | 148 | class AugNodeValueDefaulter(AugmentedAtomProperty, FrozenPropertyAlias, ABC): |
108 | 149 | def get_atom_value(self, atom: Chem.rdchem.Atom | Dict): |
109 | 150 | if isinstance(atom, Chem.rdchem.Atom): |
|
0 commit comments