text: user2970: How should I do:
  ...
  if ($(params.aligner) == "bowtie") {
      align_bowtie2(get_fq_info.out.fq_info)
  }
  else {
      align_bwa(get_fq_info.out.fq_info)
  }
  ...
  
  
  user6767: Is this inside the main.nf file or inside the process.nf file? Anyway, the param.anything variable should already be available in the nextflow context when executed, thus, you could simply do:
  if (params.aligner == "bowtie") {
      align_bowtie2(get_fq_info.out.fq_info)
  } else {
      align_bwa(get_fq_info.out.fq_info)
  }
  
  Check out this main.nf of a nextflow pipeline of mine, it contains some working if/else snippets.
  
  Here it is another StackOverflow question on conditional nextflow pipelines that might help.
  
  Hope it helps.
  
  user10775: You can move that into your workflow definition. There's an example in the docs of how best to use workflow parameters:
  
  A workflow component can access any variable and parameter defined in
  the outer scope:
  params.data = '/some/data/file'
  
  workflow my_pipeline {
      if( params.data )
          bar(params.data)
      else
          bar(foo()) }
  
  
  Your example workflow would look like:
  workflow {
  
      fq_info = get_fq_info.out.fq_info
  
      if( params.aligner == "bowtie" ) {
          align_bowtie2( fq_info )
      }
      else {
          align_bwa( fq_info )
      }
  
      ...
  }
  ```
  
  
original_text: 2970: <p>How should I do:</p>
  <pre><code>...
  if ($(params.aligner) == &quot;bowtie&quot;) {
      align_bowtie2(get_fq_info.out.fq_info)
  }
  else {
      align_bwa(get_fq_info.out.fq_info)
  }
  ...
  </code></pre>
   6767: <p>Is this inside the <code>main.nf</code> file or inside the <code>process.nf</code> file? Anyway, the <code>param.anything</code> variable should already be available in the <code>nextflow</code> context when executed, thus, you could simply do:</p>
  <pre class="lang-bash prettyprint-override"><code>if (params.aligner == &quot;bowtie&quot;) {
      align_bowtie2(get_fq_info.out.fq_info)
  } else {
      align_bwa(get_fq_info.out.fq_info)
  }
  </code></pre>
  <p>Check out this <a href="https://github.com/fmalmeida/bacannot/blob/master/main.nf" rel="nofollow noreferrer"><code>main.nf</code></a> of a nextflow pipeline of mine, it contains some working if/else snippets.</p>
  <blockquote>
  <p>Here it is <a href="https://stackoverflow.com/questions/50443545/conditional-pipeline-in-nextflow">another StackOverflow question on conditional</a> nextflow pipelines that might help.</p>
  </blockquote>
  <p>Hope it helps.</p>
   10775: <p>You can move that into your <a href="https://www.nextflow.io/docs/latest/dsl2.html#workflow-definition" rel="nofollow noreferrer">workflow definition</a>. There's an example in the docs of how best to use <a href="https://www.nextflow.io/docs/latest/dsl2.html#workflow-parameters" rel="nofollow noreferrer">workflow parameters</a>:</p>
  <blockquote>
  <p>A workflow component can access any variable and parameter defined in
  the outer scope:</p>
  <pre><code>params.data = '/some/data/file'
  
  workflow my_pipeline {
      if( params.data )
          bar(params.data)
      else
          bar(foo()) }
  </code></pre>
  </blockquote>
  <p>Your example workflow would look like:</p>
  <pre><code>workflow {
  
      fq_info = get_fq_info.out.fq_info
  
      if( params.aligner == &quot;bowtie&quot; ) {
          align_bowtie2( fq_info )
      }
      else {
          align_bwa( fq_info )
      }
  
      ...
  }
  <span class="math-container">```</span>
  </code></pre>
  