aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix1
-rw-r--r--test-tnpair.nix1
-rw-r--r--tools/xenomapper-allocate.nix35
-rw-r--r--tools/xenomapper.nix7
4 files changed, 44 insertions, 0 deletions
diff --git a/default.nix b/default.nix
index 94a6d2c..49de832 100644
--- a/default.nix
+++ b/default.nix
@@ -39,6 +39,7 @@ let
octopus = callBionix ./tools/octopus.nix {};
snver = callBionix ./tools/snver.nix {};
hisat2 = callBionix ./tools/hisat2.nix {};
+ xenomapper = callBionix ./tools/xenomapper.nix {};
slurm = attrs: bionix.extend (self: super: with self; rec {
slurmDefs = { ppn = 1; mem = 1; walltime = "24:00:00"; partition = null; slurmFlags = null; salloc = "/usr/bin/salloc"; srun = "/usr/bin/srun"; } // attrs;
diff --git a/test-tnpair.nix b/test-tnpair.nix
index 701748d..bb356b2 100644
--- a/test-tnpair.nix
+++ b/test-tnpair.nix
@@ -87,6 +87,7 @@ let
"${tnpair.tumour.name}.fastp" = check-fastp tnpair.tumour.files;
snver = snver.call { ploidy=1; } tnpairResult.alignments;
mosdepth = mosdepth.plot {} { inputs = mapAttrsToList (_: mosdepth.depth {}) tnpairResult.alignments; names = [ "seq1" "seq2" ]; };
+ xenomapper = xenomapper.allocate {} { primary = nameSort tnpairResult.alignments.tumour; secondary = nameSort tnpairResult.alignments.tumour; };
inherit alignments;
};
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
+ '';
+}
diff --git a/tools/xenomapper.nix b/tools/xenomapper.nix
new file mode 100644
index 0000000..8247e25
--- /dev/null
+++ b/tools/xenomapper.nix
@@ -0,0 +1,7 @@
+{bionix}:
+
+with bionix;
+
+{
+ allocate = callBionixE ./xenomapper-allocate.nix;
+} \ No newline at end of file