aboutsummaryrefslogtreecommitdiff
path: root/tools/samtools-merge.nix
diff options
context:
space:
mode:
Diffstat (limited to 'tools/samtools-merge.nix')
-rw-r--r--tools/samtools-merge.nix7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/samtools-merge.nix b/tools/samtools-merge.nix
index 120f825..9b7d133 100644
--- a/tools/samtools-merge.nix
+++ b/tools/samtools-merge.nix
@@ -19,7 +19,12 @@ stage {
name = "samtools-merge";
buildInputs = with pkgs; [ samtools ];
buildCommand = ''
- samtools merge ${optionalString (flags != null) flags} $out ${concatStringsSep " " inputs}
+ samtools merge ${optionalString (flags != null) flags} 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
+ # resolve the issue.
+ samtools reheader <(samtools view -H out.bam | grep -v '@PG') out.bam > $out
'';
passthru.filetype = (builtins.elemAt inputs 0).filetype;
}