Skip to content

Commit

Permalink
Merge pull request #1 from CancerCollaboratory/develop
Browse files Browse the repository at this point in the history
This updates the fork with WDL and Nextflow versions of the tool
  • Loading branch information
agduncan94 authored Aug 31, 2018
2 parents 2b1d45b + b12811b commit a4d036d
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 6 deletions.
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ sudo: required
services:
- docker

env:
- LANGUAGE=cwl
- LANGUAGE=wdl
- LANGUAGE=nfl

notifications:
slack:
on_success: never
Expand All @@ -16,10 +21,10 @@ jdk:

before_install:
- docker build -t quay.io/collaboratory/dockstore-tool-bamstats .
- pip2.7 install --user setuptools==24.0.3
- bash before-install.sh

install:
- pip2.7 install --user cwl-runner cwltool==1.0.20160712154127 schema-salad==1.14.20160708181155 avro==1.8.1
- bash install.sh

script:
- cwltool --non-strict Dockstore.cwl test.json
- bash script.sh
27 changes: 27 additions & 0 deletions Dockstore.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
task bamstats {
File bam_input
Int mem_gb

command {
bash /usr/local/bin/bamstats ${mem_gb} ${bam_input}
}

output {
File bamstats_report = "bamstats_report.zip"
}

runtime {
docker: "quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0"
memory: mem_gb + "GB"
}

meta {
author: "Andrew Duncan"
}
}

workflow bamstatsWorkflow {
File bam_input
Int mem_gb
call bamstats { input: bam_input=bam_input, mem_gb=mem_gb }
}
41 changes: 38 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ You'll then see a file, `bamstats_report.zip`, in the current directory, that's
## Running Through the Dockstore CLI

This tool can be found at the [Dockstore](https://dockstore.org), login with your GitHub account and follow the
directions to setup the CLI. It lets you run a Docker container with a CWL descriptor locally, using Docker and the CWL command line utility. This is great for testing.
directions to setup the CLI. It lets you run a Docker container with a CWL/WDL descriptor locally, using Docker and the CWL/WDL command line utility. This is great for testing.

### Make a Parameters JSON
### With CWL

#### Make a Parameters JSON

This is the parameterization of the BAM stat tool, a copy is present in this repo called `sample_configs.json`:

Expand All @@ -62,7 +64,7 @@ This is the parameterization of the BAM stat tool, a copy is present in this rep
}
```

### Run with the CLI
#### Run with the CLI

Run it using the `dockstore` CLI:

Expand All @@ -76,4 +78,37 @@ $> dockstore tool convert cwl2json --cwl Dockstore.cwl > Dockstore.json
$> dockstore tool launch --entry quay.io/collaboratory/dockstore-tool-bamstats:1.25-3 --json Dockstore.json
```

### With WDL
#### Make a Parameters JSON

This is the parameterization of the BAM stat tool, a copy is present in this repo called `test.wdl.json`:

```
{
"bamstatsWorkflow.bam_input": "rna.SRR948778.bam",
"bamstatsWorkflow.mem_gb": "4"
}
```

#### Run with the CLI

Run it using the `dockstore` CLI:

```
Usage:
# fetch WDL
$> dockstore tool wdl --entry quay.io/collaboratory/dockstore-tool-bamstats > Dockstore.wdl
# make a runtime JSON template and edit it (or use the content of test.wdl.json above)
$> dockstore tool convert wdl2json --wdl Dockstore.wdl > Dockstore.json
# run it locally with the Dockstore CLI
$> dockstore tool launch --entry quay.io/collaboratory/dockstore-tool-bamstats --json Dockstore.json
```

## Running Nextflow Workflow

Install [Nextflow](https://www.nextflow.io/). Nextflow workflows cannot be run with the Dockstore CLI yet.

The workflow can be run using the following command:
```
$> nextflow run main.nf
```
10 changes: 10 additions & 0 deletions before-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset
set -o xtrace

if [[ "${LANGUAGE}" == "cwl" ]]; then
pip2.7 install --user setuptools==24.0.3
fi
15 changes: 15 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset
set -o xtrace

if [[ "${LANGUAGE}" == "cwl" ]]; then
pip2.7 install --user cwl-runner cwltool==1.0.20160712154127 schema-salad==1.14.20160708181155 avro==1.8.1
elif [[ "${LANGUAGE}" == "wdl" ]]; then
wget https://github.com/broadinstitute/cromwell/releases/download/32/cromwell-32.jar
elif [[ "${LANGUAGE}" == "nfl" ]]; then
curl -s https://get.nextflow.io | bash
mv nextflow $HOME/bin
fi
16 changes: 16 additions & 0 deletions main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env nextflow

bamFile = file(params.bam_input)

process bamstats {
input:
file bam_input from bamFile
val mem_gb from params.mem_gb

output:
file 'bamstats_report.zip'

"""
bash /usr/local/bin/bamstats $mem_gb $bam_input
"""
}
15 changes: 15 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
manifest {
description = 'Generate some stats on a BAM file'
author = 'Andrew Duncan'
}

params {
bam_input = 'rna.SRR948778.bam'
mem_gb = '4'
}

process.container = 'quay.io/collaboratory/dockstore-tool-bamstats:1.25-6_1.0'
docker {
enabled = true
docker.runOptions = '-u $(id -u):$(id -g)'
}
14 changes: 14 additions & 0 deletions script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset
set -o xtrace

if [[ "${LANGUAGE}" == "cwl" ]]; then
cwltool --non-strict Dockstore.cwl test.json
elif [[ "${LANGUAGE}" == "wdl" ]]; then
java -jar cromwell-32.jar run Dockstore.wdl --inputs test.wdl.json
elif [[ "${LANGUAGE}" == "nfl" ]]; then
nextflow run main.nf
fi
4 changes: 4 additions & 0 deletions test.wdl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"bamstatsWorkflow.bam_input": "rna.SRR948778.bam",
"bamstatsWorkflow.mem_gb": "4"
}

0 comments on commit a4d036d

Please sign in to comment.