-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathapp_solv_mpconf196.py
More file actions
90 lines (75 loc) · 2.71 KB
/
Copy pathapp_solv_mpconf196.py
File metadata and controls
90 lines (75 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"""Run solvMPCONF196 app."""
from __future__ import annotations
from dash import Dash
from dash.html import Div
from ml_peg.app import APP_ROOT
from ml_peg.app.base_app import BaseApp
from ml_peg.app.utils.build_callbacks import (
plot_from_table_column,
struct_from_scatter,
)
from ml_peg.app.utils.load import read_plot
from ml_peg.models.get_models import get_model_names
from ml_peg.models.models import current_models
MODELS = get_model_names(current_models)
BENCHMARK_NAME = "solvMPCONF196"
DOCS_URL = (
"https://ddmms.github.io/ml-peg/user_guide/benchmarks/molecular.html#solvmpconf196"
)
DATA_PATH = APP_ROOT / "data" / "conformers" / "solv_mpconf196"
class SolvMPCONF196App(BaseApp):
"""SolvMPCONF196 benchmark app layout and callbacks."""
def register_callbacks(self) -> None:
"""Register callbacks to app."""
scatter = read_plot(
DATA_PATH / "figure_solv_mpconf196.json",
id=f"{BENCHMARK_NAME}-figure",
)
model_dir = DATA_PATH / MODELS[0]
if model_dir.exists():
labels = sorted([f.stem for f in model_dir.glob("*.xyz")])
structs = [
f"assets/conformers/solv_mpconf196/{MODELS[0]}/{label}.xyz"
for label in labels
]
else:
structs = []
plot_from_table_column(
table_id=self.table_id,
plot_id=f"{BENCHMARK_NAME}-figure-placeholder",
column_to_plot={"MAE": scatter},
)
struct_from_scatter(
scatter_id=f"{BENCHMARK_NAME}-figure",
struct_id=f"{BENCHMARK_NAME}-struct-placeholder",
structs=structs,
mode="struct",
)
def get_app() -> SolvMPCONF196App:
"""
Get solvMPCONF196 benchmark app layout and callback registration.
Returns
-------
SolvMPCONF196App
Benchmark layout and callback registration.
"""
return SolvMPCONF196App(
name=BENCHMARK_NAME,
description=(
"Performance in predicting solvent-stabilized conformer energies for "
"the solvMPCONF196 dataset (13 biomolecular fragments with explicit "
"solvation). Reference data from CCSD(T) calculations."
),
docs_url=DOCS_URL,
table_path=DATA_PATH / "solv_mpconf196_metrics_table.json",
extra_components=[
Div(id=f"{BENCHMARK_NAME}-figure-placeholder"),
Div(id=f"{BENCHMARK_NAME}-struct-placeholder"),
],
)
if __name__ == "__main__":
full_app = Dash(__name__, assets_folder=DATA_PATH.parent.parent)
benchmark_app = get_app()
full_app.layout = benchmark_app.layout
benchmark_app.register_callbacks()
full_app.run(port=8069, debug=True)