Download tests/test_large_plot_outputs.py from QPromaQ/Docking_project: direct link, hf CLI and curl.
- Browser
- Download file 4.06 kB
-
https://huggingface.co/datasets/QPromaQ/Docking_project/resolve/f0c54945b8efdf337d23cac2d5ca433de70a02da/tests/test_large_plot_outputs.py
- Command line
-
hf download hf://datasets/QPromaQ/Docking_project@f0c54945b8efdf337d23cac2d5ca433de70a02da/tests/test_large_plot_outputs.py
-
curl -L -o test_large_plot_outputs.py https://huggingface.co/datasets/QPromaQ/Docking_project/resolve/f0c54945b8efdf337d23cac2d5ca433de70a02da/tests/test_large_plot_outputs.py
4.06 kB
| from __future__ import annotations | |
| import tempfile | |
| import unittest | |
| from pathlib import Path | |
| import numpy as np | |
| import pandas as pd | |
| from pipeline.run_large_benchmark import _plot_large | |
| class TestLargePlotOutputs(unittest.TestCase): | |
| def test_required_plot_files_created(self) -> None: | |
| rows = [] | |
| run_specs = [ | |
| ("adaptive_docking_only_top1", "adaptive", "docking_only", 1), | |
| ("adaptive_docking_only", "adaptive", "docking_only", 1), | |
| ("adaptive_full_feature", "adaptive", "full_feature", 1), | |
| ("naive_docking_only_s11", "naive_random", "docking_only", 11), | |
| ("naive_full_feature_s11", "naive_random", "full_feature", 11), | |
| ("cluster_docking_only_s101", "cluster_naive", "docking_only", 101), | |
| ("cluster_full_feature_s101", "cluster_naive", "full_feature", 101), | |
| ] | |
| for run_id, grp, mode, seed in run_specs: | |
| for step in range(20): | |
| rows.append( | |
| { | |
| "run_id": run_id, | |
| "strategy": run_id, | |
| "strategy_group": grp, | |
| "mode": mode, | |
| "seed": seed, | |
| "step": step, | |
| "docking_score": float(5 + step * 0.1 + (0.5 if grp == "naive_random" else 0.0)), | |
| "final_score": float(4.5 + step * 0.1 + (0.5 if grp == "naive_random" else 0.0)), | |
| "is_reference": step == 0, | |
| "top_pose_rmsd_consistency": float(0.5 + 0.01 * step), | |
| "replicate_score_variance": float(0.1 + 0.01 * step), | |
| } | |
| ) | |
| combined = pd.DataFrame(rows) | |
| metrics = pd.DataFrame( | |
| [ | |
| { | |
| "run_id": "adaptive_docking_only_top1", | |
| "strategy": "adaptive_docking_only_top1", | |
| "strategy_group": "adaptive", | |
| "mode": "docking_only", | |
| "top10_in_first10pct": 0.2, | |
| "top10_in_first20pct": 0.3, | |
| "best_score_so_far_auc": -10.0, | |
| }, | |
| { | |
| "run_id": "adaptive_docking_only", | |
| "strategy": "adaptive_docking_only", | |
| "strategy_group": "adaptive", | |
| "mode": "docking_only", | |
| "top10_in_first10pct": 0.3, | |
| "top10_in_first20pct": 0.4, | |
| "best_score_so_far_auc": -12.0, | |
| }, | |
| { | |
| "run_id": "adaptive_full_feature", | |
| "strategy": "adaptive_full_feature", | |
| "strategy_group": "adaptive", | |
| "mode": "full_feature", | |
| "top10_in_first10pct": 0.35, | |
| "top10_in_first20pct": 0.45, | |
| "best_score_so_far_auc": -13.0, | |
| }, | |
| ] | |
| ) | |
| feature_importance = {"rdock_total_score": 0.2, "rdock_vdw_term": 0.1, "ligand_logp": 0.05} | |
| with tempfile.TemporaryDirectory() as tmp: | |
| out = Path(tmp) | |
| paths = _plot_large(output_dir=out, combined=combined, metrics_df=metrics, feature_importance=feature_importance) | |
| self.assertTrue(paths) | |
| required = [ | |
| "selected_score_vs_step_docking_only.png", | |
| "selected_score_vs_step_full_feature.png", | |
| "rdock_top1_vs_multipose_top10.png", | |
| "rdock_top1_vs_multipose_top20.png", | |
| "rdock_feature_variant_comparison.png", | |
| "rdock_pose_consistency_vs_score.png", | |
| "rdock_replicate_stability_vs_score.png", | |
| "rdock_native_feature_importance.png", | |
| ] | |
| for name in required: | |
| p = out / "plots" / name | |
| self.assertTrue(p.exists() and p.stat().st_size > 0, f"Missing/non-empty plot: {name}") | |
| if __name__ == "__main__": | |
| unittest.main() | |