1+ // check if any of the parameters it defined before executing the process.
2+ if (! params. pathToDb{{ param_id }} && ! params. fastaToDb{{ param_id }})
3+ exit 1 , " 'You must specify either a pathToDb or fastaToDb parameter.'"
4+ // checks if both are defined and if so raises an error.
5+ else if (params. pathToDb{{ param_id }} && params. fastaToDb{{ param_id }})
6+ exit 1 , " 'Both pathToDb and fastaToDb were given, choose just one.'"
7+
8+ // list of blasts allowed for diamond
9+ allowedBlasts = [" blastp" , " blastx" ]
10+ // checks if blast type os defined
11+ if (! allowedBlasts. contains(params. blastType{{ param_id }}))
12+ exit 1 , " Provide a valid blast type: blastx or blastp"
13+
14+ process diamond_{{ pid }} {
15+
16+ // Send POST request to platform
17+ {% include " post.txt" ignore missing % }
18+
19+ tag { sample_id }
20+ publishDir " results/annotation/diamond_{{ pid }}/${ sample_id} "
21+
22+ input :
23+ set sample_id, file(assembly) from {{ input_channel }}
24+ file pathToDb from params. pathToDb{{ param_id }} ?
25+ Channel . fromPath(params. pathToDb{{ param_id }}) : Channel . value(" NA" )
26+ file fastaToDb from params. fastaToDb{{ param_id }} ?
27+ Channel . fromPath(params. fastaToDb{{ param_id }}) : Channel . value(" NA" )
28+ val blast from params. blastType{{ param_id }}
29+
30+ output :
31+ file " *.txt" into diamondOutputs
32+ output :
33+ {% with task_name= " diamond" % }
34+ {%- include " compiler_channels.txt" ignore missing -% }
35+ {% endwith % }
36+
37+ script :
38+ // Use database when available or otherwise use Fasta file
39+ if (params. pathToDb{{ param_id }})
40+ """
41+ diamond ${ blast} -d ${ pathToDb} -q ${ assembly} \
42+ -o ${ pathToDb} .txt -e 1E-20 -p ${ task.cpus} \
43+ -f 6 qseqid sseqid pident length mismatch gapopen qstart qend slen sstart send evalue bitscore
44+ """
45+ else if (params. fastaToDb{{ param_id }})
46+ """
47+ diamond makedb --in ${ fastaToDb} -d ${ fastaToDb}
48+ diamond ${ blast} -d ${ fastaToDb} .dmnd -q ${ assembly} \
49+ -o ${ fastaToDb} .txt -e 1E-20 -p ${ task.cpus} \
50+ -f 6 qseqid sseqid pident length mismatch gapopen qstart qend slen sstart send evalue bitscore
51+ """
52+
53+ }
0 commit comments