Skip to content

Update blastn module #8765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions modules/nf-core/blast/blastn/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ process BLAST_BLASTN {
input:
tuple val(meta) , path(fasta)
tuple val(meta2), path(db)
path taxidlist
val taxids
val negative_tax

output:
tuple val(meta), path('*.txt'), emit: txt
Expand All @@ -23,6 +26,12 @@ process BLAST_BLASTN {
def prefix = task.ext.prefix ?: "${meta.id}"
def is_compressed = fasta.getExtension() == "gz" ? true : false
def fasta_name = is_compressed ? fasta.getBaseName() : fasta
def negative_tax_cmd = negative_tax ? "negative_" : ""
def taxidlist_cmd = taxidlist ? "-${negative_tax_cmd}taxidlist ${taxidlist}" : ""
def taxids_cmd = taxids ? "-${negative_tax_cmd}taxids ${taxids}" : ""
if (taxidlist_cmd.any() && taxids_cmd.any()) {
log.error("ERROR: taxidlist and taxids can not be used at the same time, choose only one argument to use for tax id filtering.")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muffato I added an if statement per your suggestion, similar to in the hifiasm module. However, It feels somewhat unnecessary because of how blast already outputs quite clear errors when using the two incompatible flags simultaneously. Hence, both the if statement will tell you, and blast errors will tell you. Whats your input, should the if statement stay or is it repetitive?

}

"""
if [ "${is_compressed}" == "true" ]; then
Expand All @@ -39,6 +48,8 @@ process BLAST_BLASTN {
-num_threads ${task.cpus} \\
-db \$DB \\
-query ${fasta_name} \\
${taxidlist_cmd} \\
${taxids_cmd} \\
${args} \\
-out ${prefix}.txt

Expand Down
6 changes: 6 additions & 0 deletions modules/nf-core/blast/blastn/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ nextflow_process {
"""
input[0] = [ [id:'test'], file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) ]
input[1] = BLAST_MAKEBLASTDB.out.db
input[2] = []
input[3] = []
input[4] = []
"""
}
}
Expand All @@ -55,6 +58,9 @@ nextflow_process {
"""
input[0] = [ [id:'test'], file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.gz', checkIfExists: true) ]
input[1] = BLAST_MAKEBLASTDB.out.db
input[2] = []
input[3] = []
input[4] = []
"""
}
}
Expand Down
8 changes: 4 additions & 4 deletions modules/nf-core/blast/blastn/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.5"
"nextflow": "24.10.6"
},
"timestamp": "2025-04-01T11:32:43.169365323"
"timestamp": "2025-08-04T14:26:27.847166"
},
"versions_zipped": {
"content": [
Expand All @@ -19,8 +19,8 @@
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.5"
"nextflow": "24.10.6"
},
"timestamp": "2025-04-01T11:32:48.452742327"
"timestamp": "2025-08-04T14:52:40.954652"
}
}