sbg / sevenbridges-cwl

Seven Bridges Python library for programatic generation of CWL workflows.
Other
19 stars 3 forks source link
bioinformatics common-workflow-language cwl python sevenbridges

SevenBridges CWL

Table of contents

  1. Overview
  2. Install
  3. Docs
  4. Run tests
  5. Examples

Overview

SevenBridges CWL package provides python bindings for Common Workflow Language. It is intended for developers who want to use python code to generate CWL documents. If creating a document through the GUI is preferable, then look at the Rabix Composer.

Install

Official releases

Official releases are available via pip install sevenbridges-cwl (This is the pypi entry for this project)

Development versions

To obtain unreleased versions:

The master branch is for more stable code while develop is for cutting edge features being currently worked on

Docs

Complete documentation can be found here.

If you are interested in reviewing this documentation locally, clone this repository, position yourself in the docs directory and after installing requirements-dev.txt, invoke:

make html

Run Tests

In order to run tests clone this repository, position yourself in the root of the cloned project and, after installing requirements-dev.txt, invoke:

pytest

Examples

The following code will give a brief overview of what this package can offer through simple examples.

A Complete list of all examples can be found here.

Run workflow on a SevenBridges platform

from sbg import cwl

# First node
@cwl.to_tool(
    inputs=dict(x=cwl.String()),
    outputs=dict(out=cwl.Float(required=True)),
    docker='images.sbgenomics.com/filip_tubic/ubuntu1604py'
)
def to_float(x):
    return dict(out=float(x))

# Second node
@cwl.to_tool(
    inputs=dict(x=cwl.Float(), n=cwl.Int()),
    outputs=dict(out=cwl.Float()),
    docker='images.sbgenomics.com/filip_tubic/ubuntu1604py'
)
def times_n(x, n=10):
    return dict(out=x * n)

wf = cwl.Workflow()

# create tools
t1 = to_float()
t2 = times_n()

# steps
wf.add_step(t1, expose=['x'])
wf.add_step(t2, expose=['n', 'out'])

# add connections
wf.add_connection(f'{t1.id}.out', f'{t2.id}.x')

# Session on a SBG platform
session = cwl.Session(profile='<your_profile>')

session.run('<your_project>', wf, inputs={'x': '10.2'})