aboutsummaryrefslogtreecommitdiff
path: root/tools/sambamba-generic.nix
diff options
context:
space:
mode:
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;
+}