-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.nf
94 lines (70 loc) · 2.78 KB
/
main.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#! /usr/bin/env nextflow
println "\nI want to BLAST $params.query to $params.dbDir/$params.dbName using $params.threads CPUs and output it to $params.outdir\n"
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]
--genome If specified with a genome fasta file, a BLAST database will be generated for the genome
--help This usage statement.
"""
}
// Show help message
if (params.help) {
helpMessage()
exit 0
}
Channel
.fromPath(params.query)
.splitFasta(by: params.chunkSize, file:true)
.set { queryFile_ch }
if (params.genome) {
genomefile_ch = Channel
.fromPath(params.genome)
.map { file -> tuple(file.simpleName, file.parent, file) }
process runMakeBlastDB {
input:
set val(dbName), path(dbDir), file(FILE) from genomefile_ch
output:
val dbName into dbName_ch
path dbDir into dbDir_ch
script:
"""
makeblastdb -in ${params.genome} -dbtype 'nucl' -out $dbDir/$dbName
makeblastdb -in ${params.genome} -dbtype 'prot' -out $dbDir/$dbName
"""
}
} else {
Channel.fromPath(params.dbDir)
.set { dbDir_ch }
Channel.from(params.dbName)
.set { dbName_ch }
}
process runBlast {
container = 'ncbi/blast'
publishDir "${params.outdir}/blastout"
input:
path queryFile from queryFile_ch
path dbDir from dbDir_ch.val
val dbName from dbName_ch.val
output:
path(params.outFileName) into blast_output_ch
script:
"""
$params.app -num_threads $params.threads -db $dbDir/$dbName -query $queryFile -outfmt $params.outfmt $params.options -out $params.outFileName
"""
}
blast_output_ch
.collectFile(name: 'blast_output_combined.txt', storeDir: params.outdir)