Skip to main content

snparcher CLI

This is a proof of concept for making snparcher a CLI tool. There are a handful of reasons why we are considering moving to a CLI:

  • Easier to install via pip
  • Minimize user overhead of setting up config/samplesheet files
  • Allow direct access to QC/Postprocessing/etc modules without having to setup directory structure
  • More developer control of user experience overall.

Design

Overall this is a relatively simple CLI Python app, it takes arguments/options from the command line and then does stuff. For snparcher, "doing stuff" means running our workflow files. To achieve this, I use the entrypoint function from Snakemake itself: snakemake.cli:args_to_api (see here and here for more info.) Essentialy this function takes all the CLI args and constructs the Snakemake API and executes the workflow.

I've used typer for parsing CLI arguments for its simplicity over the stdlib argparse. typer allows you to capture all CLI arguments, including unknown ones:

@app.command(
    context_settings={"allow_extra_args": True, "ignore_unknown_options": True}
)

This allows us to pass Snakemake args (--use-conda, --profile, etc) to Snakemake while capturing arguments for our command. It also allows us to specify Snakemake arguments on behalf of the user, such as the workflow file.

So when using snparcher commands, a user will pass the snparcher command arguments first, then the Snakemake arguments/options. See below for example.

Setup

To try this out:

  1. Clone this repo:
git clone https://github.com/cademirch/snparcher-cli.git
cd snparcher-cli
  1. Create Conda env, or use uv to setup env.
  • Conda:conda create -n snparcher-cli-env "python>=3.12"
  • uv:uv venv --python 3.12 && source .venv/bin/activate
  1. Install snparcher locally and editable
  • Conda: conda activate snparcher-cli-env && pip install -e .
  • uv: uv pip install -e .
  1. Check it worked! snparcher --help

Testing

You can test the cli like so:

cd test/cli
snparcher qc --coords-file cli-coords.txt --min-depth 4 test_qc_raw.vcf.gz genome1.fna.fai --use-conda --cores 8

The workflow still works when run using Snakemake:

# from root of this repo
snakemake -s snparcher/workflow/modules/qc/Snakefile -d test/run_with_snakemake --use-conda --cores 8

CLI Usage

snparcher

snparcher!

Usage:

$ snparcher [OPTIONS] COMMAND [ARGS]...

Options:

  • --install-completion: Install completion for the current shell.
  • --show-completion: Show completion for the current shell, to copy it or customize the installation.
  • --help: Show this message and exit.

Commands:

  • qc

snparcher qc

Usage:

$ snparcher qc [OPTIONS] VCF FAI

Arguments:

  • VCF: Path to vcf file [required]
  • FAI: Path to fai file [required]

Options:

  • --coords-file PATH: File containing coordinates for samples in VCF. [required]
  • --min-depth INTEGER: Min depth of SNPs to keep [required]
  • --exclude-chrs TEXT: Comma seperated list of chromosomes to exclude.
  • --nclusters INTEGER: Number of clusters for PCA [default: 3]
  • --google-api-key TEXT: Google API key for satellite map
  • --help: Show this message and exit.

Metadata

Release files for snparcher 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snparcher 0.1.0
File Size Uploaded Provenance Actions
snparcher-0.1.0.tar.gz 1.8 MB With provenance Details for snparcher-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for snparcher 0.1.0
File Interpreter ABI Platform Actions
snparcher-0.1.0-py3-none-any.whl Python 3 none any Details for snparcher-0.1.0-py3-none-any.whl

Total release size: 1.9 MB

Release files / snparcher-0.1.0.tar.gz

Download URL snparcher-0.1.0.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
9752beddabbd8af69d357175f38e8b5459e946e940023fa51d68a16ff5cca61f
BLAKE2b-256 checksum
How to use checksums
a5da3b62b9d3c554be4010444cc203e98d29b8715610f94aa495307b6419c169
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2024.

Transparency log

Release files / snparcher-0.1.0-py3-none-any.whl

Download URL snparcher-0.1.0-py3-none-any.whl
Size 35.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d6890c4493866087300f159e7fd72d48851b2ac033e64fc73875d45f5290e36
BLAKE2b-256 checksum
How to use checksums
9071d4ff8ccab706c5add76d3eca1cd3838d3a400eb0f9564334922cb86f702e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2024.

Transparency log

Security for snparcher 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for snparcher-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2024.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page