From 0418c23f5d3bff108744d96d1075b0e76b580fdd Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Tue, 18 Dec 2018 14:05:19 +1100 Subject: qsub: refactor overriding --- default.nix | 14 +++++++++----- lib/qsub.nix | 2 +- tools/bowtie.nix | 4 ++-- tools/bwa.nix | 4 ++-- tools/fastqc.nix | 2 +- tools/gridss.nix | 18 +++++++++--------- tools/infercnv.nix | 2 +- tools/kallisto.nix | 4 ++-- tools/mosdepth.nix | 4 ++-- tools/mutect.nix | 2 +- tools/platypus.nix | 2 +- tools/samtools.nix | 18 +++++++++--------- tools/strelka.nix | 2 +- 13 files changed, 41 insertions(+), 37 deletions(-) diff --git a/default.nix b/default.nix index d607aa2..6e07a74 100644 --- a/default.nix +++ b/default.nix @@ -1,13 +1,15 @@ {nixpkgs ? import {}}: let - inherit (nixpkgs) fetchurl; + inherit (nixpkgs) fetchurl callPackage; bionix = nixpkgs.lib.makeExtensible (self: let callBionix = file: attrs: import file ({ bionix = self; nixpkgs = nixpkgs; } // attrs); in with self; { callBionix = callBionix; id = x: x; + exec = f: x: y: f x y; + callBionixE = p: exec (callBionix p); types = callBionix ./lib/types.nix {}; @@ -25,12 +27,14 @@ let samtools = callBionix ./tools/samtools.nix {}; strelka = callBionix ./tools/strelka.nix {}; - qsub = nixpkgs.callPackage ./lib/qsub.nix {}; - qsubAttr = qsubAttrs: f: attrs: i: qsub qsubAttrs (f attrs i); - qsubAttrs = attrs: nixpkgs.lib.mapAttrs (_: x: qsubAttr attrs x); ref = callBionix ./lib/references.nix {}; + + qsub = attrs: bionix.extend (self: super: with self; rec { + qsubDefs = { ppn = 1; mem = 1; walltime = "24:00:00"; tmpDir = "/tmp"; sleepTime = 60; } // attrs; + qsub = attrs: (callPackage ./lib/qsub.nix {}) (qsubDefs // attrs); + exec = f: x: y: qsub (builtins.intersectAttrs qsubDefs x) (f (builtins.removeAttrs x (builtins.attrNames qsubDefs)) y); + }); def = f: defs: attrs: f (defs // attrs); - defQsub = qsubAttrs: f: defs: qsubAttr qsubAttrs (def f defs); # Fetching files of specific type fetchFastQ = attrs: with types; tagFiletype (filetype.fq {}) (fetchurl attrs); diff --git a/lib/qsub.nix b/lib/qsub.nix index f7b3c3e..77e773f 100644 --- a/lib/qsub.nix +++ b/lib/qsub.nix @@ -1,6 +1,6 @@ {stdenv, lib, writeScript}: -{ ppn ? 1, mem ? 1, walltime ? "24:00:00", tmpDir ? "/tmp" , sleepTime ? 60}: drv: lib.overrideDerivation drv ({ args, builder, name, ... }: { +{ ppn, mem, walltime, tmpDir, sleepTime}: drv: lib.overrideDerivation drv ({ args, builder, name, ... }: { builder = "/bin/bash"; args = let script = writeScript "qsub-script" '' diff --git a/tools/bowtie.nix b/tools/bowtie.nix index a9fa2e8..df8f955 100644 --- a/tools/bowtie.nix +++ b/tools/bowtie.nix @@ -3,6 +3,6 @@ with bionix; { - align = callBionix ./bowtie-align.nix; - index = callBionix ./bowtie-index.nix; + align = callBionixE ./bowtie-align.nix; + index = callBionixE ./bowtie-index.nix; } diff --git a/tools/bwa.nix b/tools/bwa.nix index 1d5215f..ea0e6a0 100644 --- a/tools/bwa.nix +++ b/tools/bwa.nix @@ -3,6 +3,6 @@ with bionix; { - align = callBionix ./bwa-mem.nix; - index = callBionix ./bwa-index.nix; + align = callBionixE ./bwa-mem.nix; + index = callBionixE ./bwa-index.nix; } diff --git a/tools/fastqc.nix b/tools/fastqc.nix index 1661e95..6e603b2 100644 --- a/tools/fastqc.nix +++ b/tools/fastqc.nix @@ -5,5 +5,5 @@ with bionix; { fastqc = callPackage ./fastqc-app.nix {}; - check = callBionix ./fastqc-check.nix; + check = callBionixE ./fastqc-check.nix; } diff --git a/tools/gridss.nix b/tools/gridss.nix index d47a669..009752e 100644 --- a/tools/gridss.nix +++ b/tools/gridss.nix @@ -8,15 +8,15 @@ rec { url = "https://github.com/PapenfussLab/gridss/releases/download/v2.0.0/gridss-2.0.0-gridss-jar-with-dependencies.jar"; sha256 = "01srl3qvv060whqg1y1fpxjc5cwga5wscs1bmf1v3z87dignra7k"; }; - gridssConfig = callBionix ./gridss-configFile.nix {}; - callVariants = callBionix ./gridss-callVariants.nix; - computeSamTags = callBionix ./gridss-computeSamTags.nix; - softClipsToSplitReads = callBionix ./gridss-softClipsToSplitReads.nix; - collectMetrics = callBionix ./gridss-collectMetrics.nix; - extractSVReads = callBionix ./gridss-extractSVReads.nix; - assemble = callBionix ./gridss-assemble.nix; - identifyVariants = attrs: input: ((callBionix ./gridss-variants.nix attrs) input).identify; - annotateVariants = attrs: input: ((callBionix ./gridss-variants.nix attrs) input).annotate; + gridssConfig = callBionixE ./gridss-configFile.nix {}; + callVariants = callBionixE ./gridss-callVariants.nix; + computeSamTags = callBionixE ./gridss-computeSamTags.nix; + softClipsToSplitReads = callBionixE ./gridss-softClipsToSplitReads.nix; + collectMetrics = callBionixE ./gridss-collectMetrics.nix; + extractSVReads = callBionixE ./gridss-extractSVReads.nix; + assemble = callBionixE ./gridss-assemble.nix; + identifyVariants = exec (attrs: input: ((callBionix ./gridss-variants.nix attrs) input).identify); + annotateVariants = exec (attrs: input: ((callBionix ./gridss-variants.nix attrs) input).annotate); preprocessBam = input: with samtools; sort {} (gridss.softClipsToSplitReads {} (gridss.computeSamTags {} (sort {nameSort = true;} (gridss.extractSVReads {} (markdup {} (sort {} (fixmate {mateScore = true;} (sort {nameSort = true;} input)))))))); call = inputs: bionix.gridss.annotateVariants {} (map gridss.preprocessBam inputs); } diff --git a/tools/infercnv.nix b/tools/infercnv.nix index 518ca76..03e073b 100644 --- a/tools/infercnv.nix +++ b/tools/infercnv.nix @@ -5,5 +5,5 @@ with bionix; { app = callPackage ./infercnv-app.nix {}; - infercnv = callBionix ./infercnv-infer.nix {}; + infercnv = callBionixE ./infercnv-infer.nix {}; } diff --git a/tools/kallisto.nix b/tools/kallisto.nix index f13f493..8a5d038 100644 --- a/tools/kallisto.nix +++ b/tools/kallisto.nix @@ -3,6 +3,6 @@ with bionix; { - index = callBionix ./kallisto-index.nix; - quant = callBionix ./kallisto-quant.nix; + index = callBionixE ./kallisto-index.nix; + quant = callBionixE ./kallisto-quant.nix; } diff --git a/tools/mosdepth.nix b/tools/mosdepth.nix index ff940a5..fa1101a 100644 --- a/tools/mosdepth.nix +++ b/tools/mosdepth.nix @@ -3,6 +3,6 @@ with bionix; { - depth = callBionix ./mosdepth-depth.nix; - plot = callBionix ./mosdepth-plot.nix; + depth = callBionixE ./mosdepth-depth.nix; + plot = callBionixE ./mosdepth-plot.nix; } diff --git a/tools/mutect.nix b/tools/mutect.nix index 9a8ce41..627b77e 100644 --- a/tools/mutect.nix +++ b/tools/mutect.nix @@ -5,5 +5,5 @@ with bionix; { app = callPackage ./mutect-app.nix {inherit (nixpkgs) stdenv fetchurl makeWrapper unzip fetchFromGitHub;}; - call = callBionix ./mutect-call.nix; + call = callBionixE ./mutect-call.nix; } diff --git a/tools/platypus.nix b/tools/platypus.nix index 0dfe397..1b214dc 100644 --- a/tools/platypus.nix +++ b/tools/platypus.nix @@ -3,5 +3,5 @@ with bionix; { - call = callBionix ./platypus-callVariants.nix; + call = callBionixE ./platypus-callVariants.nix; } diff --git a/tools/samtools.nix b/tools/samtools.nix index 62414df..c29db40 100644 --- a/tools/samtools.nix +++ b/tools/samtools.nix @@ -3,13 +3,13 @@ with bionix; { - view = callBionix ./samtools-view.nix; - faidx = callBionix ./samtools-faidx.nix; - flagstat = callBionix ./samtools-flagstat.nix; - index = callBionix ./samtools-index.nix; - dict = callBionix ./samtools-dict.nix; - sort = callBionix ./samtools-sort.nix; - merge = callBionix ./samtools-merge.nix; - markdup = callBionix ./samtools-markdup.nix; - fixmate = callBionix ./samtools-fixmate.nix; + view = callBionixE ./samtools-view.nix; + faidx = callBionixE ./samtools-faidx.nix; + flagstat = callBionixE ./samtools-flagstat.nix; + index = callBionixE ./samtools-index.nix; + dict = callBionixE ./samtools-dict.nix; + sort = callBionixE ./samtools-sort.nix; + merge = callBionixE ./samtools-merge.nix; + markdup = callBionixE ./samtools-markdup.nix; + fixmate = callBionixE ./samtools-fixmate.nix; } diff --git a/tools/strelka.nix b/tools/strelka.nix index 767c270..d9d97b1 100644 --- a/tools/strelka.nix +++ b/tools/strelka.nix @@ -3,5 +3,5 @@ with bionix; { - call = callBionix ./strelka-call.nix; + call = callBionixE ./strelka-call.nix; } -- cgit v1.2.3