Skip to content

Commit 25dc3cd

Browse files
authored
Merge pull request #403 from MannLabs/rename_plan
renaming Plan -> SearchStep
2 parents d610eff + 6ad4bde commit 25dc3cd

File tree

10 files changed

+59
-55
lines changed

10 files changed

+59
-55
lines changed

alphadia/outputtransform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ def _build_run_internal_df(
11031103
----------
11041104
11051105
folder_path: str
1106-
Path (from the base directory of the output_folder attribute of the Plan class) to the directory containing the raw file and the managers
1106+
Path (from the base directory of the output_folder attribute of the SearchStep class) to the directory containing the raw file and the managers
11071107
11081108
11091109
Returns

alphadia/search_plan.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from alphadia.outputtransform import (
1212
SearchPlanOutput,
1313
)
14-
from alphadia.planning import (
15-
Plan,
14+
from alphadia.search_step import (
15+
SearchStep,
1616
logger,
1717
)
1818
from alphadia.utilities.logging import print_environment, print_logo
@@ -41,7 +41,7 @@ def __init__(
4141
):
4242
"""Initialize search plan.
4343
44-
In case of a single step search, this can be considered as a slim wrapper around the Plan class.
44+
In case of a single step search, this can be considered as a slim wrapper around the SearchStep class.
4545
In case of a multistep search, this class orchestrates the different steps, their data paths,
4646
and passes information from one step to the next.
4747
@@ -199,7 +199,7 @@ def run_step(
199199
quant_dir: Path | None = None,
200200
) -> None:
201201
"""Run a single step of the search plan."""
202-
step = Plan(
202+
step = SearchStep(
203203
output_folder=str(output_directory),
204204
raw_path_list=self._raw_path_list,
205205
library_path=None if library_path is None else str(library_path),

alphadia/planning.py renamed to alphadia/search_step.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
logger = logging.getLogger()
2020

2121

22-
class Plan: # TODO rename -> SearchStep, planning.py -> search_step.py
22+
class SearchStep:
2323
def __init__(
2424
self,
2525
output_folder: str,
@@ -31,7 +31,8 @@ def __init__(
3131
extra_config: dict | None = None,
3232
quant_path: str | None = None,
3333
) -> None:
34-
"""Highest level class to plan a DIA Search.
34+
"""Highest level class to plan a DIA search step.
35+
3536
Owns the input file list, speclib and the config.
3637
Performs required manipulation of the spectral library like transforming RT scales and adding columns.
3738

docs/alphadia/planning.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
planning
1+
search_step
22
========
33

4-
The planning module organizes the search schedule for searching multiple files.
4+
The search_step module organizes the search schedule for searching multiple files.
55

6-
.. automodule:: alphadia.planning
6+
.. automodule:: alphadia.search_step
77
:members:
88
:undoc-members:
99
:show-inheritance:

docs/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Modules
1212
alphadia/grouping
1313
alphadia/libtransform
1414
alphadia/outputtransform
15-
alphadia/planning
15+
alphadia/search_step
1616
alphadia/plexscoring
1717
alphadia/quadrupole
1818
alphadia/utils

nbs/debug/debug_lvl1.ipynb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
]
1111
},
1212
{
13-
"cell_type": "code",
14-
"execution_count": 1,
1513
"metadata": {},
14+
"cell_type": "code",
1615
"outputs": [],
16+
"execution_count": null,
1717
"source": [
1818
"%reload_ext autoreload\n",
1919
"%autoreload 2\n",
@@ -24,7 +24,7 @@
2424
"import seaborn as sns\n",
2525
"import os\n",
2626
"\n",
27-
"from alphadia import planning\n",
27+
"from alphadia import search_step\n",
2828
"from alphadia.workflow import peptidecentric\n",
2929
"\n",
3030
"os.environ[\"NUMBA_BOUNDSCHECK\"] = \"1\"\n",
@@ -33,10 +33,10 @@
3333
]
3434
},
3535
{
36-
"cell_type": "code",
37-
"execution_count": null,
3836
"metadata": {},
37+
"cell_type": "code",
3938
"outputs": [],
39+
"execution_count": null,
4040
"source": [
4141
"import tempfile\n",
4242
"\n",
@@ -70,10 +70,10 @@
7070
]
7171
},
7272
{
73-
"cell_type": "code",
74-
"execution_count": null,
7573
"metadata": {},
74+
"cell_type": "code",
7675
"outputs": [],
76+
"execution_count": null,
7777
"source": [
7878
"config = {\n",
7979
" \"general\": {\n",
@@ -88,28 +88,28 @@
8888
" \"target_rt_tolerance\": 200,\n",
8989
" }\n",
9090
"}\n",
91-
"plan = planning.Plan(test_folder, raw_data_path_list, library_path, config=config)"
91+
"step = search_step.SearchStep(test_folder, raw_data_path_list, library_path, config=config)"
9292
]
9393
},
9494
{
95-
"cell_type": "code",
96-
"execution_count": null,
9795
"metadata": {},
96+
"cell_type": "code",
9897
"outputs": [],
98+
"execution_count": null,
9999
"source": [
100-
"for raw_name, dia_path, speclib in plan.get_run_data():\n",
100+
"for raw_name, dia_path, speclib in step.get_run_data():\n",
101101
" pass"
102102
]
103103
},
104104
{
105-
"cell_type": "code",
106-
"execution_count": null,
107105
"metadata": {},
106+
"cell_type": "code",
108107
"outputs": [],
108+
"execution_count": null,
109109
"source": [
110110
"workflow = peptidecentric.PeptideCentricWorkflow(\n",
111111
" raw_name,\n",
112-
" plan.config,\n",
112+
" step.config,\n",
113113
")\n",
114114
"workflow.load(dia_path, speclib)\n",
115115
"workflow.search_parameter_optimization()"

nbs/search/library_search.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"\n",
1212
"import os\n",
1313
"\n",
14-
"from alphadia import planning"
14+
"from alphadia import search_step"
1515
]
1616
},
1717
{
@@ -71,9 +71,9 @@
7171
" \"target_rt_tolerance\": 150,\n",
7272
" },\n",
7373
"}\n",
74-
"plan = planning.Plan(output_location, raw_files, speclib, config_update=config_update)\n",
74+
"step = search_step.SearchStep(output_location, raw_files, speclib, config_update=config_update)\n",
7575
"\n",
76-
"plan.run()"
76+
"step.run()"
7777
]
7878
}
7979
],

tests/e2e_tests/e2e_test_cases.yaml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,24 @@ test_cases:
3535
- BasicStats
3636

3737
- name: multistep
38+
# see also transfer-dimethyl.md
3839
config:
39-
search_initial:
40-
initial_num_candidates: 1
41-
initial_rt_tolerance: 300
4240
search:
43-
target_num_candidates: 1
41+
# target_num_candidates: # mbr: 3
4442
target_ms1_tolerance: 4
4543
target_ms2_tolerance: 7
46-
target_rt_tolerance: 100
47-
calibration:
48-
batch_size: 1000
44+
target_rt_tolerance: 0.5 # mbr: 0
4945
transfer_learning:
50-
epochs: 5 # this is to speed the test up a little
46+
epochs: 5 # this is reduced to speed the test up a little
5147
library_prediction:
5248
predict: True
49+
precursor_mz:
50+
- 380
51+
- 980
52+
fixed_modifications: 'Dimethyl@Any_N-term;Dimethyl@K'
53+
variable_modifications: 'Oxidation@M;Acetyl@Protein_N-term'
54+
max_var_mod_num: 1 # mbr: 2
55+
missed_cleavages: 0 # mbr: 1
5356
multistep_search:
5457
transfer_step_enabled: True
5558
mbr_step_enabled: True

tests/unit_tests/test_search_plan.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_search_plan(config):
3434

3535

3636
@patch("alphadia.search_plan.reporting.init_logging")
37-
@patch("alphadia.search_plan.Plan")
37+
@patch("alphadia.search_plan.SearchStep")
3838
def test_runs_plan_without_transfer_and_mbr_steps(mock_plan, mock_init_logging):
3939
"""Test that the SearchPlan object runs the plan correctly without transfer and mbr steps."""
4040
search_plan = get_search_plan(BASE_USER_CONFIG)
@@ -59,7 +59,7 @@ def test_runs_plan_without_transfer_and_mbr_steps(mock_plan, mock_init_logging):
5959

6060

6161
@patch("alphadia.search_plan.reporting.init_logging")
62-
@patch("alphadia.search_plan.Plan")
62+
@patch("alphadia.search_plan.SearchStep")
6363
def test_runs_plan_without_transfer_and_mbr_steps_none_dirs(
6464
mock_plan, mock_init_logging
6565
):
@@ -94,7 +94,7 @@ def test_runs_plan_without_transfer_and_mbr_steps_none_dirs(
9494

9595

9696
@patch("alphadia.search_plan.reporting.init_logging")
97-
@patch("alphadia.search_plan.Plan")
97+
@patch("alphadia.search_plan.SearchStep")
9898
@patch("alphadia.search_plan.SearchPlan._get_optimized_values_config")
9999
def test_runs_plan_with_transfer_step(
100100
mock_get_dyn_config, mock_plan, mock_init_logging
@@ -153,7 +153,7 @@ def test_runs_plan_with_transfer_step(
153153

154154

155155
@patch("alphadia.search_plan.reporting.init_logging")
156-
@patch("alphadia.search_plan.Plan")
156+
@patch("alphadia.search_plan.SearchStep")
157157
@patch("alphadia.search_plan.SearchPlan._get_optimized_values_config")
158158
def test_runs_plan_with_mbr_step(mock_get_dyn_config, mock_plan, mock_init_logging):
159159
"""Test that the SearchPlan object runs the plan correctly with the mbr step enabled."""
@@ -203,7 +203,7 @@ def test_runs_plan_with_mbr_step(mock_get_dyn_config, mock_plan, mock_init_loggi
203203

204204

205205
@patch("alphadia.search_plan.reporting.init_logging")
206-
@patch("alphadia.search_plan.Plan")
206+
@patch("alphadia.search_plan.SearchStep")
207207
@patch("alphadia.search_plan.SearchPlan._get_optimized_values_config")
208208
def test_runs_plan_with_transfer_and_mbr_steps(
209209
mock_get_dyn_config, mock_plan, mock_init_logging

tests/unit_tests/test_planning.py renamed to tests/unit_tests/test_search_step.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from alphabase.constants import _const
66
from alphabase.constants.modification import MOD_DF
77

8-
from alphadia import planning
8+
from alphadia import search_step
99
from alphadia.test_data_downloader import DataShareDownloader
1010

1111

@@ -14,35 +14,35 @@ def test_fasta_digest():
1414
# digest & predict new library
1515
common_contaminants = os.path.join(_const.CONST_FILE_FOLDER, "contaminants.fasta")
1616
tempdir = tempfile.gettempdir()
17-
plan = planning.Plan(
17+
step = search_step.SearchStep(
1818
tempdir,
1919
fasta_path_list=[common_contaminants],
2020
config={"library_prediction": {"predict": True}},
2121
)
2222

23-
assert len(plan.spectral_library.precursor_df) > 0
24-
assert len(plan.spectral_library.fragment_df) > 0
23+
assert len(step.spectral_library.precursor_df) > 0
24+
assert len(step.spectral_library.fragment_df) > 0
2525

2626
speclib_path = os.path.join(tempdir, "speclib.hdf")
2727
assert os.path.exists(speclib_path)
2828

2929
# predict existing library
30-
plan = planning.Plan(
30+
step = search_step.SearchStep(
3131
tempdir,
3232
library_path=speclib_path,
3333
config={"library_prediction": {"predict": True}},
3434
)
35-
assert len(plan.spectral_library.precursor_df) > 0
36-
assert len(plan.spectral_library.fragment_df) > 0
35+
assert len(step.spectral_library.precursor_df) > 0
36+
assert len(step.spectral_library.fragment_df) > 0
3737

3838
# load existing library without predict
39-
plan = planning.Plan(
39+
step = search_step.SearchStep(
4040
tempdir,
4141
library_path=speclib_path,
4242
config={"library_prediction": {"predict": False}},
4343
)
44-
assert len(plan.spectral_library.precursor_df) > 0
45-
assert len(plan.spectral_library.fragment_df) > 0
44+
assert len(step.spectral_library.precursor_df) > 0
45+
assert len(step.spectral_library.fragment_df) > 0
4646

4747

4848
@pytest.mark.slow()
@@ -70,9 +70,9 @@ def test_library_loading():
7070
test_data_location = DataShareDownloader(
7171
test_dict["url"], temp_directory
7272
).download()
73-
plan = planning.Plan(temp_directory, library_path=test_data_location)
74-
assert len(plan.spectral_library.precursor_df) > 0
75-
assert len(plan.spectral_library.fragment_df) > 0
73+
step = search_step.SearchStep(temp_directory, library_path=test_data_location)
74+
assert len(step.spectral_library.precursor_df) > 0
75+
assert len(step.spectral_library.fragment_df) > 0
7676

7777

7878
def test_custom_modifications():
@@ -86,5 +86,5 @@ def test_custom_modifications():
8686
}
8787
}
8888

89-
plan = planning.Plan(temp_directory, [], config=config) # noqa F841
89+
step = search_step.SearchStep(temp_directory, [], config=config) # noqa F841
9090
assert "ThisModDoesNotExists@K" in MOD_DF["mod_name"].values

0 commit comments

Comments
 (0)