aboutsummaryrefslogtreecommitdiff
path: root/tools/bwa.nix
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2018-09-20 13:57:12 +1000
committerJustin Bedo <cu@cua0.org>2018-09-20 14:34:36 +1000
commit33a121a7bad5b2608cc41ce60ab3d65676541fa6 (patch)
treedbbce4154a85988f3bfd9b13d42ad5d37f04e18a /tools/bwa.nix
parentf0a8a4de59ea79f56e074ddd16eff0ce1782dfe8 (diff)
Wrap some tools and make an example pipeline
Diffstat (limited to 'tools/bwa.nix')
-rw-r--r--tools/bwa.nix34
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/bwa.nix b/tools/bwa.nix
new file mode 100644
index 0000000..20a308f
--- /dev/null
+++ b/tools/bwa.nix
@@ -0,0 +1,34 @@
+{ stdenv
+, callPackage
+, lib
+, bwa
+, samtools ? null
+, ref
+, bamOutput ? true
+, flags ? null
+}:
+
+{ input1
+, input2 ? null
+}:
+
+assert bamOutput -> samtools != null;
+
+with lib;
+
+let index = callPackage ./bwa-index.nix { inherit bwa stdenv lib; } ref;
+
+in stdenv.mkDerivation {
+ name = "bwa-mem";
+ buildInputs = [ bwa ] ++ optional bamOutput samtools;
+ buildCommand = ''
+ ln -s ${ref} ref.fa
+ for f in ${index}/* ; do
+ ln -s $f
+ done
+ bwa mem ${optionalString (flags != null) flags} -t $NIX_BUILD_CORES ref.fa ${input1} \
+ ${optionalString (input2 != null) input2} \
+ ${optionalString bamOutput "| samtools view -b"} \
+ > $out
+ '';
+}