From 6677c98b1183a9b044c9f68fb8cc9f5324c353b4 Mon Sep 17 00:00:00 2001 From: Sruthi Suresh Date: Wed, 11 Nov 2020 18:57:51 -0600 Subject: [PATCH] Updated complement and completed slop module with all parameters available. --- software/bedtools/complement/main.nf | 3 +- software/bedtools/complement/meta.yml | 1 - software/bedtools/complement/test/main.nf | 2 +- software/bedtools/slop/functions.nf | 6 +++ software/bedtools/slop/main.nf | 17 +++++++-- software/bedtools/slop/meta.yml | 16 +++++++- software/bedtools/slop/test/main.nf | 37 ++++++++++++++----- .../output/test_asymmetrical/test.slop.bed | 3 ++ .../output/test_symmetrical/test.slop.bed | 3 ++ 9 files changed, 71 insertions(+), 17 deletions(-) create mode 100644 software/bedtools/slop/test/output/test_asymmetrical/test.slop.bed create mode 100644 software/bedtools/slop/test/output/test_symmetrical/test.slop.bed diff --git a/software/bedtools/complement/main.nf b/software/bedtools/complement/main.nf index 2d77e007..8ca54a39 100644 --- a/software/bedtools/complement/main.nf +++ b/software/bedtools/complement/main.nf @@ -27,10 +27,9 @@ process BEDTOOLS_COMPLEMENT { script: def software = getSoftwareName(task.process) - def beds_files = beds.sort() def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" """ - bedtools complement -i ${beds[0]} -g $sizes ${options.args} > ${prefix}.complement.bed + bedtools complement -i $beds -g $sizes ${options.args} > ${prefix}.complement.bed bedtools --version | sed -e "s/Bedtools v//g" > ${software}.version.txt """ } diff --git a/software/bedtools/complement/meta.yml b/software/bedtools/complement/meta.yml index a312d9a8..2565da9c 100644 --- a/software/bedtools/complement/meta.yml +++ b/software/bedtools/complement/meta.yml @@ -1,6 +1,5 @@ name: bedtools_complement description: Returns all intervals in a genome that are not covered by at least one interval in the input BED/GFF/VCF file. - keywords: - bed - complement diff --git a/software/bedtools/complement/test/main.nf b/software/bedtools/complement/test/main.nf index ee534cb9..192a7780 100644 --- a/software/bedtools/complement/test/main.nf +++ b/software/bedtools/complement/test/main.nf @@ -1,6 +1,6 @@ #!/usr/bin/env nextflow -nextflow.preview.dsl = 2 +nextflow.enable.dsl = 2 include { BEDTOOLS_COMPLEMENT } from '../main.nf' addParams( options: [publish_dir:'test_bed_file'] ) // Define input channels diff --git a/software/bedtools/slop/functions.nf b/software/bedtools/slop/functions.nf index 54dc8fe8..a3846e3f 100644 --- a/software/bedtools/slop/functions.nf +++ b/software/bedtools/slop/functions.nf @@ -22,6 +22,12 @@ def initOptions(Map args) { options.publish_dir = args.publish_dir ?: '' options.publish_files = args.publish_files options.suffix = args.suffix ?: '' + options.l = args.l ?: '' + options.r = args.r ?: '' + options.b = args.b ?: '' + options.s = args.s ?: '' + options.pct = args.pct ?: true + options.header = args.header ?: true return options } diff --git a/software/bedtools/slop/main.nf b/software/bedtools/slop/main.nf index 39be2045..a4d282be 100644 --- a/software/bedtools/slop/main.nf +++ b/software/bedtools/slop/main.nf @@ -1,6 +1,6 @@ // Import generic module functions include { initOptions; saveFiles; getSoftwareName } from './functions' - +params.options = [:] def options = initOptions(params.options) process BEDTOOLS_SLOP { @@ -27,10 +27,21 @@ process BEDTOOLS_SLOP { script: def software = getSoftwareName(task.process) - def beds_files = beds.sort() def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" + def header = params.header ? "-header":'' + def pct = params.pct ? "-pct":'' + + def symmetry = '' + if (meta.symmetry) { + """ - slopBed -i ${beds[0]} -g $sizes -l ${params.l} -r ${params.r} > ${prefix}.slop.bed + slopBed -i $beds -g $sizes -b $params.b $header $pct $options.args> ${prefix}.slop.bed bedtools --version | sed -e "s/Bedtools v//g" > ${software}.version.txt """ + } else { + """ + slopBed -i $beds -g $sizes -l $params.l -r $params.r $header $pct $options.args> ${prefix}.slop.bed + bedtools --version | sed -e "s/Bedtools v//g" > ${software}.version.txt + """ + } } diff --git a/software/bedtools/slop/meta.yml b/software/bedtools/slop/meta.yml index 5c6a70c9..58adb6dd 100644 --- a/software/bedtools/slop/meta.yml +++ b/software/bedtools/slop/meta.yml @@ -8,7 +8,7 @@ tools: description: | A set of tools for genomic analysis tasks, specifically enabling genome arithmetic (merge, count, complement) on various file types. documentation: https://bedtools.readthedocs.io/en/latest/ - + params: - l: type: integer @@ -18,6 +18,20 @@ params: type: integer description: The number of base pairs to add to the end coordinate + -b: + type: integer + description: + Increases the entry by the same number base pairs in each direction + - pct: + type: boolean + description: | + Define -l and -r as a fraction of the feature’s length. E.g. if used on a 1000bp feature, -l 0.50, will add 500 bp “upstream”. Default = false. + + - header: + type: boolean + description: | + Print the header from the input file prior to results. + - outdir: type: string description: | diff --git a/software/bedtools/slop/test/main.nf b/software/bedtools/slop/test/main.nf index ce157079..498a4cee 100644 --- a/software/bedtools/slop/test/main.nf +++ b/software/bedtools/slop/test/main.nf @@ -1,17 +1,35 @@ #!/usr/bin/env nextflow +nextflow.enable.dsl = 2 -nextflow.preview.dsl = 2 -// Test -l, -r provided. -include { BEDTOOLS_SLOP } from '../main.nf' addParams( options: [publish_dir:'test_bed_file'] ) -// Define input channels +include { BEDTOOLS_SLOP as BEDTOOLS_SLOP_S } from '../main.nf' addParams( options: [ publish_dir:'test_asymmetrical' ] ) +include { BEDTOOLS_SLOP as BEDTOOLS_SLOP_AS } from '../main.nf' addParams( options: [ publish_dir:'test_symmetrical' ] ) + +// To run with header and pct enabled, type --pct true and --header true with nextflow run command. // Run the workflow -workflow test_bed_file { +/* +Test with l/r method +*/ +workflow test_asymmetrical { def input = [] - input = [ [ id:'test', l:1, r:10 ], + input = [ [ id:'test', symmetry: false ], [ file("${baseDir}/input/A.bed", checkIfExists: true),] ] - BEDTOOLS_SLOP( + BEDTOOLS_SLOP_AS( + input, + file("${baseDir}/input/genome.sizes", checkIfExists: true) + ) + +} +/* +Test with b method +*/ +workflow test_symmetrical { + def input = [] + input = [ [ id:'test', symmetry: true], + [ file("${baseDir}/input/A.bed", checkIfExists: true),] ] + + BEDTOOLS_SLOP_S( input, file("${baseDir}/input/genome.sizes", checkIfExists: true) ) @@ -19,7 +37,8 @@ workflow test_bed_file { } workflow { - test_bed_file() + test_asymmetrical() + test_symmetrical() } - +// output has - b 10 and -l 1 -r 10 as test values. pct and header are both false. diff --git a/software/bedtools/slop/test/output/test_asymmetrical/test.slop.bed b/software/bedtools/slop/test/output/test_asymmetrical/test.slop.bed new file mode 100644 index 00000000..3ab601ef --- /dev/null +++ b/software/bedtools/slop/test/output/test_asymmetrical/test.slop.bed @@ -0,0 +1,3 @@ +chr1 851 1161 +chr1 1200 1520 +chr1 1300 1600 diff --git a/software/bedtools/slop/test/output/test_symmetrical/test.slop.bed b/software/bedtools/slop/test/output/test_symmetrical/test.slop.bed new file mode 100644 index 00000000..7e405fea --- /dev/null +++ b/software/bedtools/slop/test/output/test_symmetrical/test.slop.bed @@ -0,0 +1,3 @@ +chr1 950 1071 +chr1 1299 1430 +chr1 1399 1510