aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix1
-rw-r--r--test-tnpair.nix1
-rw-r--r--tools/subread-align.nix38
-rw-r--r--tools/subread-index.nix20
-rw-r--r--tools/subread.nix8
5 files changed, 68 insertions, 0 deletions
diff --git a/default.nix b/default.nix
index 6f6fb3d..8d262f7 100644
--- a/default.nix
+++ b/default.nix
@@ -51,6 +51,7 @@ let
whisper = callBionix ./tools/whisper.nix { };
star = callBionix ./tools/star.nix { };
genmap = callBionix ./tools/genmap.nix { };
+ subread = callBionix ./tools/subread.nix { };
slurm-run = callPackage ./lib/slurm.nix { };
slurm-exec = f: x: y:
diff --git a/test-tnpair.nix b/test-tnpair.nix
index 0960b6f..8da1207 100644
--- a/test-tnpair.nix
+++ b/test-tnpair.nix
@@ -57,6 +57,7 @@ let
alignments = {
"bowtie-normal.bam" = bowtie.align { inherit ref; } tnpair.normal.files;
+ "subread.bam" = subread.align { inherit ref; } tnpair.normal.files;
"last.maf" = lastal.align { inherit ref; } tnpair.normal.files;
"whisper.bam" = whisper.align { inherit ref; } tnpair.normal.files;
"bwa-mem.bam" = bwa.mem { inherit ref; } tnpair.normal.files;
diff --git a/tools/subread-align.nix b/tools/subread-align.nix
new file mode 100644
index 0000000..0b0f4c1
--- /dev/null
+++ b/tools/subread-align.nix
@@ -0,0 +1,38 @@
+{ bionix
+, ref
+, flags ? null
+, indexAttrs ? { }
+, RG ? { }
+, type ? 1
+}:
+
+{ input1
+, input2 ? null
+}:
+
+with bionix;
+with lib;
+with types;
+with compression;
+
+let
+ fa = f: matchFiletype "subread-ref" { fa = _: f; } f;
+ fq = f: matchFiletype "subread-input" { fq = _: f; gz = matchFiletype' "subread-input" { fq = _: f; }; } f;
+
+in
+stage {
+ name = "subread-align";
+ buildInputs = with pkgs; [ subread ];
+ buildCommand = ''
+ subread-align -i ${bionix.subread.index indexAttrs ref}/ref ${optionalString (flags != null) flags} -T $NIX_BUILD_CORES \
+ -t ${toString type} \
+ -r ${fq input1} \
+ ${optionalString (input2 != null) "-R ${fq input2}"} \
+ ${optionalString (RG ? ID) ''
+ --rg-id ${RG.ID} ${concatMapAttrsStringsSep " " (k: v: "--rg ${k}:${v}") (filterAttrs (k: _: k != "ID") RG)} \
+ ''} \
+ -o $out
+ '';
+ passthru.filetype = filetype.bam { inherit ref; sorting = sort.none { }; };
+ passthru.multicore = true;
+}
diff --git a/tools/subread-index.nix b/tools/subread-index.nix
new file mode 100644
index 0000000..a5177a1
--- /dev/null
+++ b/tools/subread-index.nix
@@ -0,0 +1,20 @@
+{ bionix
+, flags ? null
+}:
+
+ref:
+
+with bionix;
+with lib;
+with types;
+
+assert (matchFiletype "subread-index" { fa = _: true; } ref);
+
+stage {
+ name = "subread-index";
+ buildInputs = with pkgs; [ subread ];
+ buildCommand = ''
+ mkdir $out
+ subread-buildindex ${optionalString (flags != null) flags} -o $out/ref ${ref}
+ '';
+}
diff --git a/tools/subread.nix b/tools/subread.nix
new file mode 100644
index 0000000..3ac563a
--- /dev/null
+++ b/tools/subread.nix
@@ -0,0 +1,8 @@
+{ bionix }:
+
+with bionix;
+
+{
+ align = callBionixE ./subread-align.nix;
+ index = callBionixE ./subread-index.nix;
+}