Skip to content

Commit a5e6781

Browse files
authored
refactor: (1) rename minimization benchmark, (2) fix links to docs in UI (#111)
1 parent ea8344e commit a5e6781

File tree

24 files changed

+143
-141
lines changed

24 files changed

+143
-141
lines changed

docs/source/api_reference/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Benchmark implementations
3030
small_molecules/noncovalent_interactions
3131
small_molecules/tautomers
3232
small_molecules/ring_planarity
33-
small_molecules/minimization
33+
small_molecules/reference_geometry_stability
3434
small_molecules/bond_length_distribution
3535
small_molecules/radial_distribution
3636
small_molecules/solvent_radial_distribution

docs/source/api_reference/small_molecules/bond_length_distribution.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ Bond length distribution
1919

2020
.. autoclass:: BondLengthDistributionModelOutput
2121

22-
.. autoclass:: MoleculeSimulationOutput
22+
.. autoclass:: MoleculeModelOutput

docs/source/api_reference/small_molecules/minimization.rst

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. _reference_geometry_stability_api:
2+
3+
Reference Geometry Stability
4+
============================
5+
6+
.. module:: mlipaudit.benchmarks.reference_geometry_stability.reference_geometry_stability
7+
8+
.. autoclass:: ReferenceGeometryStabilityBenchmark
9+
10+
.. automethod:: __init__
11+
12+
.. automethod:: run_model
13+
14+
.. automethod:: analyze
15+
16+
.. autoclass:: ReferenceGeometryStabilityResult
17+
18+
.. autoclass:: ReferenceGeometryStabilityDatasetResult
19+
20+
.. autoclass:: ReferenceGeometryStabilityModelOutput
21+
22+
.. autoclass:: MoleculeModelOutput

docs/source/benchmarks/small_molecules/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ sampling, stability, and interactions with other molecules.
1515
Noncovalent Interactions <noncovalent_interactions>
1616
Ring planarity <ring_planarity>
1717
Tautomers <tautomers>
18-
Reference geometry stability <minimization>
18+
Reference geometry stability <reference_geometry_stability>
1919
Bond length distribution <bond_length_distribution>
2020
Reactivity <reactivity>
2121
Nudged elastic band <nudged_elastic_band>

docs/source/benchmarks/small_molecules/minimization.rst renamed to docs/source/benchmarks/small_molecules/reference_geometry_stability.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fingerprints of the original datasets.
3737
Interpretation
3838
--------------
3939

40-
The energy minimization benchmark can be understood as a sanity-check benchmark to verify that the **MLIP** recognizes a true geometrical
40+
The reference geometry stability benchmark can be understood as a sanity-check benchmark to verify that the **MLIP** recognizes a true geometrical
4141
minimum of a molecule as such. Often, true ground state structures, with forces on all atoms being essentially zero, are absent from training data.
4242
In this case the ability of the **MLIP** to correctly interpolate between near-minimum structures is tested. In any case, the ground-truth geometry
4343
should be retained and not deviate from the **QM** geometry. Since the **QM** geometry is also the starting structure, the geometry should ideally

src/mlipaudit/benchmarks/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
ReactivityModelOutput,
5050
ReactivityResult,
5151
)
52+
from mlipaudit.benchmarks.reference_geometry_stability.reference_geometry_stability import ( # noqa: E501
53+
ReferenceGeometryStabilityBenchmark,
54+
ReferenceGeometryStabilityModelOutput,
55+
ReferenceGeometryStabilityResult,
56+
)
5257
from mlipaudit.benchmarks.ring_planarity.ring_planarity import (
5358
RingPlanarityBenchmark,
5459
RingPlanarityModelOutput,
@@ -64,11 +69,6 @@
6469
ScalingModelOutput,
6570
ScalingResult,
6671
)
67-
from mlipaudit.benchmarks.small_molecule_minimization.small_molecule_minimization import ( # noqa: E501
68-
SmallMoleculeMinimizationBenchmark,
69-
SmallMoleculeMinimizationModelOutput,
70-
SmallMoleculeMinimizationResult,
71-
)
7272
from mlipaudit.benchmarks.solvent_radial_distribution.solvent_radial_distribution import ( # noqa: E501
7373
SolventRadialDistributionBenchmark,
7474
SolventRadialDistributionModelOutput,

src/mlipaudit/benchmarks/bond_length_distribution/bond_length_distribution.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Molecule(BaseModel):
7070
Molecules = TypeAdapter(dict[str, Molecule])
7171

7272

73-
class MoleculeSimulationOutput(BaseModel):
73+
class MoleculeModelOutput(BaseModel):
7474
"""Stores the simulation state for a molecule.
7575
7676
Attributes:
@@ -92,7 +92,7 @@ class BondLengthDistributionModelOutput(ModelOutput):
9292
molecules: A list of simulation states for every molecule.
9393
"""
9494

95-
molecules: list[MoleculeSimulationOutput]
95+
molecules: list[MoleculeModelOutput]
9696

9797

9898
class BondLengthDistributionMoleculeResult(BaseModel):
@@ -185,7 +185,7 @@ def run_model(self) -> None:
185185
md_engine = get_simulation_engine(atoms, self.force_field, **md_kwargs)
186186
md_engine.run()
187187

188-
molecule_output = MoleculeSimulationOutput(
188+
molecule_output = MoleculeModelOutput(
189189
molecule_name=pattern_name, simulation_state=md_engine.state
190190
)
191191
molecule_outputs.append(molecule_output)

src/mlipaudit/benchmarks/small_molecule_minimization/small_molecule_minimization.py renamed to src/mlipaudit/benchmarks/reference_geometry_stability/reference_geometry_stability.py

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Molecule(BaseModel):
8383
Molecules = TypeAdapter(dict[str, Molecule])
8484

8585

86-
class MoleculeSimulationOutput(BaseModel):
86+
class MoleculeModelOutput(BaseModel):
8787
"""Stores the simulation state for a molecule.
8888
8989
Attributes:
@@ -97,26 +97,25 @@ class MoleculeSimulationOutput(BaseModel):
9797
simulation_state: SimulationState
9898

9999

100-
class SmallMoleculeMinimizationModelOutput(ModelOutput):
101-
"""ModelOutput object for small molecule conformer minimization benchmark.
100+
class ReferenceGeometryStabilityModelOutput(ModelOutput):
101+
"""ModelOutput object for reference geometry stability benchmark.
102102
103103
Attributes:
104104
openff_neutral: A list of simulation states for each molecule in the dataset.
105105
openff_charged: A list of simulation states for each molecule in the dataset.
106106
"""
107107

108-
openff_neutral: list[MoleculeSimulationOutput]
109-
openff_charged: list[MoleculeSimulationOutput]
108+
openff_neutral: list[MoleculeModelOutput]
109+
openff_charged: list[MoleculeModelOutput]
110110

111111

112-
class SmallMoleculeMinimizationDatasetResult(BaseModel):
112+
class ReferenceGeometryStabilityDatasetResult(BaseModel):
113113
"""Result for a single dataset.
114114
115115
Attributes:
116116
rmsd_values: The list of rmsd values for each molecule.
117117
avg_rmsd: The average rmsd across all molecules in the dataset.
118-
num_exploded: The number of molecules that exploded during
119-
minimization.
118+
num_exploded: The number of molecules that exploded during minimization.
120119
num_bad_rmsds: The number of molecules that we consider to
121120
have a poor rmsd score.
122121
"""
@@ -127,8 +126,8 @@ class SmallMoleculeMinimizationDatasetResult(BaseModel):
127126
num_bad_rmsds: NonNegativeInt
128127

129128

130-
class SmallMoleculeMinimizationResult(BenchmarkResult):
131-
"""Results object for small molecule minimization benchmark.
129+
class ReferenceGeometryStabilityResult(BenchmarkResult):
130+
"""Results object for reference geometry stability benchmark.
132131
133132
Attributes:
134133
openff_neutral: The results for the openff neutral dataset.
@@ -138,25 +137,25 @@ class SmallMoleculeMinimizationResult(BenchmarkResult):
138137
0 and 1.
139138
"""
140139

141-
openff_neutral: SmallMoleculeMinimizationDatasetResult
142-
openff_charged: SmallMoleculeMinimizationDatasetResult
140+
openff_neutral: ReferenceGeometryStabilityDatasetResult
141+
openff_charged: ReferenceGeometryStabilityDatasetResult
143142
avg_rmsd: NonNegativeFloat | None = None
144143

145144

146-
class SmallMoleculeMinimizationBenchmark(Benchmark):
147-
"""Benchmark for small molecule minimization.
145+
class ReferenceGeometryStabilityBenchmark(Benchmark):
146+
"""Benchmark for reference geometry stability.
148147
149148
Attributes:
150149
name: The unique benchmark name that should be used to run the benchmark
151150
from the CLI and that will determine the output folder name for the result
152-
file. The name is `small_molecule_minimization`.
151+
file. The name is `reference_geometry_stability`.
153152
category: A string that describes the category of the benchmark, used for
154153
example, in the UI app for grouping. Default, if not overridden,
155154
is "General". This benchmark's category is "Small Molecules".
156155
result_class: A reference to the type of `BenchmarkResult` that will determine
157156
the return type of `self.analyze()`. The result class type is
158-
`SmallMoleculeMinimizationResult`.
159-
model_output_class: A reference to the `SmallMoleculeMinimizationModelOutput`
157+
`ReferenceGeometryStabilityResult`.
158+
model_output_class: A reference to the `ReferenceGeometryStabilityModelOutput`
160159
class.
161160
required_elements: The set of atomic element types that are present in the
162161
benchmark's input files.
@@ -166,10 +165,10 @@ class SmallMoleculeMinimizationBenchmark(Benchmark):
166165
element types. For this benchmark, the attribute is set to True.
167166
"""
168167

169-
name = "small_molecule_minimization"
168+
name = "reference_geometry_stability"
170169
category = "Small Molecules"
171-
result_class = SmallMoleculeMinimizationResult
172-
model_output_class = SmallMoleculeMinimizationModelOutput
170+
result_class = ReferenceGeometryStabilityResult
171+
model_output_class = ReferenceGeometryStabilityModelOutput
173172

174173
required_elements = {"N", "Cl", "H", "O", "S", "F", "P", "C", "Br"}
175174

@@ -185,7 +184,7 @@ def run_model(self) -> None:
185184
else:
186185
md_kwargs = SIMULATION_CONFIG
187186

188-
self.model_output = SmallMoleculeMinimizationModelOutput(
187+
self.model_output = ReferenceGeometryStabilityModelOutput(
189188
openff_neutral=[],
190189
openff_charged=[],
191190
)
@@ -206,12 +205,12 @@ def run_model(self) -> None:
206205
md_engine.run()
207206

208207
getattr(self.model_output, dataset_prefix).append(
209-
MoleculeSimulationOutput(
208+
MoleculeModelOutput(
210209
molecule_name=molecule_name, simulation_state=md_engine.state
211210
)
212211
)
213212

214-
def analyze(self) -> SmallMoleculeMinimizationResult:
213+
def analyze(self) -> ReferenceGeometryStabilityResult:
215214
"""Calculates the RMSD between the MLIP and reference structures.
216215
217216
The RMSD is calculated for each structure in the `inference_results` attribute.
@@ -220,7 +219,7 @@ def analyze(self) -> SmallMoleculeMinimizationResult:
220219
respect to the reference structure.
221220
222221
Returns:
223-
A `SmallMoleculeMinimizationResult` object with the benchmark results.
222+
A `ReferenceGeometryStabilityResult` object with the benchmark results.
224223
225224
Raises:
226225
RuntimeError: If called before `run_model()`.
@@ -232,7 +231,7 @@ def analyze(self) -> SmallMoleculeMinimizationResult:
232231

233232
for dataset_prefix in DATASET_PREFIXES:
234233
rmsd_values: list[float | None] = []
235-
dataset_model_output: list[MoleculeSimulationOutput] = getattr(
234+
dataset_model_output: list[MoleculeModelOutput] = getattr(
236235
self.model_output, dataset_prefix
237236
)
238237
num_exploded = 0
@@ -287,7 +286,7 @@ def analyze(self) -> SmallMoleculeMinimizationResult:
287286
rmsd for rmsd in rmsd_values if rmsd is not None
288287
)
289288

290-
dataset_result = SmallMoleculeMinimizationDatasetResult(
289+
dataset_result = ReferenceGeometryStabilityDatasetResult(
291290
rmsd_values=rmsd_values,
292291
avg_rmsd=avg_rmsd,
293292
num_exploded=num_exploded,
@@ -318,7 +317,9 @@ def analyze(self) -> SmallMoleculeMinimizationResult:
318317
if dataset_result.avg_rmsd is not None
319318
)
320319

321-
return SmallMoleculeMinimizationResult(**result, score=score, avg_rmsd=avg_rmsd)
320+
return ReferenceGeometryStabilityResult(
321+
**result, score=score, avg_rmsd=avg_rmsd
322+
)
322323

323324
def _load_dataset_from_file(self, filename: str) -> dict[str, Molecule]:
324325
"""Helper method to load, validate, and optionally truncate a dataset.

src/mlipaudit/benchmarks/ring_planarity/ring_planarity.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class RingPlanarityResult(BenchmarkResult):
127127
mae_deviation: float | None = None
128128

129129

130-
class MoleculeSimulationOutput(BaseModel):
130+
class MoleculeModelOutput(BaseModel):
131131
"""Stores the simulation state for a molecule.
132132
133133
Attributes:
@@ -148,7 +148,7 @@ class RingPlanarityModelOutput(ModelOutput):
148148
molecules: A list of simulation states for each molecule..
149149
"""
150150

151-
molecules: list[MoleculeSimulationOutput]
151+
molecules: list[MoleculeModelOutput]
152152

153153

154154
class RingPlanarityBenchmark(Benchmark):
@@ -204,7 +204,7 @@ def run_model(self) -> None:
204204
md_engine = get_simulation_engine(atoms, self.force_field, **md_kwargs)
205205
md_engine.run()
206206

207-
molecule_output = MoleculeSimulationOutput(
207+
molecule_output = MoleculeModelOutput(
208208
molecule_name=molecule_name, simulation_state=md_engine.state
209209
)
210210
molecule_outputs.append(molecule_output)

0 commit comments

Comments
 (0)