From 337b6a5eb37cfba3e71a587c2124d16a28105fa3 Mon Sep 17 00:00:00 2001 From: FloWuenne Date: Fri, 21 Jul 2023 16:43:18 +0200 Subject: [PATCH 1/2] Added first simple version of CLI script. --- src/spatialdata_io/__main__.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/spatialdata_io/__main__.py diff --git a/src/spatialdata_io/__main__.py b/src/spatialdata_io/__main__.py new file mode 100644 index 00000000..a5e9b508 --- /dev/null +++ b/src/spatialdata_io/__main__.py @@ -0,0 +1,19 @@ +import os +import click +import spatialdata_io + +@click.command() +@click.argument('input_path', type=click.Path(exists=True)) +@click.argument('output_path', type=click.Path()) +@click.option('--reader_name', type=click.Choice(['codex', 'cosmx', 'curio', 'mcmicro', 'merscope', 'metaspace', 'resolve', 'steinbock', 'visium', 'xenium']), help='name of the reader to use', required=True) +def main(input_path, output_path, reader_name): + if os.path.exists(output_path): + print("Spatialdata object already exists! If you want to recompute it, please delete the existing Zarr store.") + else: + reader_func = getattr(spatialdata_io, reader_name) + sdata = reader_func(input_path) ## Can only handle mcmicro at the moment. Add logic for other readers!!! + sdata.write(output_path) + + +if __name__ == '__main__': + main() \ No newline at end of file From 55118531f1aa0742283e82b31bfb2fd2f2191074 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 21 Jul 2023 20:02:10 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/spatialdata_io/__main__.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/spatialdata_io/__main__.py b/src/spatialdata_io/__main__.py index a5e9b508..2f0b4001 100644 --- a/src/spatialdata_io/__main__.py +++ b/src/spatialdata_io/__main__.py @@ -1,19 +1,29 @@ import os + import click + import spatialdata_io + @click.command() -@click.argument('input_path', type=click.Path(exists=True)) -@click.argument('output_path', type=click.Path()) -@click.option('--reader_name', type=click.Choice(['codex', 'cosmx', 'curio', 'mcmicro', 'merscope', 'metaspace', 'resolve', 'steinbock', 'visium', 'xenium']), help='name of the reader to use', required=True) +@click.argument("input_path", type=click.Path(exists=True)) +@click.argument("output_path", type=click.Path()) +@click.option( + "--reader_name", + type=click.Choice( + ["codex", "cosmx", "curio", "mcmicro", "merscope", "metaspace", "resolve", "steinbock", "visium", "xenium"] + ), + help="name of the reader to use", + required=True, +) def main(input_path, output_path, reader_name): if os.path.exists(output_path): print("Spatialdata object already exists! If you want to recompute it, please delete the existing Zarr store.") else: reader_func = getattr(spatialdata_io, reader_name) - sdata = reader_func(input_path) ## Can only handle mcmicro at the moment. Add logic for other readers!!! + sdata = reader_func(input_path) ## Can only handle mcmicro at the moment. Add logic for other readers!!! sdata.write(output_path) -if __name__ == '__main__': - main() \ No newline at end of file +if __name__ == "__main__": + main()