aboutsummaryrefslogtreecommitdiff
path: root/tools/bwa-mem.nix
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2018-10-05 16:16:20 +1000
committerJustin Bedo <cu@cua0.org>2018-10-05 16:19:06 +1000
commit871ef64f3c43199dfa01216ac86db56650c2c8a2 (patch)
tree7053b4533d7306b3fc0eed8f9bc25e8e2abb6d6e /tools/bwa-mem.nix
parentdd3666f6a069105e61f8889665cf55eed9a14e51 (diff)
implement types
Diffstat (limited to 'tools/bwa-mem.nix')
-rw-r--r--tools/bwa-mem.nix15
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;};
}