@@ -31,7 +31,7 @@ workflow PREPARE_GENOME {
3131 take :
3232 genome // string: genome name
3333 genomes // map: genome attributes
34- prepare_tool_index // string : tool to prepare index for
34+ prepare_tool_index // string : tool to prepare index for
3535 fasta // path: path to genome fasta file
3636 gtf // file: /path/to/genome.gtf
3737 gff // file: /path/to/genome.gff
@@ -51,7 +51,7 @@ workflow PREPARE_GENOME {
5151 //
5252 ch_fasta = Channel . empty()
5353 if (fasta. endsWith(' .gz' )) {
54- ch_fasta = GUNZIP_FASTA ([[:], fasta]). gunzip. map { it[1 ] }
54+ ch_fasta = GUNZIP_FASTA ([[:], fasta]). gunzip. map { it[1 ] }
5555 ch_versions = ch_versions. mix(GUNZIP_FASTA . out. versions)
5656 }
5757 else {
@@ -63,30 +63,20 @@ workflow PREPARE_GENOME {
6363 //
6464 if (gtf) {
6565 if (gtf. endsWith(' .gz' )) {
66- ch_gtf = GUNZIP_GTF ([[:], gtf]). gunzip. map { it[1 ] }
66+ ch_gtf = GUNZIP_GTF ([[:], gtf]). gunzip. map { it[1 ] }
6767 ch_versions = ch_versions. mix(GUNZIP_GTF . out. versions)
68- }
69- else {
68+ } else {
7069 ch_gtf = Channel . value(file(gtf, checkIfExists : true ))
7170 }
72- }
73- else if (gff) {
71+ } else if (gff) {
7472 if (gff. endsWith(' .gz' )) {
75- ch_gff = GUNZIP_GFF ([[:], file(gff, checkIfExists : true )]). gunzip. map { it[1 ] }
76- ch_versions = ch_versions. mix(GUNZIP_GFF . out. versions)
77- }
78- else {
73+ ch_gff = GUNZIP_GFF ([[:], file(gff, checkIfExists : true )]). gunzip. map { it[1 ] }
74+ ch_versions = ch_versions. mix(GUNZIP_GFF . out. versions). map { [ [:], it ] }
75+ } else {
7976 ch_gff = Channel . value(file(gff, checkIfExists : true ))
8077 }
8178
82- //
83- // Detect gff file name stripped of extension and .gz
84- //
85- extension = (gff - ' .gz' ). tokenize(' .' )[-1 ]
86- id = file(gff). baseName. toString() - ' .gz' - " .${ extension} "
87-
88- ch_gtf = GFFREAD (ch_gff. map { [[id : id], it] }, []). gtf. map { it[1 ] }
89-
79+ ch_gtf = GFFREAD (ch_gff, []). gtf. map { it[1 ] }
9080 ch_versions = ch_versions. mix(GFFREAD . out. versions)
9181 }
9282
@@ -97,9 +87,8 @@ workflow PREPARE_GENOME {
9787 if (blacklist) {
9888 if (blacklist. endsWith(' .gz' )) {
9989 ch_blacklist = GUNZIP_BLACKLIST ([[:], blacklist]). gunzip. map { it[1 ] }
100- ch_versions = ch_versions. mix(GUNZIP_BLACKLIST . out. versions)
101- }
102- else {
90+ ch_versions = ch_versions. mix(GUNZIP_BLACKLIST . out. versions)
91+ } else {
10392 ch_blacklist = Channel . value(file(blacklist))
10493 }
10594 }
@@ -113,8 +102,7 @@ workflow PREPARE_GENOME {
113102 def make_bed = false
114103 if (! gene_bed) {
115104 make_bed = true
116- }
117- else if (genome && gtf) {
105+ } else if (genome && gtf) {
118106 if (genomes[genome]. gtf != gtf) {
119107 make_bed = true
120108 }
@@ -123,13 +111,11 @@ workflow PREPARE_GENOME {
123111 if (make_bed) {
124112 ch_gene_bed = GTF2BED (ch_gtf). bed
125113 ch_versions = ch_versions. mix(GTF2BED . out. versions)
126- }
127- else {
114+ } else {
128115 if (gene_bed. endsWith(' .gz' )) {
129116 ch_gene_bed = GUNZIP_GENE_BED ([[:], gene_bed]). gunzip. map { it[1 ] }
130117 ch_versions = ch_versions. mix(GUNZIP_GENE_BED . out. versions)
131- }
132- else {
118+ } else {
133119 ch_gene_bed = Channel . value(file(gene_bed))
134120 }
135121 }
@@ -139,8 +125,8 @@ workflow PREPARE_GENOME {
139125 //
140126 CUSTOM_GETCHROMSIZES (ch_fasta. map { [[:], it] })
141127 ch_chrom_sizes = CUSTOM_GETCHROMSIZES . out. sizes. map { it[1 ] }
142- ch_fai = CUSTOM_GETCHROMSIZES . out. fai. map { it[1 ] }
143- ch_versions = ch_versions. mix(CUSTOM_GETCHROMSIZES . out. versions)
128+ ch_fai = CUSTOM_GETCHROMSIZES . out. fai. map { it[1 ] }
129+ ch_versions = ch_versions. mix(CUSTOM_GETCHROMSIZES . out. versions)
144130
145131 //
146132 // Prepare genome intervals for filtering by removing regions in blacklist file
@@ -152,7 +138,7 @@ workflow PREPARE_GENOME {
152138 ch_blacklist. ifEmpty([])
153139 )
154140 ch_genome_filtered_bed = GENOME_BLACKLIST_REGIONS . out. bed
155- ch_versions = ch_versions. mix(GENOME_BLACKLIST_REGIONS . out. versions)
141+ ch_versions = ch_versions. mix(GENOME_BLACKLIST_REGIONS . out. versions)
156142
157143 //
158144 // Uncompress BWA index or generate from scratch if required
@@ -162,15 +148,13 @@ workflow PREPARE_GENOME {
162148 if (bwa_index) {
163149 if (bwa_index. endsWith(' .tar.gz' )) {
164150 ch_bwa_index = UNTAR_BWA_INDEX ([[:], bwa_index]). untar
165- ch_versions = ch_versions. mix(UNTAR_BWA_INDEX . out. versions)
166- }
167- else {
151+ ch_versions = ch_versions. mix(UNTAR_BWA_INDEX . out. versions)
152+ } else {
168153 ch_bwa_index = [[:], file(bwa_index)]
169154 }
170- }
171- else {
155+ } else {
172156 ch_bwa_index = BWA_INDEX (ch_fasta. map { [[:], it] }). index
173- ch_versions = ch_versions. mix(BWA_INDEX . out. versions)
157+ ch_versions = ch_versions. mix(BWA_INDEX . out. versions)
174158 }
175159 }
176160
@@ -182,15 +166,13 @@ workflow PREPARE_GENOME {
182166 if (bowtie2_index) {
183167 if (bowtie2_index. endsWith(' .tar.gz' )) {
184168 ch_bowtie2_index = UNTAR_BOWTIE2_INDEX ([[:], bowtie2_index]). untar
185- ch_versions = ch_versions. mix(UNTAR_BOWTIE2_INDEX . out. versions)
186- }
187- else {
169+ ch_versions = ch_versions. mix(UNTAR_BOWTIE2_INDEX . out. versions)
170+ } else {
188171 ch_bowtie2_index = [[:], file(bowtie2_index)]
189172 }
190- }
191- else {
173+ } else {
192174 ch_bowtie2_index = BOWTIE2_BUILD (ch_fasta. map { [[:], it] }). index
193- ch_versions = ch_versions. mix(BOWTIE2_BUILD . out. versions)
175+ ch_versions = ch_versions. mix(BOWTIE2_BUILD . out. versions)
194176 }
195177 }
196178
@@ -202,15 +184,13 @@ workflow PREPARE_GENOME {
202184 if (chromap_index) {
203185 if (chromap_index. endsWith(' .tar.gz' )) {
204186 ch_chromap_index = UNTARFILES ([[:], chromap_index]). files
205- ch_versions = ch_versions. mix(UNTARFILES . out. versions)
206- }
207- else {
187+ ch_versions = ch_versions. mix(UNTARFILES . out. versions)
188+ } else {
208189 ch_chromap_index = [[:], file(chromap_index)]
209190 }
210- }
211- else {
191+ } else {
212192 ch_chromap_index = CHROMAP_INDEX (ch_fasta. map { [[:], it] }). index
213- ch_versions = ch_versions. mix(CHROMAP_INDEX . out. versions)
193+ ch_versions = ch_versions. mix(CHROMAP_INDEX . out. versions)
214194 }
215195 }
216196
@@ -222,28 +202,26 @@ workflow PREPARE_GENOME {
222202 if (star_index) {
223203 if (star_index. endsWith(' .tar.gz' )) {
224204 ch_star_index = UNTAR_STAR_INDEX ([[:], star_index]). untar. map { it[1 ] }
225- ch_versions = ch_versions. mix(UNTAR_STAR_INDEX . out. versions)
226- }
227- else {
205+ ch_versions = ch_versions. mix(UNTAR_STAR_INDEX . out. versions)
206+ } else {
228207 ch_star_index = Channel . value(file(star_index))
229208 }
230- }
231- else {
209+ } else {
232210 ch_star_index = STAR_GENOMEGENERATE (ch_fasta, ch_gtf). index
233- ch_versions = ch_versions. mix(STAR_GENOMEGENERATE . out. versions)
211+ ch_versions = ch_versions. mix(STAR_GENOMEGENERATE . out. versions)
234212 }
235213 }
236214
237215 emit :
238- fasta = ch_fasta // path: genome.fasta
239- fai = ch_fai // path: genome.fai
240- gtf = ch_gtf // path: genome.gtf
241- gene_bed = ch_gene_bed // path: gene.bed
242- chrom_sizes = ch_chrom_sizes // path: genome.sizes
243- filtered_bed = ch_genome_filtered_bed // path: *.include_regions.bed
244- bwa_index = ch_bwa_index // path: bwa/index/
245- bowtie2_index = ch_bowtie2_index // path: bowtie2/index/
246- chromap_index = ch_chromap_index // path: genome.index
247- star_index = ch_star_index // path: star/index/
216+ fasta = ch_fasta // path: genome.fasta
217+ fai = ch_fai // path: genome.fai
218+ gtf = ch_gtf // path: genome.gtf
219+ gene_bed = ch_gene_bed // path: gene.bed
220+ chrom_sizes = ch_chrom_sizes // path: genome.sizes
221+ filtered_bed = ch_genome_filtered_bed // path: *.include_regions.bed
222+ bwa_index = ch_bwa_index // path: bwa/index/
223+ bowtie2_index = ch_bowtie2_index // path: bowtie2/index/
224+ chromap_index = ch_chromap_index // path: genome.index
225+ star_index = ch_star_index // path: star/index/
248226 versions = ch_versions. ifEmpty(null ) // channel: [ versions.yml ]
249227}
0 commit comments