mdprep 0.2.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.
- mdprep/__init__.py +7 -0
- mdprep/_selftest_data/basic_protein.yaml +33 -0
- mdprep/_selftest_data/ligand_sub.mol2 +11 -0
- mdprep/ambertools/__init__.py +2 -0
- mdprep/ambertools/antechamber.py +110 -0
- mdprep/ambertools/commands.py +33 -0
- mdprep/ambertools/mol2.py +415 -0
- mdprep/ambertools/parmchk2.py +89 -0
- mdprep/ambertools/resp.py +570 -0
- mdprep/charges/__init__.py +1 -0
- mdprep/charges/esp_grid.py +190 -0
- mdprep/cli.py +451 -0
- mdprep/config/__init__.py +9 -0
- mdprep/config/loader.py +146 -0
- mdprep/config/models.py +1100 -0
- mdprep/external/__init__.py +14 -0
- mdprep/external/discovery.py +14 -0
- mdprep/external/runner.py +55 -0
- mdprep/leap/__init__.py +2 -0
- mdprep/leap/builder.py +476 -0
- mdprep/leap/forcefields.py +93 -0
- mdprep/leap/ions.py +112 -0
- mdprep/leap/log_parser.py +170 -0
- mdprep/leap/report.py +99 -0
- mdprep/leap/residues.py +653 -0
- mdprep/leap/runner.py +65 -0
- mdprep/ligands/__init__.py +2 -0
- mdprep/ligands/extract.py +355 -0
- mdprep/ligands/identity.py +39 -0
- mdprep/ligands/pyscf_charges.py +242 -0
- mdprep/ligands/report.py +146 -0
- mdprep/ligands/workflow.py +838 -0
- mdprep/md/__init__.py +5 -0
- mdprep/md/roe_brooks.py +650 -0
- mdprep/metals/__init__.py +2 -0
- mdprep/metals/c4.py +157 -0
- mdprep/metals/coordination.py +313 -0
- mdprep/metals/gxtb_hessian.py +467 -0
- mdprep/metals/hydrogenate.py +344 -0
- mdprep/metals/mace_polar1_hessian.py +357 -0
- mdprep/metals/mace_polar1_worker.py +295 -0
- mdprep/metals/mcpb.py +949 -0
- mdprep/metals/mcpb_compat.py +125 -0
- mdprep/metals/nonbonded.py +294 -0
- mdprep/metals/parameter_comparison.py +563 -0
- mdprep/metals/pyscf_mcpb.py +1388 -0
- mdprep/metals/report.py +119 -0
- mdprep/metals/workflow.py +320 -0
- mdprep/protonation/__init__.py +15 -0
- mdprep/protonation/apply.py +968 -0
- mdprep/protonation/disulfide_states.py +141 -0
- mdprep/protonation/histidine_geometry.py +950 -0
- mdprep/protonation/histidine_xtb.py +390 -0
- mdprep/protonation/overrides.py +64 -0
- mdprep/protonation/pka_rules.py +165 -0
- mdprep/protonation/propka.py +174 -0
- mdprep/protonation/propka_parser.py +140 -0
- mdprep/protonation/report.py +187 -0
- mdprep/protonation/states.py +52 -0
- mdprep/protonation/temporary_hydrogenation.py +238 -0
- mdprep/protonation/xtb_parser.py +79 -0
- mdprep/protonation/xtb_runner.py +108 -0
- mdprep/qm/__init__.py +2 -0
- mdprep/qm/point_charges.py +233 -0
- mdprep/qm/pyscf_esp.py +70 -0
- mdprep/qm/pyscf_runner.py +570 -0
- mdprep/refinement/__init__.py +5 -0
- mdprep/refinement/ash.py +541 -0
- mdprep/refinement/coordinates.py +210 -0
- mdprep/refinement/mapping.py +163 -0
- mdprep/refinement/report.py +66 -0
- mdprep/refinement/selection.py +436 -0
- mdprep/refinement/workflow.py +188 -0
- mdprep/reports/__init__.py +8 -0
- mdprep/reports/structure_report.py +92 -0
- mdprep/structure/__init__.py +14 -0
- mdprep/structure/classify.py +92 -0
- mdprep/structure/disulfides.py +51 -0
- mdprep/structure/inspect.py +105 -0
- mdprep/structure/models.py +86 -0
- mdprep/structure/normalize.py +363 -0
- mdprep/structure/pdb.py +511 -0
- mdprep/structure/repair.py +566 -0
- mdprep/structure/selectors.py +204 -0
- mdprep/structure/writer.py +84 -0
- mdprep/validation/__init__.py +2 -0
- mdprep/validation/openmm_check.py +86 -0
- mdprep/validation/parmed_check.py +43 -0
- mdprep/validation/topology.py +239 -0
- mdprep/workflows/__init__.py +6 -0
- mdprep/workflows/init.py +242 -0
- mdprep/workflows/inspect.py +21 -0
- mdprep/workflows/prepare.py +763 -0
- mdprep/workflows/selftest.py +220 -0
- mdprep/workflows/validate.py +30 -0
- mdprep-0.2.0.dist-info/METADATA +264 -0
- mdprep-0.2.0.dist-info/RECORD +100 -0
- mdprep-0.2.0.dist-info/WHEEL +4 -0
- mdprep-0.2.0.dist-info/entry_points.txt +2 -0
- mdprep-0.2.0.dist-info/licenses/LICENSE +21 -0
mdprep/config/loader.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""YAML manifest loading."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from copy import deepcopy
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
import yaml
|
|
10
|
+
|
|
11
|
+
from mdprep.config.models import ManifestConfig
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def load_yaml(path: str | Path) -> dict[str, Any]:
|
|
15
|
+
manifest_path = Path(path)
|
|
16
|
+
with manifest_path.open("r", encoding="utf-8") as handle:
|
|
17
|
+
data = yaml.safe_load(handle)
|
|
18
|
+
if not isinstance(data, dict):
|
|
19
|
+
raise ValueError(f"{manifest_path} must contain a YAML mapping at the top level")
|
|
20
|
+
return data
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def load_manifest(
|
|
24
|
+
path: str | Path,
|
|
25
|
+
*,
|
|
26
|
+
resolve_paths: bool = False,
|
|
27
|
+
) -> ManifestConfig:
|
|
28
|
+
"""Load a manifest, optionally resolving file paths from its directory.
|
|
29
|
+
|
|
30
|
+
Schema validation keeps the portable user-authored strings unchanged.
|
|
31
|
+
Execution workflows request resolution so their behavior is independent of
|
|
32
|
+
the shell's current working directory.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
manifest_path = Path(path)
|
|
36
|
+
data = load_yaml(manifest_path)
|
|
37
|
+
if resolve_paths:
|
|
38
|
+
data = _resolve_manifest_paths(data, manifest_path.parent.resolve())
|
|
39
|
+
return ManifestConfig.model_validate(data)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _resolve_manifest_paths(data: dict[str, Any], base_dir: Path) -> dict[str, Any]:
|
|
43
|
+
resolved = deepcopy(data)
|
|
44
|
+
|
|
45
|
+
def file_path(value: object, *, existing_cwd_fallback: bool = True) -> object:
|
|
46
|
+
if not isinstance(value, str) or not value:
|
|
47
|
+
return value
|
|
48
|
+
candidate = Path(value).expanduser()
|
|
49
|
+
if candidate.is_absolute():
|
|
50
|
+
return str(candidate)
|
|
51
|
+
manifest_candidate = (base_dir / candidate).resolve()
|
|
52
|
+
cwd_candidate = candidate.resolve()
|
|
53
|
+
if (
|
|
54
|
+
existing_cwd_fallback
|
|
55
|
+
and not manifest_candidate.exists()
|
|
56
|
+
and cwd_candidate.exists()
|
|
57
|
+
):
|
|
58
|
+
return str(cwd_candidate)
|
|
59
|
+
return str(manifest_candidate)
|
|
60
|
+
|
|
61
|
+
def command_path(value: object) -> object:
|
|
62
|
+
if not isinstance(value, str) or not value:
|
|
63
|
+
return value
|
|
64
|
+
candidate = Path(value).expanduser()
|
|
65
|
+
if candidate.is_absolute() or "/" in value or "\\" in value:
|
|
66
|
+
return str(candidate if candidate.is_absolute() else (base_dir / candidate).resolve())
|
|
67
|
+
return value
|
|
68
|
+
|
|
69
|
+
project = resolved.get("project")
|
|
70
|
+
if isinstance(project, dict):
|
|
71
|
+
if "input_structure" in project:
|
|
72
|
+
project["input_structure"] = file_path(project["input_structure"])
|
|
73
|
+
if "output_dir" in project:
|
|
74
|
+
project["output_dir"] = file_path(
|
|
75
|
+
project["output_dir"], existing_cwd_fallback=False
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
structure = resolved.get("structure")
|
|
79
|
+
repair = structure.get("repair") if isinstance(structure, dict) else None
|
|
80
|
+
if isinstance(repair, dict) and "sequence_source" in repair:
|
|
81
|
+
repair["sequence_source"] = file_path(repair["sequence_source"])
|
|
82
|
+
|
|
83
|
+
protonation = resolved.get("protonation")
|
|
84
|
+
if isinstance(protonation, dict):
|
|
85
|
+
propka = protonation.get("propka")
|
|
86
|
+
if isinstance(propka, dict) and "executable" in propka:
|
|
87
|
+
propka["executable"] = command_path(propka["executable"])
|
|
88
|
+
histidine = protonation.get("histidine")
|
|
89
|
+
xtb = histidine.get("xtb") if isinstance(histidine, dict) else None
|
|
90
|
+
if isinstance(xtb, dict) and "executable" in xtb:
|
|
91
|
+
xtb["executable"] = command_path(xtb["executable"])
|
|
92
|
+
|
|
93
|
+
ligands = resolved.get("ligands")
|
|
94
|
+
if isinstance(ligands, list):
|
|
95
|
+
for ligand in ligands:
|
|
96
|
+
if not isinstance(ligand, dict):
|
|
97
|
+
continue
|
|
98
|
+
for key in ("user_mol2", "user_frcmod"):
|
|
99
|
+
if key in ligand:
|
|
100
|
+
ligand[key] = file_path(ligand[key])
|
|
101
|
+
|
|
102
|
+
metals = resolved.get("metals")
|
|
103
|
+
if isinstance(metals, list):
|
|
104
|
+
for site in metals:
|
|
105
|
+
mcpb = site.get("mcpb") if isinstance(site, dict) else None
|
|
106
|
+
if not isinstance(mcpb, dict):
|
|
107
|
+
continue
|
|
108
|
+
if "executable" in mcpb:
|
|
109
|
+
mcpb["executable"] = command_path(mcpb["executable"])
|
|
110
|
+
artifacts = mcpb.get("artifacts")
|
|
111
|
+
if isinstance(artifacts, dict):
|
|
112
|
+
for key in ("small_opt_fchk", "small_fc_log", "large_mk_log"):
|
|
113
|
+
if key in artifacts:
|
|
114
|
+
artifacts[key] = file_path(artifacts[key])
|
|
115
|
+
pyscf = mcpb.get("pyscf")
|
|
116
|
+
if isinstance(pyscf, dict):
|
|
117
|
+
for key in ("optimized_small_model_pdb", "large_model_restart_checkpoint"):
|
|
118
|
+
if key in pyscf:
|
|
119
|
+
pyscf[key] = file_path(pyscf[key])
|
|
120
|
+
for backend_key in ("xtb", "gxtb"):
|
|
121
|
+
backend = pyscf.get(backend_key)
|
|
122
|
+
if isinstance(backend, dict) and "executable" in backend:
|
|
123
|
+
backend["executable"] = command_path(backend["executable"])
|
|
124
|
+
mace = pyscf.get("mace_polar1")
|
|
125
|
+
if isinstance(mace, dict) and "python_executable" in mace:
|
|
126
|
+
mace["python_executable"] = command_path(mace["python_executable"])
|
|
127
|
+
comparison = mcpb.get("parameter_comparison")
|
|
128
|
+
if isinstance(comparison, dict) and "reference_frcmod" in comparison:
|
|
129
|
+
comparison["reference_frcmod"] = file_path(comparison["reference_frcmod"])
|
|
130
|
+
|
|
131
|
+
refinement = resolved.get("refinement")
|
|
132
|
+
if isinstance(refinement, dict):
|
|
133
|
+
ash = refinement.get("ash")
|
|
134
|
+
if isinstance(ash, dict):
|
|
135
|
+
for key in ("python_executable", "xtb_executable"):
|
|
136
|
+
if key in ash:
|
|
137
|
+
ash[key] = command_path(ash[key])
|
|
138
|
+
mace = refinement.get("mace_polar1")
|
|
139
|
+
if isinstance(mace, dict):
|
|
140
|
+
if "model_path" in mace:
|
|
141
|
+
mace["model_path"] = file_path(mace["model_path"])
|
|
142
|
+
if isinstance(mace.get("python_search_paths"), list):
|
|
143
|
+
mace["python_search_paths"] = [
|
|
144
|
+
file_path(value) for value in mace["python_search_paths"]
|
|
145
|
+
]
|
|
146
|
+
return resolved
|