aboutsummaryrefslogtreecommitdiff
path: root/tools/sambamba-generic.nix
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2020-11-16 11:59:41 +1100
committerJustin Bedo <cu@cua0.org>2020-11-16 11:59:41 +1100
commit05da61d166d7d4702001510a5eaa1935102d24f0 (patch)
treec75febaeeaaa79e1bd109ec28d717d13a5b43dd5 /tools/sambamba-generic.nix
parenta50933a96096d53c341b30d487362d0913977574 (diff)
sambamba: init
Diffstat (limited to 'tools/sambamba-generic.nix')
-rw-r--r--tools/sambamba-generic.nix28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/sambamba-generic.nix b/tools/sambamba-generic.nix
new file mode 100644
index 0000000..a6be65c
--- /dev/null
+++ b/tools/sambamba-generic.nix
@@ -0,0 +1,28 @@
+{ bionix
+, flags ? null
+, tool
+, region ? null
+}:
+
+input:
+
+with bionix;
+with lib;
+
+let
+ inherit (bionix.types) matchFiletype coordSort matchFileSorting;
+in
+
+assert (matchFiletype "sambamba-${tool}" { bam = _: true; } input);
+
+stage {
+ name = "sambamba-${tool}";
+ buildInputs = [ pkgs.sambamba ];
+ buildCommand = ''
+ sambamba ${tool} -t $NIX_BUILD_CORES \
+ ${optionalString (flags != null) flags} \
+ ${if tool == "merge" then "$out ${concatStringsSep " " input}" else if tool == "slice" then "${input} ${region} > $out" else if tool == "flagstat" then "${input} > $out" else "${input} $out"}
+ '';
+ passthru.filetype = if tool == "flagstat" || tool == "index" then null else if tool == "merge" then (head input).filetype else input.filetype;
+ passthru.multicore = true;
+}