diff --git a/lib/CustomFunctions.groovy b/lib/CustomFunctions.groovy deleted file mode 100644 index 00680f09..00000000 --- a/lib/CustomFunctions.groovy +++ /dev/null @@ -1,43 +0,0 @@ -import nextflow.Nextflow - -class CustomFunctions { - - // Helper function to check if a value is neither 0, "0", nor "" - private static boolean isNonZeroNonEmpty(value) { - return (value instanceof String && value != "" && value != "0") || - (value instanceof Number && value != 0) - } - - // Function to get a list of metadata (e.g. case id) for the case [ meta ] - public static LinkedHashMap createCaseChannel(List rows) { - def case_info = [:] - def probands = [] as Set - def upd_children = [] as Set - def father = "" - def mother = "" - - rows.each { item -> - if (item?.phenotype == 2) { - probands << item.sample - } - if (isNonZeroNonEmpty(item?.paternal) && isNonZeroNonEmpty(item?.maternal)) { - upd_children << item.sample - } - if (isNonZeroNonEmpty(item?.paternal)) { - father = item.paternal - } - if (isNonZeroNonEmpty(item?.maternal)) { - mother = item.maternal - } - } - - case_info.father = father - case_info.mother = mother - case_info.probands = probands.toList() - case_info.upd_children = upd_children.toList() - case_info.id = rows[0].case_id - - return case_info - } - -} diff --git a/main.nf b/main.nf index f8066532..ddc1a354 100644 --- a/main.nf +++ b/main.nf @@ -34,6 +34,8 @@ workflow NFCORE_RAREDISEASE { take: samplesheet // channel: samplesheet read in from --input + samples + case_info main: @@ -41,7 +43,9 @@ workflow NFCORE_RAREDISEASE { // WORKFLOW: Run pipeline // RAREDISEASE ( - samplesheet + samplesheet, + samples, + case_info ) emit: multiqc_report = RAREDISEASE.out.multiqc_report // channel: /path/to/multiqc_report.html @@ -71,7 +75,9 @@ workflow { // WORKFLOW: Run main workflow // NFCORE_RAREDISEASE ( - PIPELINE_INITIALISATION.out.samplesheet + PIPELINE_INITIALISATION.out.samplesheet, + PIPELINE_INITIALISATION.out.samples, + PIPELINE_INITIALISATION.out.case_info ) // // SUBWORKFLOW: Run completion tasks diff --git a/subworkflows/local/utils_nfcore_raredisease_pipeline/main.nf b/subworkflows/local/utils_nfcore_raredisease_pipeline/main.nf index 24e7ed73..ec092c2f 100644 --- a/subworkflows/local/utils_nfcore_raredisease_pipeline/main.nf +++ b/subworkflows/local/utils_nfcore_raredisease_pipeline/main.nf @@ -102,8 +102,19 @@ workflow PIPELINE_INITIALISATION { } .set { ch_samplesheet } + ch_samples = ch_samplesheet.map { meta, fastqs -> + new_id = meta.sample + new_meta = meta - meta.subMap('lane', 'read_group') + [id:new_id] + return new_meta + }.unique() + + ch_case_info = ch_samples.toList().map { createCaseChannel(it) } + + emit: samplesheet = ch_samplesheet + samples = ch_samples + case_info = ch_case_info versions = ch_versions } @@ -160,6 +171,44 @@ workflow PIPELINE_COMPLETION { FUNCTIONS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +def boolean isNonZeroNonEmpty(value) { + return (value instanceof String && value != "" && value != "0") || + (value instanceof Number && value != 0) + } + + // Function to get a list of metadata (e.g. case id) for the case [ meta ] +def createCaseChannel(List rows) { + def case_info = [:] + def probands = [] as Set + def upd_children = [] as Set + def father = "" + def mother = "" + + rows.each { item -> + if (item?.phenotype == 2) { + probands << item.sample + } + if (isNonZeroNonEmpty(item?.paternal) && isNonZeroNonEmpty(item?.maternal)) { + upd_children << item.sample + } + if (isNonZeroNonEmpty(item?.paternal)) { + father = item.paternal + } + if (isNonZeroNonEmpty(item?.maternal)) { + mother = item.maternal + } + } + + case_info.father = father + case_info.mother = mother + case_info.probands = probands.toList() + case_info.upd_children = upd_children.toList() + case_info.id = rows[0].case_id + + return case_info +} + // // Check and validate pipeline parameters // diff --git a/workflows/raredisease.nf b/workflows/raredisease.nf index b606e17d..5a99a704 100644 --- a/workflows/raredisease.nf +++ b/workflows/raredisease.nf @@ -175,19 +175,14 @@ workflow RAREDISEASE { take: ch_samplesheet // channel: samplesheet read in from --input + ch_samples + ch_case_info + main: ch_versions = Channel.empty() ch_multiqc_files = Channel.empty() - ch_samples = ch_samplesheet.map { meta, fastqs -> - new_id = meta.sample - new_meta = meta - meta.subMap('lane', 'read_group') + [id:new_id] - return new_meta - }.unique() - - ch_case_info = ch_samples.toList().map { CustomFunctions.createCaseChannel(it) } - // // Initialize file channels for PREPARE_REFERENCES subworkflow //