dualmapref 0.2.8__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.
- args_parse.py +593 -0
- candidate_corrector.py +161 -0
- candidate_scorer.py +359 -0
- conformend/__init__.py +36 -0
- conformend/refiner.py +25 -0
- dataset/__init__.py +1 -0
- dataset/drugdataset.py +644 -0
- dataset/manifold.py +237 -0
- dataset/sharded_drugdataset.py +124 -0
- dataset/smiles2graph.py +217 -0
- dualmapref/__init__.py +24 -0
- dualmapref/refiner.py +16 -0
- dualmapref-0.2.8.dist-info/LICENSE +21 -0
- dualmapref-0.2.8.dist-info/METADATA +167 -0
- dualmapref-0.2.8.dist-info/RECORD +186 -0
- dualmapref-0.2.8.dist-info/WHEEL +5 -0
- dualmapref-0.2.8.dist-info/entry_points.txt +10 -0
- dualmapref-0.2.8.dist-info/top_level.txt +29 -0
- exputils.py +289 -0
- infer.py +23 -0
- infer_base_conformers.py +5589 -0
- infer_mean_dispersion_torsion.py +1117 -0
- infer_torsion.py +752 -0
- infer_torsional_denoiser.py +1021 -0
- manimol/__init__.py +30 -0
- manimol/__main__.py +6 -0
- manimol/cli.py +36 -0
- manimol/full_cli.py +41 -0
- manimol/legacy_imports.py +43 -0
- manimol/manifest.py +56 -0
- manimol/postprocess.py +148 -0
- manimol/priors.py +60 -0
- manimol/protocols.py +119 -0
- manimol/refiner.py +645 -0
- manimol/runtime.py +194 -0
- manimol/selection.py +85 -0
- manimol/torsion.py +22 -0
- manimol/train_cli.py +14 -0
- mixture_flow/src/__init__.py +1 -0
- mixture_flow/src/_path.py +7 -0
- mixture_flow/src/infer28_mixture_torsion_flow.py +1093 -0
- mixture_flow/src/mixture_torsion_flow.py +291 -0
- mixture_flow/src/summarize_mixture_debug.py +80 -0
- mixture_flow/src/train28_mixture_torsion_flow.py +583 -0
- mixture_torsion_flow.py +7 -0
- models/ manifold_learning.py +86 -0
- models/__init__.py +8 -0
- models/dist.py +273 -0
- models/dist2coords.py +23 -0
- models/egnn.py +107 -0
- models/experimental_backbones.py +364 -0
- models/gnnconv.py +512 -0
- models/kernel_inversion.py +141 -0
- models/kernels.py +427 -0
- models/losses.py +154 -0
- models/mean_dispersion_bridge.py +119 -0
- models/mean_dispersion_torsion_context.py +155 -0
- models/model.py +73 -0
- models/model0.py +2375 -0
- models/vis.py +128 -0
- pgraph_controls.py +107 -0
- scripts/__init__.py +2 -0
- scripts/analyze_basin_alignment.py +63 -0
- scripts/analyze_hif2a_conformer_aggregation.py +267 -0
- scripts/analyze_hif2a_contact_pharmacophore.py +1111 -0
- scripts/analyze_hif2a_fixed_budget.py +202 -0
- scripts/analyze_hif2a_pharmacophore.py +405 -0
- scripts/analyze_hif2a_pharmacophore_match_metric.py +386 -0
- scripts/analyze_p_control_candidate_flow.py +154 -0
- scripts/analyze_scaffold_basin.py +83 -0
- scripts/audit_dispersion_proposals.py +208 -0
- scripts/audit_etflow_protocol.py +258 -0
- scripts/audit_external_overlap.py +150 -0
- scripts/audit_oldbest_fulltrainval_split.py +82 -0
- scripts/audit_pdbbind_contact_pharmacophores.py +146 -0
- scripts/audit_qm9_geomol_test_split.py +94 -0
- scripts/audit_stage1_stage2_cross.py +131 -0
- scripts/build_geom_drugs_lowref_diagnostic.py +84 -0
- scripts/build_qm9_backfill_manifest.py +99 -0
- scripts/check_etflow_runtime.py +56 -0
- scripts/compare_prior_sources.py +122 -0
- scripts/compose_binding_mode_figure.py +87 -0
- scripts/compose_hif2a_contact_pharmacophore_suppfig.py +255 -0
- scripts/compose_hif2a_functional_geometry_pipeline.py +266 -0
- scripts/compose_manimol_internal_architecture.py +291 -0
- scripts/diagnose_flow_basin_intervention.py +54 -0
- scripts/diagnose_hif2a_pharmacophore_budget.py +185 -0
- scripts/diagnose_route2_p_ranking.py +123 -0
- scripts/discover_binding_mode_inputs.py +30 -0
- scripts/evaluate_functional_prior_stage1.py +230 -0
- scripts/evaluate_geomanimol.py +74 -0
- scripts/evaluate_geomanimol_flow.py +23 -0
- scripts/evaluate_geomanimol_multiscaffold.py +46 -0
- scripts/evaluate_geomanimol_residual.py +45 -0
- scripts/evaluate_geomanimol_torsion.py +40 -0
- scripts/evaluate_hif2a_bioactive_enrichment.py +91 -0
- scripts/evaluate_hif2a_pms_suite.py +440 -0
- scripts/evaluate_pdbbind_contact_pms.py +155 -0
- scripts/evaluate_platinum_external.py +114 -0
- scripts/evaluate_platinum_pool.py +82 -0
- scripts/evaluate_route2_calibrated_p.py +104 -0
- scripts/evaluate_route2_library_components.py +596 -0
- scripts/evaluate_route2_p_basin_budget.py +288 -0
- scripts/evaluate_stage1_checkpoint_only.py +30 -0
- scripts/export_dispersion_bond_audit.py +136 -0
- scripts/export_top20_shards.py +207 -0
- scripts/external_validation_metrics.py +152 -0
- scripts/fit_topology_prior.py +117 -0
- scripts/frozen_dispersion_audit.py +281 -0
- scripts/geomanimol_debug.py +50 -0
- scripts/geomanimol_smoke.py +37 -0
- scripts/infer_etflow_matched.py +524 -0
- scripts/inspect_checkpoint.py +12 -0
- scripts/inspect_conformer_capacity.py +71 -0
- scripts/inspect_pool.py +12 -0
- scripts/make_figure3_selection_loss.py +474 -0
- scripts/make_figure3_selection_summary.py +275 -0
- scripts/make_geom_debug_subset.py +62 -0
- scripts/make_low_reference_test_subset.py +70 -0
- scripts/merge_stage1_into_stage2.py +82 -0
- scripts/place_hif2a_candidates_for_evaluation.py +66 -0
- scripts/plot_hif2a_low_budget_efficiency.py +100 -0
- scripts/plot_prior_validation.py +48 -0
- scripts/precompute_stage2_assignments.py +90 -0
- scripts/prepare_bace_activity.py +98 -0
- scripts/prepare_bace_etkdg_benchmark.py +90 -0
- scripts/prepare_figure5_4x4_cases.py +470 -0
- scripts/prepare_geom_drugs_geomol_top20.py +472 -0
- scripts/prepare_pdbbind_core_raw.py +90 -0
- scripts/prepare_platinum_raw.py +74 -0
- scripts/prepare_pubchem_etkdg.py +54 -0
- scripts/rebuild_hif2a_final_sdf_and_metrics.py +55 -0
- scripts/rebuild_hif2a_fixed_pool_sweep.py +175 -0
- scripts/rebuild_hif2a_strict.py +220 -0
- scripts/recompute_hif2a_bootstrap.py +63 -0
- scripts/reference_free_geometry.py +112 -0
- scripts/render_binding_modes.py +413 -0
- scripts/render_figure5_4x4.py +330 -0
- scripts/render_figure6_pharmacophore_pymol.py +162 -0
- scripts/render_hif2a_contact_pharmacophore_pymol.py +414 -0
- scripts/render_hif2a_figure11.py +397 -0
- scripts/run_bace_2d_baseline.py +73 -0
- scripts/run_drugs_validation_matrix.py +225 -0
- scripts/run_external_reference_free.py +53 -0
- scripts/run_manimol_finalk_sensitivity.py +106 -0
- scripts/run_manimol_oversampling_sensitivity.py +109 -0
- scripts/run_pdisp_matched_intervention.py +116 -0
- scripts/run_stage1_stage2_cross20.py +83 -0
- scripts/score_hif2a_candidates_with_pgraph.py +221 -0
- scripts/summarize_dispersion_intervention.py +88 -0
- scripts/test_mean_dispersion_bridge.py +50 -0
- scripts/train_dispersion_head_diagnostic.py +320 -0
- scripts/train_dispersion_head_streaming.py +519 -0
- scripts/train_geomanimol.py +100 -0
- scripts/train_geomanimol_flow.py +26 -0
- scripts/train_geomanimol_residual.py +70 -0
- scripts/train_geomanimol_torsion.py +50 -0
- scripts/train_quantile_representation_diagnostic.py +204 -0
- scripts/validate_mean_dispersion_prior.py +173 -0
- scripts/validate_packed_shard.py +41 -0
- scripts/validate_stage1_prior.py +221 -0
- scripts/validate_top20_shards.py +36 -0
- scripts/validation/__init__.py +1 -0
- scripts/validation/hif2a_downstream_baselines.py +105 -0
- scripts/validation/hif2a_pairwise_ranker.py +218 -0
- scripts/verify_binding_mode_figure.py +47 -0
- torsion_manifold.py +281 -0
- train.py +78 -0
- train_graph_encoder.py +206 -0
- train_local_torsion_corrector.py +511 -0
- train_mean_dispersion_torsion_prior.py +329 -0
- train_probability_basin.py +235 -0
- train_torsion_generator.py +1631 -0
- train_torsion_manifold_prior.py +258 -0
- train_torsional_denoiser.py +415 -0
- trainer.py +1038 -0
- utils/__init__.py +7 -0
- utils/checkpoint.py +40 -0
- utils/device.py +17 -0
- utils/helpers.py +98 -0
- utils/kabsch.py +29 -0
- utils/lookup_table.py +164 -0
- utils/metrics.py +50 -0
- utils/optuna.py +111 -0
- utils/save_mol.py +366 -0
- utils/util.py +36 -0
manimol/runtime.py
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"""Public entry points for the full, checkpoint-backed ConforMend runtime.
|
|
2
|
+
|
|
3
|
+
The heavy inference implementation is imported lazily. This keeps the
|
|
4
|
+
lightweight numerical utilities importable on machines that do not install
|
|
5
|
+
PyTorch, PyG, or RDKit, while ``conformend[full]`` exposes the paper pipeline.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Optional, Sequence
|
|
14
|
+
|
|
15
|
+
from .manifest import write_run_manifest
|
|
16
|
+
from .protocols import prepare_protocol_argv
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def run_full_inference(argv: Optional[Sequence[str]] = None):
|
|
20
|
+
"""Run the repository's real Stage-I/Stage-II inference entry point.
|
|
21
|
+
|
|
22
|
+
Parameters are the same command-line arguments accepted by
|
|
23
|
+
``infer_mean_dispersion_torsion.py``. The implementation is deliberately
|
|
24
|
+
delegated to that source file so the package does not maintain a second
|
|
25
|
+
model or post-processing implementation.
|
|
26
|
+
"""
|
|
27
|
+
raw_argv = list(argv) if argv is not None else sys.argv[1:]
|
|
28
|
+
if "--help" in raw_argv or "-h" in raw_argv:
|
|
29
|
+
import infer_mean_dispersion_torsion
|
|
30
|
+
|
|
31
|
+
old_argv = sys.argv
|
|
32
|
+
sys.argv = ["conformend-infer", *raw_argv]
|
|
33
|
+
try:
|
|
34
|
+
return infer_mean_dispersion_torsion.main()
|
|
35
|
+
finally:
|
|
36
|
+
sys.argv = old_argv
|
|
37
|
+
|
|
38
|
+
import infer_base_conformers
|
|
39
|
+
import infer_mean_dispersion_torsion
|
|
40
|
+
|
|
41
|
+
prepared_argv, protocol, defaults = prepare_protocol_argv(raw_argv)
|
|
42
|
+
output_dir = _value_after(prepared_argv, "--output_dir", "outputs/infer")
|
|
43
|
+
checkpoint = _value_after(prepared_argv, "--base_checkpoint")
|
|
44
|
+
data_root = _value_after(prepared_argv, "--data_root")
|
|
45
|
+
manifest_path = write_run_manifest(
|
|
46
|
+
output_dir,
|
|
47
|
+
protocol=protocol,
|
|
48
|
+
argv=prepared_argv,
|
|
49
|
+
checkpoint=checkpoint,
|
|
50
|
+
data_root=data_root,
|
|
51
|
+
defaults=defaults,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
old_argv = sys.argv
|
|
55
|
+
patched_names = ("parse_args", "load_model", "sample_conformers", "optimize_with_mmff", "optimize_torsions_fast")
|
|
56
|
+
saved = {name: getattr(infer_base_conformers, name) for name in patched_names if hasattr(infer_base_conformers, name)}
|
|
57
|
+
sys.argv = ["conformend-infer", *prepared_argv]
|
|
58
|
+
try:
|
|
59
|
+
result = infer_mean_dispersion_torsion.main()
|
|
60
|
+
write_run_manifest(
|
|
61
|
+
output_dir,
|
|
62
|
+
protocol=protocol,
|
|
63
|
+
argv=prepared_argv,
|
|
64
|
+
checkpoint=checkpoint,
|
|
65
|
+
data_root=data_root,
|
|
66
|
+
status="completed",
|
|
67
|
+
defaults=defaults,
|
|
68
|
+
)
|
|
69
|
+
return result
|
|
70
|
+
finally:
|
|
71
|
+
sys.argv = old_argv
|
|
72
|
+
for name, value in saved.items():
|
|
73
|
+
setattr(infer_base_conformers, name, value)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _value_after(argv: Sequence[str], name: str, default: str = "") -> str:
|
|
77
|
+
for index, item in enumerate(argv):
|
|
78
|
+
if item == name and index + 1 < len(argv):
|
|
79
|
+
return str(argv[index + 1])
|
|
80
|
+
if item.startswith(name + "="):
|
|
81
|
+
return item.split("=", 1)[1]
|
|
82
|
+
return default
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@dataclass
|
|
86
|
+
class ConforMend:
|
|
87
|
+
"""Configuration handle for checkpoint-backed ConforMend inference.
|
|
88
|
+
|
|
89
|
+
The current production implementation consumes the same processed/raw
|
|
90
|
+
dataset records used by the paper benchmark. ``generate`` therefore
|
|
91
|
+
requires a dataset root; a direct SMILES adapter is intentionally not
|
|
92
|
+
fabricated here because it would need to reproduce the project's exact
|
|
93
|
+
PyG graph, conformer, torsion-index, and reference-free preparation
|
|
94
|
+
contract.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
checkpoint: str
|
|
98
|
+
device: str = "cpu"
|
|
99
|
+
denoiser_checkpoint: str = ""
|
|
100
|
+
|
|
101
|
+
@classmethod
|
|
102
|
+
def from_pretrained(
|
|
103
|
+
cls, checkpoint: str, *, device: str = "cpu", denoiser_checkpoint: str = ""
|
|
104
|
+
) -> "ConforMend":
|
|
105
|
+
checkpoint_path = Path(checkpoint).expanduser()
|
|
106
|
+
if not checkpoint_path.is_file():
|
|
107
|
+
raise FileNotFoundError(f"ConforMend checkpoint does not exist: {checkpoint_path}")
|
|
108
|
+
if denoiser_checkpoint and not Path(denoiser_checkpoint).expanduser().is_file():
|
|
109
|
+
raise FileNotFoundError(
|
|
110
|
+
f"ConforMend denoiser checkpoint does not exist: {denoiser_checkpoint}"
|
|
111
|
+
)
|
|
112
|
+
return cls(
|
|
113
|
+
checkpoint=str(checkpoint_path),
|
|
114
|
+
device=str(device),
|
|
115
|
+
denoiser_checkpoint=str(denoiser_checkpoint),
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
def generate(
|
|
119
|
+
self,
|
|
120
|
+
*,
|
|
121
|
+
data_root: str,
|
|
122
|
+
output_dir: str,
|
|
123
|
+
dataset: str = "Drugs",
|
|
124
|
+
raw_prefix: str = "geom_drugs",
|
|
125
|
+
split: str = "test",
|
|
126
|
+
oversample_factor: float = 15.0,
|
|
127
|
+
select_candidates: str = "",
|
|
128
|
+
protocol: str = "mean_dispersion_denoising",
|
|
129
|
+
max_output_confs: int = 0,
|
|
130
|
+
limit_molecules: int = 0,
|
|
131
|
+
**options,
|
|
132
|
+
):
|
|
133
|
+
"""Generate/evaluate using the complete repository inference path.
|
|
134
|
+
|
|
135
|
+
``options`` are forwarded as ``--key value`` pairs to the real
|
|
136
|
+
inference parser. Boolean options should be passed as ``True`` or
|
|
137
|
+
``False``. The returned value is the return value of the inference
|
|
138
|
+
entry point; generated artifacts are written under ``output_dir``.
|
|
139
|
+
"""
|
|
140
|
+
argv = [
|
|
141
|
+
"--protocol",
|
|
142
|
+
protocol,
|
|
143
|
+
"--base_checkpoint",
|
|
144
|
+
self.checkpoint,
|
|
145
|
+
"--checkpoint",
|
|
146
|
+
self.checkpoint,
|
|
147
|
+
"--dataset",
|
|
148
|
+
dataset,
|
|
149
|
+
"--data_root",
|
|
150
|
+
data_root,
|
|
151
|
+
"--raw_prefix",
|
|
152
|
+
raw_prefix,
|
|
153
|
+
"--split",
|
|
154
|
+
split,
|
|
155
|
+
"--device",
|
|
156
|
+
self.device,
|
|
157
|
+
"--oversample_factor",
|
|
158
|
+
str(float(oversample_factor)),
|
|
159
|
+
"--max_output_confs",
|
|
160
|
+
str(int(max_output_confs)),
|
|
161
|
+
"--limit_molecules",
|
|
162
|
+
str(int(limit_molecules)),
|
|
163
|
+
"--output_dir",
|
|
164
|
+
output_dir,
|
|
165
|
+
]
|
|
166
|
+
if self.denoiser_checkpoint:
|
|
167
|
+
argv.extend(["--denoiser_checkpoint", self.denoiser_checkpoint])
|
|
168
|
+
elif protocol in ("mean_dispersion_denoising", "route2_paper"):
|
|
169
|
+
argv.append("--pbasin_only")
|
|
170
|
+
if select_candidates:
|
|
171
|
+
argv.extend(["--select_candidates", select_candidates])
|
|
172
|
+
negative_flags = {
|
|
173
|
+
"use_mmff": "--no_mmff",
|
|
174
|
+
"use_torsion_refine": "--no_torsion_refine",
|
|
175
|
+
"use_etkdg": "--no_etkdg",
|
|
176
|
+
"use_egnn_refine": "--no_egnn_refine",
|
|
177
|
+
"xtb_relax": "--no_xtb_relax",
|
|
178
|
+
}
|
|
179
|
+
for key, value in options.items():
|
|
180
|
+
# The production argparse surface uses underscore-separated names.
|
|
181
|
+
# Preserve them exactly so wrapper calls remain equivalent to CLI calls.
|
|
182
|
+
flag = "--" + key
|
|
183
|
+
if isinstance(value, bool):
|
|
184
|
+
if value:
|
|
185
|
+
argv.append(flag)
|
|
186
|
+
elif key in negative_flags:
|
|
187
|
+
argv.append(negative_flags[key])
|
|
188
|
+
elif value is not None:
|
|
189
|
+
argv.extend([flag, str(value)])
|
|
190
|
+
return run_full_inference(argv)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
# Compatibility alias for pre-rename code and serialized workflows.
|
|
194
|
+
ManiMol = ConforMend
|
manimol/selection.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""Reference-free representative selection for finite conformer libraries."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def pairwise_rmsd(conformers: np.ndarray) -> np.ndarray:
|
|
9
|
+
"""Compute pairwise coordinate RMSD for aligned conformers.
|
|
10
|
+
|
|
11
|
+
The input must have shape ``(n_conformers, n_atoms, 3)``. Alignment is
|
|
12
|
+
intentionally left to the caller so that this small package does not hide
|
|
13
|
+
a choice of atom mapping or symmetry handling.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
data = np.asarray(conformers, dtype=float)
|
|
17
|
+
if data.ndim != 3 or data.shape[-1] != 3:
|
|
18
|
+
raise ValueError("conformers must have shape (n_conformers, n_atoms, 3)")
|
|
19
|
+
if data.shape[0] == 0 or data.shape[1] == 0:
|
|
20
|
+
raise ValueError("conformers must contain at least one conformer and atom")
|
|
21
|
+
if not np.isfinite(data).all():
|
|
22
|
+
raise ValueError("conformers must contain only finite coordinates")
|
|
23
|
+
delta = data[:, None, :, :] - data[None, :, :, :]
|
|
24
|
+
return np.sqrt(np.mean(delta * delta, axis=(2, 3)))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def density_centrality_select(
|
|
28
|
+
conformers: np.ndarray,
|
|
29
|
+
k: int,
|
|
30
|
+
*,
|
|
31
|
+
alpha: float = 1.0,
|
|
32
|
+
beta: float = 0.45,
|
|
33
|
+
duplicate_radius: float = 0.04,
|
|
34
|
+
) -> np.ndarray:
|
|
35
|
+
"""Select ``k`` diverse, locally central conformers without references.
|
|
36
|
+
|
|
37
|
+
A greedy score combines normalized local density and distance from the
|
|
38
|
+
already selected set. The first representative is the most central
|
|
39
|
+
candidate. ``duplicate_radius`` is applied in the same RMSD units as the
|
|
40
|
+
input coordinates. Ties are resolved by the original candidate index.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
distances = pairwise_rmsd(conformers)
|
|
44
|
+
n = distances.shape[0]
|
|
45
|
+
if not 1 <= int(k) <= n:
|
|
46
|
+
raise ValueError(f"k must be between 1 and {n}")
|
|
47
|
+
if alpha < 0 or beta < 0:
|
|
48
|
+
raise ValueError("alpha and beta must be non-negative")
|
|
49
|
+
if duplicate_radius < 0:
|
|
50
|
+
raise ValueError("duplicate_radius must be non-negative")
|
|
51
|
+
|
|
52
|
+
positive = distances[distances > 0]
|
|
53
|
+
scale = float(np.median(positive)) if positive.size else 1.0
|
|
54
|
+
scale = max(scale, np.finfo(float).eps)
|
|
55
|
+
similarity = np.exp(-distances / scale)
|
|
56
|
+
density = similarity.mean(axis=1)
|
|
57
|
+
density = _normalize(density)
|
|
58
|
+
|
|
59
|
+
selected = [int(np.argmax(density))]
|
|
60
|
+
available = np.ones(n, dtype=bool)
|
|
61
|
+
available[selected[0]] = False
|
|
62
|
+
while len(selected) < int(k):
|
|
63
|
+
min_distance = distances[:, selected].min(axis=1)
|
|
64
|
+
diversity = _normalize(min_distance)
|
|
65
|
+
score = alpha * density + beta * diversity
|
|
66
|
+
score[~available] = -np.inf
|
|
67
|
+
# Suppress near-duplicates, but retain a fallback in case all
|
|
68
|
+
# candidates are inside the radius.
|
|
69
|
+
suppressed = available & (min_distance <= duplicate_radius)
|
|
70
|
+
candidate_scores = score.copy()
|
|
71
|
+
candidate_scores[suppressed] = -np.inf
|
|
72
|
+
if not np.isfinite(candidate_scores).any():
|
|
73
|
+
candidate_scores = score
|
|
74
|
+
next_index = int(np.argmax(candidate_scores))
|
|
75
|
+
selected.append(next_index)
|
|
76
|
+
available[next_index] = False
|
|
77
|
+
return np.asarray(selected, dtype=int)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _normalize(values: np.ndarray) -> np.ndarray:
|
|
81
|
+
values = np.asarray(values, dtype=float)
|
|
82
|
+
span = values.max() - values.min()
|
|
83
|
+
if span <= np.finfo(float).eps:
|
|
84
|
+
return np.zeros_like(values)
|
|
85
|
+
return (values - values.min()) / span
|
manimol/torsion.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Small circular-statistics helpers used by torsion-space diagnostics."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def wrap_angle(angle: float | np.ndarray) -> float | np.ndarray:
|
|
9
|
+
"""Wrap radians into the interval ``[-pi, pi)``."""
|
|
10
|
+
|
|
11
|
+
return (np.asarray(angle) + np.pi) % (2.0 * np.pi) - np.pi
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def circular_standard_deviation(angles: np.ndarray) -> float:
|
|
15
|
+
"""Return circular standard deviation of angles in radians."""
|
|
16
|
+
|
|
17
|
+
values = np.asarray(angles, dtype=float)
|
|
18
|
+
if values.ndim != 1 or values.size == 0 or not np.isfinite(values).all():
|
|
19
|
+
raise ValueError("angles must be a non-empty finite one-dimensional array")
|
|
20
|
+
resultant = np.hypot(np.mean(np.cos(values)), np.mean(np.sin(values)))
|
|
21
|
+
resultant = np.clip(resultant, np.finfo(float).tiny, 1.0)
|
|
22
|
+
return float(np.sqrt(-2.0 * np.log(resultant)))
|
manimol/train_cli.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Thin console wrapper around the repository's real training entry point."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import runpy
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main() -> None:
|
|
11
|
+
script = Path(__file__).resolve().parent.parent / "train.py"
|
|
12
|
+
sys.argv = [str(script), *sys.argv[1:]]
|
|
13
|
+
runpy.run_path(str(script), run_name="__main__")
|
|
14
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Mixture-flow source modules."""
|