aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix1
-rwxr-xr-xlib/references.nix22
-rw-r--r--lib/types.nix3
-rw-r--r--tools/kallisto-index.nix22
-rw-r--r--tools/kallisto-quant.nix48
-rw-r--r--tools/kallisto.nix8
6 files changed, 103 insertions, 1 deletions
diff --git a/default.nix b/default.nix
index 5218a99..f835fa0 100644
--- a/default.nix
+++ b/default.nix
@@ -15,6 +15,7 @@ let
fastqc = callBionix ./tools/fastqc.nix {};
gridss = callBionix ./tools/gridss.nix {};
infercnv = callBionix ./tools/infercnv.nix {};
+ kallisto = callBionix ./tools/kallisto.nix {};
mosdepth = callBionix ./tools/mosdepth.nix {};
mutect = callBionix ./tools/mutect.nix {};
platypus = callBionix ./tools/platypus.nix {};
diff --git a/lib/references.nix b/lib/references.nix
index 498cfd9..bdeefa6 100755
--- a/lib/references.nix
+++ b/lib/references.nix
@@ -46,6 +46,28 @@ rec {
'';
passthru.filetype = filetype.vcf { ref = seq; };
};
+ ensembl = {
+ cdna = stdenvNoCC.mkDerivation rec {
+ name = "ensembl-grch38-cdna-${version}";
+ version = "94";
+ src = fetchurl {
+ url = "ftp://ftp.ensembl.org/pub/release-${version}/fasta/homo_sapiens/cdna/Homo_sapiens.GRCh38.cdna.all.fa.gz";
+ sha256 = "1fc5d6p2wlwsm49wnmxmm3byjx5jvr6z9fpzrq7v7fpb086adl0h";
+ };
+ buildCommand = "gunzip < $src > $out";
+ passthru.filetype = filetype.fa {};
+ };
+ ncrna = stdenvNoCC.mkDerivation rec {
+ name = "ensembl-grch38-ncrna-${version}";
+ version = "94";
+ src = fetchurl {
+ url = "ftp://ftp.ensembl.org/pub/release-${version}/fasta/homo_sapiens/ncrna/Homo_sapiens.GRCh38.ncrna.fa.gz";
+ sha256 = "1cpasykwriila52nqgvw6d3mjyh6d9qi613hvhn4h1dxkqzgnjff";
+ };
+ buildCommand = "gunzip < $src > $out";
+ passthru.filetype = filetype.fa {};
+ };
+ };
};
grcm38 = grcm38-p6;
diff --git a/lib/types.nix b/lib/types.nix
index 4dbc6ff..ef9b1b7 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -21,7 +21,8 @@ let
in
rec {
- matchFiletype = sym: y: x: if x ? filetype then match x.filetype (defError (idft sym) y filetype) else abort "unknown filetype for ${sym}";
+ matchFiletype = sym: y: x: if x ? filetype then matchFiletype' sym y x.filetype else abort "unknown filetype for ${sym}";
+ matchFiletype' = sym: y: x: match x (defError (idft sym) y filetype);
filetype = make-type "filetype" {
fa = {};
fq = {};
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;
+}