Nextflow - introduction

See if nextflow works

Install Nextflow

The simplest nextflow file is this:

#!/usr/bin/env nextflow
process {
  echo true
  script:
  """
  echo this works
  """
}

There are no inputs or outputs, this just prints to the screen.

Create this (e.g. nano main.nf, then paste in)

Run: nextflow run main.nf

“this works” should print to screen.

Add inputs

#!/usr/bin/env nextflow

params.reads = "example.fa"  //replace with [--reads yourfile] at run 
reads_ch = Channel.fromPath(params.reads) //A channel to send the file

process thing {
        echo true

        input:
        file x from reads_ch

        script:
        """
        echo yes
        echo $x
        """
}

Run: nextflow run main.nf --reads R1.fastq

Add tool

#!/usr/bin/env nextflow

params.reads = "example.fa"  //replace with [--reads yourfile] at run
reads_ch = Channel.fromPath(params.reads) //A channel to send the file
params.outdir="results"

process jellyfish {
        echo true

        input:
        file fastq from reads_ch

        output:
        file "reads.histo" into histo_ch

        script:
        """
        echo yes
        echo $fastq
        jellyfish count -m 21 -s 100M -t 10 -C $fastq
        jellyfish histo -t 10 mer_counts.jf > reads.histo
        """
}

Run: nextflow run main.nf --reads concat.fastq.gz