A collection of examples introducing to Nextflow scripting
Groovy Shell
Latest commit cbfc1b6 Feb 6, 2017 @pditommaso pditommaso Updated copyright info
Permalink
Failed to load latest commit information.
blast-db/pdb Added test data and script Feb 5, 2015
checks Added tests Feb 6, 2015
data Added test data and script Feb 5, 2015
docs [ci skip] fixed tutorial Nov 11, 2015
.dockerignore Added dockerignore file Oct 18, 2016
.gitattributes Added GitHub groovy syntax highlighting. Sep 23, 2016
.gitignore Updated examples Nov 10, 2015
Dockerfile Added clustalo and raxml to Docker image Oct 13, 2016
README.md Updated group file pairs example Jul 11, 2016
basic_map.nf Updated copyright info Feb 6, 2017
basic_read_write.nf Updated copyright info Feb 6, 2017
blast-parallel.nf Updated copyright info Feb 6, 2017
blast.nf Updated copyright info Feb 6, 2017
blast_extract.nf Updated copyright info Feb 6, 2017
channel_filter.nf Updated copyright info Feb 6, 2017
channel_split.nf Updated copyright info Feb 6, 2017
circle.yml Updated Circle launcher Jun 5, 2015
env_vars.nf Updated copyright info Feb 6, 2017
fasta_record.nf Updated copyright info Feb 6, 2017
filter_operator.nf Updated copyright info Feb 6, 2017
flat_map.nf Updated copyright info Feb 6, 2017
group_read_pairs.nf Updated copyright info Feb 6, 2017
helloworld.nf Updated copyright info Feb 6, 2017
multiple_inputs.nf Updated copyright info Feb 6, 2017
nextflow.config Updated copyright info Feb 6, 2017
phase_operator.nf Updated copyright info Feb 6, 2017
process_input.nf Updated copyright info Feb 6, 2017
process_output.nf Updated copyright info Feb 6, 2017
read_fasta.nf Updated copyright info Feb 6, 2017
set_in_out.nf Updated copyright info Feb 6, 2017
split_and_collect.nf Updated copyright info Feb 6, 2017
split_and_gather.nf Updated copyright info Feb 6, 2017
split_fasta.nf Updated copyright info Feb 6, 2017

README.md

Nextflow examples

This repository contains a collection of scripts introducing Nextflow basic features.

CircleCI status

Dependencies

  • Unix-like operating system (Linux, Solaris, OS X, etc)
  • Java 7 or 8

The examples marked with * require also the following pieces of software:

The above tools are also shipped with a Docker container available at this link.

You can choose either to install them in your computer or pull the container with this command:

docker pull nextflow/examples

In the latter case the examples below marked with a * character need to be run adding the -with-docker command line option.

Get started

Install Nextflow by copying and pasting the following snippet in your shell terminal:

curl -fsSL get.nextflow.io | bash

It will download the nextflow application launcher in your working directory. When done, you may want to complete the installation moving the nextflow executable into a directory in your $PATH variable.

Clone this repository in folder of your choice with the following command:

git clone https://github.com/nextflow-io/examples.git 

Then, change in the root directory of the repository just cloned.

Content

1. Hello world!

The classic Hello world! example. You can run it entering the following command:

nextflow run helloworld.nf 

2. Basic file operations

Shows basic file read and write operations.

Run the example entering the following command:

nextflow run basic_read_write.nf

3. Environment variables

This example shows how environment variables can be accessed directly in the script context.

Run the example with this command:

nextflow run env_vars.nf

4. Read FASTA files

Basic example showing how to read a multi FASTA file, splitting it into chunks containing 10 sequences.

Run the example with this command:

nextflow run read_fasta.nf

Read more about splitFasta operator.

5. Parse FASTA file into records

This example shows how parse a multi fasta file into records and access each sequence properties by using the splitFasta operator.

Run the example with this command:

nextflow run fasta_record.nf

Read more about splitFasta operator.

6. Execute an external process (*)

This example executes a BLAST search given an input protein sequence file.

Run the example with this command:

nextflow run process_input.nf   

7. Execute a process and capture output (*)

This example executes a BLAST search and shows how capture and print the result output.

Run the example with this command:

nextflow run process_output.nf  

Run the same example providing your own query file using the --query command line option. For example:

nextflow run process_output.nf  --query <your fasta query file>

8. Scatter input data (*)

This example shows how splits a multi FASTA file in chunks and execute a BLAST query for each of them in parallel.

Run the example with this command:

nextflow run split_fasta.nf 

By default the script split the multi FASTA file in chunks containing 10 sequences, since the query file is very small it will execute just one BLAST job.

Try to run the same example specifying a lower number of sequences in each chunk. For example:

nextflow run split_fasta.nf --chunkSize 2   

9. Gather output files (*)

Shows how splits a multi FASTA file, execute a BLAST query for ach chunk and create a result file

Run the example with this command:

nextflow run split_and_collect.nf

Read more about the collectFile operator.

10. Process multiple input file in parallel (*)

This example shows how process multiple input files in a parallel manner. For each given query FASTA file, it will execute a BLAST job.

Run the example with this command:

nextflow run multiple_inputs.nf 

By default the script process a single input file (data/sample.fa).

Try to run this example by specifying more than one input file as shown in the example below:

nextflow run multiple_inputs.nf --query data/prot_\*.fa

It will execute a BLAST search for each file that matches the the wildcard path matcher.

11. Tuple of values (*)

This example shows how process can receive as input and produce as output tuple of values, which is useful to keep together related meta data.

Run the example with this command:

nextflow run set_in_out.nf 

12. Transform channel content

Simple example showing how the items emitted by a channel can be transformed by using the map operator.

Run the example with this command:

nextflow run basic_map.nf 

Read more about the map operator.

13. Filtering a channel

This example shows how a channel content can be filtered using an arbitrary condition and how operators can be chained to create a more complex processing behaviour.

Run the example with this command:

nextflow run filter_operator.nf 

Read more about the filter operator.

14. FlatMap operator

This example shows the usage of theflatMap operator.

Run the example with this command:

nextflow run flat_map.nf 

Read more about the flatMap operator

15. Join two channels

An example showing the usage of the phase operator to synchronise the items emitted by two channels.

Run the example with this command:

nextflow run phase_operator.nf 

Read more about the phase operator.

16. Grouping files matching a common prefix (*)

This example show how handle read-pairs by using the fromPairFiles method.

Run the example by using the command:

nextflow run group_read_pairs.nf  

Read more about the fromPairFiles method.

Other examples

For a catalog of pipelines using nextflow see Awesome-nextflow list.