aboutsummaryrefslogtreecommitdiff
path: root/tools/samtools-view.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/samtools-view.nix
parentdd3666f6a069105e61f8889665cf55eed9a14e51 (diff)
implement types
Diffstat (limited to 'tools/samtools-view.nix')
-rw-r--r--tools/samtools-view.nix27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/samtools-view.nix b/tools/samtools-view.nix
new file mode 100644
index 0000000..e1cdac1
--- /dev/null
+++ b/tools/samtools-view.nix
@@ -0,0 +1,27 @@
+{ bionix
+, nixpkgs
+, nameSort ? false
+, flags ? null
+, outfmt ? null
+}:
+
+input:
+
+with nixpkgs;
+with lib;
+with bionix.types;
+
+assert (matchFiletype "samtools-sort" { bam = _: true; sam = _: true; cram = _: true; } input);
+
+let
+ outfmtR = if outfmt != null then outfmt input else input.filetype;
+ fa = ref: matchFiletype "samtools-view-ref" { fa = _: ref; } ref;
+ outfmtFlags = matchFiletype "samtools-sort-outfmt" { bam = _: "-O BAM"; sam = _: "-O SAM"; cram = x: "-O CRAM -T ${fa x.ref}"; } {filetype = outfmtR;};
+in stdenv.mkDerivation {
+ name = "samtools-view";
+ buildInputs = [ samtools ];
+ buildCommand = ''
+ samtools view ${outfmtFlags} ${optionalString (flags != null) flags} ${input} > $out
+ '';
+ passthru.filetype = outfmtR;
+}