diff --git a/src/depiction_targeted_preproc/workflow/exp/plot_map_comparison.py b/src/depiction_targeted_preproc/workflow/exp/plot_map_comparison.py index 5a8b869..b2db6e2 100644 --- a/src/depiction_targeted_preproc/workflow/exp/plot_map_comparison.py +++ b/src/depiction_targeted_preproc/workflow/exp/plot_map_comparison.py @@ -1,10 +1,11 @@ -from pathlib import Path -from typing import Annotated -import xarray import typer +import xarray from matplotlib import pyplot as plt +from pathlib import Path +from typing import Annotated +@app.default def exp_plot_map_comparison( input_mass_shift_paths: Annotated[list[Path], typer.Argument()], output_pdf_path: Annotated[Path, typer.Option()], diff --git a/src/depiction_targeted_preproc/workflow/exp/plot_map_single_for_poster.py b/src/depiction_targeted_preproc/workflow/exp/plot_map_single_for_poster.py index 3c5e069..341f7d2 100644 --- a/src/depiction_targeted_preproc/workflow/exp/plot_map_single_for_poster.py +++ b/src/depiction_targeted_preproc/workflow/exp/plot_map_single_for_poster.py @@ -1,14 +1,17 @@ -from pathlib import Path -from typing import Annotated - -import typer +import cyclopts import xarray from matplotlib import pyplot as plt +from pathlib import Path + +# TODO delete? + +app = cyclopts.App() +@app.default def exp_plot_map_single_for_poster( - input_mass_shift_path: Annotated[Path, typer.Option()], - output_pdf_path: Annotated[Path, typer.Option()], + input_mass_shift_path: Path, + output_pdf_path: Path, ) -> None: # load all the inputs shift_map = xarray.open_dataarray(input_mass_shift_path) @@ -24,4 +27,4 @@ def exp_plot_map_single_for_poster( if __name__ == "__main__": - typer.run(exp_plot_map_single_for_poster) + app() diff --git a/src/depiction_targeted_preproc/workflow/qc/plot_peak_counts_per_spectrum.py b/src/depiction_targeted_preproc/workflow/qc/plot_peak_counts_per_spectrum.py index 671541b..72c290b 100644 --- a/src/depiction_targeted_preproc/workflow/qc/plot_peak_counts_per_spectrum.py +++ b/src/depiction_targeted_preproc/workflow/qc/plot_peak_counts_per_spectrum.py @@ -1,11 +1,8 @@ -from pathlib import Path -from typing import Annotated - import altair as alt +import cyclopts import polars as pl -import typer from loguru import logger -from typer import Option +from pathlib import Path from depiction.parallel_ops import ReadSpectraParallel, ParallelConfig from depiction.persistence import ImzmlReadFile, ImzmlReader @@ -35,10 +32,14 @@ def get_peak_counts(read_peaks: ImzmlReadFile, mass_groups: pl.DataFrame, n_jobs ) +app = cyclopts.App() + + +@app.default def qc_plot_peak_counts_per_spectrum( - imzml_peaks: Annotated[Path, Option()], - output_pdf: Annotated[Path, Option()], - config_path: Annotated[Path, Option()], + imzml_peaks: Path, + output_pdf: Path, + config_path: Path, ) -> None: config = PipelineParameters.parse_yaml(config_path) read_peaks = ImzmlReadFile(imzml_peaks) @@ -63,4 +64,4 @@ def qc_plot_peak_counts_per_spectrum( if __name__ == "__main__": - typer.run(qc_plot_peak_counts_per_spectrum) + app() diff --git a/src/depiction_targeted_preproc/workflow/qc/plot_sample_spectra_before_after.py b/src/depiction_targeted_preproc/workflow/qc/plot_sample_spectra_before_after.py index f3898f1..1ad6a5c 100644 --- a/src/depiction_targeted_preproc/workflow/qc/plot_sample_spectra_before_after.py +++ b/src/depiction_targeted_preproc/workflow/qc/plot_sample_spectra_before_after.py @@ -1,8 +1,6 @@ import cyclopts import polars as pl from pathlib import Path -from typer import Option -from typing import Annotated from depiction.persistence import ImzmlReadFile from depiction.visualize.plot_mass_spectrum import PlotMassSpectrum diff --git a/src/depiction_targeted_preproc/workflow/qc/table_marker_surroundings.py b/src/depiction_targeted_preproc/workflow/qc/table_marker_surroundings.py index 845ec4c..4d427dc 100644 --- a/src/depiction_targeted_preproc/workflow/qc/table_marker_surroundings.py +++ b/src/depiction_targeted_preproc/workflow/qc/table_marker_surroundings.py @@ -1,10 +1,8 @@ -from collections.abc import Sequence -from pathlib import Path -from typing import Annotated - +import cyclopts import numpy as np import polars as pl -import typer +from collections.abc import Sequence +from pathlib import Path from depiction.parallel_ops import ParallelConfig, ReadSpectraParallel from depiction.persistence import ImzmlReadFile, ImzmlReader @@ -51,12 +49,16 @@ def get_marker_surroundings( ) +app = cyclopts.App() + + +@app.default def qc_table_marker_surroundings( - imzml_peaks: Annotated[Path, typer.Option()], - mass_list: Annotated[Path, typer.Option()], - config_path: Annotated[Path, typer.Option()], - output_table: Annotated[Path, typer.Option()], - mz_max_dist: Annotated[float, typer.Option()] = 3.0, + imzml_peaks: Path, + mass_list: Path, + config_path: Path, + output_table: Path, + mz_max_dist: float = 3.0, ) -> None: config = PipelineParameters.parse_yaml(config_path) n_jobs = config.n_jobs @@ -73,10 +75,5 @@ def qc_table_marker_surroundings( dist_df.write_parquet(output_table) -def main() -> None: - """Parses CLI args and calls `qc_table_marker_distances`.""" - typer.run(qc_table_marker_surroundings) - - if __name__ == "__main__": - main() + app()