Skip to content

sbg/sevenbridges-cwl

Repository files navigation

SevenBridges CWL

Table of contents

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

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.

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:

  • git clone this repository
  • cd sevenbridges-cwl && pip install .

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

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

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

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.

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'})