diff --git a/src/components/Footer.astro b/src/components/Footer.astro index c4507d2d..57797850 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -93,7 +93,7 @@ import LogoSeqera from "../../public/img/assets/Logo_Seqera_white.svg";
  • Mixing scripting languagesMixed script pipeline
  • diff --git a/src/components/Menu/Menu.tsx b/src/components/Menu/Menu.tsx index 221d78f0..464eb040 100644 --- a/src/components/Menu/Menu.tsx +++ b/src/components/Menu/Menu.tsx @@ -198,7 +198,7 @@ const Menu = ({}) => {
  • - Mixing scripting languages + Mixed script pipeline
  • diff --git a/src/components/SideNavigation/ExamplesSideNav.tsx b/src/components/SideNavigation/ExamplesSideNav.tsx index cbad4e3f..f05de64b 100644 --- a/src/components/SideNavigation/ExamplesSideNav.tsx +++ b/src/components/SideNavigation/ExamplesSideNav.tsx @@ -26,7 +26,7 @@ const ExamplesSideNav = () => { }, { id: 'mixing-scripting-languages', - title: 'Mixing scripting languages', + title: 'Mixed script pipeline', href: 'mixing-scripting-languages.html' }, { diff --git a/src/pages/basic-pipeline.md b/src/pages/basic-pipeline.md index 7239753d..2a93d729 100644 --- a/src/pages/basic-pipeline.md +++ b/src/pages/basic-pipeline.md @@ -88,6 +88,8 @@ The `output` block (outside the workflow) defines where and how each output shou
    +### Get started + To run this pipeline:

    1. Install Nextflow (version 25.10 or later)

    diff --git a/src/pages/mixing-scripting-languages.md b/src/pages/mixing-scripting-languages.md index e296b20e..228bc1e8 100644 --- a/src/pages/mixing-scripting-languages.md +++ b/src/pages/mixing-scripting-languages.md @@ -1,44 +1,39 @@ --- -title: Multiple inputs +title: Mixed script pipeline layout: "@layouts/ExampleLayout.astro" ---
    -

    Mixing scripting languages

    +

    Mixed script pipeline

    -

    - With Nextflow, you are not limited to Bash scripts -- you can use any scripting language! In other words, for each process you can use the language that best fits the specific task or that you simply prefer. +

    + This pipeline shows how to use different scripting languages in a single Nextflow pipeline. The first process uses a Perl script to generate random number pairs, and the second process uses a Python script to calculate the average of each pair.

    ```groovy -#!/usr/bin/env nextflow - +// Default parameter input params.range = 100 -/* - * A trivial Perl script that produces a list of number pairs - */ +// Perl process process perlTask { output: stdout - shell: - ''' + script: + """ #!/usr/bin/env perl use strict; use warnings; - my $count; - my $range = !{params.range}; - for ($count = 0; $count < 10; $count++) { - print rand($range) . ', ' . rand($range) . "\n"; + my \$count; + my \$range = ${params.range}; + for (\$count = 0; \$count < 10; \$count++) { + print rand(\$range) . ', ' . rand(\$range) . "\\n"; } - ''' + """ } -/* - * A Python script which parses the output of the previous script - */ +// Python process process pyTask { input: stdin @@ -46,6 +41,7 @@ process pyTask { output: stdout + script: """ #!/usr/bin/env python import sys @@ -63,6 +59,7 @@ process pyTask { """ } +// Workflow block workflow { perlTask | pyTask | view } @@ -72,9 +69,38 @@ workflow { ### Synopsis -In the above example we define a simple pipeline with two processes. +This pipeline defines two processes: + +

    perlTask: executes a Perl script that generates 10 pairs of random numbers within a configurable range and prints them to standard output

    + +

    pyTask: executes a Python script that reads the pairs from standard input and calculates the average of each coordinate

    + +Each process uses a shebang declaration at the start of its script block to specify the scripting language. Nextflow detects the shebang and executes the script using the appropriate interpreter. + +The `workflow` block pipes the output of `perlTask` directly into `pyTask`, and then passes the result to the `view` operator to print it to the terminal. + +
    + +### Get started + +To run this pipeline: + +

    1. Install Nextflow (version 25.10 or later)

    + +

    2. Create a new file named main.nf in your current directory

    + +

    3. Copy and save the above script to your new file

    + +

    4. Run your pipeline:

    + +
    + +``` +nextflow run main.nf +``` + +
    -The first process executes a Perl script, because the script block definition starts -with a Perl _shebang_ declaration (line 14). Since Perl uses the `$` character for variables, we use the special `shell` block instead of the normal `script` block to easily distinguish the Perl variables from the Nextflow variables. +
    -In the same way, the second process will execute a Python script, because the script block starts with a Python shebang (line 36). +See [Scripts à la carte](https://docs.seqera.io/nextflow/process#scripts-%C3%A0-la-carte) for more information about using multiple scripting languages in Nextflow.