diff options
Diffstat (limited to 'tools/bwa.nix')
-rw-r--r-- | tools/bwa.nix | 34 |
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 + ''; +} |