-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.nf
1202 lines (871 loc) · 25.9 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env nextflow
/*
* Copyright (c) 2017-2022, Centre for Genomic Regulation (CRG)
*
* Copyright (c) 2017, Anna Vlasova
*
* Copyright (c) 2017, Emilio Palumbo
*
* Copyright (c) 2018-2022, Toni Hermoso Pulido
*
* Functional Annotation Pipeline for protein annotation from non-model organisms
* from Genome Annotation Team in Catalonia (GATC) implemented in Nextflow
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// there can be three log levels: off (no messages), info (some main messages), debug (all messages + sql queries)
// default parameters
params.help = false
params.debug = false
params.dbEngine = "SQLite" // MySQL otherwise
params.mysqllog = "${baseDir}/tmp"
// Main input files
params.proteinFile = null;
params.gffFile = null;
params.speciesName = "organism"
params.dbname = "organismDB"
// Main result and log dirs
params.resultPath = "${baseDir}/results/"
params.stdoutLog = "${baseDir}/logs/out.log"
params.stderrLog = "${baseDir}/logs/err.log"
// Sizes for different programs
params.chunkIPSSize = null
params.chunkBlastSize = null
params.chunkKoalaSize = null
params.chunkWebSize = null
params.debugSize = 2
// Blast related params
params.blastFile = null
params.evalue = 0.00001
params.diamond = null
params.blastDbPath = null
// GO retrieval params
params.gogourl = ""
params.gogohits = 30
params.blastAnnotMode = "common" // common, most, all available so far
// KEGG
params.kolist = null
params.koprofiles = null
params.koentries = null
params.kegg_release = null
params.kegg_species = "hsa, dme, cel, ath"
params.keggFile = null
// Params for InterProScan
// Temporary location for InterproScan intermediary files. This can be huge
params.ipscantmp = "${baseDir}/tmp/"
// Location of InterproScan properties. Do not modify unless it matches your container
params.ipscanproperties = "/usr/local/interproscan/interproscan.properties"
params.ipscandata = ""
ipscandata = "/usr/local/interproscan/data"
if ( params.ipscandata != "" ) {
ipscandata = params.ipscandata
} else {
if ( params.iprscanVersion ) {
if ( params.dbPath ) {
if ( new File( params.dbPath + "/iprscan/" + params.iprscanVersion ).exists() ) {
ipscandata = "${params.dbPath}/iprscan/${params.iprscanVersion}"
}
}
}
}
// Params for dealing with GFF
params.gffclean = true
params.gffstats = true
// Remove version from protein entries (e.g. X5543AP.2)
params.rmversion = false
// File with GO information, otherwise is downloaded
params.oboFile = null
// Skip params
params.skip_cdSearch = false
params.skip_sigtarp = false
// Mail for sending reports
params.email = ""
// Download paths
params.dbPath = null
params.blastDbFolder = null
params.dbipscanPath = null
params.dbKOPath = null
// Handling defaults from download part
Date date = new Date()
String datePart = date.format("yyyyMM")
// Handle BlastDB paths
blastDbPath = null;
if ( ! params.blastDbPath ) {
if ( ! params.blastDbFolder ) {
if ( ! params.dbPath ) {
log.info "At least dbPath needs to be defined!"
exit 1
} else {
blastDbFolder = "${params.dbPath}/ncbi/${datePart}/blastdb/db"
// Let's assume Swissprot
blastDbPath = "${blastDbFolder}/swissprot"
}
} else {
// Let's assume Swissprot
blastDbPath = "${params.blastDbFolder}/swissprot"
}
} else {
blastDbPath = params.blastDbPath
}
// KEGG paths
kolist = null
koprofiles = null
koentries = null
if ( params.kolist ) {
kolist = params.kolist
}
if ( params.koprofiles ) {
koprofiles = params.koprofiles
}
if ( params.koentries ) {
koentries = params.koentries
}
if ( ! params.kolist && ! params.keggFile ) {
if ( params.koVersion && params.dbPath ) {
kolist = "${params.dbPath}/kegg/${params.koVersion}/ko_list"
}
}
if ( ! params.koprofiles && ! params.keggFile ) {
if ( params.koVersion && params.dbPath ) {
koprofiles = "${params.dbPath}/kegg/${params.koVersion}/profiles"
}
}
if ( ! params.koentries ) {
if ( params.koVersion && params.dbPath ) {
koentries = "${params.dbPath}/kegg/${params.koVersion}/ko_store"
}
}
//print usage
if ( params.help ) {
log.info ''
log.info 'Functional annotation pipeline'
log.info '----------------------------------------------------'
log.info 'Run functional annotation for a given species.'
log.info ''
log.info 'Usage: '
log.info " ./nextflow run main.nf --config params.config [options]"
log.info ''
log.info 'Options:'
log.info '-resume resume pipeline from the previous step, i.e. in case of error'
log.info '-help this message'
exit 1
}
/*
* Parse the input parameters
*/
// species-specific parameters
protein = null
annotation = null
config_file = file(params.config)
dbFile = false
boolean exists = false
boolean mysql = false
gffavail = false
gffclean = false
gffstats = false
// Skip
skip_cdSearch = false
skip_sigtarp = false
if( params.dbEngine.toLowerCase()=="mysql" ) {
mysql = true
}
if ( params.gffclean ) {
gffclean = true
}
if ( params.gffstats ) {
gffstats = true
}
if ( params.skip_cdSearch ) {
skip_cdSearch = true
}
if ( params.skip_sigtarp ) {
skip_sigtarp = true
}
// Handling MySQL in a cleaner way
dbhost = null
// Getting contents of file
if ( mysql ) {
dbhost = "127.0.0.1" // Default value. Localhost
if ( new File( params.mysqllog+"/DBHOST" ).exists() ) {
dbhost = new File( params.mysqllog+"/DBHOST" ).text.trim()
}
} else {
dbFileName = params.resultPath+params.dbname+'.db'
dbFile = file(dbFileName)
if ( dbFile.exists() && dbFile.size() > 0 ) {
exists = true
}
}
// print log info
log.info ""
log.info "Functional annotation pipeline"
log.info ""
log.info "General parameters"
log.info "------------------"
if ( params.proteinFile == null || params.proteinFile == "" ) {
log.info "No protein sequence file specified!"
exit 1
} else {
if ( file( params.proteinFile ).exists() && file( params.proteinFile ).size() > 0 ) {
log.info "Protein sequence file : ${params.proteinFile}"
protein = file(params.proteinFile)
} else {
log.info "Protein sequence file does not exist or it is empty!"
exit 1
}
}
if ( params.gffFile == null || params.gffFile == "" ) {
log.info "No GFF Structural Annotation file specified!"
log.info "We proceed anyway..."
} else {
if ( file( params.gffFile ).exists() && file( params.gffFile ).size() > 0 ) {
log.info "GFF Structural Annotation file : ${params.gffFile}"
gffavail = true
annotation = file(params.gffFile)
} else {
log.info "GFF Structural Annotation file is missing or empty."
log.info "We stop the pipeline so you can check it and define as \"\" otherwise if no GFF file is provided."
exit 1
}
}
if ( params.blastFile ) {
log.info "BLAST results file : ${params.blastFile}"
}
log.info "Species name : ${params.speciesName}"
log.info "KEGG species : ${params.kegg_species}"
if ( mysql ) {
log.info "MySQL FA database : ${params.dbname}"
} else {
log.info "SQLite FA database : $dbFileName"
}
if ( skip_cdSearch ) {
log.info "CD-Search queries will be skipped."
}
if ( skip_sigtarp ) {
log.info "SignalP and targetP queries will be skipped."
}
// split protein fasta file into chunks and then execute annotation for each chunk
// chanels for: interpro, blast, signalP, targetP, cdsearch_hit, cdsearch_features
chunkSize = params.chunkSize
chunkBlastSize = chunkSize
chunkIPSSize = chunkSize
chunkKoalaSize = chunkSize
chunkWebSize = chunkSize
if ( params.chunkBlastSize ) {
chunkBlastSize = params.chunkBlastSize
}
if ( params.chunkIPSSize ) {
chunkIPSSize = params.chunkIPSSize
}
if ( params.chunkKoalaSize ) {
chunkKoalaSize = params.chunkKoalaSize
}
if ( params.chunkWebSize ) {
chunkWebSize = params.chunkWebSize
}
seqData = Channel
.from(protein)
.splitFasta( by: chunkSize )
seqBlastData = Channel
.from(protein)
.splitFasta( by: chunkBlastSize )
seqKoalaData = Channel
.from(protein)
.splitFasta( by: chunkKoalaSize )
seqIPSData = Channel
.from(protein)
.splitFasta( by: chunkIPSSize )
seqWebData = Channel
.from(protein)
.splitFasta( by: chunkWebSize )
ipscan_properties = file(params.ipscanproperties)
if ( params.debug == "true" || params.debug == true ) {
println("Debugging... only the first $params.debugSize chunks will be processed")
// Diferent parts for different processes.
// TODO: With DSL2 this is far simpler
(seq_file1, seq_file2) = seqData.take(params.debugSize).into(2)
(seq_file_blast) = seqBlastData.take(params.debugSize).into(1)
(seq_file_koala) = seqKoalaData.take(params.debugSize).into(1)
(seq_file_ipscan) = seqIPSData.take(params.debugSize).into(1)
(web_seq_file1, web_seq_file2) = seqWebData.take(params.debugSize).into(2)
testNum = ( params.chunkSize.toInteger() * params.debugSize )
seqTestData = Channel
.from(protein)
.splitFasta(by: testNum)
(seq_test) = seqTestData.take(1).into(1)
} else {
println("Process entire dataset")
(seq_file1, seq_file2) = seqData.into(2)
(seq_file_blast) = seqBlastData.into(1)
(seq_file_koala) = seqKoalaData.into(1)
(seq_file_ipscan) = seqIPSData.into(1)
(web_seq_file1, web_seq_file2) = seqWebData.into(2)
seqTestData = Channel
.from(protein)
// Anything for keeping. This is only kept for coherence
(seq_test) = seqTestData.into(1)
}
if ( params.oboFile == "" || params.oboFile == null ) {
oboFile = downloadURL( "http://www.geneontology.org/ontology/gene_ontology.obo", "gene_ontology.obo" )
} else {
oboFile = params.oboFile
}
// Preprocessing GFF File
if ( gffavail ) {
if ( gffclean ) {
process cleanGFF {
publishDir params.resultPath, mode: 'copy'
label 'gffcheck'
input:
file config_file
output:
file "annot.gff" into gff_file
file "annot.gff.clean.txt" into gff_file_log
"""
# get annot file
export escaped=\$(echo '$baseDir')
export basedirvar=\$(echo '\\\$\\{baseDir\\}')
export basedirvar=\$(echo '\\\$\\{baseDir\\}')
input_file=`perl -lae 'if (\$_=~/gffFile\\s*\\=\\s*[\\x27|\\"](\\S+)[\\x27|\\"]/) { \$base = \$1; \$base=~s/\$ENV{'basedirvar'}/\$ENV{'escaped'}/g; print \$base }' $config_file`
if [ "\${input_file: -3}" == ".gz" ]; then
gunzip -c \$input_file > input_gff
input_file=input_gff
fi
agat_convert_sp_gxf2gxf.pl --gff \$input_file -o annot.gff > annot.gff.clean.txt
"""
}
} else {
process copyGFF {
label 'gffcheck'
input:
file config_file
output:
file "annot.gff" into gff_file
"""
# get annot file
export escaped=\$(echo '$baseDir')
export basedirvar=\$(echo '\\\$\\{baseDir\\}')
input_file=`perl -lae 'if (\$_=~/gffFile\\s*\\=\\s*[\\x27|\\"](\\S+)[\\x27|\\"]/) { \$base = \$1; \$base=~s/\$ENV{'basedirvar'}/\$ENV{'escaped'}/g; print \$base }' $config_file`
if [ "\${input_file: -3}" == ".gz" ]; then
gunzip -c \$input_file > input_gff
input_file=input_gff
fi
cp \$input_file annot.gff
"""
}
}
if ( gffstats ) {
process statsGFF {
publishDir params.resultPath, mode: 'copy'
label 'gffcheck'
input:
file gff_file
output:
file "*.txt" into gff_stats
"""
# Generate Stats
agat_sp_statistics.pl --gff $gff_file > ${gff_file}.stats.txt
"""
}
}
} else {
// Dummy empty GFF
process dummyGFF {
label 'gffcheck'
input:
file config_file
output:
file "annot.gff" into gff_file
"""
# empty annot file
touch annot.gff
"""
}
}
// Blast like processes
// TODO: To change for different aligners
diamond = false
if( params.diamond == "true" || params.diamond == true ) {
diamond = true
}
// BlastAnnotMode
blastAnnotMode = "common"
if( params.blastAnnotMode != "" && params.blastAnnotMode != null ) {
blastAnnotMode = params.blastAnnotMode
}
if ( params.blastFile == "" || params.blastFile == null ){
// program-specific parameters
db_name = file(blastDbPath).name
db_path = file(blastDbPath).parent
// Handling Database formatting
formatdbDetect = "false"
if ( diamond ) {
formatDbFileName = blastDbPath + ".dmnd"
formatDbFile = file(formatDbFileName)
if ( formatDbFile.exists() && formatDbFile.size() > 0 ) {
formatdbDetect = "true"
}
if ( formatdbDetect == "false" ) {
process diamondFormat{
label 'diamond'
output:
file "${db_name}_formatdb.dmnd" into formatdb
"""
diamond makedb --in ${db_path}/${db_name} --db "${db_name}_formatdb"
"""
}
} else {
formatdb = blastDbPath
}
} else {
formatDbDir = file( db_path )
filter = ~/${db_name}.*.phr/
def fcount = 0
formatDbDir.eachFileMatch( filter ) { it ->
fcount = fcount + 1
}
if ( fcount > 0 ) {
formatdbDetect = "true"
}
println( formatdbDetect )
if ( formatdbDetect == "false" ) {
// println( "TUR" )
process blastFormat{
label 'blast'
output:
file "${db_name}.p*" into formatdb
"""
makeblastdb -dbtype prot -in ${db_path}/${db_name} -parse_seqids -out ${db_name}
"""
}
} else {
formatdb = blastDbPath
}
}
if ( diamond == true ) {
process diamond{
label 'diamond'
input:
file seq from seq_file_blast
file formatdb_file from formatdb
output:
file "blastXml${seq}" into (blastXmlResults1, blastXmlResults2, blastXmlResults3)
script:
if ( formatdbDetect == "false" ) {
command = "diamond blastp --db ${formatdb_file} --query $seq --outfmt 5 --threads ${task.cpus} --evalue ${params.evalue} --out blastXml${seq}"
} else {
command = "diamond blastp --db ${db_path}/${db_name} --query $seq --outfmt 5 --threads ${task.cpus} --evalue ${params.evalue} --out blastXml${seq}"
}
command
}
} else {
process blast{
label 'blast'
// publishDir "results", mode: 'copy'
input:
file seq from seq_file_blast
file formatdb_file from formatdb
output:
file "blastXml${seq}" into (blastXmlResults1, blastXmlResults2, blastXmlResults3)
script:
if ( formatdbDetect == "false" ) {
command = "blastp -db ${formatdb_file} -query $seq -num_threads ${task.cpus} -evalue ${params.evalue} -out blastXml${seq} -outfmt 5"
} else {
command = "blastp -db ${db_path}/${db_name} -query $seq -num_threads ${task.cpus} -evalue ${params.evalue} -out blastXml${seq} -outfmt 5"
}
command
}
}
} else {
blastInput=file(params.blastFile)
process convertBlast {
// publishDir "results", mode: 'copy'
input:
file blastFile from blastInput
output:
file("*.xml") into (blastXmlResults1, blastXmlResults2, blastXmlResults3)
"""
hugeBlast2XML.pl -blast $blastFile -n 1000 -out blast.res
"""
}
}
if ( kolist != "" || kolist != null ){
process kofamscan{
label 'kofamscan'
input:
file seq from seq_file_koala
output:
file "koala_${seq}" into koalaResults
"""
exec_annotation --cpu ${task.cpus} -p ${koprofiles} -k ${kolist} -o koala_${seq} $seq
"""
}
process kofam_parse {
input:
file "koala_*" from koalaResults.collect()
output:
file allKoala into ( koala_parsed, koala_parsed2 )
"""
mkdir -p output
processHmmscan2TSV.pl "koala_*" output
cat output/koala_* > allKoala
"""
}
// Replacing keggfile
keggfile = koala_parsed
} else {
if (params.keggFile == "" || params.keggFile == null ) {
println "Please run KEGG KO group annotation on the web server http://www.genome.jp/tools/kaas/"
exit 1
} else {
keggfile = file(params.keggFile)
}
}
// GO retrieval from BLAST results
if (params.gogourl != "") {
process blast_annotator {
label 'blastannotator'
maxForks 3
input:
file blastXml from blastXmlResults2.flatMap()
output:
file "blastAnnot" into ( blast_annotator_results1, blast_annotator_results2 )
"""
blast-annotator.pl -in $blastXml -out blastAnnot --hits $params.gogohits --url $params.gogourl -t $blastAnnotMode -q --format blastxml
"""
}
}
process blastDef {
// publishDir "results", mode: 'copy'
tag "${blastXml}"
input:
file blastXml from blastXmlResults3.flatMap()
output:
file "blastDef_${blastXml}.txt" into blastDef_results
"""
definitionFromBlast.pl -in $blastXml -out blastDef_${blastXml}.txt -format xml -q
"""
}
process ipscn {
label 'ipscan'
if ( workflow.containerEngine == "singularity" ) {
containerOptions "--bind ${ipscandata}:/usr/local/interproscan/data"
} else {
containerOptions "--volume ${ipscandata}:/usr/local/interproscan/data"
}
input:
file seq from seq_file_ipscan
file ("interproscan.properties") from file( ipscan_properties )
output:
file("out_interpro_${seq}") into (ipscn_result1, ipscn_result2)
"""
sed 's/*//g' $seq > tmp4ipscn
interproscan.sh -i tmp4ipscn --goterms --iprlookup --pathways -o out_interpro_${seq} -f TSV -T ${params.ipscantmp}
"""
}
process 'cdSearchHit' {
label 'cdSearch'
if ( ! skip_cdSearch ) {
maxForks 1
}
input:
file seq from web_seq_file1
output:
file("out_hit_${seq}") into ( cdSearch_hit_result1, cdSearch_hit_result2 )
script:
if ( skip_cdSearch ) {
// Dummy content
command = "touch out_hit_${seq}"
} else {
command = "submitCDsearch.pl -o out_hit_${seq} -in $seq"
}
command
}
process 'cdSearchFeat' {
label 'cdSearch'
if ( ! skip_cdSearch ) {
maxForks 1
}
input:
file seq from web_seq_file2
output:
file("out_feat_${seq}") into ( cdSearch_feat_result1, cdSearch_feat_result2 )
script:
if ( skip_cdSearch ) {
// Dummy content
command = "touch out_feat_${seq}"
} else {
command = "submitCDsearch.pl -t feats -o out_feat_${seq} -in $seq"
}
command
}
if ( skip_sigtarp ) {
process 'signalP_dummy' {
input:
file seq from seq_file1
output:
file("out_signalp_${seq}") into (signalP_result1, signalP_result2)
"""
touch out_signalp_${seq}
"""
}
process 'targetP_dummy' {
input:
file seq from seq_file2
output:
file("out_targetp_${seq}") into (targetP_result1, targetP_result2)
"""
touch out_targetp_${seq}
"""
}
} else {
process 'signalP' {
label 'sigtarp'
input:
file seq from seq_file1
output:
file("out_signalp_${seq}") into (signalP_result1, signalP_result2)
"""
signalp -fasta $seq -stdout > out_signalp_${seq}
"""
}
process 'targetP' {
label 'sigtarp'
input:
file seq from seq_file2
output:
file("out_targetp_${seq}") into (targetP_result1, targetP_result2)
"""
targetp -fasta $seq -stdout > out_targetp_${seq}
"""
}
}
// Database setup below
process initDB {
input:
file config_file
file gff_file
file seq from seq_test
output:
file 'config' into (config4perl7, config4perl8, config4perl10)
script:
command = "mkdir -p $params.resultPath\n"
command += "sed 's/^\\s*params\\s*{\\s*\$//gi' $config_file | sed 's/^\\s*}\\s*\$//gi' | sed '/^\\s*\$/d' | sed 's/\\s\\=\\s/:/gi' | sed '/^\\s*\\/\\//d' > configt\n"
command += "export escaped=\$(echo '$baseDir')\n"
command += "export basedirvar=\$(echo '\\\$\\{baseDir\\}')\n"
command += "perl -lae '\$_=~s/\$ENV{'basedirvar'}/\$ENV{'escaped'}/g; print;' configt > config\n"
if ( mysql ) {
// Add dbhost to config
command += "echo \"\$(cat config)\n dbhost:${dbhost}\" > configIn ;\n"
command += "fa_main.v1.pl init -conf configIn"
if ( gffavail && gffclean ) {
command += " -gff ${gff_file}"
}
} else {
if (exists) {
log.info "SQLite database ${dbFileName} exists. We proceed anyway..."
}
command += "fa_main.v1.pl init -conf config"
if ( gffavail && gffclean ) {
command += " -gff ${gff_file}"
}
}
if ( params.debug=="TRUE"||params.debug=="true" ) {
// If in debug mode, we restrict de seq entries we process
command += " -fasta ${seq}"
}
if ( params.rmversion=="TRUE"||params.rmversion=="true" ) {
// If remove versioning in protein sequences (for cases like ENSEMBL)
command += " -rmversion"
}
command
}
if ( ! koentries ) {
process 'kegg_download'{
maxForks 1
input:
file keggfile from keggfile
file config from config4perl8
output:
file("down_kegg") into (down_kegg)
script:
command = "download_kegg_KAAS.pl -input $keggfile -conf $config > done 2>err"
command
}
} else {
process 'kegg_download_dummy' {
input:
file keggfile from keggfile
file config from config4perl8
output:
file("down_kegg") into (down_kegg)
script:
command = "touch down_kegg"
command
}
}
// Data upload process
process 'data_upload' {
maxForks 1
label 'upload'
input:
file "def*" from blastDef_results.collect()
file "out_signalp*" from signalP_result1.collect()
file "out_targetp*" from targetP_result1.collect()