This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Nextflow DSL2 error while constructing BLAST pipeline
` ''' #! /usr/bin/env nextflow

nextflow.enable.dsl=2

println "\nI want to BLAST $params.query to $params.dbDir/$params.dbName using $params.threads CPUs and output it to $params.outdir\n"


process runBlast {

script:
    """
    blastn  -num_threads $params.threads -db $params.dbDir/$params.dbName -query $params.query -outfmt 6 -out input.blastout
    """

}


params {
query = "$PWD/input.fasta"
dbDir = "$PWD/DB/"
dbName = "blastDB"
threads = 2
outdir = "out_dir"
}

`

What workflow {} statement should I add to the main.nf file? The basic BLAST command works, but it does not take additional parameters when added to the command line. The error I get is as follows:

ERROR ~ No such variable: query

Please help if you can, thank you!

I have been following this tutorial: https://bioinformaticsworkbook.org/dataAnalysis/nextflow/02_creatingAworkflow.html#gsc.tab=0

And using this DSL2 documentation for support: https://www.nextflow.io/docs/latest/dsl2.html

nextflow pipeline blast dsl2

1 answer

try (not tested)


nextflow.enable.dsl=2

params.query = "$PWD/input.fasta"
params.dbDir = "$PWD/DB/"
params.dbName = "blastDB"



workflow {
runBlast("${params.dbDir}/${params.dbName}","${params.query}")
}



process runBlast {
cpus 2
input:
    val(dbFile)
    val(query)
script:
    """
    blastn  -num_threads ${task.cpus} -db '${dbFile}' -query '${query}' -outfmt 6 -out blast.out
    """
}

also do not use variable like params.outdir but use the publishDir directive (see NF manual)

Log in to answer this question.