/* * Multi-step Nextflow pipeline demo * * Steps: * 1. GREET – write a greeting to a file * 2. SHOUT – convert the greeting to uppercase * 3. REPORT – count words and produce a summary * * Run: * module load nextflow/26.04.6 * nextflow run multi-step.nf --name "SCC User" */ params.name = "World" // override with: --name "Your Name" // --------------------------------------------------------------------------- // Step 1: create a greeting // --------------------------------------------------------------------------- process GREET { input: val name output: path 'greeting.txt' script: """ echo "Hello, ${name}! Welcome to the SCC." > greeting.txt """ } // --------------------------------------------------------------------------- // Step 2: convert greeting to uppercase // --------------------------------------------------------------------------- process SHOUT { input: path greeting output: path 'greeting_upper.txt' script: """ tr '[:lower:]' '[:upper:]' < ${greeting} > greeting_upper.txt """ } // --------------------------------------------------------------------------- // Step 3: count words and produce a short report // --------------------------------------------------------------------------- process REPORT { publishDir "results/", mode: 'copy' // copy final output to results/ input: path upper_greeting output: path 'report.txt' script: """ WORDS=\$(wc -w < ${upper_greeting}) echo "=== Pipeline Report ===" > report.txt echo "Greeting (uppercase):" >> report.txt cat ${upper_greeting} >> report.txt echo "" >> report.txt echo "Word count: \${WORDS}" >> report.txt """ } // --------------------------------------------------------------------------- // Workflow: wire the processes together // --------------------------------------------------------------------------- workflow { // create a channel from the parameter value name_ch = Channel.of(params.name) // chain processes: output of each becomes input of the next GREET(name_ch) SHOUT(GREET.out) REPORT(SHOUT.out) }