diff options
author | Justin Bedo <cu@cua0.org> | 2019-05-02 07:45:02 +1000 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2019-05-02 07:45:02 +1000 |
commit | e7a2705bb3818db7647c7a37ef675760c323bd26 (patch) | |
tree | bfab0205d6414f8ee0c76c80c5bc21866e310db6 /tools | |
parent | 95c8a36a7e673fac090175729069a668daa919da (diff) |
samtools-merge: detect correct sorting
Diffstat (limited to 'tools')
-rw-r--r-- | tools/samtools-merge.nix | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/samtools-merge.nix b/tools/samtools-merge.nix index 9b7d133..81b0c15 100644 --- a/tools/samtools-merge.nix +++ b/tools/samtools-merge.nix @@ -10,7 +10,8 @@ with lib; let inherit (bionix.types) matchFiletype matchSorting; - inputIsHomogenous = length (unique (map (matchFiletype "samtools-merge" {bam = x: x // {sorting = matchSorting "samtools-merge" {coord = _: "coord";} x;};}) inputs)) == 1; + inputIsHomogenous = length (unique (map (matchFiletype "samtools-merge" {bam = x: x // {sorting = matchSorting "samtools-merge" {coord = _: "coord"; name = _: "name"; } x;};}) inputs)) == 1; + nameSorted = matchFiletype "samtools-merge" { bam = x: matchSorting "samtools-merge" {coord = _: false; name = _: true;} x;} (lib.head inputs); in assert inputIsHomogenous; @@ -19,7 +20,9 @@ stage { name = "samtools-merge"; buildInputs = with pkgs; [ samtools ]; buildCommand = '' - samtools merge ${optionalString (flags != null) flags} out.bam ${concatStringsSep " " inputs} + samtools merge ${optionalString (flags != null) flags} \ + ${if nameSorted then "-n" else ""} \ + out.bam ${concatStringsSep " " inputs} # Merge is non-deterministic with PG lines; if files have clashing PG IDs then a random # suffix is appended to make it unique. PG lines are stripped in the following to |