snakescale

Non-strict wrappers for the data pipelining language Snakemake.


Keywords
snakemake, pipeline, wrapper
License
MIT
Install
pip install snakescale==0.8.0

Documentation

snakescale

Testing Status codecov Documentation Build Status PyPi Release Anaconda-Server Badge Python Versions MyPy Checked Code style: black

Non-strict wrappers for the data pipelining language Snakemake.

❯ conda install -c bioconda snakemake snakescale

Features:

  • Write Snakemake rules in Python-only syntax, no more shell directives!
  • These wrappers wrap the style of the tool's CLI only, and not strict, inflexible shell templates.
  • Use builtin Python types for every single parameter values:
    >>> params:
    ...     reference=True
    ...     adapters_to_check=['nextera', 'illumina']
    >>> wrapper: scale('picard', 'tool')
    ❯ picard tool REFERENCE=true ADAPTERS_TO_CHECK=nextera ADAPTERS_TO_CHECK=illumina
  • Use the Snakemake resource system for JVM resources:
    >>> resources:
    ...     heap_size=2800
    >>> wrapper: scale('picard', 'tool')
    ❯ picard -Xmx2800 tool 
  • Continuous support for new tool arguments and options by smart parameter style conversion:
    >>> params:
    ...     this_flag_is_so_new=False
    >>> wrapper: scale('picard', 'tool')
    ❯ picard tool THIS_FLAG_IS_SO_NEW=false

Complete Example

from snakescale import scale

rule bedtools_subtract:
    input:
        a='data/a.bed',
        b='data/b.bed'
    output: 'data/result.bed'
    params:
        no_name_check=True,
        g='data/ref.genome'
    wrapper: scale('bedtools', 'subtract')

Which executes this under the hood:

❯ bedtools subtract -a data/a.bed -b data/b.bed -nonamecheck -g data/ref.genome > data/result.bed

By invoking the following:

❯ snakemake -F --use-conda

Building DAG of jobs...

Creating conda environment .../bedtools/subtract/environment.yaml...
Downloading remote packages.
Environment for .../bedtools/subtract/environment.yaml created (location: .snakemake/conda/32f9fcde)
Using shell: /usr/local/bin/bash
Provided cores: 1

Rules claiming more threads will be scaled down.
Job counts:
	count	jobs
	1	bedtools_subtract
	1

[Fri Dec 28 13:13:47 2018]
rule bedtools_subtract:
    input: data/a.bed, data/b.bed
    output: data/result.bed
    jobid: 0

Activating conda environment: .snakemake/conda/32f9fcde

[Fri Dec 28 13:13:47 2018]
Finished job 0.

1 of 1 steps (100%) done
Complete log: .snakemake/log/2018-12-28T131312.471617.snakemake.log