Code Monkey home page Code Monkey logo

ruffus's Introduction

Overview

The ruffus module is a lightweight way to add support for running computational pipelines.

Computational pipelines are often conceptually quite simple, especially if we breakdown the process into simple stages, or separate tasks.

Each stage or task in a computational pipeline is represented by a python function Each python function can be called in parallel to run multiple jobs.

Ruffus was originally designed for use in bioinformatics to analyse multiple genome data sets.

Documentation

Ruffus documentation can be found here , with installation notes , a short tutorial and an in-depth manual .

Background

The purpose of a pipeline is to determine automatically which parts of a multi-stage process needs to be run and in what order in order to reach an objective ("targets")

Computational pipelines, especially for analysing large scientific datasets are in widespread use. However, even a conceptually simple series of steps can be difficult to set up and to maintain, perhaps because the right tools are not available.

Design

The ruffus module has the following design goals:

  • Simplicity. Can be picked up in 10 minutes
  • Elegance
  • Lightweight
  • Unintrusive
  • Flexible/Powerful

Features

Automatic support for

  • Managing dependencies
  • Parallel jobs
  • Re-starting from arbitrary points, especially after errors
  • Display of the pipeline as a flowchart
  • Reporting

A Simple example

Use the @transform(...) python decorator before the function definitions:

from ruffus import *

# make 10 dummy DNA data files
data_files = [(prefix + ".fastq") for prefix in range("abcdefghij")]
for df in data_files:
    open(df, "w").close()


@transform(data_files, suffix(".fastq"), ".bam")
def run_bwa(input_file, output_file):
    print "Align DNA sequences in %s to a genome -> %s " % (input_file, output_file)
    # make dummy output file
    open(output_file, "w").close()


@transform(run_bwa, suffix(".bam"), ".sorted.bam")
def sort_bam(input_file, output_file):
    print "Sort DNA sequences in %s -> %s " % (input_file, output_file)
    # make dummy output file
    open(output_file, "w").close()

pipeline_run([sort_bam], multithread = 5)

the @transform decorator indicate that the data flows from the run_bwa function to sort_bwa down the pipeline.

Usage

Each stage or task in a computational pipeline is represented by a python function Each python function can be called in parallel to run multiple jobs.

  1. Import module:

    import ruffus
    
  1. Annotate functions with python decorators

  2. Print dependency graph if you necessary

    • For a graphical flowchart in jpg, svg, dot, png, ps, gif formats:

      pipeline_printout_graph ("flowchart.svg")
      

    This requires dot to be installed

    • For a text printout of all jobs

      pipeline_printout(sys.stdout)
      
  3. Run the pipeline:

    pipeline_run(list_of_target_tasks, verbose = NNN, [multithread | multiprocess = NNN])
    

ruffus's People

Contributors

bunbun avatar jakebiesinger avatar larsyencken avatar vasisht avatar alecw avatar khughitt avatar nfoti avatar funnell avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.