轻量级python计算管道管理
ruffus的Python项目详细描述
概述
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.
文档
Ruffus documentation can be found here , with download notes , a tutorial and an in-depth manual .
背景
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 maintain.
设计
The ruffus module has the following design goals:
- Lightweight
- Scalable / Flexible / Powerful
- Standard Python
- Unintrusive
- As simple as possible
功能
Automatic support for
- Managing dependencies
- Parallel jobs, including dispatching work to computational clusters
- Re-starting from arbitrary points, especially after errors (checkpointing)
- Display of the pipeline as a flowchart
- Managing complex pipeline topologies
一个简单的例子
Use the @follows(…) python decorator before the function definitions:
from ruffus import * import sys def first_task(): print "First task" @follows(first_task) def second_task(): print "Second task" @follows(second_task) def final_task(): print "Final task"the ^{tt1}$ decorator indicate that the ^{tt2}$ function precedes ^{tt3}$ in the pipeline.
The canonical Ruffus decorator is ^{tt4}$ which transforms data flowing down a computational pipeline from one stage to teh next.
用法
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.
Import module:
import ruffus
Annotate functions with python decorators
Print dependency graph if you necessary
For a graphical flowchart in ^{tt5}$, ^{tt6}$, ^{tt7}$, ^{tt8}$, ^{tt9}$, ^{tt10}$ formats:
pipeline_printout_graph ("flowchart.svg")This requires ^{tt7}$ to be installed
For a text printout of all jobs
pipeline_printout(sys.stdout)运行管道:
pipeline_run()