-
Notifications
You must be signed in to change notification settings - Fork 0
/
palidis.nf
executable file
·147 lines (116 loc) · 3.36 KB
/
palidis.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
/*
* Nextflow pipeline for identifying insertion sequences from metagenomic data
*
* Author:
* Victoria Carr [email protected]
*
*/
nextflow.enable.dsl=2
// import modules
include { convertToFasta } from './modules/convertToFasta.nf'
include { filterContigs } from './modules/filterContigs.nf'
include { buildDB } from './modules/buildDB.nf'
include { runProdigal } from './modules/runProdigal.nf'
include { installInterproscan } from './modules/installInterproscan.nf'
include { runInterproscan } from './modules/runInterproscan.nf'
include { mergeTSV } from './modules/merge.nf'
include { contigCandidates } from './modules/contigCandidates.nf'
include { palmem } from './modules/palmem.nf'
include { clipIRs } from './modules/clipIRs.nf'
include { mapIRs } from './modules/mapirs.nf'
include { getInsertionSequences } from './modules/getInsertionSequences.nf'
workflow palidis {
take:
reads_ch
contig_file_ch
main:
/*
* Get maximal exact matches from reads
*/
convertToFasta(reads_ch)
palmem(convertToFasta.out)
clipIRs(palmem.out)
/*
* Filter contigs
*/
filterContigs(contig_file_ch)
if (!file("${params.db_path}/${params.interproscan_db}").exists()) {
installInterproscan()
db_path = file("${params.db_path}")
db_path.mkdir()
installInterproscan.out
.set { interproscan_ch }
interproscan_ch
.subscribe{ it ->
it.copyTo("${db_path}")
}
} else {
Channel
.fromPath(file("${params.db_path}/${params.interproscan_db}"))
.set { interproscan_ch }
}
/*
* Annotate transposase
*/
runProdigal(filterContigs.out.prodigal_ch)
runProdigal.out.prot
.splitFasta(by: params.chunk_size, file:true)
.combine(interproscan_ch)
.set { chunk_ch }
runInterproscan(chunk_ch)
mergeTSV(runInterproscan.out.groupTuple(size: 0))
filterContigs.out.fasta_ch
.join(mergeTSV.out)
.set { contig_tsv_ch }
contigCandidates(contig_tsv_ch)
buildDB(contigCandidates.out.ref)
/*
* Map IRs to candidate contigs
*/
clipIRs.out
.join(buildDB.out.contig_db_ch)
.set { irs_contig_ch }
mapIRs(irs_contig_ch)
/*
* Get insertion sequences and corresponding information
*/
contigCandidates.out.fasta_info
.join(mapIRs.out)
.set { contig_info_ch }
getInsertionSequences(contig_info_ch)
is_info_ch = getInsertionSequences.out.txt
is_fasta_ch = getInsertionSequences.out.fasta
emit:
is_fasta_ch
is_info_ch
}
workflow {
// Define parameters
batch_path = file("./${params.batch_name}")
batch_path.mkdir()
/*
* Parameters
*/
Channel
.fromPath(params.manifest, checkIfExists: true)
.splitCsv(header:true, sep:"\t")
.map { row -> tuple(row.sample_id, file(row.read_directory)) }
.groupTuple()
.set { reads_ch }
Channel
.fromPath(params.manifest, checkIfExists: true)
.splitCsv(header:true, sep:"\t")
.map { row -> tuple(row.sample_id, file(row.contigs_path)) }
.set { contig_file_ch }
palidis(reads_ch, contig_file_ch)
// Publish IS fasta sequences
palidis.out.is_fasta_ch
.subscribe { it ->
it.copyTo("${batch_path}")
}
// Publish annotations
palidis.out.is_info_ch
.subscribe { it ->
it.copyTo("${batch_path}")
}
}