From 96a896c956584d98da46b483b4685a8457996a03 Mon Sep 17 00:00:00 2001 From: Ruben Vorderman <r.h.p.vorderman@lumc.nl> Date: Thu, 23 Jan 2020 11:48:33 +0100 Subject: [PATCH] add intersect bed task --- bedtools.wdl | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/bedtools.wdl b/bedtools.wdl index 50f9f92..6ae3b3c 100644 --- a/bedtools.wdl +++ b/bedtools.wdl @@ -164,3 +164,49 @@ task Sort { docker: dockerImage } } + +task Intersect { + input { + File regionsA + File regionsB + # Giving a faidx file will set the sorted option. + File? faidx + String outputBed = "intersect.bed" + String dockerImage = "quay.io/biocontainers/bedtools:2.23.0--hdbcaa40_3" + } + Boolean sorted = defined(faidx) + + command { + set -e + ~{"cut -f1,2 " + faidx} ~{true="> sorted.genome" false ="" sorted} + bedtools intersect \ + -a ~{regionsA} \ + -b ~{regionsB} \ + ~{true="--sorted" false="" sorted} \ + ~{true="-g sorted.genome" false="" sorted} \ + > ~{outputBed} + } + + output { + File intersectedBed = outputBed + } + + runtime { + docker: dockerImage + } + + parameter_meta { + faidx: {description: "The fasta index (.fai) file that is used to create the genome file required for sorted output. Implies sorted option.", + category: "common"} + regionsA: {description: "Region file a to intersect", + category: "required"} + regionsB: {description: "Region file b to intersect", + category: "required"} + outputBed: {description: "The path to write the output to", + category: "advanced"} + dockerImage: { + description: "The docker image used for this task. Changing this may result in errors which the developers may choose not to address.", + category: "advanced" + } + } +} -- GitLab