#!/usr/bin/env nextflow /* main.nf * * -------------------------------------------------------------------------- * Licensed under MIT (https://git.biohpc.swmed.edu/BICF/Astrocyte/cellranger_mkfastq/blob/develop/LICENSE) * -------------------------------------------------------------------------- * */ // Define Input variables params.name = "run" params.bcl = "${baseDir}/../test_data/*.tar.gz" params.designFile = "${baseDir}/../test_data/design.csv" params.outDir = "${baseDir}/output" params.multiqcConf = "${baseDir}/conf/multiqc_config.yaml" params.references = "${baseDir}/../docs/references.md" // Define List of Files tarList = Channel .fromPath( params.bcl ) bclCount = Channel .fromPath( params.bcl ) .count() // Define regular variables name = params.name designLocation = Channel .fromPath(params.designFile) .ifEmpty { exit 1, "design file not found: ${params.designFile}" } outDir = params.outDir multiqcConf = params.multiqcConf references = params.references process checkDesignFile { tag "${name}" input: file designLocation output: file("design.checked.csv") into designPaths file("design.checked.csv") into designCount script: """ hostname ulimit -a noSpaceDesign=\$(echo "${designLocation}" | tr -d ' ') if [[ "\${noSpaceDesign}" != "${designLocation}" ]]; then mv "${designLocation}" "\${noSpaceDesign}" fi python3 ${baseDir}/scripts/check_design.py -d \${noSpaceDesign} """ } process untarBCL { tag "${tar}" input: file tar from tarList output: file("*") into bclPaths mode flatten script: """ hostname ulimit -a bash ${baseDir}/scripts/untarBCL.sh -t ${tar} """ } process mkfastq { tag "${bcl.baseName}" publishDir "${outDir}/${task.process}", mode: 'copy', pattern: "{*/outs/**/*.fastq.gz}" input: each bcl from bclPaths.collect() file design from designPaths output: file("**/outs/**/*.fastq.gz") into fastqPaths file("**/outs/**/*.fastq.gz") into cellrangerCount file("**/outs/fastq_path/Stats/Stats.json") into bqcPaths val "${bcl.baseName}" into bclName script: """ hostname ulimit -a cellranger mkfastq --id=${bcl.baseName} --run=${bcl} --csv=${design} -r \$SLURM_CPUS_ON_NODE -p \$SLURM_CPUS_ON_NODE -w \$SLURM_CPUS_ON_NODE """ } if (bclCount.value == 1) { process countDesign { tag "${name}" publishDir "${outDir}/${task.process}/${name}", mode: 'copy' input: file fastqs from cellrangerCount.collect() file design from designCount output: file("Cellranger_Count_Design.csv") into CountDesign script: """ bash ${baseDir}/scripts/countDesign.sh """ } } process fastqc { tag "${bclName}" input: file fastqPaths val bclName output: file("*fastqc.zip") into fqcPaths script: """ hostname ulimit -a find *.fastq.gz -exec mv {} ${bclName}.{} \\; bash ${baseDir}/scripts/fastqc.sh """ } /* process versions { tag "${name}" input: output: file("*.yaml") into yamlPaths script: """ hostname ulimit -a echo ${workflow.nextflow.version} > version_nextflow.txt bash ${baseDir}/scripts/versions_mkfastq.sh bash ${baseDir}/scripts/versions_fastqc.sh python3 ${baseDir}/scripts/generate_versions.py -f version_*.txt -o versions python3 ${baseDir}/scripts/generate_references.py -r ${references} -o references """ } process multiqc { tag "${name}" publishDir "${outDir}/${task.process}/${name}", mode: 'copy', pattern: "{multiqc*}" input: file bqc name "bqc/?/*" from bqcPaths.collect() file fqc name "fqc/*" from fqcPaths.collect() file yamlPaths output: file("multiqc_report.html") into mqcPaths script: """ hostname ulimit -a multiqc -c ${multiqcConf} . """ } */