Skip to content

Commit f44507a

Browse files
authored
Merge pull request #705 from MannLabs/improve_reuse_quant
Improve reuse quant
2 parents 7bb22a9 + 6ced195 commit f44507a

File tree

6 files changed

+53
-11
lines changed

6 files changed

+53
-11
lines changed

alphadia/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def _get_config_from_args(
159159
try:
160160
_recursive_update(config, json.loads(args.config_dict))
161161
except Exception as e:
162-
print(f"Could not parse config update: {e}")
162+
raise ValueError(f"Could not parse config dict: {e}") from e
163163

164164
return config, args.config, args.config_dict
165165

alphadia/search_step.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _save_config(self, output_folder: str) -> None:
107107
file_path = os.path.join(output_folder, "frozen_config.yaml")
108108
moved_path = move_existing_file(file_path)
109109
self._config.to_yaml(file_path)
110-
if moved_path:
110+
if moved_path != file_path:
111111
logging.info(f"Moved existing config file {file_path} to {moved_path}")
112112

113113
@staticmethod
@@ -434,12 +434,13 @@ def run(
434434
for file_name in required_files
435435
):
436436
logger.info(
437-
f"reuse_quant: found existing quantification for {raw_name}, skipping processing .."
437+
f"general.reuse_quant: found existing quantification for {raw_name}, skipping processing .."
438438
)
439439
is_already_processed = True
440-
logger.info(
441-
f"reuse_quant: found no existing quantification for {raw_name}, proceeding with processing .."
442-
)
440+
else:
441+
logger.warning(
442+
f"general.reuse_quant: found no existing quantification for {raw_name}, proceeding with processing .."
443+
)
443444

444445
if not is_already_processed:
445446
self._process_raw_file(workflow, dia_path, speclib)

docs/guides/libfree-gui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Also ensure the right execution engine has been selected and your version is up
99
<img src="../_static/images/libfree-gui-v1.10.1/initial_engine.png" width="100%" height="auto">
1010

1111
## 2. Project Structure
12-
In this workflow, we will perform a DIA search that handles both library generation and cross-sample quantification (Match Between Runs) automatically. We will not use transfer learning in this workflow as we are looking for unmodified peptides from isntruments well supported by the default PeptDeep model.
12+
In this workflow, we will perform a DIA search that handles both library generation and cross-sample quantification (Match Between Runs) automatically. We will not use transfer learning in this workflow as we are looking for unmodified peptides from instruments well supported by the default PeptDeep model.
1313

1414
Start by preparing a single output folder for your analysis results.
1515

docs/methods/command-line.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,34 @@ alphadia \
121121
--config config_astral_first_pass.yaml \
122122
--config-dict "{\"library_prediction\":{\"nce\":26}}"
123123
```
124+
125+
## Advanced
126+
127+
### Restarting
128+
During the main search, alphaDIA processes each raw file independently.
129+
After each file, quantification results are saved to `<output_folder>/quant/<raw_file_name>`,
130+
which can be used as a checkpoint in case the processing is interrupted.
131+
132+
The config switch `general.reuse_quant` enables skipping raw file processing
133+
when quantification results already exist, which is useful for
134+
distributed searches or for re-running the consensus step with protein inference, FDR and LFQ quantification with different parameters.
135+
136+
When enabled: Before processing each raw file, checks if quantification results already exist.
137+
If so, skips processing entirely and reuses existing quantification.
138+
If not, the file is being searched.
139+
After all quantifications are available, the workflow continues normally, combining results from all files.
140+
This way, an alphaDIA run that failed at file 9/10 (e.g. due to a cluster timeout) can simply be restarted,
141+
as only the missing files (9 and 10) will be processed.
142+
143+
The `--quant-dir` CLI parameter (Config: `quant_directory`, default: null)
144+
can be used to specify the directory containing quantification results.
145+
146+
On startup, the current configuration is dumped as `frozen_config.yaml`, which contains all information to reproduce this run.
147+
148+
Combining these three concepts, here's an example how to reuse an existing quantification (from the `previous_run` directory), but create additional
149+
output (`peptide_level_lfq`)
150+
```
151+
alphadia -o ./output_dir --quant-dir ./previous_run/quant --config ./previous_run/frozen_config.yaml --config-dict '{"general": {"reuse_quant": "True"}, "search_output": {"peptide_level_lfq": "True"}}'
152+
```
153+
154+
Cf. also the documentation on [distributed search](./dist_search_setup.md).

tests/unit_tests/test_cli.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,16 @@ def test_cli_unknown_args(
104104
@patch("alphadia.cli.parser.parse_known_args")
105105
def test_cli_minimal_args(mock_parse_known_args):
106106
"""Test the run function of the CLI with minimal arguments maps correctly to SearchPlan."""
107-
mock_args = MagicMock(config=None, version=None, check=None, output="/output")
107+
mock_args = MagicMock(
108+
config=None,
109+
version=None,
110+
check=None,
111+
output="/output",
112+
config_dict="{}",
113+
file=[],
114+
directory=[],
115+
regex=".*",
116+
)
108117
mock_parse_known_args.return_value = (mock_args, [])
109118

110119
mock_search_plan = MagicMock()
@@ -147,6 +156,10 @@ def test_cli_minimal_args_all_none(mock_parse_known_args):
147156
fasta=None,
148157
library=None,
149158
quant_dir=None,
159+
config_dict="{}",
160+
file=[],
161+
directory=[],
162+
regex=".*",
150163
)
151164
mock_parse_known_args.return_value = (mock_args, [])
152165

tests/unit_tests/workflow/test_config.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ def test_config_update_simple_two_files():
9090
# when
9191
config_1.update([config_2, config_3], do_print=True)
9292

93-
config_1.__repr__()
94-
print("X")
95-
9693
assert config_1 == expected_generic_default_config_dict | {
9794
"simple_value_int": 2,
9895
"simple_value_float": 5.0,

0 commit comments

Comments
 (0)