Skip to content

Commit 84c170b

Browse files
committed
add aug rdkit norm prop
1 parent de0c97f commit 84c170b

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

chebai_graph/preprocessing/datasets/chebi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
from abc import ABC
33
from collections.abc import Callable
4+
from pprint import pformat
45

56
import pandas as pd
67
import torch
@@ -376,7 +377,7 @@ def load_processed_data_from_file(self, filename: str) -> list[dict]:
376377
)
377378
rank_zero_info(
378379
f"Finished loading dataset from properties.\nEncoding lengths: {prop_lengths}\n"
379-
f"Properties Categories {props_categories}\n"
380+
f"Properties Categories:\n{pformat(props_categories)}"
380381
f"n_atom_node_properties: {n_atom_node_properties}, "
381382
f"n_fg_node_properties: {n_fg_node_properties}, "
382383
f"n_bond_properties: {n_bond_properties}, "

chebai_graph/preprocessing/properties/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
AugBondAromaticity,
4444
AugBondType,
4545
AugBondInRing,
46+
AugRDKit2DNormalized,
4647
)
4748

4849
# isort: on
@@ -84,4 +85,5 @@
8485
"AugBondAromaticity",
8586
"AugBondType",
8687
"AugBondInRing",
88+
"AugRDKit2DNormalized",
8789
]

chebai_graph/preprocessing/properties/augmented_properties.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
AllNodeTypeProperty,
1515
AtomNodeTypeProperty,
1616
AugmentedBondProperty,
17+
AugmentedMoleculeProperty,
1718
FGNodeTypeProperty,
1819
FrozenPropertyAlias,
1920
)
@@ -402,3 +403,9 @@ class AugBondInRing(AugBondValueDefaulter, pr.BondInRing):
402403
"""
403404

404405
...
406+
407+
408+
# --------------------- Molecule Properties ------------------------------
409+
410+
411+
class AugRDKit2DNormalized(AugmentedMoleculeProperty, pr.RDKit2DNormalized): ...

chebai_graph/preprocessing/properties/base.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,17 @@ def _get_bond_prop_value(bond: Chem.rdchem.Bond | dict, prop: str) -> str:
439439
return bond[prop]
440440
else:
441441
raise TypeError("Bond/Edge should be of type `Chem.rdchem.Bond` or `dict`.")
442+
443+
444+
class AugmentedMoleculeProperty(MoleculeProperty, ABC):
445+
def get_property_value(self, augmented_mol: dict) -> list:
446+
"""
447+
Get molecular property values from augmented molecule dict.
448+
Args:
449+
augmented_mol (dict): Augmented molecule dict.
450+
Returns:
451+
list: Property values of molecule.
452+
"""
453+
mol: Chem.Mol = augmented_mol[AugmentedAtomProperty.MAIN_KEY]["atom_nodes"]
454+
assert isinstance(mol, Chem.Mol), "Molecule should be instance of `Chem.Mol`"
455+
return super().get_property_value(mol)

configs/data/chebi50_aug_prop_as_per_node.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ init_args:
1616
- chebai_graph.preprocessing.properties.IsHydrogenBondAcceptorFG
1717
- chebai_graph.preprocessing.properties.IsFGAlkyl
1818
# Graph Node type properties
19-
- chebai_graph.preprocessing.properties.RDKit2DNormalized
19+
- chebai_graph.preprocessing.properties.AugRDKit2DNormalized
2020
# Bond properties
2121
- chebai_graph.preprocessing.properties.BondLevel
2222
- chebai_graph.preprocessing.properties.AugBondAromaticity

0 commit comments

Comments
 (0)