Skip to content

Commit

Permalink
add cli
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Oct 25, 2024
1 parent 9cf0ac1 commit 358b6a6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/depiction/tools/process_spectra/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import cyclopts
import yaml
from pathlib import Path
from rich.pretty import pprint
from depiction.persistence import ImzmlReadFile, ImzmlWriteFile, ImzmlModeEnum
from depiction.tools.process_spectra.config import ProcessSpectraConfig
from depiction.tools.process_spectra.process import process_spectra

app = cyclopts.App()


@app.command
def validate(config_file: Path) -> ProcessSpectraConfig:
config = ProcessSpectraConfig.model_validate(yaml.safe_load(config_file.read_text()))
pprint(config)
return config


@app.default
def process(input_imzml_file: Path, output_imzml_file: Path, config_file: Path) -> None:
config = validate(config_file)
read_file = ImzmlReadFile(input_imzml_file)
# TODO in the future we might implement logic to determine when this can still be set to CONTINUOUS
write_file = ImzmlWriteFile(output_imzml_file, ImzmlModeEnum.PROCESSED)
process_spectra(read_file=read_file, write_file=write_file, config=config)


if __name__ == "__main__":
app()

0 comments on commit 358b6a6

Please sign in to comment.