Skip to content

Commit ce6fdc1

Browse files
committed
set up output directory, improve workflow setup
1 parent d190e67 commit ce6fdc1

File tree

5 files changed

+35
-35
lines changed

5 files changed

+35
-35
lines changed

RNAseq/Workflow_Documentation/NF_RCP/workflow_code/main.nf

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@ def colorCodes = [
99
c_yellow: "\u001b[33;1m",
1010
c_reset: "\033[0m"
1111
]
12+
1213
// Command for: 'run main.nf --version'
14+
if (params.version) {
15+
println("${workflow.manifest.name} ${workflow.manifest.version}")
16+
exit 0
17+
}
1318

1419
// Print the pipeline version on start
1520
println """
1621
${colorCodes.c_bright_green}${colorCodes.c_line}
1722
${workflow.manifest.name} ${workflow.manifest.version}
1823
${colorCodes.c_line}${colorCodes.c_reset}
1924
""".stripIndent()
20-
if (params.version) {
21-
println("${workflow.manifest.name} ${workflow.manifest.version}")
22-
exit 0
23-
}
25+
2426
// Debug warning
2527
println("${colorCodes.c_yellow}")
2628
if (params.limit_samples_to || params.truncate_to || params.force_single_end || params.genome_subsample) {
@@ -64,12 +66,13 @@ ch_reference_gtf = params.reference_gtf ? Channel.fromPath(params.reference_gtf)
6466

6567
// Set outdir based on the presence of an accession input.. currently not implemented as nextflow.config's outdir is only used for nextflow run info
6668
// and ch_outdir is used for all processes' publishDir in order to set either ./results or ./{accession}
67-
ch_outdir = params.accession ? "$projectDir/${params.accession}" : "$projectDir/results"
69+
ch_outdir = params.outdir ? channel.fromPath(params.outdir, checkIfExists: true) : null
6870

6971
// Main workflows
7072
workflow {
7173
if (params.mode == 'microbes') {
7274
RNASEQ_MICROBES(
75+
ch_outdir,
7376
ch_dp_tools_plugin,
7477
ch_reference_table,
7578
ch_accession,
@@ -87,6 +90,7 @@ workflow {
8790
)
8891
} else {
8992
RNASEQ(
93+
ch_outdir,
9094
ch_dp_tools_plugin,
9195
ch_reference_table,
9296
ch_accession,

RNAseq/Workflow_Documentation/NF_RCP/workflow_code/nextflow.config

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ params {
4949
rseqc_sample_count = 15000000
5050

5151
// Boilerplate options
52-
outdir = './results'
52+
outdir = '.'
5353
publish_dir_mode = 'link'
5454
email = null
5555
version = false
@@ -60,14 +60,6 @@ validation {
6060
enabled = true
6161
}
6262
}
63-
// Default publishing logic for pipeline
64-
// process {
65-
// publishDir = [
66-
// path: { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" },
67-
// mode: params.publish_dir_mode,
68-
// saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
69-
// ]
70-
// }
7163

7264
// Profiles:
7365
// The following profile definitions are used to set environments for the pipeline.

RNAseq/Workflow_Documentation/NF_RCP/workflow_code/nextflow_schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"format": "directory-path",
1111
"description": "The output directory where the results will be saved. You have to use absolute paths to storage on Cloud infrastructure.",
1212
"fa_icon": "fas fa-folder-open",
13-
"default": "./results",
13+
"default": ".",
1414
"hidden": true
1515
},
1616
"api_url": {

RNAseq/Workflow_Documentation/NF_RCP/workflow_code/workflows/rnaseq.nf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def colorCodes = [
7070

7171
workflow RNASEQ {
7272
take:
73+
ch_outdir
7374
dp_tools_plugin
7475
annotations_csv_url_string
7576
accession

RNAseq/Workflow_Documentation/NF_RCP/workflow_code/workflows/rnaseq_microbes.nf

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def colorCodes = [
8282

8383
workflow RNASEQ_MICROBES {
8484
take:
85+
ch_outdir
8586
dp_tools_plugin
8687
annotations_csv_url_string
8788
accession
@@ -97,48 +98,50 @@ workflow RNASEQ_MICROBES {
9798
reference_store_path
9899
derived_store_path
99100
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
104116
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
111117
if ( isa_archive_path == null ) {
112118
FETCH_ISA( osd_accession, glds_accession )
113119
isa_archive = FETCH_ISA.out.isa_archive
114120
}
115-
//Convert ISA archive to runsheet
116121
ISA_TO_RUNSHEET( osd_accession, glds_accession, isa_archive, dp_tools_plugin )
117122
runsheet_path = ISA_TO_RUNSHEET.out.runsheet
118-
ch_isa_versions = ISA_TO_RUNSHEET.out.versions // Capture version if ISA_TO_RUNSHEET runs
119123
}
120124

121-
// Validate input parameters
125+
// Validate input parameters and runsheet
122126
validateParameters()
123127

124128
// Print summary of supplied parameters
125129
log.info paramsSummaryLog(workflow)
126130

131+
// Parse the runsheet
127132
PARSE_RUNSHEET( runsheet_path )
128133

134+
// Get samples from runsheet
129135
samples = PARSE_RUNSHEET.out.samples
130136
//samples | view
131137
samples | first
132138
| map { meta, reads -> meta }
133139
| set { ch_meta }
134-
135-
has_ercc = ch_meta.map { it.has_ercc }
136140

137141
ch_meta | map { meta -> meta.organism_sci }
138142
| set { organism_sci }
139143

140144
PARSE_ANNOTATIONS_TABLE( annotations_csv_url_string, organism_sci )
141-
gene_annotations_url = PARSE_ANNOTATIONS_TABLE.out.gene_annotations_url
142145

143146
// Use manually provided reference genome files if provided. Reference source and version are optional.
144147
if ( params.reference_fasta && params.reference_gtf ) {
@@ -163,8 +166,8 @@ workflow RNASEQ_MICROBES {
163166
}
164167

165168
// 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 } )
168171
.ifEmpty { genome_references_pre_ercc.value } | set { genome_references }
169172

170173
// Convert GTF file to RSeQC-compatible BED file
@@ -272,7 +275,7 @@ workflow RNASEQ_MICROBES {
272275
DGE_DESEQ2( ch_meta, runsheet_path, counts )
273276
dge_table = DGE_DESEQ2.out.dge_table
274277
// 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 )
276279
annotated_dge_table = ADD_GENE_ANNOTATIONS.out.annotated_dge_table
277280

278281
// MultiQC
@@ -294,7 +297,7 @@ workflow RNASEQ_MICROBES {
294297

295298
// Mix in versions from each process
296299
ch_software_versions = ch_software_versions
297-
| mix(ch_isa_versions)
300+
| mix(ISA_TO_RUNSHEET.out.versions)
298301
| mix(GTF_TO_PRED.out.versions)
299302
| mix(PRED_TO_BED.out.versions)
300303
| mix(RAW_FASTQC.out.versions)

0 commit comments

Comments
 (0)