-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 34 additions & 23 deletions
57
subworkflows/local/generate_downstream_samplesheets/main.nf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,54 @@ | ||
// | ||
// Subworkflow with functionality specific to the nf-core/taxprofiler pipeline | ||
// Subworkflow with functionality specific to the nf-core/mag pipeline | ||
// | ||
|
||
workflow GENERATE_DOWNSTREAM_SAMPLESHEETS { | ||
workflow SAMPLESHEET_MAG { | ||
take: | ||
ch_processed_reads | ||
|
||
main: | ||
format = 'csv' // most common format in nf-core | ||
format_sep = ',' | ||
|
||
if ( params.generate_pipeline_samplesheets == 'mag' && params.save_analysis_ready_fastqs ) { | ||
def fastq_rel_path = '/' | ||
format = 'csv' | ||
format_sep = ',' | ||
ch_list_for_samplesheet = ch_processed_reads | ||
.filter { meta, sample_id, instrument_platform,fastq_1,fastq_2,fasta -> (fastq_1 && fastq_2) && !fasta } | ||
.map { | ||
meta, sample_id, instrument_platform,fastq_1,fastq_2,fasta -> | ||
def sample = meta.id | ||
def run = meta.run_accession //this should be optional | ||
def group = "" | ||
def short_reads_1 = file(params.outdir).toString() + '/' + meta.id + '/' + fastq_1.getName() | ||
def short_reads_2 = file(params.outdir).toString() + '/' + meta.id + '/' + fastq_2.getName() | ||
def long_reads = "" | ||
[sample: sample, run: run, group: group, short_reads_1: short_reads_1, short_reads_2: short_reads_2, long_reads: long_reads] | ||
|
||
ch_list_for_samplesheet = ch_processed_reads | ||
.filter { meta, sample_id, instrument_platform,fastq_1,fastq_2,fasta -> (fastq_1 && fastq_2) && !fasta }.view() | ||
.map { | ||
meta, sample_id, instrument_platform,fastq_1,fastq_2,fasta -> | ||
def sample = meta.id | ||
def run = meta.run_accession //this should be optional | ||
def group = "" | ||
def short_reads_1 = file(params.outdir).toString() + '/' + meta.id + '/' + fastq_1.getName() | ||
def short_reads_2 = file(params.outdir).toString() + '/' + meta.id + '/' + fastq_2.getName() | ||
def long_reads = "" | ||
[sample: sample, run: run, group: group, short_reads_1: short_reads_1, short_reads_2: short_reads_2, long_reads: long_reads] | ||
} | ||
.tap{ ch_header } | ||
} | ||
.tap { ch_colnames } | ||
|
||
channelToSamplesheet(ch_colnames, ch_list_for_samplesheet, 'downstream_samplesheets', format, format_sep) | ||
} | ||
|
||
workflow GENERATE_DOWNSTREAM_SAMPLESHEETS { | ||
|
||
take: | ||
ch_processed_reads | ||
|
||
main: | ||
if ( params.generate_pipeline_samplesheets == 'mag' && params.save_analysis_ready_fastqs ) { | ||
SAMPLESHEET_MAG(ch_processed_reads) | ||
} | ||
} | ||
|
||
def channelToSamplesheet(ch_header, ch_list_for_samplesheet, outdir_subdir, format, format_sep) { | ||
// Constructs the header string and then the strings of each row, and | ||
// finally concatenates for saving. Originally designed by @mahesh-panchal | ||
ch_header | ||
.first() | ||
.map{ it.keySet().join(format_sep) } | ||
.concat( ch_list_for_samplesheet.map{ it.values().join(format_sep) }) | ||
.map { it.keySet().join(format_sep) } | ||
.concat(ch_list_for_samplesheet.map { it.values().join(format_sep) }) | ||
.collectFile( | ||
name:"${params.outdir}/downstream_samplesheet/${params.generate_pipeline_samplesheets}.${format}", | ||
name: "${params.outdir}/${outdir_subdir}/${params.generate_pipeline_samplesheets}.${format}", | ||
newLine: true, | ||
sort: false | ||
) | ||
|
||
} |