From 2a48e7f7f0c5d63c4372e9b906cd8909d089efc0 Mon Sep 17 00:00:00 2001 From: vagkaratzas Date: Thu, 10 Oct 2024 10:10:00 +0100 Subject: [PATCH] first draft push with TODOs --- nextflow.config | 3 ++ .../generate_downstream_samplesheets/main.nf | 46 +++++++++++++++++++ workflows/mag.nf | 45 +++++++++++++----- 3 files changed, 83 insertions(+), 11 deletions(-) create mode 100644 subworkflows/local/generate_downstream_samplesheets/main.nf diff --git a/nextflow.config b/nextflow.config index ae8f6c59..5a7600b4 100644 --- a/nextflow.config +++ b/nextflow.config @@ -194,6 +194,9 @@ params { validationShowHiddenParams = false validate_params = true + // Generate downstream samplesheets + generate_samplesheet = false + downstream_pipeline = 'taxprofiler' } // Load base.config by default for all pipelines diff --git a/subworkflows/local/generate_downstream_samplesheets/main.nf b/subworkflows/local/generate_downstream_samplesheets/main.nf new file mode 100644 index 00000000..158bda4a --- /dev/null +++ b/subworkflows/local/generate_downstream_samplesheets/main.nf @@ -0,0 +1,46 @@ +// +// Subworkflow with functionality specific to the nf-core/createtaxdb pipeline +// + +workflow GENERATE_DOWNSTREAM_SAMPLESHEETS { + take: + ch_databases + + main: + ch_header = Channel.empty() + format = 'csv' // most common format in nf-core + format_sep = ',' + + // TODO -- + // Make your samplesheet channel construct here depending on your downstream + // pipelines + if ( params.downstream_pipeline == 'taxprofiler' ) { + format = 'csv' + format_sep = ',' + ch_list_for_samplesheet = ch_databases + .map { + meta, db -> + def tool = meta.tool + def db_name = meta.id + '-' + meta.tool + def db_params = "" + def db_type = "" + def db_path = file(params.outdir).getParent() + '/' + meta.tool + '/' + db.getName() + [ tool: tool, db_name: db_name, db_params: db_params, db_type: db_type, db_path: db_path ] + } + .tap{ ch_header } + } + // -- FINISH TODO + + // Constructs the header string and then the strings of each row, and + // finally concatenates for saving. + ch_header + .first() + .map{ it.keySet().join(format_sep) } + .concat( ch_list_for_samplesheet.map{ it.values().join(format_sep) }) + .collectFile( + name:"${params.outdir}/downstream_samplesheet/${params.downstream_pipeline}.${format}", + newLine: true, + sort: false + ) + +} diff --git a/workflows/mag.nf b/workflows/mag.nf index 6c158284..fd0dc7aa 100644 --- a/workflows/mag.nf +++ b/workflows/mag.nf @@ -13,17 +13,18 @@ include { methodsDescriptionText } from '../subworkflows/local/utils_nfcore_mag_ // // SUBWORKFLOW: Consisting of a mix of local and nf-core/modules // -include { BINNING_PREPARATION } from '../subworkflows/local/binning_preparation' -include { BINNING } from '../subworkflows/local/binning' -include { BINNING_REFINEMENT } from '../subworkflows/local/binning_refinement' -include { BUSCO_QC } from '../subworkflows/local/busco_qc' -include { VIRUS_IDENTIFICATION } from '../subworkflows/local/virus_identification' -include { CHECKM_QC } from '../subworkflows/local/checkm_qc' -include { GUNC_QC } from '../subworkflows/local/gunc_qc' -include { GTDBTK } from '../subworkflows/local/gtdbtk' -include { ANCIENT_DNA_ASSEMBLY_VALIDATION } from '../subworkflows/local/ancient_dna' -include { DOMAIN_CLASSIFICATION } from '../subworkflows/local/domain_classification' -include { DEPTHS } from '../subworkflows/local/depths' +include { BINNING_PREPARATION } from '../subworkflows/local/binning_preparation' +include { BINNING } from '../subworkflows/local/binning' +include { BINNING_REFINEMENT } from '../subworkflows/local/binning_refinement' +include { BUSCO_QC } from '../subworkflows/local/busco_qc' +include { VIRUS_IDENTIFICATION } from '../subworkflows/local/virus_identification' +include { CHECKM_QC } from '../subworkflows/local/checkm_qc' +include { GUNC_QC } from '../subworkflows/local/gunc_qc' +include { GTDBTK } from '../subworkflows/local/gtdbtk' +include { ANCIENT_DNA_ASSEMBLY_VALIDATION } from '../subworkflows/local/ancient_dna' +include { DOMAIN_CLASSIFICATION } from '../subworkflows/local/domain_classification' +include { DEPTHS } from '../subworkflows/local/depths' +include { GENERATE_DOWNSTREAM_SAMPLESHEETS } from '../subworkflows/local/generate_downstream_samplesheets/main.nf' // // MODULE: Installed directly from nf-core/modules @@ -356,6 +357,8 @@ workflow MAG { } } + // TODO remove ch_short_reads_assembly.view() + /* ================================================================================ Preprocessing and QC for long reads @@ -1002,6 +1005,26 @@ workflow MAG { } } + // + // Samplesheet generation + // + ch_input_for_samplesheet = Channel + .empty() + // TODO + // .mix( + // ch_centrifuge_output.map {meta, db -> [ meta + [tool: "centrifuge"] , db ]}, + // ch_diamond_output.map {meta, db -> [ meta + [tool: "diamond"] , db ]}, + // ch_kaiju_output.map {meta, db -> [ meta + [tool: "kaiju"] , db ]}, + // ch_kraken2_bracken_output.map{meta, db -> [ meta + [tool: "kraken2_bracken"], db ]}, + // ch_krakenuniq_output.map {meta, db -> [ meta + [tool: "krakenuniq"] , db ]}, + // ch_malt_output.map {meta, db -> [ meta + [tool: "malt"] , db ]} + // ) + // .view() + + if ( params.generate_samplesheet ) { + GENERATE_DOWNSTREAM_SAMPLESHEETS ( ch_input_for_samplesheet ) + } + // // Collate and save software versions //