From 1f2ebb48d1555aff58035b1b0e8208749167227b Mon Sep 17 00:00:00 2001 From: Luca Cozzuto Date: Wed, 29 May 2024 18:08:37 +0200 Subject: [PATCH] adding new pipe --- mop_dna/comparison.tsv | 1 + mop_dna/config.yaml | 26 +++++++ mop_dna/mop_dna.nf | 167 ++++++++++++++++++++++++++++++++++++++++ mop_dna/nextflow.config | 2 + mop_dna/params.yaml | 13 ++++ mop_dna/tools_opt.tsv | 2 + 6 files changed, 211 insertions(+) create mode 100644 mop_dna/comparison.tsv create mode 100644 mop_dna/config.yaml create mode 100755 mop_dna/mop_dna.nf create mode 100644 mop_dna/nextflow.config create mode 100755 mop_dna/params.yaml create mode 100644 mop_dna/tools_opt.tsv diff --git a/mop_dna/comparison.tsv b/mop_dna/comparison.tsv new file mode 100644 index 0000000..951ed74 --- /dev/null +++ b/mop_dna/comparison.tsv @@ -0,0 +1 @@ +CO_22_K1 CO_22_S1 diff --git a/mop_dna/config.yaml b/mop_dna/config.yaml new file mode 100644 index 0000000..2a39fc4 --- /dev/null +++ b/mop_dna/config.yaml @@ -0,0 +1,26 @@ +title: "Master of Pores" +subtitle: "" +intro_text: False + +report_header_info: + - Application Type: 'Nanopore sequencing' + +custom_logo: 'logo_small.png' +custom_logo_url: 'https://github.com/biocorecrg/nanopore_analysis' +custom_logo_title: 'Master of Pores' + +extra_fn_clean_trim: + - '_QC' + +table_columns_visible: + FastQC: + percent_duplicates: True + +module_order: + - fastqc: + name: 'FastQC' + info: 'This section of the report shows FastQC results on raw reads.' + + - alnQC: + name: "alnQC" + info: 'This section of the report shows alnQC results on aligned reads' diff --git a/mop_dna/mop_dna.nf b/mop_dna/mop_dna.nf new file mode 100755 index 0000000..497ffad --- /dev/null +++ b/mop_dna/mop_dna.nf @@ -0,0 +1,167 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl=2 + +/* + * Define the pipeline parameters + * + */ + +// Pipeline version +version = '3.0' + +params.help = false +params.resume = false + +log.info """ + +╔╦╗┌─┐╔═╗ ╔╦╗╔╗╔╔═╗ +║║║│ │╠═╝ ║║║║║╠═╣ +╩ ╩└─┘╩ ═╩╝╝╚╝╩ ╩ + +==================================================== +BIOCORE@CRG Master of Pores 3. Detection of DNA variations - N F ~ version ${version} +==================================================== + +***************** Input files ******************* +input_path : ${params.input_path} +comparison : ${params.comparison} + +********** reference has to be the genome ************* +reference : ${params.reference} +output : ${params.output} +pars_tools : ${params.pars_tools} + +************************* Flows ******************************* +clairS : ${params.clairS} + +email : ${params.email} +""" + +// Help and avoiding typos +if (params.help) exit 1 +if (params.resume) exit 1, "Are you making the classical --resume typo? Be careful!!!! ;)" + +// check input files +reference = file(params.reference) +if( !reference.exists() ) exit 1, "Missing reference file: ${reference}!" + +// include functions, outdirs from other files +evaluate(new File("../outdirs.nf")) +def local_modules = file("$baseDir/../local_modules.nf") + +def subworkflowsDir = "${baseDir}/../BioNextflow/subworkflows" + +def flows = [:] +flows["clairS"] = params.clairS + +include { getParameters; mapIDPairs } from "${local_modules}" +include { final_message; notify_slack } from "${subworkflowsDir}/global_functions.nf" +include { checkRef } from "${local_modules}" + +// Create a channel for tool options +progPars = getParameters(params.pars_tools) + +include { RUN as RUN_CLAIRS } from "${subworkflowsDir}/snp_calling/clairS" addParams(LABEL: 'big_mem_cpus', EXTRAPARS: progPars["clairS--clairS"], OUTPUT: outputClairS) + + + +/* + * Creates the channels with comparisons + */ + +comparisons = channel.empty() + +if (params.comparison != "") { + compfile = file(params.comparison) + if( !compfile.exists() ) exit 1, "Missing comparison file: ${compfile}. Specify path with --comparisons" + + Channel + .from(compfile.readLines()) + .map { line -> + list = line.split("\t") + if (list.length <2) { + error "ERROR!!! Comparison file has to be tab separated\n" + } + if (list[0]!= "") { + def sampleID = list[0] + def ctrlID = list[1] + [ sampleID, ctrlID ] + } + }.set {comparisons} +} + + +workflow { + // Get Sample Names from comparisons + comparisons.flatten().unique().set{unique_samples} + // get BAM FILEs + unique_samples.map { + [it, file("${params.input_path}/alignment/${it}_s.bam")] + }.transpose().set{bams} + // get BAI FILEs + unique_samples.map { + [it, file("${params.input_path}/alignment/${it}_s.bam.bai")] + }.transpose().set{bais} + + // ref_file = checkRef(reference) + clairS_flow(bams, comparisons, reference) + + +} + + +workflow clairS_flow { + + take: + bam + comparisons + reference + + main: + data = mapIDPairs(comparisons, bam) + RUN_CLAIRS(data, reference) + +// emit: + +} + + + + +workflow.onComplete { + + def text = final_message("MoP3") + println text + if (params.hook != "") { + notify_slack(text, params.hook) + } +} + +/* +* Mail notification +*/ + +if (params.email == "yourmail@yourdomain" || params.email == "") { + log.info 'Skipping the email\n' +} +else { + log.info "Sending the email to ${params.email}\n" + + workflow.onComplete { + + def msg = """\ + Pipeline BIOCORE@CRG Master of Pore 3 modification module's execution summary + --------------------------- + Completed at: ${workflow.complete} + Duration : ${workflow.duration} + Success : ${workflow.success} + workDir : ${workflow.workDir} + exit status : ${workflow.exitStatus} + Error report: ${workflow.errorReport ?: '-'} + """ + .stripIndent() + + sendMail(to: params.email, subject: "Master of Pore 3 execution", body: msg) + } +} diff --git a/mop_dna/nextflow.config b/mop_dna/nextflow.config new file mode 100644 index 0000000..bcff46c --- /dev/null +++ b/mop_dna/nextflow.config @@ -0,0 +1,2 @@ +includeConfig "../nextflow.global.config" +//singularity.cacheDir = "$baseDir/../singularity" diff --git a/mop_dna/params.yaml b/mop_dna/params.yaml new file mode 100755 index 0000000..40de8b6 --- /dev/null +++ b/mop_dna/params.yaml @@ -0,0 +1,13 @@ +input_path: "${projectDir}/test_dataset/" +comparison: "${projectDir}/comparison.tsv" + +reference: "/db/gencode/human/release_38/GRCh38.primary_assembly.genome.fa.gz" +output: "${projectDir}/output_dna" +pars_tools: "${projectDir}/tools_opt.tsv" + +# flows +clairS: "YES" + +# epinano plots +hook: "" +email: "" diff --git a/mop_dna/tools_opt.tsv b/mop_dna/tools_opt.tsv new file mode 100644 index 0000000..08f111d --- /dev/null +++ b/mop_dna/tools_opt.tsv @@ -0,0 +1,2 @@ +#flows tool extrapars +clairS clairS "-p ont_r9_guppy"