Skip to content

Commit

Permalink
Update _argument_parser.py
Browse files Browse the repository at this point in the history
Remove batch_num as param for GUI
  • Loading branch information
RobbinBouwmeester committed Aug 19, 2024
1 parent 3567cb4 commit de35427
Showing 1 changed file with 39 additions and 38 deletions.
77 changes: 39 additions & 38 deletions deeplc/_argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from gooey import GooeyParser as ArgumentParser
except ImportError:
from argparse import ArgumentParser

HAS_GOOEY = False
else:
HAS_GOOEY = True
Expand All @@ -23,10 +24,10 @@ def parse_arguments(gui=False):

# Define Gooey-specific arguments upfront to be enabled only if Gooey is available
gooey_args = {
"io_args": {"gooey_options": {'columns':2}},
"io_args": {"gooey_options": {"columns": 2}},
"file_pred": {
"widget": "FileChooser",
"metavar": "Input peptides for prediction (required)"
"metavar": "Input peptides for prediction (required)",
},
"file_cal": {"widget": "FileChooser"},
"file_pred_out": {"widget": "FileSaver"},
Expand All @@ -35,31 +36,31 @@ def parse_arguments(gui=False):
"gooey_options": {"checkbox_label": "Enable"},
"metavar": "Plot predictions",
},
"model_cal_args": {"gooey_options": {'columns':2}},
"model_cal_args": {"gooey_options": {"columns": 2}},
"file_model": {"widget": "MultiFileChooser"},
"pygam_calibration": {
"widget": "BlockCheckbox",
"gooey_options": {"checkbox_label": "Use pyGAM calibration"},
"metavar": "Use pyGAM calibration"
"metavar": "Use pyGAM calibration",
},
"transfer_learning": {
"widget": "BlockCheckbox",
"gooey_options": {"checkbox_label": "Use transfer learning calibration"},
"metavar": "Use transfer learning calibration"
"metavar": "Use transfer learning calibration",
},
"split_cal": {"gooey_options": {"visible": False}},
"dict_divider": {"gooey_options": {"visible": False}},
"advanced_args": {"gooey_options": {'columns':2}},
"advanced_args": {"gooey_options": {"columns": 2}},
"use_library": {"widget": "FileChooser"},
"write_library": {
"widget": "BlockCheckbox",
"gooey_options": {"checkbox_label": "Enable"},
"metavar": "Append to prediction library",
},
"batch_num": {
"widget": "IntegerField",
"gooey_options": {"min": 10e3, "max": 10e9, "increment": 1000},
},
# "batch_num": {
# "widget": "IntegerField",
# "gooey_options": {"min": 10e3, "max": 10e9, "increment": 1000},
# },
"n_threads": {
"widget": "Slider",
"gooey_options": {"min": 1, "max": cpu_count(), "increment": 1},
Expand All @@ -74,47 +75,44 @@ def parse_arguments(gui=False):
parser = ArgumentParser(
prog="DeepLC",
description=(
"Retention time prediction for (modified) peptides using deep "
"learning."),
"Retention time prediction for (modified) peptides using deep " "learning."
),
usage="deeplc [OPTIONS] --file_pred <peptide_file>",
formatter_class=lambda prog: HelpFormatter(prog, max_help_position=42),
add_help=False,
)

io_args = parser.add_argument_group(
"Input and output files",
**gooey_args["io_args"]
"Input and output files", **gooey_args["io_args"]
)
io_args.add_argument(
"--file_pred",
required=True,
type=str,
help="path to peptide CSV file for which to make predictions (required)",
**gooey_args["file_pred"]
**gooey_args["file_pred"],
)
io_args.add_argument(
"--file_cal",
type=str,
default=None,
metavar="Input peptides for calibration" if gui else "",
help=(
"path to peptide CSV file with retention times to use for "
"calibration"
"path to peptide CSV file with retention times to use for " "calibration"
),
**gooey_args["file_cal"]
**gooey_args["file_cal"],
)
io_args.add_argument(
"--file_pred_out",
type=str,
default=None,
metavar="Output filename" if gui else "",
help="path to write output file with predictions",
**gooey_args["file_pred_out"]
**gooey_args["file_pred_out"],
)

model_cal_args = parser.add_argument_group(
"Model and calibration",
**gooey_args["model_cal_args"]
"Model and calibration", **gooey_args["model_cal_args"]
)
model_cal_args.add_argument(
"--file_model",
Expand All @@ -128,10 +126,10 @@ def parse_arguments(gui=False):
**gooey_args["file_model"],
)

#calibration_group = model_cal_args.add_mutually_exclusive_group(
# calibration_group = model_cal_args.add_mutually_exclusive_group(
# **gooey_args["calibration_group"]
#)
#model_cal_args.add_argument(
# )
# model_cal_args.add_argument(
# "--pygam_calibration",
# dest="pygam_calibration",
# action="store_true",
Expand All @@ -141,15 +139,15 @@ def parse_arguments(gui=False):
# "recommended; default"
# ),
# **gooey_args["pygam_calibration"]
#)
# )

model_cal_args.add_argument(
"--transfer_learning",
dest="transfer_learning",
action="store_true",
default=False,
help="use transfer learning as calibration method",
**gooey_args["transfer_learning"]
**gooey_args["transfer_learning"],
)

"""
Expand All @@ -172,7 +170,7 @@ def parse_arguments(gui=False):
"number of splits in the chromatogram for piecewise linear "
"calibration fit"
),
**gooey_args["split_cal"]
**gooey_args["split_cal"],
)
model_cal_args.add_argument(
"--dict_divider",
Expand All @@ -185,7 +183,7 @@ def parse_arguments(gui=False):
"calibration; e.g. 10 means a precision of 0.1 between the "
"calibration anchor points"
),
**gooey_args["dict_divider"]
**gooey_args["dict_divider"],
)

advanced_args = parser.add_argument_group(
Expand Down Expand Up @@ -216,7 +214,7 @@ def parse_arguments(gui=False):
**gooey_args["write_library"]
)
"""

"""
advanced_args.add_argument(
"--batch_num",
type=int,
Expand All @@ -227,45 +225,48 @@ def parse_arguments(gui=False):
"prediction batch size (in peptides); lower to decrease memory "
"footprint; default=250000"
),
**gooey_args["batch_num"]
**gooey_args["batch_num"],
)
"""
advanced_args.add_argument(
"--n_threads",
type=int,
default=max(cpu_count(), 16),
metavar="Parallelization " if gui else "",
help="number of CPU threads to use; default=all with max of 16",
**gooey_args["n_threads"]
**gooey_args["n_threads"],
)
advanced_args.add_argument(
"--log_level",
type=str,
action="store",
dest="log_level",
default='info',
default="info",
metavar="Logging level" if gui else "",
choices=["debug","info","warning","error","critical"],
choices=["debug", "info", "warning", "error", "critical"],
help="verbosity of logging messages; default=info",
**gooey_args["log_level"]
**gooey_args["log_level"],
)
advanced_args.add_argument(
"-v",
"--version",
action="version",
version=__version__,
**gooey_args["version"]
**gooey_args["version"],
)
advanced_args.add_argument(
"-h",
"--help",
action="help",
help="show this help message and exit",
**gooey_args["help"]
**gooey_args["help"],
)

results = parser.parse_args()

if not results.file_pred_out:
results.file_pred_out = os.path.splitext(results.file_pred)[0] + '_deeplc_predictions.csv'
results.file_pred_out = (
os.path.splitext(results.file_pred)[0] + "_deeplc_predictions.csv"
)

return results

0 comments on commit de35427

Please sign in to comment.