@@ -82,6 +82,7 @@ def colorCodes = [
82
82
83
83
workflow RNASEQ_MICROBES {
84
84
take :
85
+ ch_outdir
85
86
dp_tools_plugin
86
87
annotations_csv_url_string
87
88
accession
@@ -97,48 +98,50 @@ workflow RNASEQ_MICROBES {
97
98
reference_store_path
98
99
derived_store_path
99
100
main :
100
- publishdir = " results" // default path passed to publishDir, updated below to "GLDS-#" if processing an OSDR dataset
101
- ch_isa_versions = Channel . empty() // Initialize empty channel for ISA versions
102
-
103
- // Set up runsheet
101
+ // Parse accession, structure output directory as:
102
+ // params.outdir/
103
+ // ├── GLDS-#/results/ # Main pipeline results
104
+ // └── nextflow_info/ # Pipeline execution metadata
105
+ if ( accession ) {
106
+ GET_ACCESSIONS ( accession, api_url )
107
+ osd_accession = GET_ACCESSIONS . out. accessions_txt. map { it. readLines()[0 ]. trim() }
108
+ glds_accession = GET_ACCESSIONS . out. accessions_txt. map { it. readLines()[1 ]. trim() }
109
+ ch_outdir = ch_outdir. combine(glds_accession). map { outdir, glds -> outdir + " /" + glds }
110
+ }
111
+ else {
112
+ ch_outdir = ch_outdir. map { it + " /results" }
113
+ }
114
+ // if runsheet_path is not provided, set it up from ISA input
115
+ // If ISA input is not provided, use the accession to get the ISA
104
116
if ( runsheet_path == null ) {
105
- GET_ACCESSIONS ( accession, api_url ) // Get both OSD and GLDS accessions based on the input accession
106
- accessions_txt = GET_ACCESSIONS . out. accessions_txt // returns accessions.txt with line1 = osd_accession, line2 = glds_accession.
107
- osd_accession = accessions_txt. map { it. readLines()[0 ]. trim() }
108
- glds_accession = accessions_txt. map { it. readLines()[1 ]. trim() }
109
- publishdir = accessions_txt. map { it. readLines()[1 ]. trim() }
110
- // Fetch ISA archive if not provided
111
117
if ( isa_archive_path == null ) {
112
118
FETCH_ISA ( osd_accession, glds_accession )
113
119
isa_archive = FETCH_ISA . out. isa_archive
114
120
}
115
- // Convert ISA archive to runsheet
116
121
ISA_TO_RUNSHEET ( osd_accession, glds_accession, isa_archive, dp_tools_plugin )
117
122
runsheet_path = ISA_TO_RUNSHEET . out. runsheet
118
- ch_isa_versions = ISA_TO_RUNSHEET . out. versions // Capture version if ISA_TO_RUNSHEET runs
119
123
}
120
124
121
- // Validate input parameters
125
+ // Validate input parameters and runsheet
122
126
validateParameters()
123
127
124
128
// Print summary of supplied parameters
125
129
log. info paramsSummaryLog(workflow)
126
130
131
+ // Parse the runsheet
127
132
PARSE_RUNSHEET ( runsheet_path )
128
133
134
+ // Get samples from runsheet
129
135
samples = PARSE_RUNSHEET . out. samples
130
136
// samples | view
131
137
samples | first
132
138
| map { meta, reads -> meta }
133
139
| set { ch_meta }
134
-
135
- has_ercc = ch_meta. map { it. has_ercc }
136
140
137
141
ch_meta | map { meta -> meta. organism_sci }
138
142
| set { organism_sci }
139
143
140
144
PARSE_ANNOTATIONS_TABLE ( annotations_csv_url_string, organism_sci )
141
- gene_annotations_url = PARSE_ANNOTATIONS_TABLE . out. gene_annotations_url
142
145
143
146
// Use manually provided reference genome files if provided. Reference source and version are optional.
144
147
if ( params. reference_fasta && params. reference_gtf ) {
@@ -163,8 +166,8 @@ workflow RNASEQ_MICROBES {
163
166
}
164
167
165
168
// Add ERCC Fasta and GTF to genome files
166
- DOWNLOAD_ERCC ( has_ercc, reference_store_path ). ifEmpty([file(" ERCC92.fa" ), file(" ERCC92.gtf" )]) | set { ch_maybe_ercc_refs }
167
- CONCAT_ERCC ( reference_store_path, organism_sci, reference_source, reference_version, genome_references_pre_ercc, ch_maybe_ercc_refs, has_ercc )
169
+ DOWNLOAD_ERCC ( ch_meta . map { it . has_ercc } , reference_store_path ). ifEmpty([file(" ERCC92.fa" ), file(" ERCC92.gtf" )]) | set { ch_maybe_ercc_refs }
170
+ CONCAT_ERCC ( reference_store_path, organism_sci, reference_source, reference_version, genome_references_pre_ercc, ch_maybe_ercc_refs, ch_meta . map { it . has_ercc } )
168
171
.ifEmpty { genome_references_pre_ercc. value } | set { genome_references }
169
172
170
173
// Convert GTF file to RSeQC-compatible BED file
@@ -272,7 +275,7 @@ workflow RNASEQ_MICROBES {
272
275
DGE_DESEQ2 ( ch_meta, runsheet_path, counts )
273
276
dge_table = DGE_DESEQ2 . out. dge_table
274
277
// Add annotations to DGE table
275
- ADD_GENE_ANNOTATIONS ( ch_meta, gene_annotations_url, dge_table )
278
+ ADD_GENE_ANNOTATIONS ( ch_meta, PARSE_ANNOTATIONS_TABLE . out . gene_annotations_url, dge_table )
276
279
annotated_dge_table = ADD_GENE_ANNOTATIONS . out. annotated_dge_table
277
280
278
281
// MultiQC
@@ -294,7 +297,7 @@ workflow RNASEQ_MICROBES {
294
297
295
298
// Mix in versions from each process
296
299
ch_software_versions = ch_software_versions
297
- | mix(ch_isa_versions )
300
+ | mix(ISA_TO_RUNSHEET . out . versions )
298
301
| mix(GTF_TO_PRED . out. versions)
299
302
| mix(PRED_TO_BED . out. versions)
300
303
| mix(RAW_FASTQC . out. versions)
0 commit comments