Skip to content
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
Binary file added DB/blastDB.nhr
Binary file not shown.
Binary file added DB/blastDB.nin
Binary file not shown.
Binary file added DB/blastDB.nsq
Binary file not shown.
8 changes: 8 additions & 0 deletions dirlisting
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DB
README.md
dirlisting
input.fasta
main.nf
nextflow.config
out_dir
test
10 changes: 10 additions & 0 deletions input.fasta
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
>Scaffold_1_1..100
CAGGCAAAATGTGGCACAAAAACAACAAATTGTTTAGTAGATACAGGGGCATCCATTTGTTGTATTTCGTCTGCTTTTCTGAGCACAGCTTTTGAAAACC
>Scaffold_1_101..200
TTACTCTTGGAAACTCACCCTTTCCACAGGTAAAAGGTGTTGGCGGCGAATTGCATAAAGTGTTAGGTTCAGTTGTGTTAGATTTTGTCATTGAGGATCA
>Scaffold_1_201..300
GGAATTTTCTCAAAGATTCTATGTACTGCCTACACTGCCGAAGGCAGTGATACTAGGTGAGAACTTCCTTAATGACAATGATGCAGTCTTAGATTATAGC
>Scaffold_1_301..400
TGTCATTCCTTGATACTCAACAACAGCACCTCAGATAGGCAATATATCAATTTCATAGCCAATTCAGTGCATGAGATTAGTGGATTAGCAAAAACACTAG
>Scaffold_1_401..500
ATCAGATTTACATCCCCCCTCAGAGTGAAATTCATTTCAAGGTCAGACTATCAGAGACCAAAGAGGATTCCCTCATCCTCATTGAACCCATTGCTTCCCT
56 changes: 53 additions & 3 deletions main.nf
Original file line number Diff line number Diff line change
@@ -1,6 +1,56 @@
#! /usr/bin/env nextflow

blastdb="myBlastDatabase"
params.query="file.fasta"
println "\nI want to BLAST $params.query to $params.dbDir/$params.dbName using $params.threads CPUs and output it to $params.outdir"

def helpMessage() {
log.info """
Usage:
The typical command for running the pipeline is as follows:
nextflow run main.nf --query QUERY.fasta --dbDir "blastDatabaseDirectory" --dbName "blastPrefixName"

Mandatory arguments:
--query Query fasta file of sequences you wish to BLAST
--dbDir BLAST database directory (full path required)
--dbName Prefix name of the BLAST database

Optional arguments:
--outdir Output directory to place final BLAST output
--outfmt Output format ['6']
--options Additional options for BLAST command [-evalue 1e-3]
--outFileName Prefix name for BLAST output [input.blastout]
--threads Number of CPUs to use during blast job [16]
--chunkSize Number of fasta records to use when splitting the query fasta file
--app BLAST program to use [blastn;blastp,tblastn,blastx]
--help This usage statement.
"""
}

// Show help message
if (params.help) {
helpMessage()
exit 0
}

Channel
.fromPath(params.query)
.splitFasta(by: 1, file:true)
.set { queryFile_ch }

process runBlast {

input:
path(queryFile) from queryFile_ch

output:
path(params.outFileName) into blast_output_ch

script:
"""
blastn -num_threads $params.threads -db $params.dbDir/$params.dbName -query $queryFile -outfmt $params.outfmt $params.options -out $params.outFileName
"""

}

blast_output_ch
.collectFile(name: 'blast_output_combined.txt', storeDir: params.outdir)

println "I will BLAST $params.query against $blastdb"
11 changes: 11 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
params {
query = "$PWD/input.fasta"
dbDir = "$PWD/DB/"
dbName = "blastDB"
threads = 2
outdir = "out_dir"
outFileName = "input.blastout"
options = "-evalue 1e-3"
outfmt = "'6'"
help = false
}
5 changes: 5 additions & 0 deletions out_dir/blast_output_combined.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Scaffold_1_401..500 Scaffold_1_401..500 100.000 100 0 0 1 100 1 100 4.90e-52 185
Scaffold_1_301..400 Scaffold_1_301..400 100.000 100 0 0 1 100 1 100 4.90e-52 185
Scaffold_1_201..300 Scaffold_1_201..300 100.000 100 0 0 1 100 1 100 4.90e-52 185
Scaffold_1_101..200 Scaffold_1_101..200 100.000 100 0 0 1 100 1 100 4.90e-52 185
Scaffold_1_1..100 Scaffold_1_1..100 100.000 100 0 0 1 100 1 100 4.90e-52 185
1 change: 1 addition & 0 deletions out_dir/blastout/input.blastout
1 change: 1 addition & 0 deletions test/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content of test.txt
Empty file added test/test2.txt
Empty file.