/
PTR_Calculation_Single_and_Paired.nf
210 lines (144 loc) · 4.21 KB
/
PTR_Calculation_Single_and_Paired.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
#!/usr/bin/env nextflow
params.genome = "/Users/jerrypan/Desktop/GRIPS/Data/GCF_000027085.1_ASM2708v1_genomic.fna"
genome_file = file(params.genome)
params.ref1_file = "/Users/jerrypan/Desktop/GRIPS/Data/ERR930224_1.fastq"
ref1_file = file(params.ref1_file)
params.ref2_file = "/Users/jerrypan/Desktop/GRIPS/Data/ERR930224_2.fastq"
ref2_file = file(params.ref2_file)
// params.ref_file = "/Users/jerrypan/Desktop/GRIPS/Data/Ery_T0_r1_1.fastq"
params.ref_file = "/Users/jerrypan/Desktop/GRIPS/Data/Citrobacter_Rodentium/Vcit_A4_3.fastq"
ref_file = file(params.ref_file)
// params.test1 = Channel.fromPath("/Users/jerrypan/Desktop/GRIPS/Data/Ery_Test/Ery_T0_r1_1").buffer(size:2)
// params.test2 = Channel.fromPath("/Users/jerrypan/Desktop/GRIPS/Data/Ery_Test/Ery_T0_r1_2").buffer(size:2)
// params.cr_genome = Channel.fromPath("/Users/jerrypan/Desktop/GRIPS/Data/CR_Test/*.fastq").buffer(size:3)
params.window_size = 10000
params.step_size = 100
params.single_file = false
// true: error
// false: works fine
output = "/Users/jerrypan/Desktop/Coverage_Reads_Graph.jpg"
window_size = params.window_size
step_size = params.step_size
params.build_icm = "/Users/jerrypan/Desktop/GRIPS/Glimmer/bin/build-icm"
params.glimmer3 = "/Users/jerrypan/Desktop/GRIPS/Glimmer/bin/glimmer3"
params.sickle = "/Users/jerrypan/Desktop/GRIPS/Sickle_Master/sickle"
params.bowtie2_build = "/Users/jerrypan/Desktop/GRIPS/Bowtie2_Binary/bowtie2-build"
params.bowtie2 = "/Users/jerrypan/Desktop/GRIPS/Bowtie2_Binary/bowtie2"
params.r_algo = "/Users/jerrypan/Desktop/GRIPS/Microbiota_Project/PTR_Calculation_Graph.R"
params.samtools = "/Users/jerrypan/Desktop/GRIPS/Samtools_1.9/samtools"
process glimmer_build_icm_ {
input:
file "genome" from genome_file
output:
file 'icm' into icm_file
script:
"""
$params.build_icm icm < $genome
"""
}
process glimmer3_ {
input:
file "genome" from genome_file
file "icm" from icm_file
output:
file 'predict' into predict_file
script:
"""
$params.glimmer3 $genome $icm predict > predict
"""
}
process sickle_pe_ {
input:
file "ref1" from ref1_file
file "ref2" from ref2_file
output:
//file 'trimmed*' into trimmed_file
file trimmed1 into trimmed_file1
file trimmed2 into trimmed_file2
file trimmedS into trimmed_file3
when:
!params.single_file
script:
"""
$params.sickle pe -f $ref1 -r $ref2 -t sanger -o trimmed1 -p trimmed2 -s trimmedS
"""
}
process bowtie2_build_ {
input:
file "genome" from genome_file
output:
file 'index' into index_file
script:
"""
$params.bowtie2_build $genome index > index
"""
}
process bowtie2_pe_ {
input:
file "trimmed1" from trimmed_file1
file "trimmed2" from trimmed_file2
val "index" from index_file
output:
file 'bam' into bam_file_pe
when:
!params.single_file
script:
"""
$params.bowtie2 -x $index -1 $trimmed1 -2 $trimmed2 | $params.samtools view -b - > bam
"""
}
process calculation_and_graph_pe_ {
input:
file "bam" from bam_file_pe
// val "window_size" from window_size
// val "step_size" from step_size
// val "output" from output
output:
// file 'graph' into output1
// file 'text' into output2
when:
!params.single_file
script:
"""
$params.r_algo $bam --window_size $window_size --step_size $step_size --output $output
"""
}
process sickle_se_ {
input:
file "ref" from ref_file
output:
//file 'trimmed*' into trimmed_file
file 'trimmed' into trimmed_file
when:
params.single_file
script:
"""
$params.sickle se -f $ref -t sanger -o trimmed
"""
}
process bowtie2_se_ {
input:
file "trimmed" from trimmed_file
val "index" from index_file
output:
file 'bam' into bam_file_se
when:
params.single_file
script:
"""
$params.bowtie2 -x $index -1 $trimmed | $params.samtools view -b > bam
"""
}
process calculation_and_graph_se_ {
input:
file "bam" from bam_file_se
output:
// file 'graph' into output1
// file 'text' into output2
when:
params.single_file
script:
"""
$params.r_algo $bam --window_size $window_size --step_size $step_size --output $output
"""
}