Skip to content

Latest commit

 

History

History
101 lines (69 loc) · 2.88 KB

README.rst

File metadata and controls

101 lines (69 loc) · 2.88 KB

pytest-ngsfixtures

https://travis-ci.org/percyfal/pytest-ngsfixtures.svg?branch=master

About

This is a pytest plugin that provides functionality for next generation sequencing pytest fixtures. There are some predefined fixtures, but the main functionality depends on configuring fixtures via the pytest.mark helper function.

See the pytest-ngsfixtures documentation for more information and usage.

  • Free software: GNU General Public License v3

Features

  • a small test ngs data set
  • predefined sample layouts
  • wrappers for quickly setting up workflow tests

Installation

$ conda install -c percyfal pytest-ngsfixtures
$ pip install pytest-ngsfixtures

Usage

You can easily setup a test requiring the predefined samples and ref fixtures:

def test_data(samples, ref):
 shell("bwa index {}".format(ref.join("scaffolds.fa")))
 shell("bwa mem {} {} {} | samtools view -b > {}".format(
     ref.join("scaffolds.fa"),
     samples.join("s1_1.fastq.gz"),
     samples.join("s1_2.fastq.gz"),
     samples.join("s1.bam")
 ))
 assert samples.join("s1.bam").exists()

The samples and ref fixtures can also be configured to use local files:

import pytest

@pytest.mark.samples(layout={'s1_1.fastq.gz': "/path/to/read1.fastq.gz",
                             's1_2.fastq.gz': "/path/to/read2.fastq.gz"})
@pytest.mark.ref(data={'ref.fa': "/path/to/reference.fa"})
def test_data(samples, ref):
    # Do something with data

In addition, there are wrapper functions and fixtures for workflow managers, including Snakemake.

import pytest
from pytest_ngsfixtures.wm.snakemake import snakefile, run as snakemake_run

# By default, the snakefile fixture assumes there is a Snakefile in
# the test file directory
def test_workflow(samples, snakefile):
    snakemake_run(snakefile, options=["-d", str(samples)])
    assert samples.join("results.txt").exists()

See the pytest-ngsfixtures documentation for more examples.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.