From 86b1b192501eecc8a4e566795327772c32b1633d Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Wed, 5 Dec 2018 10:48:05 +1100 Subject: bowtie: init --- tools/bowtie-align.nix | 36 ++++++++++++++++++++++++++++++++++++ tools/bowtie-index.nix | 22 ++++++++++++++++++++++ tools/bowtie.nix | 8 ++++++++ 3 files changed, 66 insertions(+) create mode 100644 tools/bowtie-align.nix create mode 100644 tools/bowtie-index.nix create mode 100644 tools/bowtie.nix (limited to 'tools') diff --git a/tools/bowtie-align.nix b/tools/bowtie-align.nix new file mode 100644 index 0000000..456747a --- /dev/null +++ b/tools/bowtie-align.nix @@ -0,0 +1,36 @@ +{ bionix +, nixpkgs +, ref +, bamOutput ? true +, flags ? null +, indexAttrs ? {} +}: + +{ input1 +, input2 ? null +}: + +with nixpkgs; +with lib; +with bionix.types; +with bionix.compression; + +let + fa = f: matchFiletype "bowtie2-ref" { fa = _: f; } f; + fq = f: matchFiletype "bowtie2-input" { fq = _: f; gz = matchFiletype' "bowtie2-input" { fq = _: f; }; } f; + +in stdenv.mkDerivation { + name = "bowtie2-align"; + buildInputs = [ bowtie2 bc ] ++ optional bamOutput samtools; + buildCommand = '' + cores=$(echo $NIX_BUILD_CORES ${optionalString bamOutput "- 1"} | bc) + if [[ $cores -lt 1 ]] ; then + cores=1 + fi + bowtie2 -x ${bionix.bowtie.index indexAttrs ref}/ref ${optionalString (flags != null) flags} --threads $cores \ + ${if input2 != null then "-1 " + fq input1 + " -2 " + fq input2 else "-U " + fq input1} \ + ${optionalString bamOutput "| samtools view -b"} \ + > $out + ''; + passthru.filetype = if bamOutput then filetype.bam {ref = ref; sorting = sort.name {};} else filetype.sam {ref = ref; sorting = sort.name {};}; +} diff --git a/tools/bowtie-index.nix b/tools/bowtie-index.nix new file mode 100644 index 0000000..98e529f --- /dev/null +++ b/tools/bowtie-index.nix @@ -0,0 +1,22 @@ +{ bionix +, nixpkgs +, flags ? null +, seed ? 42 +}: + +ref: + +with nixpkgs; +with lib; +with bionix.types; + +assert (matchFiletype "bowtie-index" { fa = _: true; } ref); + +stdenv.mkDerivation { + name = "bowtie-index"; + buildInputs = [ bowtie2 ]; + buildCommand = '' + mkdir $out + bowtie2-build --seed ${toString seed} --threads $NIX_BUILD_CORES ${optionalString (flags != null) flags} ${ref} $out/ref + ''; +} diff --git a/tools/bowtie.nix b/tools/bowtie.nix new file mode 100644 index 0000000..a9fa2e8 --- /dev/null +++ b/tools/bowtie.nix @@ -0,0 +1,8 @@ +{ bionix, nixpkgs }: + +with bionix; + +{ + align = callBionix ./bowtie-align.nix; + index = callBionix ./bowtie-index.nix; +} -- cgit v1.2.3 From d79fc6785f2b8714fa2762bd07a9a9f937bf4513 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Tue, 11 Dec 2018 14:11:21 +1100 Subject: gridss: fix softClipsToSplitReads after assembly --- tools/gridss-annotateVariants.nix | 4 ++-- tools/gridss-assemble.nix | 2 +- tools/gridss-softClipsToSplitReads.nix | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/gridss-annotateVariants.nix b/tools/gridss-annotateVariants.nix index 655b268..3560f77 100644 --- a/tools/gridss-annotateVariants.nix +++ b/tools/gridss-annotateVariants.nix @@ -5,7 +5,7 @@ , indexAttrs ? {} , assemblyAttrs ? {} , collectMetricsAttrs ? {} -, softClipsToSplitReadsAttrs ? {} +, softClipsToSplitReadsAttrs ? { flags = "REALIGN_ENTIRE_READ=true"; } , identifyVariantsAttrs ? {} , flags ? null , config ? null @@ -45,7 +45,7 @@ let ln -s ${bionix.samtools.index indexAttrs input} $WRKDIR/$BASENAME.sv.bai ''; - assembly = bionix.samtools.sort {} (softClipsToSplitReads softClipsToSplitReadsAttrs (bionix.samtools.sort { nameSort = true;} (bionix.gridss.assemble assemblyAttrs inputs))); + assembly = bionix.samtools.sort {} (softClipsToSplitReads softClipsToSplitReadsAttrs (bionix.gridss.assemble assemblyAttrs inputs)); in assert (all sorted inputs); diff --git a/tools/gridss-assemble.nix b/tools/gridss-assemble.nix index 847830a..a8124e0 100644 --- a/tools/gridss-assemble.nix +++ b/tools/gridss-assemble.nix @@ -55,5 +55,5 @@ stdenv.mkDerivation rec { WORKING_DIR=$TMPDIR/ \ TMP_DIR=$TMPDIR/ ''; - passthru.filetype = filetype.bam { ref = ref; sorting = sort.coord {}; }; + passthru.filetype = filetype.bam { ref = ref; sorting = sort.name {}; }; } diff --git a/tools/gridss-softClipsToSplitReads.nix b/tools/gridss-softClipsToSplitReads.nix index 9bce063..c23168f 100644 --- a/tools/gridss-softClipsToSplitReads.nix +++ b/tools/gridss-softClipsToSplitReads.nix @@ -35,5 +35,5 @@ stdenv.mkDerivation rec { ${optionalString (config != null) ("OPTIONS_FILE=" + bionix.gridss.gridssConfig config)} \ WORKER_THREADS=$NIX_BUILD_CORES ''; - passthru.filetype = filetype.bam { ref = ref; sorting = matchFileSorting "grids-softClipsToSplitReads" { coord = _: input.sorting; name = _: sort.none {}; none = _: input.sorting;} input;}; + passthru.filetype = filetype.bam { ref = ref; sorting = sort.none {}; }; } -- cgit v1.2.3 From 10bdecf6c1338d7f531ddf7b41da14dfe4a4ac33 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Tue, 11 Dec 2018 14:11:52 +1100 Subject: samtools-sort: fix reversed link for identity sort --- tools/samtools-sort.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/samtools-sort.nix b/tools/samtools-sort.nix index e77f3db..37df5c8 100644 --- a/tools/samtools-sort.nix +++ b/tools/samtools-sort.nix @@ -25,7 +25,7 @@ in stdenv.mkDerivation { buildInputs = [ samtools ]; buildCommand = if alreadySorted then - "ln -s $out ${input}" + "ln -s ${input} $out" else '' samtools sort -@ $NIX_BUILD_CORES \ -- cgit v1.2.3