Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor config #411

Merged
merged 18 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions alphadia/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,18 @@ def _get_raw_path_list_from_args_and_config(
arguments, including files from specified directories. It filters the resulting
list of file paths using a regular expression provided in the arguments.

Args:
args (argparse.Namespace): Command-line arguments containing file and directory
paths, as well as a regex pattern for filtering.
config (dict): Configuration dictionary that may include a list of raw paths
and a directory to search for files.

Returns:
list: A list of file paths that match the specified regex pattern.
Parameters
----------
args : argparse.Namespace
Command-line arguments containing file and directory
paths, as well as a regex pattern for filtering.
config : dict
Configuration dictionary that may include a list of raw paths
and a directory to search for files.

Returns
-------
list: a list of file paths that match the specified regex pattern.
"""

raw_path_list = config.get("raw_path_list", [])
Expand Down
18 changes: 16 additions & 2 deletions alphadia/constants/default.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# configuration for the extraction plan
version: 1

library: null
output_directory: null
raw_path_list: []
output: null

general:
thread_count: 10
# maximum number of threads or processes to use per raw file
Expand All @@ -25,6 +30,7 @@ library_prediction:
variable_modifications: 'Oxidation@M;Acetyl@Protein_N-term'
max_var_mod_num: 2
missed_cleavages: 1
# using tuples here as it makes interaction with the GUI easier
precursor_len:
- 7
- 35
Expand Down Expand Up @@ -52,6 +58,9 @@ library_prediction:

# define custom alphabase modifications not part of unimod or alphabase
# also used for decoy channels
# TODO make this a list
# - name: Dimethyl:d12@K
# composition: H(-2)2H(8)13C(2)
custom_modifications:
# Dimethyl @K channel decoy
Dimethyl:d12@K:
Expand Down Expand Up @@ -190,8 +199,12 @@ library_multiplexing:
# channels can be either a number or a string
# for every channel, the library gets copied and the modifications are translated according to the mapping
# the following example shows how to multiplex mTRAQ to three sample channels and a decoy channel
# TODO make this a list
# - channel_name: 0
# channel_modifications:
# mTRAQ@K: mTRAQ@K
# mTRAQ@Any_N-term: mTRAQ@Any_N-term
multiplex_mapping: {}

#0:
# mTRAQ@K: mTRAQ@K
# mTRAQ@Any_N-term: mTRAQ@Any_N-term
Expand Down Expand Up @@ -372,11 +385,12 @@ transfer_learning:
# instrument type encoded during training
instrument: 'Lumos'


# configuration for the calibration manager
# the config has to start with the calibration keyword and consists of a list of calibration groups.
# each group consists of datapoints which have multiple properties.
# This can be for example precursors (mz, rt ...), fragments (mz, ...), quadrupole (transfer_efficiency)
calibration_manager:
calibration_manager: # TODO move to a separate file or hard-code
- name: fragment
estimators:
- name: mz
Expand Down
5 changes: 3 additions & 2 deletions alphadia/search_plan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Search plan for single- and multistep search."""

import os
from collections import defaultdict
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -230,7 +231,7 @@ def _get_optimized_values_config(output_folder: Path) -> dict:
)
return {}

extra_config = {"search": {}}
extra_config = defaultdict(dict)

if not np.isnan(target_ms1_tolerance):
extra_config["search"]["target_ms1_tolerance"] = target_ms1_tolerance
Expand All @@ -243,4 +244,4 @@ def _get_optimized_values_config(output_folder: Path) -> dict:
# - target_mobility_tolerance and target_rt_tolerance should be reoptimized with the lib resulting from transfer learning step

logger.info(f"Extracted extra_config from previous step: {extra_config}")
return extra_config
return dict(extra_config)
2 changes: 1 addition & 1 deletion alphadia/search_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _init_config(
extra_config["output"] = output_folder
config_updates.append(extra_config_update)

config.update(config_updates, print_modifications=True)
config.update(config_updates, do_print=True)

if "output" not in config:
config["output"] = output_folder
Expand Down
Loading
Loading