Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .icons/nextflow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions registry/coder/modules/nextflow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
display_name: Nextflow
description: A module that adds Nextflow to your Coder template.
icon: ../../../../.icons/nextflow.svg
verified: true
tags: [nextflow, workflow, hpc, bioinformatics]
---

# Nextflow

A module that adds Nextflow to your Coder template.

![Nextflow](../../.images/nextflow.png)

```tf
module "nextflow" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/nextflow/coder"
version = "0.9.0"
agent_id = coder_agent.example.id
}
```
99 changes: 99 additions & 0 deletions registry/coder/modules/nextflow/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
terraform {
required_version = ">= 1.0"

required_providers {
coder = {
source = "coder/coder"
version = ">= 2.5"
}
}
}

# Add required variables for your modules and remove any unneeded variables
variable "agent_id" {
type = string
description = "The ID of a Coder agent."
}

variable "nextflow_version" {
type = string
description = "Nextflow version"
default = "25.04.7"
}

variable "project_path" {
type = string
description = "The path to Nextflow project, it will be mounted in the container."
}

variable "http_server_port" {
type = number
description = "The port to run HTTP server on."
default = 9876
}

variable "http_server_reports_dir" {
type = string
description = "Subdirectory for HTTP server reports, relative to the project path."
default = "reports"
}

variable "stub_run" {
type = bool
description = "Execute a stub run?"
default = false
}

variable "stub_run_command" {
type = string
description = "Nextflow command to be executed in the stub run."
default = "run rnaseq-nf -with-report reports/report.html -with-trace reports/trace.txt -with-timeline reports/timeline.html -with-dag reports/flowchart.png"
}

variable "order" {
type = number
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
default = null
}

variable "share" {
type = string
default = "owner"
validation {
condition = var.share == "owner" || var.share == "authenticated" || var.share == "public"
error_message = "Incorrect value. Please set either 'owner', 'authenticated', or 'public'."
}
}

variable "group" {
type = string
description = "The name of a group that this app belongs to."
default = null
}

resource "coder_script" "nextflow" {
agent_id = var.agent_id
display_name = "nextflow"
icon = "/icon/nextflow.svg"
script = templatefile("${path.module}/run.sh", {
NEXTFLOW_VERSION : var.nextflow_version,
PROJECT_PATH : var.project_path,
HTTP_SERVER_PORT : var.http_server_port,
HTTP_SERVER_REPORTS_DIR : var.http_server_reports_dir,
STUB_RUN : var.stub_run,
STUB_RUN_COMMAND : var.stub_run_command,
})
run_on_start = true
}

resource "coder_app" "nextflow" {
agent_id = var.agent_id
slug = "nextflow-reports"
display_name = "Nextflow Reports"
url = "http://localhost:${var.http_server_port}"
icon = "/icon/nextflow.svg"
subdomain = true
share = var.share
order = var.order
group = var.group
}
49 changes: 49 additions & 0 deletions registry/coder/modules/nextflow/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env sh

set -eu

BOLD='\033[0;1m'
RESET='\033[0m'

printf "$${BOLD}Starting Nextflow...$${RESET}\n"

if ! command -v nextflow > /dev/null 2>&1; then
# Update system dependencies
sudo apt update
sudo apt install openjdk-18-jdk -y
sudo apt install salmon fastqc multiqc -y

# Install nextflow
export NXF_VER=${NEXTFLOW_VERSION}
curl -s https://get.nextflow.io | bash
sudo mv nextflow /usr/local/bin/
sudo chmod +x /usr/local/bin/nextflow

# Verify installation
tmp_verify=$(mktemp -d coder-nextflow-XXXXXX)
nextflow run hello \
-with-report "$$tmp_verify/report.html" \
-with-trace "$$tmp_verify/trace.txt" \
-with-timeline "$$tmp_verify/timeline.html" \
-with-dag "$$tmp_verify/flowchart.png"
rm -f "$$tmp_verify"
else
echo "Nextflow is already installed\n\n"
fi

if [ ! -z ${PROJECT_PATH} ]; then
# Project is located at PROJECT_PATH
echo "Change directory: ${PROJECT_PATH}"
cd ${PROJECT_PATH}
fi

# Start a web server to preview reports
mkdir -p ${HTTP_SERVER_REPORTS_DIR}
python3 -m http.server --directory ${HTTP_SERVER_REPORTS_DIR} ${HTTP_SERVER_PORT}

# Stub run?
if [ "${STUB_RUN}" = "true" ]; then
nextflow ${STUB_RUN_COMMAND} -stub-run
fi

printf "\n$${BOLD}Nextflow ${NEXTFLOW_VERSION} is ready. HTTP server is listening on port ${HTTP_SERVER_PORT}$${RESET}\n"