1
$\begingroup$

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/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 -> 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) 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 >  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/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`


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!

$\endgroup$
0

1 Answer 1

4
$\begingroup$
Command error:
  .command.sh: line 2: ./minimap2: No such file or directory

Work dir:
  /Users/rimo/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, which comes enabled by default with Nextflow 22.10.0:

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("${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. Nextflow has built-in support for Conda and gives you access to all of the tools, including Minimap2, available in Bioconda. Install miniconda to get started, then add conda.enabled = true to your nextflow.config and the conda directive (e.g. conda 'minimap2=2.24') to your process definition for example. In the same way, you could also use Docker (or Singularity) containers with the container directive. Note that Docker containers are also built by the Bioconda build system and these are uploaded to quay.io as part of the Biocontainers project (e.g. biocontainers/minimap2).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.