From 3b34a430c7cb1b63625cccb9f8c7ea063dd08194 Mon Sep 17 00:00:00 2001 From: Rob Syme Date: Wed, 13 Mar 2024 15:02:28 -0400 Subject: [PATCH 1/3] Generate fasta and fastq in a single map operation --- workflows/tostadas.nf | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/workflows/tostadas.nf b/workflows/tostadas.nf index 79370423..eca2efd3 100644 --- a/workflows/tostadas.nf +++ b/workflows/tostadas.nf @@ -75,27 +75,19 @@ workflow TOSTADAS { } // Generate the fasta and fastq paths - fasta_ch = + reads_ch = METADATA_VALIDATION.out.csv_Files.flatten() - | splitCsv(header: true) - | map { row -> + .splitCsv(header: true) + .map { row -> meta = [id:row.sequence_name] fasta_path = row.fasta_path ? file(row.fasta_path) : null - [meta, fasta_path] - } - - fastq_ch = - METADATA_VALIDATION.out.csv_Files.flatten() - | splitCsv(header: true) - | map { row -> - meta = [id:row.sequence_name] fastq1 = row.fastq_path_1 ? file(row.fastq_path_1) : null fastq2 = row.fastq_path_2 ? file(row.fastq_path_2) : null - [meta, fastq1, fastq2] + [meta, fasta_path, fastq1, fastq2] } + // Create initial submission channel - submission_ch = metadata_ch.join(fasta_ch) - submission_ch = submission_ch.join(fastq_ch) + submission_ch = metadata_ch.join(reads_ch) // check if the user wants to skip annotation or not if ( params.annotation ) { if ( params.virus && !params.bacteria ) { From cacae991b7c9096db4832a148030e6b944a0a752 Mon Sep 17 00:00:00 2001 From: Rob Syme Date: Wed, 13 Mar 2024 15:18:55 -0400 Subject: [PATCH 2/3] Map closure cleanup --- workflows/tostadas.nf | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/workflows/tostadas.nf b/workflows/tostadas.nf index eca2efd3..d36c1011 100644 --- a/workflows/tostadas.nf +++ b/workflows/tostadas.nf @@ -69,8 +69,7 @@ workflow TOSTADAS { // todo: the names of these tsv_Files need to be from sample name not fasta file name metadata_ch = METADATA_VALIDATION.out.tsv_Files.flatten() .map { - def meta = [:] - meta['id'] = it.getSimpleName() + meta = [id:it.getSimpleName()] [ meta, it ] } @@ -101,7 +100,7 @@ workflow TOSTADAS { ) repeatmasker_gff_ch = REPEATMASKER_LIFTOFF.out.gff.collect().flatten() .map { - def meta = [:] + meta = [:] meta['id'] = it.getSimpleName().replaceAll('_reformatted', '') [ meta, it ] } @@ -117,12 +116,14 @@ workflow TOSTADAS { RUN_UTILITY.out, fasta_ch ) - vadr_gff_ch = RUN_VADR.out.gff.collect().flatten() - .map { - def meta = [:] - meta['id'] = it.getSimpleName().replaceAll('_reformatted', '') - [ meta, it ] - } + vadr_gff_ch = RUN_VADR.out.gff + .collect() + .flatten() + .map { + meta = [:] + meta['id'] = it.getSimpleName().replaceAll('_reformatted', '') + [ meta, it ] + } submission_ch = submission_ch.join(vadr_gff_ch) // meta.id, fasta, fastq1, fastq2, gff } } @@ -134,12 +135,12 @@ workflow TOSTADAS { fasta_ch ) // set up submission channels - bakta_gff_ch = RUN_BAKTA.out.gff3.flatten() + bakta_gff_ch = RUN_BAKTA.out.gff3 + .flatten() .map { - def meta = [:] - meta['id'] = it.getSimpleName() + meta = [id:it.getSimpleName()] [ meta, it ] - } + } // submission_ch = metadata_ch.join(fasta_ch) submission_ch = submission_ch.join(bakta_gff_ch) // meta.id, fasta, fastq1, fastq2, gff } From 1f04a58c0c260611d0f786104194b4fdc3fe005d Mon Sep 17 00:00:00 2001 From: Rob Syme Date: Wed, 13 Mar 2024 15:20:23 -0400 Subject: [PATCH 3/3] Consistent style --- workflows/tostadas.nf | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/workflows/tostadas.nf b/workflows/tostadas.nf index d36c1011..fca22aa5 100644 --- a/workflows/tostadas.nf +++ b/workflows/tostadas.nf @@ -67,15 +67,17 @@ workflow TOSTADAS { params.meta_path ) // todo: the names of these tsv_Files need to be from sample name not fasta file name - metadata_ch = METADATA_VALIDATION.out.tsv_Files.flatten() - .map { - meta = [id:it.getSimpleName()] - [ meta, it ] - } + metadata_ch = METADATA_VALIDATION.out.tsv_Files + .flatten() + .map { + meta = [id:it.getSimpleName()] + [ meta, it ] + } // Generate the fasta and fastq paths reads_ch = - METADATA_VALIDATION.out.csv_Files.flatten() + METADATA_VALIDATION.out.csv_Files + .flatten() .splitCsv(header: true) .map { row -> meta = [id:row.sequence_name]