-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.nf
More file actions
169 lines (140 loc) · 4.97 KB
/
main.nf
File metadata and controls
169 lines (140 loc) · 4.97 KB
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
#!/usr/bin/env nextflow
/*
===============================================================================
nextflow based nucMACC pipeline
===============================================================================
Authors:
Uwe Schwartz <uwe.schwartz@ur.de>
-------------------------------------------------------------------------------
*/
nextflow.enable.dsl = 2
// show settings
if (!params.help) {
include{settings} from './modules/setting'
settings()
}
// help message
// Show help message
if (params.help) {
include{helpMessage} from './modules/help'
helpMessage()
exit 0
}
// workflow
// read csv file
if(params.test){
if (params.bamEntry){
// sample mono
Channel
.fromPath(params.csvInput)
.splitCsv(header:true)
.map{ row -> tuple(row.Sample_Name,file(row.path_mono))}
.set{bamEntry_mono}
// sample sub
Channel
.fromPath(params.csvInput)
.splitCsv(header:true)
.map{ row -> tuple(row.Sample_Name,file(row.path_sub))}
.set{bamEntry_sub}
}
else {
// forward reads
Channel
.fromPath(params.csvInput)
.splitCsv(header:true)
.map{ row -> tuple(row.Sample_Name,
file(params.project.concat(row.path_fwdReads)))}
.set{samples_fwd_ch}
// reverse reads
Channel
.fromPath(params.csvInput)
.splitCsv(header:true)
.map{ row -> tuple(row.Sample_Name,
file(params.project.concat(row.path_revReads)))}
.set{samples_rev_ch}
}
}
else if (params.bamEntry == true){
// sample mono
Channel
.fromPath(params.csvInput)
.splitCsv(header:true)
.map{ row -> tuple(row.Sample_Name,file(row.path_mono))}
.set{bamEntry_mono}
// sample sub
Channel
.fromPath(params.csvInput)
.splitCsv(header:true)
.map{ row -> tuple(row.Sample_Name,file(row.path_sub))}
.set{bamEntry_sub}
println "BamEntry csv part" }
else {
// forward reads
Channel
.fromPath(params.csvInput)
.splitCsv(header:true)
.map{ row -> tuple(row.Sample_Name,file(row.path_fwdReads))}
.set{samples_fwd_ch}
// reverse reads
Channel
.fromPath(params.csvInput)
.splitCsv(header:true)
.map{ row -> tuple(row.Sample_Name,file(row.path_revReads))}
.set{samples_rev_ch}
}
if(params.bamEntry==false) {
//Channel for fastqc
samples_fwd_ch.mix(samples_rev_ch).set{sampleSingle_ch}
//Channel for alignment
samples_fwd_ch.join(samples_rev_ch).set{samplePair_ch}
}
//read MNase concentration
Channel
.fromPath(params.csvInput)
.splitCsv(header:true)
.map{ row -> tuple(row.MNase_U.toDouble(),row.Sample_Name)}
.set{samples_conc}
// load workflows
// generate profiles
include{MNaseQC} from './workflows/MNaseQC'
include{sub_bamEntry; sub_FASTQ_entry; common_nucMACC} from './workflows/nucMACC'
// Check mandatory parameters
if (params.csvInput) { ch_csv = file(params.csvInput) } else { exit 1, 'Input samplesheet not found!' }
if (params.TSS) {ch_TSS = file (params.TSS)}
if(params.TSS){
if (ch_TSS.isEmpty()) { exit 1, 'TSS file not found!'}
}
if (params.blacklist) {ch_blacklist = file (params.blacklist)}
if(params.blacklist){
if (ch_blacklist.isEmpty()) { exit 1, 'Blacklist file not found!'}
}
if(params.analysis =='MNaseQC'){
if (params.genomeIdx) { ch_idx = file(params.genomeIdx).parent }
if (ch_idx.isEmpty()) { exit 1, 'Folder containing bowtie2 indices not found!'}
}
if(params.analysis=='nucMACC'){
if(params.bamEntry == true){
if (params.genome) { ch_genome = file(params.genome)}
if (ch_genome.isEmpty()) { exit 1, 'Genome fasta not found!'}
}
else {
if (params.genomeIdx) { ch_idx = file(params.genomeIdx).parent }
if (ch_idx.isEmpty()) { exit 1, 'Folder containing bowtie2 indices not found!'}
if (params.genome) { ch_genome = file(params.genome)}
if (ch_genome.isEmpty()) { exit 1, 'Genome fasta not found!'}}
}
workflow{
if(params.analysis=='MNaseQC'){
MNaseQC(sampleSingle_ch,samplePair_ch,samples_conc)
}
if(params.analysis=='nucMACC'){
if (params.bamEntry == true) {
sub_bamEntry(bamEntry_mono,bamEntry_sub)
common_nucMACC(sub_bamEntry.out[0], sub_bamEntry.out[1], samples_conc)
}
else {
sub_FASTQ_entry(sampleSingle_ch,samplePair_ch,samples_conc)
common_nucMACC(sub_FASTQ_entry.out[0], sub_FASTQ_entry.out[1], samples_conc)
}
}
}