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.
Files changed (100) hide show
  1. mdprep/__init__.py +7 -0
  2. mdprep/_selftest_data/basic_protein.yaml +33 -0
  3. mdprep/_selftest_data/ligand_sub.mol2 +11 -0
  4. mdprep/ambertools/__init__.py +2 -0
  5. mdprep/ambertools/antechamber.py +110 -0
  6. mdprep/ambertools/commands.py +33 -0
  7. mdprep/ambertools/mol2.py +415 -0
  8. mdprep/ambertools/parmchk2.py +89 -0
  9. mdprep/ambertools/resp.py +570 -0
  10. mdprep/charges/__init__.py +1 -0
  11. mdprep/charges/esp_grid.py +190 -0
  12. mdprep/cli.py +451 -0
  13. mdprep/config/__init__.py +9 -0
  14. mdprep/config/loader.py +146 -0
  15. mdprep/config/models.py +1100 -0
  16. mdprep/external/__init__.py +14 -0
  17. mdprep/external/discovery.py +14 -0
  18. mdprep/external/runner.py +55 -0
  19. mdprep/leap/__init__.py +2 -0
  20. mdprep/leap/builder.py +476 -0
  21. mdprep/leap/forcefields.py +93 -0
  22. mdprep/leap/ions.py +112 -0
  23. mdprep/leap/log_parser.py +170 -0
  24. mdprep/leap/report.py +99 -0
  25. mdprep/leap/residues.py +653 -0
  26. mdprep/leap/runner.py +65 -0
  27. mdprep/ligands/__init__.py +2 -0
  28. mdprep/ligands/extract.py +355 -0
  29. mdprep/ligands/identity.py +39 -0
  30. mdprep/ligands/pyscf_charges.py +242 -0
  31. mdprep/ligands/report.py +146 -0
  32. mdprep/ligands/workflow.py +838 -0
  33. mdprep/md/__init__.py +5 -0
  34. mdprep/md/roe_brooks.py +650 -0
  35. mdprep/metals/__init__.py +2 -0
  36. mdprep/metals/c4.py +157 -0
  37. mdprep/metals/coordination.py +313 -0
  38. mdprep/metals/gxtb_hessian.py +467 -0
  39. mdprep/metals/hydrogenate.py +344 -0
  40. mdprep/metals/mace_polar1_hessian.py +357 -0
  41. mdprep/metals/mace_polar1_worker.py +295 -0
  42. mdprep/metals/mcpb.py +949 -0
  43. mdprep/metals/mcpb_compat.py +125 -0
  44. mdprep/metals/nonbonded.py +294 -0
  45. mdprep/metals/parameter_comparison.py +563 -0
  46. mdprep/metals/pyscf_mcpb.py +1388 -0
  47. mdprep/metals/report.py +119 -0
  48. mdprep/metals/workflow.py +320 -0
  49. mdprep/protonation/__init__.py +15 -0
  50. mdprep/protonation/apply.py +968 -0
  51. mdprep/protonation/disulfide_states.py +141 -0
  52. mdprep/protonation/histidine_geometry.py +950 -0
  53. mdprep/protonation/histidine_xtb.py +390 -0
  54. mdprep/protonation/overrides.py +64 -0
  55. mdprep/protonation/pka_rules.py +165 -0
  56. mdprep/protonation/propka.py +174 -0
  57. mdprep/protonation/propka_parser.py +140 -0
  58. mdprep/protonation/report.py +187 -0
  59. mdprep/protonation/states.py +52 -0
  60. mdprep/protonation/temporary_hydrogenation.py +238 -0
  61. mdprep/protonation/xtb_parser.py +79 -0
  62. mdprep/protonation/xtb_runner.py +108 -0
  63. mdprep/qm/__init__.py +2 -0
  64. mdprep/qm/point_charges.py +233 -0
  65. mdprep/qm/pyscf_esp.py +70 -0
  66. mdprep/qm/pyscf_runner.py +570 -0
  67. mdprep/refinement/__init__.py +5 -0
  68. mdprep/refinement/ash.py +541 -0
  69. mdprep/refinement/coordinates.py +210 -0
  70. mdprep/refinement/mapping.py +163 -0
  71. mdprep/refinement/report.py +66 -0
  72. mdprep/refinement/selection.py +436 -0
  73. mdprep/refinement/workflow.py +188 -0
  74. mdprep/reports/__init__.py +8 -0
  75. mdprep/reports/structure_report.py +92 -0
  76. mdprep/structure/__init__.py +14 -0
  77. mdprep/structure/classify.py +92 -0
  78. mdprep/structure/disulfides.py +51 -0
  79. mdprep/structure/inspect.py +105 -0
  80. mdprep/structure/models.py +86 -0
  81. mdprep/structure/normalize.py +363 -0
  82. mdprep/structure/pdb.py +511 -0
  83. mdprep/structure/repair.py +566 -0
  84. mdprep/structure/selectors.py +204 -0
  85. mdprep/structure/writer.py +84 -0
  86. mdprep/validation/__init__.py +2 -0
  87. mdprep/validation/openmm_check.py +86 -0
  88. mdprep/validation/parmed_check.py +43 -0
  89. mdprep/validation/topology.py +239 -0
  90. mdprep/workflows/__init__.py +6 -0
  91. mdprep/workflows/init.py +242 -0
  92. mdprep/workflows/inspect.py +21 -0
  93. mdprep/workflows/prepare.py +763 -0
  94. mdprep/workflows/selftest.py +220 -0
  95. mdprep/workflows/validate.py +30 -0
  96. mdprep-0.2.0.dist-info/METADATA +264 -0
  97. mdprep-0.2.0.dist-info/RECORD +100 -0
  98. mdprep-0.2.0.dist-info/WHEEL +4 -0
  99. mdprep-0.2.0.dist-info/entry_points.txt +2 -0
  100. mdprep-0.2.0.dist-info/licenses/LICENSE +21 -0
@@ -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