Answers.Body: <blockquote>
  <pre><code>Command error:
    .command.sh: line 2: ./minimap2: No such file or directory
  
  Work dir:
    /Users/rimo/Desktop/AWS/minimap2/work/ae/47e3c0708f33b1949315fc83066b95
  </code></pre>
  </blockquote>
  <p>The problem is that your command is expecting the <code>minimap2</code> binary inside your working directory (i.e. the 'work dir', as defined above), but it could not be found. To avoid using relative (or absolute) paths, and to help keep your workflow portable, instead move your <code>minimap2</code> binary into a directory in your <code>$PATH</code>. Then, you should be able to call <code>minimap2</code> without a relative (or absolute) path to it. Here's one way using the new <a href="https://www.nextflow.io/docs/latest/dsl2.html" rel="nofollow noreferrer">DSL2</a>, which comes enabled by default with Nextflow 22.10.0:</p>
  <pre><code>params.assmblreads = '/Users/rimo/Desktop/Assemblies/Assemblies_Flye/flye_assembly.fasta'
  params.assmblref = '/Users/rimo/Desktop/Assemblies/gene_targets/GENE.fsa'
  
  
  process minimap2 {
  
      input:
      tuple val(readID), path(readFile)
      path genome
  
      output:
      tuple val(readID), path(&quot;${readID}.paf&quot;)
  
      &quot;&quot;&quot;
      minimap2 &quot;<span class="math-container">${readFile}" "$</span>{genome}&quot; &gt; &quot;${readID}.paf&quot;
      &quot;&quot;&quot;
  }
  
  workflow {
  
      refgenome_file = file( params.assmblref )
      fasta_files = Channel.fromPath( params.assmblreads )
                           .map { file -&gt; tuple( file.baseName, file ) }
  
      minimap2( fasta_files, refgenome_file )
  }
  </code></pre>
  <p>To make your pipeline more portable, and to avoid manually installing and configuring your own tools, another way is to use <a href="https://www.nextflow.io/docs/latest/conda.html" rel="nofollow noreferrer">Conda environments</a>. Nextflow has built-in support for <a href="https://docs.conda.io/en/latest/" rel="nofollow noreferrer">Conda</a> and gives you access to all of the tools, including <a href="https://anaconda.org/bioconda/minimap2" rel="nofollow noreferrer">Minimap2</a>, available in <a href="https://bioconda.github.io/" rel="nofollow noreferrer">Bioconda</a>. Install <a href="https://docs.conda.io/en/latest/miniconda.html" rel="nofollow noreferrer">miniconda</a> to get started, then add <code>conda.enabled = true</code> to your <a href="https://www.nextflow.io/docs/latest/config.html#configuration-file" rel="nofollow noreferrer">nextflow.config</a> and the <a href="https://www.nextflow.io/docs/latest/process.html#conda" rel="nofollow noreferrer"><code>conda</code></a> directive (e.g. <code>conda 'minimap2=2.24'</code>) to your process definition for example. In the same way, you could also use <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>) containers with the <a href="https://www.nextflow.io/docs/latest/process.html#container" rel="nofollow noreferrer"><code>container</code></a> directive. Note that Docker containers are also built by the Bioconda build system and these are uploaded to <a href="https://quay.io/" rel="nofollow noreferrer">quay.io</a> as part of the <a href="https://quay.io/organization/biocontainers" rel="nofollow noreferrer">Biocontainers project</a> (e.g. <a href="https://quay.io/repository/biocontainers/minimap2" rel="nofollow noreferrer">biocontainers/minimap2</a>).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-26T00:49:27.853Z
Answers.LastActivityDate: 2022-10-26T01:45:00.793Z
Answers.LastEditDate: 2022-10-26T01:45:00.793Z
Answers.UserDisplayName: Steve
Body: <p>I'm trying to create a Nextflow script that maps assemblies to reference gene sequences. This is what I have so far:</p>
  <pre><code>
  #!/usr/bin/env nexflow
  nextflow.enable.dsl = 1
  
  
  params.assmblreads = '/Users/rimo/Desktop/Assemblies/Assemblies_Flye/flye_assembly.fasta'
  params.assmblref = '/Users/rimo/Desktop/Assemblies/gene_targets/GENE.fsa'
  
  refgenome_file = file(params.assmblref)
  fasta_files = Channel.fromPath(params.assmblreads)
                       .map { file -&gt; tuple(file.baseName, file) }
  
  
  process minimapping {
  
      input:
      file genome from refgenome_file
      set val(readID), file(readFile) from fasta_files
  
      output:
      set val(readID), file(&quot;${readID}.paf&quot;) into mapped_reads
  
      script:
      &quot;&quot;&quot;
      ./minimap2 <span class="math-container">$readFile $</span>genome &gt; ${readID}.paf
      &quot;&quot;&quot;
  
  }
  </code></pre>
  <p>I'm running this on a macOS so I have to include the &quot;./&quot; before a command or it will give the error: command not found&quot;</p>
  <p>But everytime I run the script with the command: <code>./nextflow run trials.nf</code> it results in this error message:</p>
  <pre><code>(base) rimo@Ritas-MBP minimap2 % ./nextflow run ../attempt_out.nf
  N E X T F L O W  ~  version 22.10.0
  Launching `../attempt_out.nf` [nasty_baekeland] DSL1 - revision: 98d1deaebd
  executor &gt;  local (1)
  [ae/47e3c0] process &gt; minimapping (1) [  0%] 0 of 1
  Error executing process &gt; 'minimapping (1)'
  
  Caused by:
  executor &gt;  local (1)
  [ae/47e3c0] process &gt; minimapping (1) [100%] 1 of 1, failed: 1 ✘
  Error executing process &gt; 'minimapping (1)'
  
  Caused by:
    Process `minimapping (1)` terminated with an error exit status (1)
  
  Command executed:
  
    ./minimap2 flye_assembly.fasta GENE.fsa &gt; flye_assembly.paf
  
  Command exit status:
    1
  
  Command output:
    (empty)
  
  Command error:
    .command.sh: line 2: ./minimap2: No such file or directory
  
  Work dir:
    /Users/rimo/Desktop/AWS/minimap2/work/ae/47e3c0708f33b1949315fc83066b95
  
  Tip: you can try to figure out what's wrong by changing to the process work dir and showing the script file named `.command.sh`
  
  
  </code></pre>
  <p>This is my first time ever writing a Nextflow script so I'm very new and confused to this new way of scripting. If someone could help me out that would be great!</p>
  
Tags: <read-mapping><nextflow><errors><minimap2>
Title: Nextflow with Minimap2 not working
ThreadText: # Nextflow with Minimap2 not working
  
  (Asked by: username_0 on 2022-10-25)
  
  I'm trying to create a Nextflow script that maps assemblies to reference gene sequences. This is what I have so far:
  
  ```
  
  #!/usr/bin/env nexflow
  nextflow.enable.dsl = 1
  
  params.assmblreads = '/Users/username_0/Desktop/Assemblies/Assemblies_Flye/flye_assembly.fasta'
  params.assmblref = '/Users/username_0/Desktop/Assemblies/gene_targets/GENE.fsa'
  
  refgenome_file = file(params.assmblref)
  fasta_files = Channel.fromPath(params.assmblreads)
                       .map { file -> tuple(file.baseName, file) }
  
  process minimapping {
  
      input:
      file genome from refgenome_file
      set val(readID), file(readFile) from fasta_files
  
      output:
      set val(readID), file("${readID}.paf") into mapped_reads
  
      script:
      """
      ./minimap2 $readFile $genome > ${readID}.paf
      """
  
  }
  
  ```
  
  I'm running this on a macOS so I have to include the "./" before a command or it will give the error: command not found"
  
  But everytime I run the script with the command: `./nextflow run trials.nf` it results in this error message:
  
  ```
  (base) username_0@Ritas-MBP minimap2 % ./nextflow run ../attempt_out.nf
  N E X T F L O W  ~  version 22.10.0
  Launching `../attempt_out.nf` [nasty_baekeland] DSL1 - revision: 98d1deaebd
  executor >  local (1)
  [ae/47e3c0] process > minimapping (1) [  0%] 0 of 1
  Error executing process > 'minimapping (1)'
  
  Caused by:
  executor >  local (1)
  [ae/47e3c0] process > minimapping (1) [100%] 1 of 1, failed: 1 ✘
  Error executing process > 'minimapping (1)'
  
  Caused by:
    Process `minimapping (1)` terminated with an error exit status (1)
  
  Command executed:
  
    ./minimap2 flye_assembly.fasta GENE.fsa > flye_assembly.paf
  
  Command exit status:
    1
  
  Command output:
    (empty)
  
  Command error:
    .command.sh: line 2: ./minimap2: No such file or directory
  
  Work dir:
    /Users/username_0/Desktop/AWS/minimap2/work/ae/47e3c0708f33b1949315fc83066b95
  
  Tip: you can try to figure out what's wrong by changing to the process work dir and showing the script file named `.command.sh`
  
  ```
  
  This is my first time ever writing a Nextflow script so I'm very new and confused to this new way of scripting. If someone could help me out that would be great!
  
  **Tags:** read-mapping, nextflow, errors, minimap2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-10-26. Score: 4
  
  > ```
  > Command error:
  >   .command.sh: line 2: ./minimap2: No such file or directory
  >
  > Work dir:
  >   /Users/username_0/Desktop/AWS/minimap2/work/ae/47e3c0708f33b1949315fc83066b95
  >
  > ```
  
  The problem is that your command is expecting the `minimap2` binary inside your working directory (i.e. the 'work dir', as defined above), but it could not be found. To avoid using relative (or absolute) paths, and to help keep your workflow portable, instead move your `minimap2` binary into a directory in your `$PATH`. Then, you should be able to call `minimap2` without a relative (or absolute) path to it. Here's one way using the new [DSL2](https://www.nextflow.io/docs/latest/dsl2.html), which comes enabled by default with Nextflow 22.10.0:
  
  ```
  params.assmblreads = '/Users/username_0/Desktop/Assemblies/Assemblies_Flye/flye_assembly.fasta'
  params.assmblref = '/Users/username_0/Desktop/Assemblies/gene_targets/GENE.fsa'
  
  process minimap2 {
  
      input:
      tuple val(readID), path(readFile)
      path genome
  
      output:
      tuple val(readID), path("${readID}.paf")
  
      """
      minimap2 "${readFile}" "${genome}" > "${readID}.paf"
      """
  }
  
  workflow {
  
      refgenome_file = file( params.assmblref )
      fasta_files = Channel.fromPath( params.assmblreads )
                           .map { file -> tuple( file.baseName, file ) }
  
      minimap2( fasta_files, refgenome_file )
  }
  
  ```
  
  To make your pipeline more portable, and to avoid manually installing and configuring your own tools, another way is to use [Conda environments](https://www.nextflow.io/docs/latest/conda.html). Nextflow has built-in support for [Conda](https://docs.conda.io/en/latest/) and gives you access to all of the tools, including [Minimap2](https://anaconda.org/bioconda/minimap2), available in [Bioconda](https://bioconda.github.io/). Install [miniconda](https://docs.conda.io/en/latest/miniconda.html) to get started, then add `conda.enabled = true` to your [nextflow.config](https://www.nextflow.io/docs/latest/config.html#configuration-file) and the [`conda`](https://www.nextflow.io/docs/latest/process.html#conda) directive (e.g. `conda 'minimap2=2.24'`) to your process definition for example. In the same way, you could also use [Docker](https://www.nextflow.io/docs/latest/container.html#docker) (or [Singularity](https://www.nextflow.io/docs/latest/container.html#singularity)) containers with the [`container`](https://www.nextflow.io/docs/latest/process.html#container) directive. Note that Docker containers are also built by the Bioconda build system and these are uploaded to [quay.io](https://quay.io/) as part of the [Biocontainers project](https://quay.io/organization/biocontainers) (e.g. [biocontainers/minimap2](https://quay.io/repository/biocontainers/minimap2)).
  
  
  ---
  
  