Skip to content

Commit

Permalink
use cyclopts
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Oct 23, 2024
1 parent 1a784de commit 78f331b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -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()],
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -24,4 +27,4 @@ def exp_plot_map_single_for_poster(


if __name__ == "__main__":
typer.run(exp_plot_map_single_for_poster)
app()
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -63,4 +64,4 @@ def qc_plot_peak_counts_per_spectrum(


if __name__ == "__main__":
typer.run(qc_plot_peak_counts_per_spectrum)
app()
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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()

0 comments on commit 78f331b

Please sign in to comment.