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

Rename progress folder #371

Open
wants to merge 5 commits into
base: separate_configs
Choose a base branch
from
Open
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
45 changes: 20 additions & 25 deletions alphadia/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
default="{}",
)
parser.add_argument(
"--custom-quant-dir",
"--quant-dir",
type=str,
help="Directory to save the quantification results (psm & frag parquet files) to be reused in a distributed search",
nargs="?",
Expand Down Expand Up @@ -172,10 +172,10 @@ def parse_output_directory(args: argparse.Namespace, config: dict) -> str:
return output_directory


def parse_custom_quant_dir(args: argparse.Namespace, config: dict) -> str:
"""Parse custom quant directory.
1. Use custom quant directory from config file if specified.
2. Use custom quant directory from command line if specified.
def parse_quant_dir(args: argparse.Namespace, config: dict) -> str:
"""Parse custom quant path.
1. Use custom quant path from config file if specified.
2. Use custom quant path from command line if specified.

Parameters
----------
Expand All @@ -189,26 +189,22 @@ def parse_custom_quant_dir(args: argparse.Namespace, config: dict) -> str:
Returns
-------

custom_quant_dir : str
Custom quant directory.
quant_dir : str
path to quant directory.
"""

custom_quant_dir = None
if "custom_quant_dir" in config:
custom_quant_dir = (
utils.windows_to_wsl(config["custom_quant_dir"])
quant_dir = None
if "quant_dir" in config:
quant_dir = (
utils.windows_to_wsl(config["quant_dir"])
if args.wsl
else config["custom_quant_dir"]
else config["quant_dir"]
)

if args.custom_quant_dir is not None:
custom_quant_dir = (
utils.windows_to_wsl(args.custom_quant_dir)
if args.wsl
else args.custom_quant_dir
)
if args.quant_dir is not None:
quant_dir = utils.windows_to_wsl(args.quant_dir) if args.wsl else args.quant_dir

return custom_quant_dir
return quant_dir


def parse_raw_path_list(args: argparse.Namespace, config: dict) -> list:
Expand Down Expand Up @@ -349,7 +345,7 @@ def run(*args, **kwargs):
print("No output directory specified.")
return

custom_quant_dir = parse_custom_quant_dir(args, config)
quant_dir = parse_quant_dir(args, config)

reporting.init_logging(output_directory)
raw_path_list = parse_raw_path_list(args, config)
Expand All @@ -367,11 +363,10 @@ def run(*args, **kwargs):
for f in fasta_path_list:
logger.progress(f" {f}")

# TODO rename all output_directory, output_folder => output_path, quant_dir->quant_path (except cli parameter)
logger.progress(f"Saving output to: {output_directory}")
if custom_quant_dir is not None:
logger.progress(
f"Saving quantification output to 'custom_quant_dir': {custom_quant_dir}"
)
if quant_dir is not None:
logger.progress(f"Saving quantification output to {quant_dir=}")

try:
import matplotlib
Expand All @@ -387,7 +382,7 @@ def run(*args, **kwargs):
library_path=library_path,
fasta_path_list=fasta_path_list,
config=config,
custom_quant_dir=custom_quant_dir,
quant_path=quant_dir,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we call both of them quant_dir for simplicity?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"_path" is more correct and should be used throughout the code base (cf. also the # TODO rename all output_directory, output_folder => output_path, quant_dir->quant_path (except cli parameter))

imho it's fine to name the cli parameter quant-dir as this might be more familiar to users .. very early on this should be called quant_path then

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me

)

plan.run()
Expand Down
10 changes: 5 additions & 5 deletions alphadia/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(
fasta_path_list: list[str] | None = None,
config: dict | None = None,
config_base_path: str | None = None,
custom_quant_dir: str | None = None,
quant_path: str | None = None,
) -> None:
"""Highest level class to plan a DIA Search.
Owns the input file list, speclib and the config.
Expand All @@ -60,8 +60,8 @@ def __init__(
config_update : dict, optional
dict to update the default config. Can be used for debugging purposes etc.

custom_quant_dir : str, optional
directory to save the quantification results (psm & frag parquet files). If not provided, the results are saved in the usual workflow folder
quant_path : str, optional
path to directory to save the quantification results (psm & frag parquet files). If not provided, the results are saved in the usual workflow folder

"""
if config is None:
Expand All @@ -84,7 +84,7 @@ def __init__(
self.raw_path_list = raw_path_list
self.library_path = library_path
self.fasta_path_list = fasta_path_list
self.custom_quant_dir = custom_quant_dir
self.quant_path = quant_path

logger.progress(f"version: {alphadia.__version__}")

Expand Down Expand Up @@ -323,7 +323,7 @@ def run(
workflow = peptidecentric.PeptideCentricWorkflow(
raw_name,
self.config,
custom_temp_folder=self.custom_quant_dir,
quant_path=self.quant_path,
)

# check if the raw file is already processed
Expand Down
12 changes: 6 additions & 6 deletions alphadia/workflow/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

logger = logging.getLogger()

TEMP_FOLDER = ".progress"
QUANT_FOLDER_NAME = "quant"


class WorkflowBase:
Expand All @@ -32,7 +32,7 @@ def __init__(
self,
instance_name: str,
config: dict,
custom_temp_folder: str = None,
quant_path: str = None,
) -> None:
"""
Parameters
Expand All @@ -44,13 +44,13 @@ def __init__(
config: dict
Configuration for the workflow. This will be used to initialize the calibration manager and fdr manager

custom_temp_folder: str
custom parent_path for workflow folders, relevant for distributed searches
quant_path: str
path to directory holding quant folders, relevant for distributed searches

"""
self._instance_name: str = instance_name
self._parent_path: str = custom_temp_folder or os.path.join(
config["output"], TEMP_FOLDER
self._parent_path: str = quant_path or os.path.join(
config["output"], QUANT_FOLDER_NAME
)
self._config: dict = config
self.reporter: reporting.Pipeline | None = None
Expand Down
4 changes: 2 additions & 2 deletions alphadia/workflow/peptidecentric.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ def __init__(
self,
instance_name: str,
config: dict,
custom_temp_folder: str = None,
quant_path: str = None,
) -> None:
super().__init__(
instance_name,
config,
custom_temp_folder,
quant_path,
)
self.optlock = None

Expand Down
4 changes: 2 additions & 2 deletions misc/distributed_search/inner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ cd $chunk_directory || exit
config_filename="config.yaml"

# run with or without custom quant_dir
if [ -z "${custom_quant_dir}" ]; then
if [ -z "${quant_dir}" ]; then
alphadia --config ${config_filename}
else
alphadia --config ${config_filename} --custom-quant-dir ${custom_quant_dir}
alphadia --config ${config_filename} --quant-dir ${quant_dir}
fi

echo "AlphaDIA completed successfully"
8 changes: 4 additions & 4 deletions misc/distributed_search/outer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ mkdir -p ${first_search_directory}
mbr_library_directory="${target_directory}/3_mbr_library"
mkdir -p ${mbr_library_directory}

mbr_progress_directory="${target_directory}/3_mbr_library/chunk_0/.progress"
mbr_progress_directory="${target_directory}/3_mbr_library/chunk_0/quant"
mkdir -p ${mbr_progress_directory}

second_search_directory="${target_directory}/4_second_search"
Expand All @@ -85,7 +85,7 @@ mkdir -p ${second_search_directory}
lfq_directory="${target_directory}/5_lfq"
mkdir -p ${lfq_directory}

lfq_progress_directory="${target_directory}/5_lfq/chunk_0/.progress"
lfq_progress_directory="${target_directory}/5_lfq/chunk_0/quant"
mkdir -p ${lfq_progress_directory}

### PREDICT LIBRARY ###
Expand Down Expand Up @@ -150,7 +150,7 @@ if [[ "$first_search" -eq 1 ]]; then
--ntasks-per-node=${ntasks_per_node} \
--cpus-per-task=${cpus} \
--mem=${mem} \
--export=ALL,target_directory=${first_search_directory},custom_quant_dir=${mbr_progress_directory} ./inner.sh
--export=ALL,target_directory=${first_search_directory},quant_dir=${mbr_progress_directory} ./inner.sh
else
echo "Skipping first search"
fi
Expand Down Expand Up @@ -211,7 +211,7 @@ if [[ "$second_search" -eq 1 ]]; then
--ntasks-per-node=${ntasks_per_node} \
--cpus-per-task=${cpus} \
--mem=${mem} \
--export=ALL,target_directory=${second_search_directory},custom_quant_dir=${lfq_progress_directory} ./inner.sh
--export=ALL,target_directory=${second_search_directory},quant_dir=${lfq_progress_directory} ./inner.sh
else
echo "Skipping second search"
fi
Expand Down
7 changes: 4 additions & 3 deletions tests/unit_tests/test_outputaccumulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from conftest import mock_fragment_df, mock_precursor_df

from alphadia import outputtransform
from alphadia.workflow.base import QUANT_FOLDER_NAME


def prepare_input_data():
Expand Down Expand Up @@ -64,11 +65,11 @@ def prepare_input_data():
temp_folder = os.path.join(tempfile.gettempdir(), "alphadia")
os.makedirs(temp_folder, exist_ok=True)

progress_folder = os.path.join(temp_folder, "progress")
os.makedirs(progress_folder, exist_ok=True)
quant_path = os.path.join(temp_folder, QUANT_FOLDER_NAME)
os.makedirs(quant_path, exist_ok=True)

# setup raw folders
raw_folders = [os.path.join(progress_folder, run) for run in run_columns]
raw_folders = [os.path.join(quant_path, run) for run in run_columns]

psm_base_df = mock_precursor_df(n_precursor=100, with_decoy=True)
fragment_base_df = mock_fragment_df(n_precursor=200, n_fragments=10)
Expand Down
7 changes: 4 additions & 3 deletions tests/unit_tests/test_outputtransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from alphadia import outputtransform
from alphadia.workflow import manager, peptidecentric
from alphadia.workflow.base import QUANT_FOLDER_NAME


def test_output_transform():
Expand Down Expand Up @@ -54,11 +55,11 @@ def test_output_transform():
temp_folder = os.path.join(tempfile.gettempdir(), "alphadia")
os.makedirs(temp_folder, exist_ok=True)

progress_folder = os.path.join(temp_folder, "progress")
os.makedirs(progress_folder, exist_ok=True)
quant_path = os.path.join(temp_folder, QUANT_FOLDER_NAME)
os.makedirs(quant_path, exist_ok=True)

# setup raw folders
raw_folders = [os.path.join(progress_folder, run) for run in run_columns]
raw_folders = [os.path.join(quant_path, run) for run in run_columns]

psm_base_df = mock_precursor_df(n_precursor=100)
fragment_base_df = mock_fragment_df(n_precursor=200)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_workflow_base():
assert my_workflow.config["output"] == config["output"]
assert my_workflow.instance_name == workflow_name
assert my_workflow.parent_path == os.path.join(
config["output"], base.TEMP_FOLDER
config["output"], base.QUANT_FOLDER_NAME
)
assert my_workflow.path == os.path.join(
my_workflow.parent_path, workflow_name
Expand Down
Loading