diff options
Diffstat (limited to 'tools/bwa-mem.nix')
-rw-r--r-- | tools/bwa-mem.nix | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/bwa-mem.nix b/tools/bwa-mem.nix index ca9e6a8..0d0f7d8 100644 --- a/tools/bwa-mem.nix +++ b/tools/bwa-mem.nix @@ -12,12 +12,18 @@ with nixpkgs; with lib; +with bionix.types; +with bionix.compression; -stdenv.mkDerivation { +let + fa = f: matchFiletype "bwa-ref" { fa = _: f; } f; + fq = f: matchFiletype "bwa-input" { fq = _: f; } f; + +in stdenv.mkDerivation { name = "bwa-mem"; buildInputs = [ bwa bc ] ++ optional bamOutput samtools; buildCommand = '' - ln -s ${ref.seq} ref.fa + ln -s ${fa ref} ref.fa for f in ${bionix.bwa.index indexAttrs ref}/* ; do ln -s $f done @@ -26,9 +32,10 @@ stdenv.mkDerivation { >&2 echo "not enough build cores" exit 1 fi - bwa mem ${optionalString (flags != null) flags} -t $cores ref.fa ${input1} \ - ${optionalString (input2 != null) input2} \ + bwa mem ${optionalString (flags != null) flags} -t $cores ref.fa ${fq input1} \ + ${optionalString (input2 != null) (fq input2)} \ ${optionalString bamOutput "| samtools view -b"} \ > $out ''; + passthru.filetype = if bamOutput then filetype.bam {ref = ref; sorting = option-sort.none;} else filetype.sam {ref = ref; sorting = option-sort.none;}; } |