Using a launch script can be helpful in automatically running the latest version of a workflow, automatically clean up, or not having to deal with long commands. The suggestions below also allow for testing changes made to your own fork or local copy of a workflow too. If nextflow
fails for some reason, the cache isn’t cleaned due to set -e
at the top of the bash script.
run_nextflow.sh
:
#! /usr/bin/env bash
set -euo pipefail
# Select workflow (default: nf-core/rnaseq)
WORKFLOW="${WORKFLOW:-nf-core/rnaseq}"
# Select profile (default: standard)
PROFILE="${PROFILE:-standard}"
# Set working directory
WORKDIR="${WORKDIR:-work}"
# Workflow options
WF_OPTIONS="${WF_OPTIONS:-"-resume -ansi-log false"}"
# Check for params file as arg
WF_PARAMS=""
if test -f "${1:-''}"; then
WF_PARAMS="-params-file $1"
fi
if test -f "$WORKFLOW"; then
# File is a local script
nextflow run "$WORKFLOW" \
-work-dir "$WORKDIR" \
-profile "$PROFILE" \
$WF_OPTIONS \
$WF_PARAMS
else
# Run latest release
TAG=$( curl -s "https://api.github.com/repos/$WORKFLOW/releases/latest" | jq -r '.tag_name' )
# Workflow version or branch to use (default: latest tag)
BRANCH="${BRANCH:-$TAG}"
# Workflow hosted on remote
nextflow run "$WORKFLOW" \
-work-dir "$WORKDIR" \
-profile "$PROFILE" \
-r "$BRANCH" \
-latest \
$WF_OPTIONS \
$WF_PARAMS
fi
# Clean up Nextflow cache to remove unused files
nextflow clean -f -before "$( nextflow log -q | tail -n 1 )"
# Clean up empty work directories
find "$WORKDIR" -type d -empty -delete
Example usage:
PROFILE=test,docker bash run_nextflow.sh params.yml