D4CMPP2 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- D4CMPP2/_Data/AGENTS.md +24 -0
- D4CMPP2/_Data/Aqsoldb.csv +9291 -0
- D4CMPP2/_Data/BradleyMP.csv +3042 -0
- D4CMPP2/_Data/Lipophilicity.csv +1131 -0
- D4CMPP2/_Data/README.md +8 -0
- D4CMPP2/_Data/__init__.py +26 -0
- D4CMPP2/_Data/optical.csv +20237 -0
- D4CMPP2/_Data/test.csv +190 -0
- D4CMPP2/__init__.py +16 -0
- D4CMPP2/__main__.py +5 -0
- D4CMPP2/_main.py +500 -0
- D4CMPP2/cli.py +7 -0
- D4CMPP2/exceptions.py +53 -0
- D4CMPP2/grid_search.py +259 -0
- D4CMPP2/network_refer.yaml +160 -0
- D4CMPP2/networks/AFP_model.py +72 -0
- D4CMPP2/networks/AFPwithSolv_model.py +72 -0
- D4CMPP2/networks/DMPNN_model.py +90 -0
- D4CMPP2/networks/DMPNNwithSolv_model.py +89 -0
- D4CMPP2/networks/GAT_model.py +48 -0
- D4CMPP2/networks/GATwithSolv_model.py +63 -0
- D4CMPP2/networks/GCN_model.py +113 -0
- D4CMPP2/networks/GCNwithSolv_model.py +103 -0
- D4CMPP2/networks/GC_model.py +122 -0
- D4CMPP2/networks/ISATPM_model.py +14 -0
- D4CMPP2/networks/ISATPN_model.py +199 -0
- D4CMPP2/networks/ISAT_model.py +90 -0
- D4CMPP2/networks/MPNN_model.py +56 -0
- D4CMPP2/networks/MPNNwithSolv_model.py +72 -0
- D4CMPP2/networks/__init__.py +25 -0
- D4CMPP2/networks/base.py +250 -0
- D4CMPP2/networks/registry.py +187 -0
- D4CMPP2/networks/src/AFP.py +118 -0
- D4CMPP2/networks/src/BiDropout.py +29 -0
- D4CMPP2/networks/src/DMPNN.py +35 -0
- D4CMPP2/networks/src/GAT.py +69 -0
- D4CMPP2/networks/src/GC.py +85 -0
- D4CMPP2/networks/src/GCN.py +71 -0
- D4CMPP2/networks/src/ISAT.py +153 -0
- D4CMPP2/networks/src/Linear.py +49 -0
- D4CMPP2/networks/src/MPNN.py +56 -0
- D4CMPP2/networks/src/SolventLayer.py +62 -0
- D4CMPP2/networks/src/__init__.py +0 -0
- D4CMPP2/networks/src/distGCN.py +21 -0
- D4CMPP2/networks/src/pyg_hetero.py +24 -0
- D4CMPP2/optimize.py +472 -0
- D4CMPP2/src/Analyzer/ISAAnalyzer.py +458 -0
- D4CMPP2/src/Analyzer/ISAPNAnalyzer.py +366 -0
- D4CMPP2/src/Analyzer/ISAwSAnalyzer.py +117 -0
- D4CMPP2/src/Analyzer/MolAnalyzer.py +319 -0
- D4CMPP2/src/Analyzer/__init__.py +54 -0
- D4CMPP2/src/Analyzer/core.py +480 -0
- D4CMPP2/src/Analyzer/factory.py +166 -0
- D4CMPP2/src/Analyzer/interpretation.py +232 -0
- D4CMPP2/src/Analyzer/results.py +101 -0
- D4CMPP2/src/DataManager/Dataset/GraphDataset.py +314 -0
- D4CMPP2/src/DataManager/Dataset/ISAGraphDataset.py +384 -0
- D4CMPP2/src/DataManager/Dataset/__init__.py +0 -0
- D4CMPP2/src/DataManager/GraphGenerator/ISAGraphGenerator.py +223 -0
- D4CMPP2/src/DataManager/GraphGenerator/MolGraphGenerator.py +73 -0
- D4CMPP2/src/DataManager/GraphGenerator/__init__.py +14 -0
- D4CMPP2/src/DataManager/ISADataManager.py +67 -0
- D4CMPP2/src/DataManager/MolDataManager.py +735 -0
- D4CMPP2/src/DataManager/__init__.py +14 -0
- D4CMPP2/src/DataManager/contracts.py +179 -0
- D4CMPP2/src/NetworkManager/ISANetworkManager.py +12 -0
- D4CMPP2/src/NetworkManager/NetworkManager.py +520 -0
- D4CMPP2/src/NetworkManager/__init__.py +14 -0
- D4CMPP2/src/PostProcessor.py +160 -0
- D4CMPP2/src/TrainManager/ISATrainManager.py +26 -0
- D4CMPP2/src/TrainManager/TrainManager.py +254 -0
- D4CMPP2/src/TrainManager/__init__.py +14 -0
- D4CMPP2/src/TrainManager/callbacks.py +119 -0
- D4CMPP2/src/__init__.py +0 -0
- D4CMPP2/src/utils/PATH.py +246 -0
- D4CMPP2/src/utils/__init__.py +0 -0
- D4CMPP2/src/utils/argparser.py +56 -0
- D4CMPP2/src/utils/checkpointing.py +90 -0
- D4CMPP2/src/utils/config_resolution.py +123 -0
- D4CMPP2/src/utils/config_validation.py +370 -0
- D4CMPP2/src/utils/csv_validation.py +105 -0
- D4CMPP2/src/utils/data_quality.py +181 -0
- D4CMPP2/src/utils/featureizer.py +202 -0
- D4CMPP2/src/utils/functional_group.csv +169 -0
- D4CMPP2/src/utils/graph_cache.py +213 -0
- D4CMPP2/src/utils/leaderboard.py +212 -0
- D4CMPP2/src/utils/metrics.py +31 -0
- D4CMPP2/src/utils/module_loader.py +147 -0
- D4CMPP2/src/utils/output.py +80 -0
- D4CMPP2/src/utils/reproducibility.py +70 -0
- D4CMPP2/src/utils/run_manifest.py +175 -0
- D4CMPP2/src/utils/scaler.py +40 -0
- D4CMPP2/src/utils/sculptor.py +713 -0
- D4CMPP2/src/utils/splitting.py +250 -0
- D4CMPP2/src/utils/supportfile_saver.py +94 -0
- D4CMPP2/src/utils/tools.py +156 -0
- D4CMPP2/src/utils/transfer_learning.py +111 -0
- d4cmpp2-0.4.0.dist-info/METADATA +420 -0
- d4cmpp2-0.4.0.dist-info/RECORD +103 -0
- d4cmpp2-0.4.0.dist-info/WHEEL +5 -0
- d4cmpp2-0.4.0.dist-info/entry_points.txt +2 -0
- d4cmpp2-0.4.0.dist-info/licenses/LICENSE +21 -0
- d4cmpp2-0.4.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Lazy exports for built-in data-manager modules."""
|
|
2
|
+
|
|
3
|
+
from importlib import import_module
|
|
4
|
+
from types import ModuleType
|
|
5
|
+
|
|
6
|
+
__all__ = ["MolDataManager", "ISADataManager", "contracts"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def __getattr__(name: str) -> ModuleType:
|
|
10
|
+
if name not in __all__:
|
|
11
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
12
|
+
module = import_module(f"{__name__}.{name}")
|
|
13
|
+
globals()[name] = module
|
|
14
|
+
return module
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"""Additive metadata for DataManager and Dataset batch contracts."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from types import MappingProxyType
|
|
5
|
+
from typing import Any, Mapping, Optional, Protocol, Sequence, Tuple
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BatchUnwrapper(Protocol):
|
|
9
|
+
"""Static typing aid for Dataset unwrapper callables."""
|
|
10
|
+
|
|
11
|
+
def __call__(self, *args: Any, device: str = "cpu", **kwargs: Any) -> Mapping[str, Any]:
|
|
12
|
+
...
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass(frozen=True)
|
|
16
|
+
class DatasetBatchContract:
|
|
17
|
+
"""Describe keys returned by a built-in Dataset unwrapper."""
|
|
18
|
+
|
|
19
|
+
name: str
|
|
20
|
+
required_keys: Tuple[str, ...] = ("target",)
|
|
21
|
+
optional_keys: Tuple[str, ...] = ()
|
|
22
|
+
molecule_suffixes: Tuple[str, ...] = ()
|
|
23
|
+
numeric_suffix: Optional[str] = None
|
|
24
|
+
|
|
25
|
+
def expected_keys(
|
|
26
|
+
self,
|
|
27
|
+
molecule_columns: Sequence[str] = (),
|
|
28
|
+
numeric_input_columns: Sequence[str] = (),
|
|
29
|
+
) -> Tuple[str, ...]:
|
|
30
|
+
keys = list(self.required_keys)
|
|
31
|
+
for column in molecule_columns:
|
|
32
|
+
keys.extend(f"{column}{suffix}" for suffix in self.molecule_suffixes)
|
|
33
|
+
if self.numeric_suffix is not None:
|
|
34
|
+
keys.extend(
|
|
35
|
+
f"{column}{self.numeric_suffix}"
|
|
36
|
+
for column in numeric_input_columns
|
|
37
|
+
)
|
|
38
|
+
return tuple(dict.fromkeys(keys))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass(frozen=True)
|
|
42
|
+
class DataManagerContract:
|
|
43
|
+
"""Immutable snapshot available before NetworkManager construction."""
|
|
44
|
+
|
|
45
|
+
manager: str
|
|
46
|
+
graph_type: str
|
|
47
|
+
dataset: str
|
|
48
|
+
unwrapper: str
|
|
49
|
+
feature_dimensions: Mapping[str, int]
|
|
50
|
+
batch: DatasetBatchContract
|
|
51
|
+
|
|
52
|
+
def __post_init__(self) -> None:
|
|
53
|
+
object.__setattr__(
|
|
54
|
+
self,
|
|
55
|
+
"feature_dimensions",
|
|
56
|
+
MappingProxyType(dict(self.feature_dimensions)),
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
GENERAL_BATCH_CONTRACT = DatasetBatchContract(
|
|
61
|
+
name="generalized_graph",
|
|
62
|
+
required_keys=("target",),
|
|
63
|
+
optional_keys=("original_row_index",),
|
|
64
|
+
molecule_suffixes=(
|
|
65
|
+
"_graphs",
|
|
66
|
+
"_node_feature",
|
|
67
|
+
"_edge_feature",
|
|
68
|
+
"_smiles",
|
|
69
|
+
),
|
|
70
|
+
numeric_suffix="_var",
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
ISA_BATCH_CONTRACT = DatasetBatchContract(
|
|
74
|
+
name="generalized_isa",
|
|
75
|
+
required_keys=("target",),
|
|
76
|
+
optional_keys=("original_row_index",),
|
|
77
|
+
molecule_suffixes=(
|
|
78
|
+
"_graphs",
|
|
79
|
+
"_r_node",
|
|
80
|
+
"_r2r_edge",
|
|
81
|
+
"_i_node",
|
|
82
|
+
"_i2i_edge",
|
|
83
|
+
"_d_node",
|
|
84
|
+
"_d2d_edge",
|
|
85
|
+
"_smiles",
|
|
86
|
+
),
|
|
87
|
+
numeric_suffix="_var",
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
LEGACY_GENERAL_BATCH_CONTRACT = DatasetBatchContract(
|
|
91
|
+
name="legacy_general",
|
|
92
|
+
required_keys=("graph", "node_feats", "edge_feats", "target", "smiles"),
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
LEGACY_SOLVENT_BATCH_CONTRACT = DatasetBatchContract(
|
|
96
|
+
name="legacy_solvent",
|
|
97
|
+
required_keys=(
|
|
98
|
+
"graph",
|
|
99
|
+
"node_feats",
|
|
100
|
+
"edge_feats",
|
|
101
|
+
"solv_graph",
|
|
102
|
+
"solv_node_feats",
|
|
103
|
+
"solv_edge_feats",
|
|
104
|
+
"target",
|
|
105
|
+
"smiles",
|
|
106
|
+
"solv_smiles",
|
|
107
|
+
),
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
LEGACY_ISA_BATCH_CONTRACT = DatasetBatchContract(
|
|
111
|
+
name="legacy_isa",
|
|
112
|
+
required_keys=(
|
|
113
|
+
"graph",
|
|
114
|
+
"r_node",
|
|
115
|
+
"r_edge",
|
|
116
|
+
"i_node",
|
|
117
|
+
"d_node",
|
|
118
|
+
"d_edge",
|
|
119
|
+
"target",
|
|
120
|
+
"smiles",
|
|
121
|
+
),
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def validate_data_manager_contract(
|
|
126
|
+
manager: Any,
|
|
127
|
+
config: Mapping[str, Any],
|
|
128
|
+
) -> Optional[DataManagerContract]:
|
|
129
|
+
"""Validate built-in metadata, or return None for metadata-free custom managers."""
|
|
130
|
+
|
|
131
|
+
dataset = getattr(manager, "dataset", None)
|
|
132
|
+
batch_contract = getattr(dataset, "batch_contract", None)
|
|
133
|
+
if batch_contract is None:
|
|
134
|
+
return None
|
|
135
|
+
dataset_name = getattr(dataset, "__name__", type(dataset).__name__)
|
|
136
|
+
if not isinstance(batch_contract, DatasetBatchContract):
|
|
137
|
+
raise TypeError(
|
|
138
|
+
f"Dataset {dataset_name!r} "
|
|
139
|
+
"batch_contract must be DatasetBatchContract."
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
unwrapper = getattr(manager, "unwrapper", None)
|
|
143
|
+
if not callable(unwrapper):
|
|
144
|
+
raise TypeError(
|
|
145
|
+
f"DataManager {type(manager).__name__!r} selected Dataset "
|
|
146
|
+
f"{dataset_name!r} but its unwrapper is not callable."
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
dimension_keys = getattr(manager, "feature_dimension_keys", None)
|
|
150
|
+
if dimension_keys is None:
|
|
151
|
+
return None
|
|
152
|
+
missing = [key for key in dimension_keys if key not in config]
|
|
153
|
+
if missing:
|
|
154
|
+
raise ValueError(
|
|
155
|
+
f"DataManager {type(manager).__name__!r} did not initialize required "
|
|
156
|
+
f"feature dimension keys {missing!r} before NetworkManager construction. "
|
|
157
|
+
f"Available config keys: {sorted(config)!r}."
|
|
158
|
+
)
|
|
159
|
+
invalid = {
|
|
160
|
+
key: config[key]
|
|
161
|
+
for key in dimension_keys
|
|
162
|
+
if isinstance(config[key], bool)
|
|
163
|
+
or not isinstance(config[key], int)
|
|
164
|
+
or config[key] < 0
|
|
165
|
+
}
|
|
166
|
+
if invalid:
|
|
167
|
+
raise ValueError(
|
|
168
|
+
f"DataManager {type(manager).__name__!r} produced invalid feature "
|
|
169
|
+
f"dimensions {invalid!r}; expected non-negative integers."
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
return DataManagerContract(
|
|
173
|
+
manager=type(manager).__name__,
|
|
174
|
+
graph_type=str(getattr(manager, "graph_type", "unknown")),
|
|
175
|
+
dataset=dataset_name,
|
|
176
|
+
unwrapper=getattr(unwrapper, "__qualname__", repr(unwrapper)),
|
|
177
|
+
feature_dimensions={key: config[key] for key in dimension_keys},
|
|
178
|
+
batch=batch_contract,
|
|
179
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
import importlib
|
|
3
|
+
import os
|
|
4
|
+
import yaml
|
|
5
|
+
import pandas as pd
|
|
6
|
+
from D4CMPP2.src.utils import PATH
|
|
7
|
+
from .NetworkManager import NetworkManager
|
|
8
|
+
|
|
9
|
+
class ISANetworkManager(NetworkManager):
|
|
10
|
+
"""Compatibility extension point referenced by ISA registries and saved configs."""
|
|
11
|
+
|
|
12
|
+
pass
|