Writing a basic workflow

John Salamon

Aug 28, 2024

Getting started

workflow {

}

Running our workflow

 N E X T F L O W   ~  version 24.04

Launching `main.nf` [exotic_brenner] DSL2 - revision: 11d0d8e692

Adding a process

process EXAMPLE {
    "echo hello > out.txt"
}

workflow {
    EXAMPLE()
}

Running our process again

 N E X T F L O W   ~  version 24.04.2

Launching `main.nf` [romantic_snyder] DSL2 - revision: 5ef5ed8a25

executor >  local (1)
[ee/c693f3] EXAMPLE [100%] 1 of 1 ✔
work/
└── ee
    └── c693f3241dcd5e3576e575b62ce5e8
        └── out.txt

Checking logs of previous executions

$ nextflow log romantic_snyder -f 'process,exit,hash,duration'
EXAMPLE 0   ee/c693f3   6ms

Defining inputs

process EXAMPLE {
    
    input:
    val msg

    "echo $msg > out.txt"
}

Defining outputs

process EXAMPLE {

    input:
    val msg

    output:
    path "out.txt"

    "echo $msg > out.txt"
}

Script block

process EXAMPLE {

    input:
    val msg

    output:
    path "out.txt"
    
    script:
    """
    echo $msg > out.txt
    """
}

Defining channels in our workflow

workflow {
    EXAMPLE( "hello world" )
}
workflow {
   
    ch_input = channel.value( "hello world" ) 
    EXAMPLE( ch_input )
}
workflow {
   
    ch_input = channel.of( "one", "two", "three" )
    EXAMPLE(ch_input)
}

Order of execution is not guaranteed

Let’s try adding in the view operator and println function in different places…

In the next section