-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.nf
201 lines (150 loc) · 4.67 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
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
params.project = "EcoliRNASeq"
params.nbcpu = "8"
params.genome_name = "Ecoli_K12"
workflow {
// Initialise les channels
bio_conds = Channel.of([1,"WT_1"],[2,"WT_2"],[3,"MazF_1"],[4,"MazF_2"])
ftp_ebis = Channel.of([1,"005/ERR2686025/ERR2686025"], [2,"006/ERR2686026/ERR2686026"], [3,"007/ERR2686027/ERR2686027"], [4,"008/ERR2686028/ERR2686028"])
// channel combiné
bio_cond_ftp_ebis = bio_conds.cross(ftp_ebis)
// Telechargement du genome et indexation
DL_GENOME | INDEX_GENOME
// Telecharger les reads
DL_FASTQ(bio_cond_ftp_ebis)
// Trim des adapters
CUTADAPT(bio_conds, DL_FASTQ.out)
FASTQC(CUTADAPT.out)
// Mapping et convert to bam
MAPPING(INDEX_GENOME.out, CUTADAPT.out)
//MAPPING.out.view()
SAM_TO_BAM(MAPPING.out)
// Comptage des reads sur chaque gene
GENE_COUNT(SAM_TO_BAM.out, DL_GENOME.out.genome_gtf)
// Final run avec multiqc
MULTIQC(FASTQC.out.collect(), GENE_COUNT.out.collect())
}
/*
* Download genome files
* We have now to download the genome file of Escherichis coli K-12. We download first the sequence (fasta file) and then the annotation (gff file).
*/
process DL_GENOME {
publishDir params.genome
output:
path "${params.genome_name}.fna", emit: genome_fna
path "${params.genome_name}.gtf", emit: genome_gtf
script:
"""
fna_file=${params.genome_name}.fna
gtf_file=${params.genome_name}.gtf
echo "Downloaded fasta file" ${params.fna_ftp}
wget -c -O \${fna_file}.gz ${params.fna_ftp}
gunzip -d \${fna_file}.gz
echo "Downloaded fasta file" ${params.gtf_ftp}
wget -c -O \${gtf_file}.gz ${params.gtf_ftp}
gunzip -d \${gtf_file}.gz
"""
}
process INDEX_GENOME {
publishDir params.genome
input:
path genome_fna
path genome_gtf
output:
tuple val(params.genome_name), path("${params.genome_name}.*.bt2")
script:
"""
bowtie2-build --threads $params.nbcpu ${genome_fna} ${params.genome_name}
"""
}
process DL_FASTQ {
publishDir params.rawdata
input:
tuple val(bio_cond), val(ftp_ebi)
output:
tuple path("${bio_cond[1]}_R1.fastq.gz"), path("${bio_cond[1]}_R2.fastq.gz")
script:
"""
data=${bio_cond[1]}_R1.fastq.gz
if [ ! -f \$data ]; then
wget -O \$data ${params.ebi_fq}${ftp_ebi[1]}_1.fastq.gz
fi
data=${bio_cond[1]}_R2.fastq.gz
if [ ! -f \$data ]; then
wget -O \$data ${params.ebi_fq}${ftp_ebi[1]}_2.fastq.gz
fi
"""
}
process CUTADAPT {
publishDir params.fastq
input:
val bio_cond
tuple path(data_R1), path(data_R2)
output:
tuple val(bio_cond), path("${bio_cond[1]}_R1.fastq"), path("${bio_cond[1]}_R2.fastq")
script:
"""
cutadapt -j $params.nbcpu -b $params.read1Adapt -B $params.read2Adapt -o ${bio_cond[1]}_R1.fastq \
-p ${bio_cond[1]}_R2.fastq ${data_R1} ${data_R2}
"""
}
process FASTQC {
publishDir params.fastqc
input:
tuple val(bio_cond), path(fastq_R1), path(fastq_R2)
output:
tuple path("${bio_cond[1]}_R1_fastqc*"), path("${bio_cond[1]}_R2_fastqc*")
script:
"""
fastqc -t $params.nbcpu ${fastq_R1} ${fastq_R2}
"""
}
process MAPPING {
publishDir params.mapping
input:
tuple val(index_path), path(genome_indexes)
tuple val(bio_cond), path(fastq_R1), path(fastq_R2)
output:
tuple val(bio_cond), path("${bio_cond[1]}.sam"), path("${bio_cond[1]}.log")
script:
"""
bowtie2 -p $params.nbcpu -x ${index_path} -1 ${fastq_R1} -2 ${fastq_R2} -S ${bio_cond[1]}.sam 2> ${bio_cond[1]}.log
"""
}
process SAM_TO_BAM {
publishDir params.mapping
input:
tuple val(bio_cond), path(sam_file), path(log_file)
output:
tuple path("${bio_cond[1]}.bam"), path("${bio_cond[1]}.bam.bai")
script:
"""
samtools view --threads $params.nbcpu -b -q 1 ${sam_file} > ${bio_cond[1]}_raw.bam
samtools sort --threads $params.nbcpu -o ${bio_cond[1]}.bam ${bio_cond[1]}_raw.bam
samtools index -@ $params.nbcpu ${bio_cond[1]}.bam
rm ${bio_cond[1]}_raw.bam
"""
}
process GENE_COUNT {
publishDir params.count
input:
tuple path(bam_file), path(bai_file)
path genome_gtf
output:
tuple path("${bam_file}.txt"), path("${bam_file}.txt.summary")
script:
"""
featureCounts -T $params.nbcpu -p -t "gene" -a ${genome_gtf} -o ${bam_file}.txt ${bam_file}
"""
}
process MULTIQC {
publishDir params.multiqc
input:
tuple path(fastqc_R1), path(fastqc_R2)
tuple path(gene_count), path(gene_count_summary)
script:
"""
multiqc --filename "MultiQC_${params.project}" ${projectDir}
"""
}