From 676822dc7b8394d65fdb300d89bb818e97fa1476 Mon Sep 17 00:00:00 2001 From: Zohaib Anwar Date: Tue, 8 Oct 2024 11:31:38 -0700 Subject: [PATCH 1/8] fixing nanopore branch error when empty list in array --- subworkflows/local/plasmids.nf | 2 ++ subworkflows/local/seqqc.nf | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/subworkflows/local/plasmids.nf b/subworkflows/local/plasmids.nf index 5749bc4..b00dbee 100644 --- a/subworkflows/local/plasmids.nf +++ b/subworkflows/local/plasmids.nf @@ -7,6 +7,8 @@ workflow PLASMIDS { take: genome main: + ch_plasmidfinder_fa = Channel.empty() + ch_mobsuite_fa = Channel.empty() // inititalize version channel ch_versions = Channel.empty() diff --git a/subworkflows/local/seqqc.nf b/subworkflows/local/seqqc.nf index 75c5f49..b032d5c 100644 --- a/subworkflows/local/seqqc.nf +++ b/subworkflows/local/seqqc.nf @@ -105,13 +105,29 @@ workflow SEQQC { } .set {ch_raw_reads} + ch_nanopore_reads = ch_raw_reads.nanopore + .map { meta, reads -> + def validReads = reads instanceof List ? reads.findAll { it && it.toString().trim() } : [] + return validReads ? [meta, validReads.collect { file(it) }] : null + } + .filter { it != null } + ch_nanopore_reads + .ifEmpty { + log.warn "No valid nanopore reads found. Skipping CAT_NANOPORE_FASTQ process." + } + + ch_reads_merged = ch_nanopore_reads.flatMap { meta, reads -> + CAT_NANOPORE_FASTQ(meta, reads).reads + } - CAT_NANOPORE_FASTQ(ch_raw_reads.nanopore) - ch_reads_merged = CAT_NANOPORE_FASTQ.out.reads - //ch_versions = ch_versions.mix(CAT_NANOPORE_FASTQ.out.versions) ch_reads = ch_reads.mix(ch_raw_reads.illumina).mix(ch_reads_merged) + //CAT_NANOPORE_FASTQ(ch_raw_reads.nanopore) + //ch_reads_merged = CAT_NANOPORE_FASTQ.out.reads + //ch_versions = ch_versions.mix(CAT_NANOPORE_FASTQ.out.versions) + //ch_reads = ch_reads.mix(ch_raw_reads.illumina).mix(ch_reads_merged) + // // SUBWORKFLOW: QC sub-workflow // From 1b43547d110123949e92e18e89b0a1e929094bf8 Mon Sep 17 00:00:00 2001 From: Zohaib Anwar Date: Tue, 8 Oct 2024 21:55:53 -0700 Subject: [PATCH 2/8] added additional check to make sure empty list is not passed to reads channel --- subworkflows/local/seqqc.nf | 24 ++---------------------- workflows/bacpaq.nf | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/subworkflows/local/seqqc.nf b/subworkflows/local/seqqc.nf index b032d5c..8dbc5ae 100644 --- a/subworkflows/local/seqqc.nf +++ b/subworkflows/local/seqqc.nf @@ -97,7 +97,6 @@ workflow SEQQC { // SUBWORKFLOW: Read in samplesheet, validate and stage input files // - ch_input .branch { illumina : it[0].mode == 'illumina' @@ -105,29 +104,10 @@ workflow SEQQC { } .set {ch_raw_reads} - ch_nanopore_reads = ch_raw_reads.nanopore - .map { meta, reads -> - def validReads = reads instanceof List ? reads.findAll { it && it.toString().trim() } : [] - return validReads ? [meta, validReads.collect { file(it) }] : null - } - .filter { it != null } - - ch_nanopore_reads - .ifEmpty { - log.warn "No valid nanopore reads found. Skipping CAT_NANOPORE_FASTQ process." - } - - ch_reads_merged = ch_nanopore_reads.flatMap { meta, reads -> - CAT_NANOPORE_FASTQ(meta, reads).reads - } - + CAT_NANOPORE_FASTQ(ch_raw_reads.nanopore) + ch_reads_merged = CAT_NANOPORE_FASTQ.out.reads ch_reads = ch_reads.mix(ch_raw_reads.illumina).mix(ch_reads_merged) - //CAT_NANOPORE_FASTQ(ch_raw_reads.nanopore) - //ch_reads_merged = CAT_NANOPORE_FASTQ.out.reads - //ch_versions = ch_versions.mix(CAT_NANOPORE_FASTQ.out.versions) - //ch_reads = ch_reads.mix(ch_raw_reads.illumina).mix(ch_reads_merged) - // // SUBWORKFLOW: QC sub-workflow // diff --git a/workflows/bacpaq.nf b/workflows/bacpaq.nf index dc06a46..2fefab6 100644 --- a/workflows/bacpaq.nf +++ b/workflows/bacpaq.nf @@ -12,7 +12,12 @@ ch_multiqc_custom_config = params.multiqc_config ? Channel.fromPath( params.mu ch_multiqc_logo = params.multiqc_logo ? Channel.fromPath( params.multiqc_logo, checkIfExists: true ) : Channel.empty() //ch_multiqc_custom_methods_description = params.multiqc_methods_description ? file(params.multiqc_methods_description, checkIfExists: true) : file("$projectDir/assets/methods_description_template.yml", checkIfExists: true) */ - +def convertEmptyToNull = { value -> + if (value.toString().trim().isEmpty() || (value instanceof List && value.isEmpty())) { + return null + } + return value +} /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -43,6 +48,9 @@ workflow BACPAQ { ch_multiqc_files = Channel.empty() ch_illumina = samplesheet + .map { meta, fastq_1, fastq_2, fastq_dir, genome -> + [meta, convertEmptyToNull(fastq_1), fastq_2, fastq_dir, genome] + } .filter { meta, fastq_1, fastq_2, fastq_dir, genome -> fastq_1 != null } @@ -53,14 +61,26 @@ workflow BACPAQ { return [ [ id:meta.id, single_end: false, mode:'illumina' ], [fastq_1, fastq_2 ]] } } + ch_illumina.ifEmpty { + log.warn "No Illumina samples found in the samplesheet, skipping Illumina-specifc processes." + } ch_onp = samplesheet + .map { meta, fastq_1, fastq_2, fastq_dir, genome -> + [meta, fastq_1, fastq_2, convertEmptyToNull(fastq_dir), genome] + } .filter { meta, fastq_1, fastq_2, fastq_dir, genome -> fastq_dir != null } .map { meta, fastq_1, fastq_2, fastq_dir, genome -> return [ [ id:meta.id, single_end: true, mode:'nanopore' ], [fastq_dir ]] } + ch_onp.ifEmpty { + log.warn "No Nanopore samples found in the samplesheet, skipping Nanopore-specifc processes." + } ch_genome = samplesheet + .map { meta, fastq_1, fastq_2, fastq_dir, genome -> + [meta, fastq_1, fastq_2, fastq_dir, convertEmptyToNull(genome)] + } .filter { meta, fastq_1, fastq_2, fastq_dir, genome -> genome != null } From d6364828b2ad5c42f6c831362c1d5ceb755a88e3 Mon Sep 17 00:00:00 2001 From: Zohaib Anwar Date: Wed, 9 Oct 2024 11:02:29 -0700 Subject: [PATCH 3/8] update github actons --- .../workflows/notify-slack-on-pr-merge.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/notify-slack-on-pr-merge.yml diff --git a/.github/workflows/notify-slack-on-pr-merge.yml b/.github/workflows/notify-slack-on-pr-merge.yml new file mode 100644 index 0000000..c5130f9 --- /dev/null +++ b/.github/workflows/notify-slack-on-pr-merge.yml @@ -0,0 +1,19 @@ +name: Notify Slack on Pull Request Merge to Dev + +on: + pull_request: + types: [closed] + +jobs: + notify: + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev' + runs-on: ubuntu-latest + + steps: + - name: Send notification to Slack + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + run: | + curl -X POST -H 'Content-type: application/json' --data \ + '{"text":"A pull request has been merged into the *dev* branch: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> by *${{ github.event.pull_request.user.login }}*."}' \ + $SLACK_WEBHOOK_URL From 0dbe52e30b08fb7d22b927a62482dec62427c345 Mon Sep 17 00:00:00 2001 From: Zohaib Anwar Date: Wed, 9 Oct 2024 11:10:33 -0700 Subject: [PATCH 4/8] update github actons --- .github/workflows/notify-slack-on-pr-merge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-slack-on-pr-merge.yml b/.github/workflows/notify-slack-on-pr-merge.yml index c5130f9..1241da5 100644 --- a/.github/workflows/notify-slack-on-pr-merge.yml +++ b/.github/workflows/notify-slack-on-pr-merge.yml @@ -16,4 +16,4 @@ jobs: run: | curl -X POST -H 'Content-type: application/json' --data \ '{"text":"A pull request has been merged into the *dev* branch: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> by *${{ github.event.pull_request.user.login }}*."}' \ - $SLACK_WEBHOOK_URL + $CIDGOH_SLACK_WEBHOOK From 8de2429d273d058b31efa3c107f1672e1b5bf389 Mon Sep 17 00:00:00 2001 From: Zohaib Anwar Date: Wed, 9 Oct 2024 11:12:23 -0700 Subject: [PATCH 5/8] update github actons --- .github/workflows/notify-slack-on-pr-merge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-slack-on-pr-merge.yml b/.github/workflows/notify-slack-on-pr-merge.yml index 1241da5..02772a6 100644 --- a/.github/workflows/notify-slack-on-pr-merge.yml +++ b/.github/workflows/notify-slack-on-pr-merge.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Send notification to Slack env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_URL: ${{ secrets.CIDGOH_SLACK_WEBHOOK }} run: | curl -X POST -H 'Content-type: application/json' --data \ '{"text":"A pull request has been merged into the *dev* branch: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> by *${{ github.event.pull_request.user.login }}*."}' \ From 63bb70482dfcb7274b7d4bba2d4f283d5d0ecc21 Mon Sep 17 00:00:00 2001 From: Zohaib Anwar Date: Wed, 9 Oct 2024 11:14:35 -0700 Subject: [PATCH 6/8] update github actons --- .github/workflows/notify-slack-on-pr-merge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-slack-on-pr-merge.yml b/.github/workflows/notify-slack-on-pr-merge.yml index 02772a6..a797961 100644 --- a/.github/workflows/notify-slack-on-pr-merge.yml +++ b/.github/workflows/notify-slack-on-pr-merge.yml @@ -16,4 +16,4 @@ jobs: run: | curl -X POST -H 'Content-type: application/json' --data \ '{"text":"A pull request has been merged into the *dev* branch: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> by *${{ github.event.pull_request.user.login }}*."}' \ - $CIDGOH_SLACK_WEBHOOK + $SLACK_WEBHOOK_URL From 9e5f9831c732f35c9cd4689de70e7b44fad02701 Mon Sep 17 00:00:00 2001 From: Zohaib Anwar Date: Wed, 9 Oct 2024 11:30:49 -0700 Subject: [PATCH 7/8] update github actons --- .github/workflows/notify-slack-on-release.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/notify-slack-on-release.yml diff --git a/.github/workflows/notify-slack-on-release.yml b/.github/workflows/notify-slack-on-release.yml new file mode 100644 index 0000000..5e0963c --- /dev/null +++ b/.github/workflows/notify-slack-on-release.yml @@ -0,0 +1,18 @@ +name: Notify Slack on New Release + +on: + release: + types: [published] + +jobs: + notify: + runs-on: ubuntu-latest + + steps: + - name: Send notification to Slack + env: + SLACK_WEBHOOK_URL: ${{ secrets.CIDGOH_SLACK_WEBHOOK }} + run: | + curl -X POST -H 'Content-type: application/json' --data \ + '{"text":"A new release has been published: <${{ github.event.release.html_url }}|${{ github.event.release.tag_name }}> by *${{ github.event.release.author.login }}*.\n\n*Release Notes:* \n${{ github.event.release.body }}"}' \ + $SLACK_WEBHOOK_URL From 0c0620da6a95595fc9e5e34f781de0164e1e12a3 Mon Sep 17 00:00:00 2001 From: Zohaib Anwar Date: Wed, 9 Oct 2024 11:37:21 -0700 Subject: [PATCH 8/8] removed pr actions --- .../workflows/notify-slack-on-pr-merge.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .github/workflows/notify-slack-on-pr-merge.yml diff --git a/.github/workflows/notify-slack-on-pr-merge.yml b/.github/workflows/notify-slack-on-pr-merge.yml deleted file mode 100644 index a797961..0000000 --- a/.github/workflows/notify-slack-on-pr-merge.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Notify Slack on Pull Request Merge to Dev - -on: - pull_request: - types: [closed] - -jobs: - notify: - if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev' - runs-on: ubuntu-latest - - steps: - - name: Send notification to Slack - env: - SLACK_WEBHOOK_URL: ${{ secrets.CIDGOH_SLACK_WEBHOOK }} - run: | - curl -X POST -H 'Content-type: application/json' --data \ - '{"text":"A pull request has been merged into the *dev* branch: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> by *${{ github.event.pull_request.user.login }}*."}' \ - $SLACK_WEBHOOK_URL