diff --git a/.travis.yml b/.travis.yml index 609d331..1785d87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,11 @@ sudo: required services: - docker +env: + - LANGUAGE=cwl + - LANGUAGE=wdl + - LANGUAGE=nfl + notifications: slack: on_success: never @@ -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 diff --git a/Dockstore.wdl b/Dockstore.wdl new file mode 100644 index 0000000..7b98792 --- /dev/null +++ b/Dockstore.wdl @@ -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 } +} diff --git a/README.md b/README.md index 1cf8728..4082278 100644 --- a/README.md +++ b/README.md @@ -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`: @@ -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: @@ -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 +``` diff --git a/before-install.sh b/before-install.sh new file mode 100755 index 0000000..fdfd49c --- /dev/null +++ b/before-install.sh @@ -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 \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..c92a385 --- /dev/null +++ b/install.sh @@ -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 \ No newline at end of file diff --git a/main.nf b/main.nf new file mode 100644 index 0000000..406159c --- /dev/null +++ b/main.nf @@ -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 + """ +} \ No newline at end of file diff --git a/nextflow.config b/nextflow.config new file mode 100644 index 0000000..1b9eb30 --- /dev/null +++ b/nextflow.config @@ -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)' +} diff --git a/script.sh b/script.sh new file mode 100755 index 0000000..62bc193 --- /dev/null +++ b/script.sh @@ -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 \ No newline at end of file diff --git a/test.wdl.json b/test.wdl.json new file mode 100644 index 0000000..d4382eb --- /dev/null +++ b/test.wdl.json @@ -0,0 +1,4 @@ +{ + "bamstatsWorkflow.bam_input": "rna.SRR948778.bam", + "bamstatsWorkflow.mem_gb": "4" +}