forked from bigbio/mokume
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_benchmark.py
More file actions
178 lines (144 loc) · 4.74 KB
/
run_benchmark.py
File metadata and controls
178 lines (144 loc) · 4.74 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env python3
"""
HeLa Benchmark Runner
Master script to run the complete benchmarking pipeline:
1. Download data from PRIDE
2. Prepare peptide data
3. Run quantification methods
4. Compute evaluation metrics
5. Generate visualizations
Usage:
python run_benchmark.py # Run all phases
python run_benchmark.py --phase 3 # Run from phase 3 onwards
python run_benchmark.py --phase 3 --stop 3 # Run only phase 3
"""
import argparse
from pathlib import Path
# Phase modules
from config import ALL_DATASETS, HELA_DATASETS, TMT_LFQ_COMPARISON
# Use importlib to handle numbered module names
import importlib.util
def import_module(name, path):
"""Import a module from a file path."""
spec = importlib.util.spec_from_file_location(name, path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
def run_phase_1(datasets, force=False):
"""Phase 1: Download data."""
print("\n" + "=" * 70)
print("PHASE 1: Data Acquisition")
print("=" * 70)
script_dir = Path(__file__).parent
mod = import_module("download_data", script_dir / "01_download_data.py")
results = mod.download_all_datasets(datasets=datasets)
return results
def run_phase_2(datasets, force=False):
"""Phase 2: Prepare peptides."""
print("\n" + "=" * 70)
print("PHASE 2: Peptide Preparation")
print("=" * 70)
script_dir = Path(__file__).parent
mod = import_module("prepare_peptides", script_dir / "02_prepare_peptides.py")
results = mod.process_all_datasets(datasets=datasets, force=force)
return results
def run_phase_3(datasets, force=False):
"""Phase 3: Run quantification."""
print("\n" + "=" * 70)
print("PHASE 3: Protein Quantification")
print("=" * 70)
script_dir = Path(__file__).parent
mod = import_module("run_quantification", script_dir / "03_run_quantification.py")
results = mod.quantify_all_datasets(datasets=datasets, force=force)
return results
def run_phase_4(datasets, force=False):
"""Phase 4: Compute metrics."""
print("\n" + "=" * 70)
print("PHASE 4: Evaluation Metrics")
print("=" * 70)
script_dir = Path(__file__).parent
mod = import_module("compute_metrics", script_dir / "04_compute_metrics.py")
results = mod.run_all_metrics(datasets=datasets)
mod.save_results(results)
return results
def run_phase_5(force=False):
"""Phase 5: Generate plots."""
print("\n" + "=" * 70)
print("PHASE 5: Visualizations")
print("=" * 70)
script_dir = Path(__file__).parent
mod = import_module("generate_plots", script_dir / "05_generate_plots.py")
mod.generate_all_plots()
return {}
def main():
parser = argparse.ArgumentParser(
description="Run HeLa benchmarking pipeline"
)
parser.add_argument(
"--phase",
type=int,
choices=[1, 2, 3, 4, 5],
default=1,
help="Start from this phase (default: 1)"
)
parser.add_argument(
"--stop",
type=int,
choices=[1, 2, 3, 4, 5],
default=5,
help="Stop at this phase (default: 5)"
)
parser.add_argument(
"--force",
action="store_true",
help="Reprocess even if output exists"
)
parser.add_argument(
"--hela-only",
action="store_true",
help="Only use HeLa datasets (skip PXD007683)"
)
parser.add_argument(
"--comparison-only",
action="store_true",
help="Only use PXD007683 TMT/LFQ comparison"
)
args = parser.parse_args()
# Select datasets
if args.hela_only:
datasets = HELA_DATASETS
elif args.comparison_only:
datasets = TMT_LFQ_COMPARISON
else:
datasets = ALL_DATASETS
print("=" * 70)
print("HeLa Protein Quantification Benchmark")
print("=" * 70)
print(f"\nDatasets: {len(datasets)}")
print(f"Phases: {args.phase} to {args.stop}")
print(f"Force recompute: {args.force}")
# Run phases
phases = {
1: ("Data Acquisition", run_phase_1),
2: ("Peptide Preparation", run_phase_2),
3: ("Protein Quantification", run_phase_3),
4: ("Evaluation Metrics", run_phase_4),
5: ("Visualizations", run_phase_5),
}
for phase_num in range(args.phase, args.stop + 1):
name, func = phases[phase_num]
if phase_num == 5:
func(force=args.force)
else:
func(datasets, force=args.force)
print("\n" + "=" * 70)
print("BENCHMARK COMPLETE")
print("=" * 70)
print("\nResults saved to:")
print(" - Analysis: hela/analysis/")
print(" - Plots: hela/plots/")
if __name__ == "__main__":
# Change to script directory for relative imports
import os
os.chdir(Path(__file__).parent)
main()