From f416c145204765a1566782f0ff384d3f65d6ed35 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Fri, 2 Nov 2018 15:35:22 +1100 Subject: kallisto: init --- tools/kallisto-index.nix | 22 ++++++++++++++++++++++ tools/kallisto-quant.nix | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ tools/kallisto.nix | 8 ++++++++ 3 files changed, 78 insertions(+) create mode 100644 tools/kallisto-index.nix create mode 100644 tools/kallisto-quant.nix create mode 100644 tools/kallisto.nix (limited to 'tools') 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; +} -- cgit v1.2.3