Utility functions to turbocharge your snakemake workflows. Virtualenvs, tarfiles, and more.
Project description
Snakeboost
Snakeboost provides enhancers and helpers to turbocharge your snakemake workflows. The project is currently in it's alpha stage.
Script Enhancers
Overview
Script enhancer functions wrap around bash scripts given to the shell
directive in Snakemake Rules.
All enhancers have a common interface designed for easy use in your workflow.
To illustrate, we'll take PipEnv
as an example (it lets you use pip virtual environments!).
- Initiate the enhancer
Import the enhancer at the top of your Snakefile
and instantiate it.
Most enhancers take a few arguments defining their global settings.
from snakeboost import PipEnv
my_env = PipEnv(packages=["numpy", "flake8"], root=("/tmp"))
- Use the enhancer in a rule
When instantiated, enhancers can be called using the bash command as an argument.
rule lint_python:
inputs: "some-script.py"
shell:
my_env.script("flake8 {input}")
Some enhancers, such as PipEnv
, provide multiple functions (e.g. .script
, .python
, etc) that provide slightly different functionality.
Others, such as Tar
, have methods that return a modified instance.
rule inspect_tarball:
inputs: "some_archive.tar.gz"
shell:
tar.using(inputs=["{input}"])("ls {input}/")
Snakeboost uses this slightly convoluted way of setting arguments to allow easy chaining of multiple enhancers. This leads us to step 3:
- Use
boost()
to chain multiple enhancers
Chaining many enhancers together can quickly lead to indentation hell:
rule lint_tarred_scripts:
inputs: "script_archive.tar.gz"
shell:
xvfb-run(
tar.using(inputs=["{input}"])(
my_env.script(
"flake8 {input}/script.py"
)
)
)
The boost()
function lets you rewrite this as:
from snakeboost import Boost
boost = Boost()
rule lint_tarred_scripts:
inputs: "script_archive.tar.gz"
shell:
boost(
xvfb_run,
tar.using(inputs=["{input}"]),
my_env.script,
"flake8 {input}/script.py"
)
That makes your rules much cleaner! However, boost provides a much more important function, as discussed fully in the docs...
Enhancers
Current enhancers include:
PipEnv
: Use pip environments in snakemake workflowsPyScript
: Use python scripts along with pip envs and other Snakeboost enhancersTar
: tar up your output files or untar input files before the jobXvfb
: Start a virtual X-server to run headless graphical commands (e.g. rendering) on servers without graphics support.
Contributing
If you have a small utility function for your Snakemake workflows, it would likely make a great addition to the Snakeboost ecosystem. Script enhancers should follow the basic interface of the other enhancers: a class initialized with global settings that exposes one or more functions that take a bash script as argument.
Snakebids uses Poetry for dependency management and pre-commit for Quality Assurance tests. If Poetry is not already installed on your system, follow the instructions on their website. Then clone the repo and initialize by running:
poetry install
poetry run pre-commit install
Project details
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
File details
Details for the file snakeboost-0.3.0.tar.gz
.
File metadata
- Download URL: snakeboost-0.3.0.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.0 Linux/5.10.102.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53a0098ef869b0c78252d3dd768291b5e2afe29a1f689c336d8a13acf9a3d7b7 |
|
MD5 | 5d5d6264b023c4857d8acc3689d3d526 |
|
BLAKE2b-256 | 4ff67d58c89445e25d5e2cb11f601e4d71262876cca3117c177fac3177af0e39 |
File details
Details for the file snakeboost-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: snakeboost-0.3.0-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.0 Linux/5.10.102.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6035d3e1c7e000be079f7bd7171102e6aeb751eb68eb9bcbd2fa800a625fe54f |
|
MD5 | 2569e7637fae7bf686be23b5924c4b78 |
|
BLAKE2b-256 | 2611c20f3b0165753426bab0e21d21982b02f17d22104d87304b89a0cf2c3153 |