aboutsummaryrefslogtreecommitdiff
path: root/tools/xenomapper-allocate.nix
diff options
context:
space:
mode:
Diffstat (limited to 'tools/xenomapper-allocate.nix')
-rw-r--r--tools/xenomapper-allocate.nix35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/xenomapper-allocate.nix b/tools/xenomapper-allocate.nix
new file mode 100644
index 0000000..3c0fc08
--- /dev/null
+++ b/tools/xenomapper-allocate.nix
@@ -0,0 +1,35 @@
+{ bionix
+, flags ? null
+}:
+
+{primary, secondary}:
+
+with bionix;
+with lib;
+with types;
+
+let
+
+ isSortedBam = matchFiletype "xenomapper-allocate" {bam = matchSorting "xenomapper-allocate" { coord = _: false; name = _: true; none = _: false; }; };
+ outs = [ "primary_specific" "primary_multi" "secondary_specific" "secondary_multi" "unassigned" "unresolved"];
+
+in
+
+assert isSortedBam primary;
+assert isSortedBam secondary;
+
+stage {
+ name = "xenomapper-allocate";
+ buildInputs = with pkgs; [ samtools python3Packages.xenomapper ];
+ outputs = [ "out" ] ++ outs;
+ buildCommand = ''
+ xenomapper ${optionalString (flags != null) flags} \
+ --primary_bam ${primary} --secondary_bam ${secondary} \
+ ${concatMapStringsSep " " (out: "--${out} >(samtools view -bS - > ${"$" + out})") outs}
+
+ mkdir -p $out
+ for x in ${concatStringsSep " " outs} ; do
+ ln -s ''${!x} $out/$x.bam
+ done
+ '';
+}