Help Needed with Wrapping Nextflow Script into Galaxy Tool XML File

Hi everyone,

I’m working on integrating a simple ‘Hello World’ Nextflow script into Galaxy by wrapping it in an XML tool definition. My goal is to execute the script by clicking the run button in Galaxy, have it run in the background, and then bring the output text file into the history section.

I’m using a local Galaxy instance on a server. I’ve created both the .nf and .xml files and tested the tool with Planemo (both with update-test-data and test), and everything worked fine. However, when I attempt to run the tool within Galaxy, it stalls indefinitely without producing any output.

I believe the issue might lie in how I’m handling the output file between Nextflow and Galaxy. Since both generate outputs to dynamic paths, I’m using the publishDir parameter in Nextflow to publish the output to the working directory. The challenge arises because Nextflow expects a specific filename in the run command. If I specify --output_file '$hello_output', Planemo update-test-data produces an empty test output. On the other hand, if I specify --output_file 'hello_output.txt', the test passes but the tool stalls in Galaxy.

As a beginner with Nextflow and programming in general, I may be missing some crucial details. Could someone help me bridge this gap and connect the dots to ensure the output gets properly captured in Galaxy?

Below are my scripts for reference. Any guidance would be greatly appreciated!

Thank you in advance for your help.

~/galaxy/tools/nextflow_pipelines/hello/hello.nf

#!/usr/bin/env nextflow

/*
 * Use echo to print 'Hello World!' to standard out
 */

params.output_file = 'hello_output.txt'  // Keep this as a file name, not a path
params.greeting = 'Bonjour, World!'

process sayHello {
    publishDir '.', mode: 'copy' // Use the current directory for Galaxy to detect the file

    input:
        val greeting

    output:
        path params.output_file  // Output the file to the current working directory

    script:
    """
    echo '$greeting' > $params.output_file
    """
}

workflow {
    // create a channel for inputs
    greeting_ch = Channel.of(params.greeting)

    // run the process with the input channel
    sayHello(greeting_ch)
}

~/galaxy/tools/nextflow_pipelines/hello/hello_nextflow.xml

<?xml version="1.0" encoding="UTF-8"?>
<tool id="nextflow_hello" name="Hello World via Nextflow" version="1.0">
    <description>Simple Hello World using Nextflow</description>

    <requirements>
        <requirement type="package" version="24.04.4">nextflow</requirement>
        <requirement type="package" version="11">openjdk</requirement>
    </requirements>

    <command><![CDATA[
        nextflow run /home/refgen/galaxy/tools/nextflow_pipelines/hello/hello.nf --greeting '$greeting' --output_file 'hello_output.txt'
    ]]></command>

    <inputs>
        <param name="greeting" type="text" label="Greeting Message" value="Bonjour, Galaxy!"/>
    </inputs>

    <outputs>
        <data name="hello_output" format="txt" label="Hello World Output" from_work_dir="hello_output.txt"/>
    </outputs>

    <tests>
        <test>
            <param name="greeting" value="Hello, Planemooo!"/>
            <output name="hello_output" file="hello_output.txt"/>
        </test>
    </tests>

    <help><![CDATA[
This tool runs a simple Nextflow pipeline that outputs a message to a text file.

**Inputs**

- **Message to say**: The message that will be written to the output file.

**Outputs**

- **Hello World Output**: A text file containing the message.

**Dependencies**

This tool requires:

- Nextflow 24.04.4
- OpenJDK 11

These dependencies are managed via Conda.
    ]]></help>

    <citations>
        <citation type="doi">10.1038/nbt.3820</citation>
    </citations>
</tool>

Welcome, @gozdekb

This is a prior post with some help → nf-core Pipeline Integration to Local Galaxy

This part is probably a clue. If Planemo works, but working directly on your server doesn’t – maybe look for the difference at that part? Meaning, did your Galaxy installation get set up correctly? Do datasets load? Do the default tools in the tool panel execute? Is there anything reported in the server logs?

Let’s start there, thanks! :slight_smile:

1 Like

Thank you, @jennaj. I received valuable guidance from @fubar in a previous post on some critical points. However, I’ve encountered another challenge and would like to seek the community’s input.

Galaxy has been running smoothly on the server for some time now—I’ve successfully analyzed a large amount of data, downloaded and executed multiple tools, and even implemented a Python tool that functions exactly as intended. Until now, I haven’t experienced any issues with Galaxy, which leads me to believe this may be more of a path or output-related issue.

See https://help.galaxyproject.org/t/re-nf-core-pipeline-integration-to-local-galaxy/13304/6?u=fubar

Problem seems to be with nextflow DDL. I have no idea nor any interest in why that DDL code writes a symlink with the passed name rather than writing to a file. That’s a question for a nextflow expert, but with the suggested bug fixes it works and passes tests with valid output in my hands.

Not a Galaxy bug.

2 Likes