aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorl-d-s <distefano.l@wehi.edu.au>2018-10-24 21:53:12 +1100
committerl-d-s <distefano.l@wehi.edu.au>2018-10-24 21:53:23 +1100
commitfdcf948c93ee5a3a3f00e38f5d4fed7bc964a56b (patch)
tree1d271aadf5a0be90ace1d8056d6b3afbd83e6025 /tools
parent3acc6ee91d3394c5e98436939936e8ab93b3c8ae (diff)
Add merge to samtools.
Diffstat (limited to 'tools')
-rw-r--r--tools/samtools-merge.nix28
-rw-r--r--tools/samtools.nix1
2 files changed, 29 insertions, 0 deletions
diff --git a/tools/samtools-merge.nix b/tools/samtools-merge.nix
new file mode 100644
index 0000000..6d072b0
--- /dev/null
+++ b/tools/samtools-merge.nix
@@ -0,0 +1,28 @@
+{ bionix
+, nixpkgs
+, flags ? null
+, outfmt ? null
+}:
+
+inputs:
+
+with nixpkgs;
+with lib;
+
+let
+ inherit (bionix.types) matchFiletype option-sort;
+ inputIsSorted = input: matchFiletype "samtools-merge" {
+ bam = _: true; #{sorting, ...}: sorting == option-sort.some (bionix.types.sorting.coord {});
+ } input;
+in
+
+assert (all inputIsSorted inputs);
+
+stdenv.mkDerivation {
+ name = "samtools-merge";
+ buildInputs = [ samtools ];
+ buildCommand = ''
+ samtools merge ${optionalString (flags != null) flags} $out ${concatStringsSep " " inputs}
+ '';
+ passthru.filetype = (builtins.elemAt inputs 0).filetype;
+}
diff --git a/tools/samtools.nix b/tools/samtools.nix
index 89a96b0..a05f53a 100644
--- a/tools/samtools.nix
+++ b/tools/samtools.nix
@@ -8,4 +8,5 @@ with bionix;
flagstat = callBionix ./samtools-flagstat.nix;
index = callBionix ./samtools-index.nix;
sort = callBionix ./samtools-sort.nix;
+ merge = callBionix ./samtools-merge.nix;
}