aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2018-11-02 15:35:22 +1100
committerJustin Bedo <cu@cua0.org>2018-11-02 15:40:27 +1100
commitf416c145204765a1566782f0ff384d3f65d6ed35 (patch)
tree0ce95603001956ac9941f95bd4870aa7a06cce28 /tools
parentec77e9c3a9c2dc7425ee07474f525dd0a3d01fab (diff)
kallisto: init
Diffstat (limited to 'tools')
-rw-r--r--tools/kallisto-index.nix22
-rw-r--r--tools/kallisto-quant.nix48
-rw-r--r--tools/kallisto.nix8
3 files changed, 78 insertions, 0 deletions
diff --git a/tools/kallisto-index.nix b/tools/kallisto-index.nix
new file mode 100644
index 0000000..33dfb80
--- /dev/null
+++ b/tools/kallisto-index.nix
@@ -0,0 +1,22 @@
+{bionix
+, nixpkgs
+, kmerSize ? 31
+, unique ? false}:
+
+with nixpkgs;
+with lib;
+with bionix.types;
+
+assert (kmerSize > 1);
+
+input:
+
+assert (matchFiletype input { fa = _: true; } input);
+
+stdenv.mkDerivation {
+ name = "kallisto-index";
+ buildInputs = [ kallisto ];
+ buildCommand = ''
+ kallisto index -k ${toString kmerSize} ${optionalString unique "--make-unique"} -i $out ${input}
+ '';
+}
diff --git a/tools/kallisto-quant.nix b/tools/kallisto-quant.nix
new file mode 100644
index 0000000..c410721
--- /dev/null
+++ b/tools/kallisto-quant.nix
@@ -0,0 +1,48 @@
+{bionix
+, nixpkgs
+, indexFlags ? {}
+, bias ? false
+, bootstrapSamples ? 0
+, seed ? 42
+, plaintext ? false
+, fusion ? false
+, single ? false
+, frStranded ? false
+, rfStranded ? false
+, fragmentLength ? null
+, fragmentSD ? null
+, ref}:
+
+with nixpkgs;
+with lib;
+
+assert (!single || (fragmentLength != null && fragmentSD != null));
+
+inputs:
+
+let
+ inherit (bionix.types) matchFiletype';
+ isFastQ = matchFiletype' "kallisto-quant" {fq = _: true; gz = isFastQ; };
+in
+
+assert (all (x: isFastQ (x.filetype)) inputs);
+
+stdenv.mkDerivation {
+ name = "kallisto-quant";
+ buildInputs = [ kallisto ];
+ buildCommand = ''
+ mkdir $out
+ kallisto quant \
+ -i ${bionix.kallisto.index indexFlags ref} \
+ -o $out \
+ ${optionalString bias "--bias"} \
+ ${optionalString (bootstrapSamples > 0) "-b ${toString bootstrapSamples} --seed=${toString seed}"} \
+ ${optionalString plaintext "--plaintext"} \
+ ${optionalString fusion "--fusion"} \
+ ${optionalString single "--single -l ${toString fragmentLength} -s ${toString fragmentSD}"} \
+ ${optionalString frStranded "--fr-stranded"} \
+ ${optionalString rfStranded "--rf-stranded"} \
+ -t $NIX_BUILD_CORES \
+ ${concatStringsSep " " inputs}
+ '';
+}
diff --git a/tools/kallisto.nix b/tools/kallisto.nix
new file mode 100644
index 0000000..f13f493
--- /dev/null
+++ b/tools/kallisto.nix
@@ -0,0 +1,8 @@
+{bionix, nixpkgs}:
+
+with bionix;
+
+{
+ index = callBionix ./kallisto-index.nix;
+ quant = callBionix ./kallisto-quant.nix;
+}