Answers.Body: <p>Nextflow does not have an <code>env</code> process directive. If <code>stringtie</code> is not already in your <code>$PATH</code>, you'll need to append it before running <code>nextflow</code>, for example:</p>
  <pre><code>export PATH=&quot;${PATH}:/data/selena/stringtie-2.2.1&quot;
  nextflow run de-pipeline.nf
  </code></pre>
  <p>However, you may prefer to avoid local tool installations altogether, and use either the <a href="https://www.nextflow.io/docs/latest/process.html#conda" rel="nofollow noreferrer"><code>conda</code></a> or <a href="https://www.nextflow.io/docs/latest/process.html#container" rel="nofollow noreferrer"><code>container</code></a> process directives. The latter will however require a container runtime, like <a href="https://www.nextflow.io/docs/latest/container.html#docker" rel="nofollow noreferrer">Docker</a> or <a href="https://www.nextflow.io/docs/latest/container.html#singularity" rel="nofollow noreferrer">Singularity</a>.</p>
  <p>You may also consider including a 'sample name' or some sort of sample identifier in your config file, which I suspect is just a simple tab-separated file of filenames. This would greatly simplify your workflow. For example:</p>
  <pre><code>params.samplesheet = './samples.tsv'
  params.genome = './genomes/GRCh38/GRCh38'
  params.gtf = './Homo_sapiens.GRCh38.gtf'
  
  genome_name = file( params.genome ).name
  genome_path = file( params.genome ).parent
  
  params.outdir = './results'
  </code></pre>
  <pre><code>process HISAT2 {
  
      tag { sample }
  
      publishDir &quot;<span class="math-container">${params.outdir}/HISAT2/$</span>{sample}&quot;, mode: 'copy'
  
      cpus 16
  
      input:
      tuple val(sample), path(reads)
      path genome_dir
  
      output:
      tuple val(sample), path(&quot;${sample}.sam&quot;)
  
      script:
      def (r1, r2) = reads
  
      &quot;&quot;&quot;
      hisat2 \\
          -p <span class="math-container">${task.cpus} \\
          -x "$</span>{genome_dir}/<span class="math-container">${genome_name}" \\
          -1 "$</span>{r1}&quot; \\
          -2 &quot;<span class="math-container">${r2}" \\
          -S "$</span>{sample}.sam&quot;
      &quot;&quot;&quot;
  }
  </code></pre>
  <pre><code>process SAMtools_sort {
  
      tag { sample }
  
      input:
      tuple val(sample), path(bam)
  
      output:
      tuple val(sample), path(&quot;${sample}.sorted.bam&quot;)
  
      &quot;&quot;&quot;
      samtools sort \\
          -o &quot;<span class="math-container">${sample}.sorted.bam" \\
          "$</span>{bam}&quot;
      &quot;&quot;&quot;
  }
  </code></pre>
  <pre><code>process StringTie {
  
      tag { sample }
  
      publishDir &quot;<span class="math-container">${params.outdir}/StringTie/$</span>{sample}&quot;, mode: 'copy'
  
      input:
      tuple val(sample), path(bam)
      path gtf
  
      output:
      tuple val(sample), path(&quot;${sample}.gtf&quot;)
  
      &quot;&quot;&quot;
      stringtie \\
          -e \\
          -G &quot;<span class="math-container">${gtf}" \\
          -o "$</span>{sample}.gtf&quot; \\
          &quot;${bam}&quot;
      &quot;&quot;&quot;
  }
  </code></pre>
  <pre><code>workflow {
  
      gtf = file( params.gtf )
  
      Channel
          .fromPath( params.samplesheet )
          .splitCsv( sep: '\t' )
          .map { sample, fq1, fq2 -&gt;
              def reads = tuple( file(fq1), file(fq2) )
  
              tuple( sample, reads )
          }
          .set { samples }
  
      HISAT2( samples, genome_path )
  
      SAMtools_sort( HISAT2.out )
  
      StringTie( SAMtools_sort.out, gtf )
  }
  </code></pre>
  <p>Where the contents of the input sample sheet (e.g. <code>samples.tsv</code>) looks like:</p>
  <pre><code>sample_A    /path/to/reads/A_R1.fastq.gz    /path/to/reads/A_R2.fastq.gz
  sample_B    /path/to/reads/B_R1.fastq.gz    /path/to/reads/B_R2.fastq.gz
  sample_C    /path/to/reads/C_R1.fastq.gz    /path/to/reads/C_R2.fastq.gz
  </code></pre>
  <p>Results:</p>
  <pre><code>$ nextflow run main.nf
  N E X T F L O W  ~  version 22.04.0
  Launching `main.nf` [adoring_poisson] DSL2 - revision: 43e8c59949
  executor &gt;  local (9)
  [60/1cba2f] process &gt; HISAT2 (sample_A)        [100%] 3 of 3 ✔
  [0a/931a07] process &gt; SAMtools_sort (sample_A) [100%] 3 of 3 ✔
  [6d/7689a2] process &gt; StringTie (sample_A)     [100%] 3 of 3 ✔
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-20T06:44:59.540Z
Answers.LastActivityDate: 2023-03-20T13:20:15.533Z
Answers.LastEditDate: 2023-03-20T13:20:15.533Z
Answers.UserDisplayName: Steve
Body: <p>I'm attempting to run a nextflow pipeline and have begun getting unexpected output for a few of the processes in my pipeline. I believe this to be a syntax error, but I am not sure where to correct it. Any help is finding where my error is located is appreciated.</p>
  <p><a href="https://i.sstatic.net/pxfDb.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pxfDb.png" alt="Error" /></a></p>
  <pre><code>#!/usr/bin/env nextflow
   nextflow.enable.dsl=2
   import groovy.io.*
  
  
  
  
    process hisat2Alignment {
      fastq1 = NS.1389.002.NEBNext_dual_i7_*_R1.fastq.gz
      fastq2 = NS.1389.002.NEBNext_dual_i7_*_R2.fastq.gz
      input:
      tuple path(&quot;fastq1&quot;), path(&quot;fastq2&quot;)
  
      output:
      tuple path(&quot;*.sam&quot;), val(fastq1.baseName.substring(0, fastq1.baseName.indexOf(&quot;_R1&quot;)))
      script:
      &quot;&quot;&quot;
      hisat2 -p 16 -x genome -1 <span class="math-container">${fastq1} -2 $</span>{fastq2} -S mapped_${baseName}.sam
      &quot;&quot;&quot;
  
  
   }
  
  process Stringtier {
      publishDir &quot;<span class="math-container">${params.baseDir}/assembled/$</span>baseName&quot;, mode: &quot;move&quot;
      env {
       PATH = $PATH:/data/selena/stringtie-2.2.1
      }
  
      input:
      tuple path(mapped_bam), val(baseName)
      output:
      tuple path(&quot;*.gtf&quot;), val(baseName)
  
  
      script:
      &quot;&quot;&quot;
      stringtie -e -G <span class="math-container">${params.annotation} -o $</span>{baseName}.gtf ${mapped_bam}
  
      &quot;&quot;&quot;
  }
  
   workflow {
      samples = new File(params.configFilePath).readLines()*.split('\t');
      samples  = Channel.fromList(samples);
      hisat2Alignment(samples);
      assembled = Stringtier(samples)
      
  }
  </code></pre>
  
Tags: <rna-seq><nextflow><errors>
Title: Nextflow Pipeline: Unexpected Input "{"
ThreadText: # Nextflow Pipeline: Unexpected Input "{"
  
  (Asked by: username_0 on 2023-03-19)
  
  I'm attempting to run a nextflow pipeline and have begun getting unexpected output for a few of the processes in my pipeline. I believe this to be a syntax error, but I am not sure where to correct it. Any help is finding where my error is located is appreciated.
  
  [![Error](https://i.sstatic.net/pxfDb.png)](https://i.sstatic.net/pxfDb.png)
  
  ```
  #!/usr/bin/env nextflow
   nextflow.enable.dsl=2
   import groovy.io.*
  
    process hisat2Alignment {
      fastq1 = NS.1389.002.NEBNext_dual_i7_*_R1.fastq.gz
      fastq2 = NS.1389.002.NEBNext_dual_i7_*_R2.fastq.gz
      input:
      tuple path("fastq1"), path("fastq2")
  
      output:
      tuple path("*.sam"), val(fastq1.baseName.substring(0, fastq1.baseName.indexOf("_R1")))
      script:
      """
      hisat2 -p 16 -x genome -1 ${fastq1} -2 ${fastq2} -S mapped_${baseName}.sam
      """
  
   }
  
  process Stringtier {
      publishDir "${params.baseDir}/assembled/$baseName", mode: "move"
      env {
       PATH = $PATH:/data/selena/stringtie-2.2.1
      }
  
      input:
      tuple path(mapped_bam), val(baseName)
      output:
      tuple path("*.gtf"), val(baseName)
  
      script:
      """
      stringtie -e -G ${params.annotation} -o ${baseName}.gtf ${mapped_bam}
  
      """
  }
  
   workflow {
      samples = new File(params.configFilePath).readLines()*.split('\t');
      samples  = Channel.fromList(samples);
      hisat2Alignment(samples);
      assembled = Stringtier(samples)
      
  }
  
  ```
  
  **Tags:** rna-seq, nextflow, errors
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-03-20. Score: 2 | Accepted answer
  
  Nextflow does not have an `env` process directive. If `stringtie` is not already in your `$PATH`, you'll need to append it before running `nextflow`, for example:
  
  ```
  export PATH="${PATH}:/data/selena/stringtie-2.2.1"
  nextflow run de-pipeline.nf
  
  ```
  
  However, you may prefer to avoid local tool installations altogether, and use either the [`conda`](https://www.nextflow.io/docs/latest/process.html#conda) or [`container`](https://www.nextflow.io/docs/latest/process.html#container) process directives. The latter will however require a container runtime, like [Docker](https://www.nextflow.io/docs/latest/container.html#docker) or [Singularity](https://www.nextflow.io/docs/latest/container.html#singularity).
  
  You may also consider including a 'sample name' or some sort of sample identifier in your config file, which I suspect is just a simple tab-separated file of filenames. This would greatly simplify your workflow. For example:
  
  ```
  params.samplesheet = './samples.tsv'
  params.genome = './genomes/GRCh38/GRCh38'
  params.gtf = './Homo_sapiens.GRCh38.gtf'
  
  genome_name = file( params.genome ).name
  genome_path = file( params.genome ).parent
  
  params.outdir = './results'
  
  ```
  
  ```
  process HISAT2 {
  
      tag { sample }
  
      publishDir "${params.outdir}/HISAT2/${sample}", mode: 'copy'
  
      cpus 16
  
      input:
      tuple val(sample), path(reads)
      path genome_dir
  
      output:
      tuple val(sample), path("${sample}.sam")
  
      script:
      def (r1, r2) = reads
  
      """
      hisat2 \\
          -p ${task.cpus} \\
          -x "${genome_dir}/${genome_name}" \\
          -1 "${r1}" \\
          -2 "${r2}" \\
          -S "${sample}.sam"
      """
  }
  
  ```
  
  ```
  process SAMtools_sort {
  
      tag { sample }
  
      input:
      tuple val(sample), path(bam)
  
      output:
      tuple val(sample), path("${sample}.sorted.bam")
  
      """
      samtools sort \\
          -o "${sample}.sorted.bam" \\
          "${bam}"
      """
  }
  
  ```
  
  ```
  process StringTie {
  
      tag { sample }
  
      publishDir "${params.outdir}/StringTie/${sample}", mode: 'copy'
  
      input:
      tuple val(sample), path(bam)
      path gtf
  
      output:
      tuple val(sample), path("${sample}.gtf")
  
      """
      stringtie \\
          -e \\
          -G "${gtf}" \\
          -o "${sample}.gtf" \\
          "${bam}"
      """
  }
  
  ```
  
  ```
  workflow {
  
      gtf = file( params.gtf )
  
      Channel
          .fromPath( params.samplesheet )
          .splitCsv( sep: '\t' )
          .map { sample, fq1, fq2 ->
              def reads = tuple( file(fq1), file(fq2) )
  
              tuple( sample, reads )
          }
          .set { samples }
  
      HISAT2( samples, genome_path )
  
      SAMtools_sort( HISAT2.out )
  
      StringTie( SAMtools_sort.out, gtf )
  }
  
  ```
  
  Where the contents of the input sample sheet (e.g. `samples.tsv`) looks like:
  
  ```
  sample_A    /path/to/reads/A_R1.fastq.gz    /path/to/reads/A_R2.fastq.gz
  sample_B    /path/to/reads/B_R1.fastq.gz    /path/to/reads/B_R2.fastq.gz
  sample_C    /path/to/reads/C_R1.fastq.gz    /path/to/reads/C_R2.fastq.gz
  
  ```
  
  Results:
  
  ```
  $ nextflow run main.nf
  N E X T F L O W  ~  version 22.04.0
  Launching `main.nf` [adoring_poisson] DSL2 - revision: 43e8c59949
  executor >  local (9)
  [60/1cba2f] process > HISAT2 (sample_A)        [100%] 3 of 3 ✔
  [0a/931a07] process > SAMtools_sort (sample_A) [100%] 3 of 3 ✔
  [6d/7689a2] process > StringTie (sample_A)     [100%] 3 of 3 ✔
  
  ```
  
  
  ---
  
  