From b36bc45877181079644572a8509465ec47cf57d7 Mon Sep 17 00:00:00 2001 From: Judith Ballesteros Date: Fri, 26 Jan 2024 12:03:04 +0100 Subject: [PATCH] trying to add bed from reference file --- ...ermination.nf => run_sex_determination.nf} | 30 ++++++++++---- workflows/eager.nf | 41 +++++-------------- 2 files changed, 32 insertions(+), 39 deletions(-) rename subworkflows/local/{sex_determination.nf => run_sex_determination.nf} (59%) diff --git a/subworkflows/local/sex_determination.nf b/subworkflows/local/run_sex_determination.nf similarity index 59% rename from subworkflows/local/sex_determination.nf rename to subworkflows/local/run_sex_determination.nf index b20c9cdd7..e522bf9db 100644 --- a/subworkflows/local/sex_determination.nf +++ b/subworkflows/local/run_sex_determination.nf @@ -20,21 +20,33 @@ workflow RUN_SEXDETERMINE { // Generate sex_determine input // Break here the input not in the workflow - ch_samtoolsdepth_input = sexdeterrmine_bam - .combine(sexdeterrmine_bed) - .multiMap{ - meta, bam, meta2, bed -> - bam : [ meta, bam ] - intervals : [ meta2, bed ] - } + ch_bed = sexdeterrmine_bed + .map { + // Prepend a new meta that contains the meta.id value as the new_meta.reference attribute + WorkflowEager.addNewMetaFromAttributes( it, "id" , "reference" , false ) + } + + ch_input_sexdetermine = sexdeterrmine_bam + .map { + // Prepend a new meta that contains the meta.reference value as the new_meta.reference attribute + WorkflowEager.addNewMetaFromAttributes( it, "reference" , "reference" , false ) + } + .combine( ch_bed, by: 0 ) // [ [combine_meta], [meta], bam, bai, [ref_meta], bed ] + + ch_samtoolsdepth_input = ch_input_sexdetermine + .multiMap { + ignore_me, meta, bam, bai, ref_meta, bed -> + bam: [ meta, bam ] + bed: [ ref_meta, bed ] + } SAMTOOLS_DEPTH_SEXDETERMINE(ch_samtoolsdepth_input) ch_sex_determine_input = SAMTOOLS_DEPTH_SEXDETERMINE.out.tsv ch_versions = ch_versions.mix( SAMTOOLS_DEPTH_SEXDETERMINE.out.versions ) // Run sex determination with samtools depth input - // Does it need a sample list file to run? - SEXDETERRMINE(ch_sex_determine_input, sexdeterrmine_list) + // Does it need a sample list file to run? yep + SEXDETERRMINE(ch_sex_determine_input) ch_coverages = SEXDETERRMINE.out.tsv ch_multiqc_files = ch_multiqc_files.mix( SEXDETERRMINE.out.json ) ch_versions = ch_versions.mix( SEXDETERRMINE.out.versions ) diff --git a/workflows/eager.nf b/workflows/eager.nf index 7e09d1bf8..5aa4f89dd 100644 --- a/workflows/eager.nf +++ b/workflows/eager.nf @@ -71,7 +71,7 @@ include { MANIPULATE_DAMAGE } from '../subworkflows/local/manipulate include { METAGENOMICS_COMPLEXITYFILTER } from '../subworkflows/local/metagenomics_complexityfilter' include { ESTIMATE_CONTAMINATION } from '../subworkflows/local/estimate_contamination' include { CALCULATE_DAMAGE } from '../subworkflows/local/calculate_damage' -include { RUN_SEXDETERMINE } from '../subworkflows/local/sex_determination' +include { RUN_SEXDETERMINE } from '../subworkflows/local/run_sex_determination' /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -134,25 +134,12 @@ workflow EAGER { } - // Sex determine + // SUBWORKFLOW: Run Sex determination if ( params.sexdeterrmine_bedfile ) { - ch_sexdeterrmine_bed = Channel.fromPath( params.sexdeterrmine_bedfile, checkIfExists: true ) - .collect() - .map { - file -> - meta = file.simpleName - [meta,file] - } - - } else { - ch_sexdeterrmine_bed = [] - } - - if ( params.sexdeterrmine_samplelist) { - ch_sexdeterrmine_samplelist = Channel.fromPath( params.sexdeterrmine_samplelist, checkIfExists: true ) - - } else { - ch_sexdeterrmine_samplelist = [] + ch_sexdeterrmine_bed = REFERENCE_INDEXING.out.sexdeterrmine_bed + .map{ + WorkflowEager.addNewMetaFromAttributes( it, "id" , "reference" , false ) + } } // @@ -534,21 +521,15 @@ workflow EAGER { } // - // SUBWORKFLOW: Sex Determine + // SUBWORKFLOW: Run Sex Determination // if ( params.run_sexdeterrmine ) { + ch_sexdeterrmine_input = ch_dedupped_bams - ch_sexdeterrmine_input = ch_dedupped_bams - .map { - meta, bam, bai -> - [ meta, bam ] - } - - RUN_SEXDETERMINE(ch_sexdeterrmine_input, ch_sexdeterrmine_bed, ch_sexdeterrmine_samplelist) - ch_versions = ch_versions.mix( RUN_SEXDETERMINE.out.versions ) - ch_multiqc_files = ch_multiqc_files.mix( RUN_SEXDETERMINE.out.mqc.collect{it[1]}.ifEmpty([]) ) - + RUN_SEXDETERMINE(ch_sexdeterrmine_input, REFERENCE_INDEXING.out.sexdeterrmine_bed ) + ch_versions = ch_versions.mix( ESTIMATE_CONTAMINATION.out.versions ) + ch_multiqc_files = ch_multiqc_files.mix( ESTIMATE_CONTAMINATION.out.mqc.collect{it[1]}.ifEmpty([]) ) } //