diff --git a/src/main.nf b/src/main.nf index 7e6993101901e50d983f8d722800a7cde81c46d0..d7aa89fe59505ded44235ef1a6e21daadce0f93c 100755 --- a/src/main.nf +++ b/src/main.nf @@ -7,7 +7,7 @@ include {MODKIT_AND_MULTIQC} from './sub_workflows/MODKIT_AND_MULTIQC.nf' // Main workflow logic workflow { // Log execution parameters - if (params.step.toString() == "1") { + if (params.step == 1) { log.info """ ================================================================= STEP 1 - OXFORD NANOPORE DNA SEQUENCING BASECALLING AND ALIGNMENT @@ -25,7 +25,7 @@ workflow { Output directory : ${params.out_dir} ================================================================= """ - } else if (params.step.toString() == "2_from_step_1" || params.step.toString() == "2_from_minknow") { + } else if (params.step == "2_from_step_1" || params.step == "2_from_minknow") { log.info """ ====================================== STEP 2 - FILTERING AND QUALITY CONTROL @@ -37,7 +37,7 @@ workflow { BAM files barcoded? : ${params.is_barcoded} ====================================== """ - } else if (params.step.toString() == "3") { + } else if (params.step == 3) { log.info """ =============================================== STEP 3 - METHYLATION CALLING AND MULTIQC REPORT @@ -51,10 +51,11 @@ workflow { System.exit(1) } // Set initial files and channels + // always used samtools_threads = Channel.value(params.samtools_threads) // step conditionals - if (params.step.toString() == "1") { + if (params.step == 1) { if (params.prefix == "None") { fast5_path = Channel.fromPath("${params.basecall_path}/**.fast5").map{file -> tuple(file.parent.toString().split("/")[-3] + "_" + file.simpleName.split('_')[0] + "_" + file.simpleName.split('_')[-3..-2].join("_"), file) }.groupTuple() pod5_path = Channel.fromPath("${params.basecall_path}/**.pod5").map{file -> tuple(file.parent.toString().split("/")[-3] + "_" + file.simpleName.split('_')[0] + "_" + file.simpleName.split('_')[-3..-2].join("_"), file) }.groupTuple() @@ -72,16 +73,16 @@ workflow { gpu_devices = Channel.value(params.gpu_devices) reference_file = file(params.reference_file) pod5_threads = Channel.value(params.pod5_threads) - } else if (params.step.toString() == "2_from_step_1") { + } else if (params.step == "2_from_step_1") { bam_files = Channel.fromPath("${params.steps_2_and_3_input_directory}/basecalling_output/*.bam").map {file -> tuple(file.baseName, file) }.toSortedList( { a, b -> a[0] <=> b[0] } ).flatten().buffer(size:2) txt_files = Channel.fromPath("${params.steps_2_and_3_input_directory}/basecalling_output/*.txt").toSortedList( { a, b -> a.baseName <=> b.baseName } ).flatten() mapq = Channel.value(params.mapq) qscore_thresh = Channel.value(params.qscore_thresh) - } else if (params.step.toString() == "2_from_minknow") { + } else if (params.step == "2_from_minknow") { input_dir = Channel.fromPath("${params.steps_2_and_3_input_directory}/") mapq = Channel.value(params.mapq) qscore_thresh = Channel.value(params.qscore_thresh) - } else if (params.step.toString() == "3") { + } else if (params.step == 3) { filtered_bams = Channel.fromPath("${params.steps_2_and_3_input_directory}/bam_filtering/*-Filtered*.bam").map {file -> tuple(file.baseName, file) }.toSortedList( { a, b -> a[0] <=> b[0] } ).flatten().buffer(size:2) filtered_bais = Channel.fromPath("${params.steps_2_and_3_input_directory}/bam_filtering/*-Filtered*.bam.bai").toSortedList( { a, b -> a.baseName <=> b.baseName } ).flatten() num_reads = Channel.fromPath("${params.steps_2_and_3_input_directory}/intermediate_qc_reports/number_of_reads/*") @@ -94,13 +95,13 @@ workflow { modkit_extract_qsize = Channel.value(params.modkit_extract_qsize) } // Run steps - if (params.step.toString() == "1") { + if (params.step == 1) { BASECALLING(pod5_path, fast5_path, basecall_speed, basecall_mods, basecall_config, basecall_trim, qscore_thresh, barcoding_kit, trimmed_barcodes, gpu_devices, reference_file, pod5_threads, samtools_threads) - } else if (params.step.toString() == "2_from_step_1") { + } else if (params.step == "2_from_step_1") { FILTERING_AND_QC_FROM_STEP_1(bam_files, txt_files, mapq, qscore_thresh, samtools_threads) - } else if (params.step.toString() == "2_from_minknow") { + } else if (params.step == "2_from_minknow") { FILTERING_AND_QC_FROM_MINKNOW(input_dir, mapq, qscore_thresh, samtools_threads) - } else if (params.step.toString()== "3") { + } else if (params.step == 3) { MODKIT_AND_MULTIQC(filtered_bams, filtered_bais, num_reads, read_length, quality_thresholds, multiqc_config, multiqc_input, samtools_threads, modkit_threads, modkit_isize, modkit_extract_qsize) } } diff --git a/src/modules/convert_input_from_minknow.nf b/src/modules/convert_input_from_minknow.nf index 60a6756a7bc497989b4972dfd3093f5af1f29e28..4339e420e992d499c53a4e23f8ff91551754684c 100755 --- a/src/modules/convert_input_from_minknow.nf +++ b/src/modules/convert_input_from_minknow.nf @@ -13,7 +13,7 @@ process CONVERT_INPUT_FROM_MINKNOW_BARCODED { script: """ # Define the input directory path - input_dir="${input.toString()}" + input_dir="${input}" # Check if the input directory exists if [ -d "\${input_dir}" ]; then echo "Input directory exists." diff --git a/src/sub_workflows/FILTERING_AND_QC_FROM_MINKNOW.nf b/src/sub_workflows/FILTERING_AND_QC_FROM_MINKNOW.nf index aa1b109f5f6a5595006ed4b39159d798c1cd997d..320c9c083088ac8cb911756377ee285211de3a34 100755 --- a/src/sub_workflows/FILTERING_AND_QC_FROM_MINKNOW.nf +++ b/src/sub_workflows/FILTERING_AND_QC_FROM_MINKNOW.nf @@ -12,10 +12,10 @@ workflow FILTERING_AND_QC_FROM_MINKNOW { samtools_threads main: - if (params.is_barcoded == true) { + if (params.is_barcoded) { CONVERT_INPUT_FROM_MINKNOW_BARCODED(input, samtools_threads) converted_input = CONVERT_INPUT_FROM_MINKNOW_BARCODED.out - } else if (params.is_barcoded == false) { + } else { CONVERT_INPUT_FROM_MINKNOW_NOT_BARCODED(input, samtools_threads) converted_input = CONVERT_INPUT_FROM_MINKNOW_NOT_BARCODED.out }