This repository contains a collection of scripts introducing Nextflow basic features.
- 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.
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.
The classic Hello world! example. You can run it entering the following command:
nextflow run helloworld.nf
Shows basic file read and write operations.
Run the example entering the following command:
nextflow run basic_read_write.nf
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
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.
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.
This example executes a BLAST search given an input protein sequence file.
Run the example with this command:
nextflow run process_input.nf
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>
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
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.
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.
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
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.
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.
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
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.
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.
For a catalog of pipelines using nextflow see Awesome-nextflow list.