Add your description here
Project description
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:
- Clone this repo:
git clone https://github.com/cademirch/snparcher-cli.git
cd snparcher-cli
- 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
- Install
snparcherlocally and editable
- Conda:
conda activate snparcher-cli-env && pip install -e . - uv:
uv pip install -e .
- 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snparcher-0.1.0.tar.gz.
File metadata
- Download URL: snparcher-0.1.0.tar.gz
- Upload date:
- Size: 1.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9752beddabbd8af69d357175f38e8b5459e946e940023fa51d68a16ff5cca61f
|
|
| MD5 |
e6cb9e31510668ff006353ebfc32ae15
|
|
| BLAKE2b-256 |
a5da3b62b9d3c554be4010444cc203e98d29b8715610f94aa495307b6419c169
|
Provenance
The following attestation bundles were made for snparcher-0.1.0.tar.gz:
Publisher:
release.yaml on cademirch/snparcher-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snparcher-0.1.0.tar.gz -
Subject digest:
9752beddabbd8af69d357175f38e8b5459e946e940023fa51d68a16ff5cca61f - Sigstore transparency entry: 153358269
- Sigstore integration time:
-
Permalink:
cademirch/snparcher-cli@a1b82e37e2a0a5a8b6ceac0c4f4017bcd36a5239 -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/cademirch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@a1b82e37e2a0a5a8b6ceac0c4f4017bcd36a5239 -
Trigger Event:
push
-
Statement type:
File details
Details for the file snparcher-0.1.0-py3-none-any.whl.
File metadata
- Download URL: snparcher-0.1.0-py3-none-any.whl
- Upload date:
- Size: 35.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d6890c4493866087300f159e7fd72d48851b2ac033e64fc73875d45f5290e36
|
|
| MD5 |
16f479b41aa55906aa309aab450af643
|
|
| BLAKE2b-256 |
9071d4ff8ccab706c5add76d3eca1cd3838d3a400eb0f9564334922cb86f702e
|
Provenance
The following attestation bundles were made for snparcher-0.1.0-py3-none-any.whl:
Publisher:
release.yaml on cademirch/snparcher-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snparcher-0.1.0-py3-none-any.whl -
Subject digest:
8d6890c4493866087300f159e7fd72d48851b2ac033e64fc73875d45f5290e36 - Sigstore transparency entry: 153358271
- Sigstore integration time:
-
Permalink:
cademirch/snparcher-cli@a1b82e37e2a0a5a8b6ceac0c4f4017bcd36a5239 -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/cademirch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@a1b82e37e2a0a5a8b6ceac0c4f4017bcd36a5239 -
Trigger Event:
push
-
Statement type: