aboutsummaryrefslogtreecommitdiff
path: root/tools/last-align.nix
diff options
context:
space:
mode:
Diffstat (limited to 'tools/last-align.nix')
-rw-r--r--tools/last-align.nix39
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/last-align.nix b/tools/last-align.nix
new file mode 100644
index 0000000..b2c8460
--- /dev/null
+++ b/tools/last-align.nix
@@ -0,0 +1,39 @@
+{ bionix
+, ref
+, flags ? null
+, indexAttrs ? {}
+}:
+
+{ input1
+, input2 ? null
+}:
+
+with bionix;
+with lib;
+with types;
+
+let
+ fa = f: matchFiletype "last-ref" { fa = _: f; } f;
+ fq = f: matchFiletype "last-input" { fq = _: f; } f;
+ fqfa = f: matchFiletype "last-input" { fq = _: f; fa = _: f; } f;
+ Q = f: matchFiletype "last-input" { fq = _: 1; fa = _: 0; } f;
+ parallel = f: matchFiletype "last-input" { fq = _: "parallel-fastq"; fa = _: "parallel-fasta"; } f;
+
+in stage {
+ name = "last-align";
+ buildInputs = with pkgs; [ last ];
+ buildCommand = ''
+ ${if (input2 != null) then "fastq-interleave ${fq input1} ${fq input2}" else "cat ${fa input1}"} | \
+ ${parallel input1} -j $NIX_BUILD_CORES \
+ lastal -Q${toString (Q input1)} \
+ ${optionalString (input2 != null) "-i1"} \
+ ${optionalString (flags != null) flags} \
+ ${bionix.lastal.index indexAttrs ref}/index \
+ > tmp
+ '' + (if input2 == null then ''
+ cp tmp $out
+ '' else ''
+ last-pair-probs tmp > $out
+ '');
+ passthru.multicore = true;
+}