aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/subread-align.nix38
-rw-r--r--tools/subread-index.nix20
-rw-r--r--tools/subread.nix8
3 files changed, 66 insertions, 0 deletions
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;
+}