Skip to content

Commit daadac3

Browse files
authored
Merge pull request #435 from ftabaro/fix-gffread
Fix GFFREAD
2 parents 50bd6f6 + 705797c commit daadac3

File tree

2 files changed

+58
-53
lines changed

2 files changed

+58
-53
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
### Enhancements & fixes
99

10-
[[PR #434](https://github.com/nf-core/chipseq/pull/434)] - Prevent pipeline fails from erroneous param validation when igenomes is used.
10+
- [[PR #434](https://github.com/nf-core/chipseq/pull/434)] - Prevent pipeline fails from erroneous param validation when igenomes is used.
11+
- [[#432](https://github.com/nf-core/chipseq/issues/432)] - Fix `GFFREAD` call to have the two expected input channels.
1112

1213
### Parameters
1314

subworkflows/local/prepare_genome.nf

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,35 @@
33
//
44

55
include {
6-
GUNZIP as GUNZIP_FASTA
7-
GUNZIP as GUNZIP_GTF
8-
GUNZIP as GUNZIP_GFF
9-
GUNZIP as GUNZIP_GENE_BED
10-
GUNZIP as GUNZIP_BLACKLIST } from '../../modules/nf-core/gunzip/main'
6+
GUNZIP as GUNZIP_FASTA ;
7+
GUNZIP as GUNZIP_GTF ;
8+
GUNZIP as GUNZIP_GFF ;
9+
GUNZIP as GUNZIP_GENE_BED ;
10+
GUNZIP as GUNZIP_BLACKLIST
11+
} from '../../modules/nf-core/gunzip/main'
1112

1213
include {
13-
UNTAR as UNTAR_BWA_INDEX
14-
UNTAR as UNTAR_BOWTIE2_INDEX
15-
UNTAR as UNTAR_STAR_INDEX } from '../../modules/nf-core/untar/main'
16-
17-
include { UNTARFILES } from '../../modules/nf-core/untarfiles/main'
18-
include { GFFREAD } from '../../modules/nf-core/gffread/main'
19-
include { CUSTOM_GETCHROMSIZES } from '../../modules/nf-core/custom/getchromsizes/main'
20-
include { BWA_INDEX } from '../../modules/nf-core/bwa/index/main'
21-
include { BOWTIE2_BUILD } from '../../modules/nf-core/bowtie2/build/main'
22-
include { CHROMAP_INDEX } from '../../modules/nf-core/chromap/index/main'
23-
24-
include { GTF2BED } from '../../modules/local/gtf2bed'
25-
include { GENOME_BLACKLIST_REGIONS } from '../../modules/local/genome_blacklist_regions'
26-
include { STAR_GENOMEGENERATE } from '../../modules/local/star_genomegenerate'
14+
UNTAR as UNTAR_BWA_INDEX ;
15+
UNTAR as UNTAR_BOWTIE2_INDEX ;
16+
UNTAR as UNTAR_STAR_INDEX
17+
} from '../../modules/nf-core/untar/main'
18+
19+
include { UNTARFILES } from '../../modules/nf-core/untarfiles/main'
20+
include { GFFREAD } from '../../modules/nf-core/gffread/main'
21+
include { CUSTOM_GETCHROMSIZES } from '../../modules/nf-core/custom/getchromsizes/main'
22+
include { BWA_INDEX } from '../../modules/nf-core/bwa/index/main'
23+
include { BOWTIE2_BUILD } from '../../modules/nf-core/bowtie2/build/main'
24+
include { CHROMAP_INDEX } from '../../modules/nf-core/chromap/index/main'
25+
26+
include { GTF2BED } from '../../modules/local/gtf2bed'
27+
include { GENOME_BLACKLIST_REGIONS } from '../../modules/local/genome_blacklist_regions'
28+
include { STAR_GENOMEGENERATE } from '../../modules/local/star_genomegenerate'
2729

2830
workflow PREPARE_GENOME {
2931
take:
3032
genome // string: genome name
3133
genomes // map: genome attributes
32-
prepare_tool_index // string : tool to prepare index for
34+
prepare_tool_index // string: tool to prepare index for
3335
fasta // path: path to genome fasta file
3436
gtf // file: /path/to/genome.gtf
3537
gff // file: /path/to/genome.gff
@@ -49,30 +51,32 @@ workflow PREPARE_GENOME {
4951
//
5052
ch_fasta = Channel.empty()
5153
if (fasta.endsWith('.gz')) {
52-
ch_fasta = GUNZIP_FASTA ( [ [:], fasta ] ).gunzip.map{ it[1] }
54+
ch_fasta = GUNZIP_FASTA([[:], fasta]).gunzip.map { it[1] }
5355
ch_versions = ch_versions.mix(GUNZIP_FASTA.out.versions)
54-
} else {
55-
ch_fasta = Channel.value(file(fasta))
56+
}
57+
else {
58+
ch_fasta = Channel.value(file(fasta, checkIfExists: true))
5659
}
5760

5861
//
5962
// Uncompress GTF annotation file or create from GFF3 if required
6063
//
6164
if (gtf) {
6265
if (gtf.endsWith('.gz')) {
63-
ch_gtf = GUNZIP_GTF ( [ [:], gtf ] ).gunzip.map{ it[1] }
66+
ch_gtf = GUNZIP_GTF([[:], gtf]).gunzip.map { it[1] }
6467
ch_versions = ch_versions.mix(GUNZIP_GTF.out.versions)
6568
} else {
66-
ch_gtf = Channel.value(file(gtf))
69+
ch_gtf = Channel.value(file(gtf, checkIfExists: true))
6770
}
6871
} else if (gff) {
6972
if (gff.endsWith('.gz')) {
70-
ch_gff = GUNZIP_GFF ( [ [:], gff ] ).gunzip.map{ it[1] }
71-
ch_versions = ch_versions.mix(GUNZIP_GFF.out.versions)
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 ] }
7275
} else {
73-
ch_gff = Channel.value(file(gff))
76+
ch_gff = Channel.value(file(gff, checkIfExists: true))
7477
}
75-
ch_gtf = GFFREAD ( [ [:], ch_gff ] ).gtf
78+
79+
ch_gtf = GFFREAD(ch_gff, []).gtf.map { it[1] }
7680
ch_versions = ch_versions.mix(GFFREAD.out.versions)
7781
}
7882

@@ -82,7 +86,7 @@ workflow PREPARE_GENOME {
8286
ch_blacklist = Channel.empty()
8387
if (blacklist) {
8488
if (blacklist.endsWith('.gz')) {
85-
ch_blacklist = GUNZIP_BLACKLIST ( [ [:], blacklist ] ).gunzip.map{ it[1] }
89+
ch_blacklist = GUNZIP_BLACKLIST([[:], blacklist]).gunzip.map { it[1] }
8690
ch_versions = ch_versions.mix(GUNZIP_BLACKLIST.out.versions)
8791
} else {
8892
ch_blacklist = Channel.value(file(blacklist))
@@ -99,17 +103,17 @@ workflow PREPARE_GENOME {
99103
if (!gene_bed) {
100104
make_bed = true
101105
} else if (genome && gtf) {
102-
if (genomes[ genome ].gtf != gtf) {
106+
if (genomes[genome].gtf != gtf) {
103107
make_bed = true
104108
}
105109
}
106110

107111
if (make_bed) {
108-
ch_gene_bed = GTF2BED ( ch_gtf ).bed
112+
ch_gene_bed = GTF2BED(ch_gtf).bed
109113
ch_versions = ch_versions.mix(GTF2BED.out.versions)
110114
} else {
111115
if (gene_bed.endsWith('.gz')) {
112-
ch_gene_bed = GUNZIP_GENE_BED ( [ [:], gene_bed ] ).gunzip.map{ it[1] }
116+
ch_gene_bed = GUNZIP_GENE_BED([[:], gene_bed]).gunzip.map { it[1] }
113117
ch_versions = ch_versions.mix(GUNZIP_GENE_BED.out.versions)
114118
} else {
115119
ch_gene_bed = Channel.value(file(gene_bed))
@@ -119,22 +123,22 @@ workflow PREPARE_GENOME {
119123
//
120124
// Create chromosome sizes file
121125
//
122-
CUSTOM_GETCHROMSIZES ( ch_fasta.map { [ [:], it ] } )
126+
CUSTOM_GETCHROMSIZES(ch_fasta.map { [[:], it] })
123127
ch_chrom_sizes = CUSTOM_GETCHROMSIZES.out.sizes.map { it[1] }
124-
ch_fai = CUSTOM_GETCHROMSIZES.out.fai.map{ it[1] }
128+
ch_fai = CUSTOM_GETCHROMSIZES.out.fai.map { it[1] }
125129
ch_versions = ch_versions.mix(CUSTOM_GETCHROMSIZES.out.versions)
126130

127131
//
128132
// Prepare genome intervals for filtering by removing regions in blacklist file
129133
//
130134
ch_genome_filtered_bed = Channel.empty()
131135

132-
GENOME_BLACKLIST_REGIONS (
136+
GENOME_BLACKLIST_REGIONS(
133137
ch_chrom_sizes,
134138
ch_blacklist.ifEmpty([])
135139
)
136140
ch_genome_filtered_bed = GENOME_BLACKLIST_REGIONS.out.bed
137-
ch_versions = ch_versions.mix(GENOME_BLACKLIST_REGIONS.out.versions)
141+
ch_versions = ch_versions.mix(GENOME_BLACKLIST_REGIONS.out.versions)
138142

139143
//
140144
// Uncompress BWA index or generate from scratch if required
@@ -143,13 +147,13 @@ workflow PREPARE_GENOME {
143147
if (prepare_tool_index == 'bwa') {
144148
if (bwa_index) {
145149
if (bwa_index.endsWith('.tar.gz')) {
146-
ch_bwa_index = UNTAR_BWA_INDEX ( [ [:], bwa_index ] ).untar
150+
ch_bwa_index = UNTAR_BWA_INDEX([[:], bwa_index]).untar
147151
ch_versions = ch_versions.mix(UNTAR_BWA_INDEX.out.versions)
148152
} else {
149-
ch_bwa_index = [ [:], file(bwa_index) ]
153+
ch_bwa_index = [[:], file(bwa_index)]
150154
}
151155
} else {
152-
ch_bwa_index = BWA_INDEX ( ch_fasta.map { [ [:], it ] } ).index
156+
ch_bwa_index = BWA_INDEX(ch_fasta.map { [[:], it] }).index
153157
ch_versions = ch_versions.mix(BWA_INDEX.out.versions)
154158
}
155159
}
@@ -161,13 +165,13 @@ workflow PREPARE_GENOME {
161165
if (prepare_tool_index == 'bowtie2') {
162166
if (bowtie2_index) {
163167
if (bowtie2_index.endsWith('.tar.gz')) {
164-
ch_bowtie2_index = UNTAR_BOWTIE2_INDEX ( [ [:], bowtie2_index ] ).untar
165-
ch_versions = ch_versions.mix(UNTAR_BOWTIE2_INDEX.out.versions)
168+
ch_bowtie2_index = UNTAR_BOWTIE2_INDEX([[:], bowtie2_index]).untar
169+
ch_versions = ch_versions.mix(UNTAR_BOWTIE2_INDEX.out.versions)
166170
} else {
167-
ch_bowtie2_index = [ [:], file(bowtie2_index) ]
171+
ch_bowtie2_index = [[:], file(bowtie2_index)]
168172
}
169173
} else {
170-
ch_bowtie2_index = BOWTIE2_BUILD ( ch_fasta.map { [ [:], it ] } ).index
174+
ch_bowtie2_index = BOWTIE2_BUILD(ch_fasta.map { [[:], it] }).index
171175
ch_versions = ch_versions.mix(BOWTIE2_BUILD.out.versions)
172176
}
173177
}
@@ -179,14 +183,14 @@ workflow PREPARE_GENOME {
179183
if (prepare_tool_index == 'chromap') {
180184
if (chromap_index) {
181185
if (chromap_index.endsWith('.tar.gz')) {
182-
ch_chromap_index = UNTARFILES ( [ [:], chromap_index ] ).files
183-
ch_versions = ch_versions.mix(UNTARFILES.out.versions)
186+
ch_chromap_index = UNTARFILES([[:], chromap_index]).files
187+
ch_versions = ch_versions.mix(UNTARFILES.out.versions)
184188
} else {
185-
ch_chromap_index = [ [:], file(chromap_index) ]
189+
ch_chromap_index = [[:], file(chromap_index)]
186190
}
187191
} else {
188-
ch_chromap_index = CHROMAP_INDEX ( ch_fasta.map { [ [:], it ] } ).index
189-
ch_versions = ch_versions.mix(CHROMAP_INDEX.out.versions)
192+
ch_chromap_index = CHROMAP_INDEX(ch_fasta.map { [[:], it] }).index
193+
ch_versions = ch_versions.mix(CHROMAP_INDEX.out.versions)
190194
}
191195
}
192196

@@ -197,13 +201,13 @@ workflow PREPARE_GENOME {
197201
if (prepare_tool_index == 'star') {
198202
if (star_index) {
199203
if (star_index.endsWith('.tar.gz')) {
200-
ch_star_index = UNTAR_STAR_INDEX ( [ [:], star_index ] ).untar.map{ it[1] }
204+
ch_star_index = UNTAR_STAR_INDEX([[:], star_index]).untar.map { it[1] }
201205
ch_versions = ch_versions.mix(UNTAR_STAR_INDEX.out.versions)
202206
} else {
203207
ch_star_index = Channel.value(file(star_index))
204208
}
205209
} else {
206-
ch_star_index = STAR_GENOMEGENERATE ( ch_fasta, ch_gtf ).index
210+
ch_star_index = STAR_GENOMEGENERATE(ch_fasta, ch_gtf).index
207211
ch_versions = ch_versions.mix(STAR_GENOMEGENERATE.out.versions)
208212
}
209213
}
@@ -219,5 +223,5 @@ workflow PREPARE_GENOME {
219223
bowtie2_index = ch_bowtie2_index // path: bowtie2/index/
220224
chromap_index = ch_chromap_index // path: genome.index
221225
star_index = ch_star_index // path: star/index/
222-
versions = ch_versions.ifEmpty(null) // channel: [ versions.yml ]
226+
versions = ch_versions.ifEmpty(null) // channel: [ versions.yml ]
223227
}

0 commit comments

Comments
 (0)