diff options
author | Justin Bedo <cu@cua0.org> | 2018-10-04 12:06:54 +1000 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2018-10-04 12:06:54 +1000 |
commit | fe68926931b280aaf29808566b49b2e704e8556a (patch) | |
tree | dad0e9e11852e161c87ea6b7f4f6100a5180b9f2 | |
parent | 51f3817ecd2ad099b951d11e55eb3e2c516174d3 (diff) |
Refactor to use bionix tree directly
-rw-r--r-- | default.nix | 25 | ||||
-rw-r--r-- | test-tnpair.nix | 12 | ||||
-rw-r--r-- | tools/bwa-index.nix | 6 | ||||
-rw-r--r-- | tools/bwa-mem.nix | 15 | ||||
-rw-r--r-- | tools/bwa.nix | 6 | ||||
-rw-r--r-- | tools/crumble-toCram.nix | 12 | ||||
-rw-r--r-- | tools/crumble.nix | 4 | ||||
-rw-r--r-- | tools/fastqc-check.nix | 12 | ||||
-rw-r--r-- | tools/fastqc.nix | 4 | ||||
-rw-r--r-- | tools/gridss-callVariants.nix | 20 | ||||
-rw-r--r-- | tools/gridss.nix | 4 | ||||
-rw-r--r-- | tools/mosdepth-depth.nix | 14 | ||||
-rw-r--r-- | tools/mosdepth-plot.nix | 10 | ||||
-rw-r--r-- | tools/mosdepth.nix | 6 | ||||
-rw-r--r-- | tools/platypus-callVariants.nix | 14 | ||||
-rw-r--r-- | tools/samtools-faidx.nix | 7 | ||||
-rw-r--r-- | tools/samtools-flagstat.nix | 7 | ||||
-rw-r--r-- | tools/samtools-index.nix | 7 | ||||
-rw-r--r-- | tools/samtools-sort.nix | 7 | ||||
-rw-r--r-- | tools/samtools.nix | 10 | ||||
-rw-r--r-- | tools/strelka-call.nix | 15 | ||||
-rw-r--r-- | tools/strelka.nix | 4 |
22 files changed, 110 insertions, 111 deletions
diff --git a/default.nix b/default.nix index 10d2249..9f96a9d 100644 --- a/default.nix +++ b/default.nix @@ -2,18 +2,21 @@ let bionix = nixpkgs.lib.makeExtensible (self: - let callBionix = file: import file { bionix = self; nixpkgs = nixpkgs; }; - in with self; { - bwa = callBionix ./tools/bwa.nix; - crumble = callBionix ./tools/crumble.nix; - fastqc = callBionix ./tools/fastqc.nix; - gridss = callBionix ./tools/gridss.nix; - mosdepth = callBionix ./tools/mosdepth.nix; - platypus = callBionix ./tools/platypus.nix; - samtools = callBionix ./tools/samtools.nix; - strelka = callBionix ./tools/strelka.nix; + let callBionix = file: attrs: import file ({ bionix = self; nixpkgs = nixpkgs; } // attrs); + in with self; { + callBionix = callBionix; + id = x: x; + + bwa = callBionix ./tools/bwa.nix {}; + crumble = callBionix ./tools/crumble.nix {}; + fastqc = callBionix ./tools/fastqc.nix {}; + gridss = callBionix ./tools/gridss.nix {}; + mosdepth = callBionix ./tools/mosdepth.nix {}; + platypus = callBionix ./tools/platypus.nix {}; + samtools = callBionix ./tools/samtools.nix {}; + strelka = callBionix ./tools/strelka.nix {}; qsub = nixpkgs.callPackage ./lib/qsub.nix {}; - ref = callBionix ./lib/references.nix; + ref = callBionix ./lib/references.nix {}; }); in bionix diff --git a/test-tnpair.nix b/test-tnpair.nix index ef2af1b..77b5727 100644 --- a/test-tnpair.nix +++ b/test-tnpair.nix @@ -1,11 +1,19 @@ with (import <nixpkgs> {}); -with (import <bionix> {}); with lib; let + bionix = (import <bionix> {}).extend (self: super: { + bwa = super.bwa // { index = attrs: super.bwa.index ({ flags = "-a is" ; } // attrs); }; + }); + +in + +with bionix; + +let ref = ./example/ref.fa; alignWithRG = rg: bwa.align { inherit ref; flags = "-R'@RG\\tID:${rg}\\tSM:${rg}'";}; - sort = samtools.sort { }; + sort = samtools.sort {}; flagstat = samtools.flagstat {}; check = fastqc.check {}; callVariants = strelka.call { inherit ref; }; diff --git a/tools/bwa-index.nix b/tools/bwa-index.nix index 3329221..3f9d385 100644 --- a/tools/bwa-index.nix +++ b/tools/bwa-index.nix @@ -1,11 +1,11 @@ -{ stdenv -, lib -, bwa +{ bionix +, nixpkgs , flags ? null }: ref: +with nixpkgs; with lib; stdenv.mkDerivation { diff --git a/tools/bwa-mem.nix b/tools/bwa-mem.nix index 9af3992..6e83a6d 100644 --- a/tools/bwa-mem.nix +++ b/tools/bwa-mem.nix @@ -1,21 +1,16 @@ -{ stdenv -, callPackage -, lib -, bc -, bwa -, index ? callPackage ./bwa-index.nix { inherit bwa stdenv lib; } -, samtools ? null +{ bionix +, nixpkgs , ref , bamOutput ? true , flags ? null +, indexAttrs ? {} }: { input1 , input2 ? null }: -assert bamOutput -> samtools != null; - +with nixpkgs; with lib; stdenv.mkDerivation { @@ -23,7 +18,7 @@ stdenv.mkDerivation { buildInputs = [ bwa bc ] ++ optional bamOutput samtools; buildCommand = '' ln -s ${ref} ref.fa - for f in ${index ref}/* ; do + for f in ${bionix.bwa.index indexAttrs ref}/* ; do ln -s $f done cores=$(echo $NIX_BUILD_CORES ${optionalString bamOutput "- 1"} | bc) diff --git a/tools/bwa.nix b/tools/bwa.nix index df61cba..1d5215f 100644 --- a/tools/bwa.nix +++ b/tools/bwa.nix @@ -1,8 +1,8 @@ { bionix, nixpkgs }: -with nixpkgs; +with bionix; { - align = attrs: callPackage ./bwa-mem.nix attrs; - index = attrs: callPackage ./bwa-index.nix attrs; + align = callBionix ./bwa-mem.nix; + index = callBionix ./bwa-index.nix; } diff --git a/tools/crumble-toCram.nix b/tools/crumble-toCram.nix index 6b2431f..2544e17 100644 --- a/tools/crumble-toCram.nix +++ b/tools/crumble-toCram.nix @@ -1,15 +1,15 @@ -{ stdenv -, lib -, callPackage -, crumble ? callPackage ./crumble-app.nix {} -, flags ? null}: +{ bionix +, nixpkgs +, flags ? null +}: +with nixpkgs; with lib; input: stdenv.mkDerivation { name = "crumble"; - buildInputs = [ crumble ]; + buildInputs = [ bionix.crumble.crumble ]; buildCommand = "crumble ${optionalString (flags != null) flags} ${input} $out"; } diff --git a/tools/crumble.nix b/tools/crumble.nix index 4798329..fb48c8f 100644 --- a/tools/crumble.nix +++ b/tools/crumble.nix @@ -1,7 +1,9 @@ { bionix, nixpkgs }: with nixpkgs; +with bionix; { - toCram = attrs: callPackage ./crumble-toCram.nix attrs; + crumble = callPackage ./crumble-app.nix {}; + toCram = callBionix ./crumble-toCram.nix; } diff --git a/tools/fastqc-check.nix b/tools/fastqc-check.nix index 1d9993a..17d6183 100644 --- a/tools/fastqc-check.nix +++ b/tools/fastqc-check.nix @@ -1,16 +1,16 @@ -{ stdenv -, lib -, callPackage -, fastqc ? callPackage ./fastqc-app.nix {} -, flags ? null}: +{ bionix +, nixpkgs +, flags ? null +}: +with nixpkgs; with lib; input: stdenv.mkDerivation { name = "fastqc-check"; - buildInputs = [ fastqc ]; + buildInputs = [ bionix.fastqc.fastqc ]; buildCommand = '' mkdir $out fastqc \ diff --git a/tools/fastqc.nix b/tools/fastqc.nix index 2034c91..1661e95 100644 --- a/tools/fastqc.nix +++ b/tools/fastqc.nix @@ -1,7 +1,9 @@ { bionix, nixpkgs }: with nixpkgs; +with bionix; { - check = attrs: callPackage ./fastqc-check.nix attrs; + fastqc = callPackage ./fastqc-app.nix {}; + check = callBionix ./fastqc-check.nix; } diff --git a/tools/gridss-callVariants.nix b/tools/gridss-callVariants.nix index 9d78896..e431560 100644 --- a/tools/gridss-callVariants.nix +++ b/tools/gridss-callVariants.nix @@ -1,15 +1,11 @@ -{ stdenv -, lib -, callPackage -, fetchurl -, jre -, R -, bwa +{ bionix +, nixpkgs , ref , blacklist ? null -, bwaIndex ? callPackage ./bwa-index.nix { inherit stdenv bwa lib; } -, faidx ? callPackage ./samtools-faidx.nix { inherit stdenv; } -, flags ? null}: +, bwaIndexAttrs ? {} +, faidxAttrs ? {} +, flags ? null +}: with lib; @@ -24,8 +20,8 @@ stdenv.mkDerivation rec { }; buildCommand = '' ln -s ${ref} ref.fa - ln -s ${faidx ref} ref.fa.fai - for f in ${bwaIndex ref}/*; do + ln -s ${bionix.samtools.faidx faidxAttrs ref} ref.fa.fai + for f in ${bionix.bwa.index bwaIndexAttrs ref}/*; do ln -s $f done mkdir $out diff --git a/tools/gridss.nix b/tools/gridss.nix index fa52606..edf9f57 100644 --- a/tools/gridss.nix +++ b/tools/gridss.nix @@ -1,7 +1,7 @@ {bionix, nixpkgs}: -with nixpkgs; +with bionix; { - callVariants = attrs: callPackage ./gridss-callVariants.nix attrs; + callVariants = callBiolnix ./gridss-callVariants.nix; } diff --git a/tools/mosdepth-depth.nix b/tools/mosdepth-depth.nix index be28aaf..7043c43 100644 --- a/tools/mosdepth-depth.nix +++ b/tools/mosdepth-depth.nix @@ -1,10 +1,10 @@ -{ stdenv -, lib -, callPackage -, mosdepth -, index ? callPackage ./samtools-index.nix {} -, flags ? null}: +{ bionix +, nixpkgs +, indexAttrs ? {} +, flags ? null +}: +with nixpkgs; with lib; input: @@ -15,7 +15,7 @@ stdenv.mkDerivation { buildCommand = '' mkdir $out ln -s ${input} input.bam - ln -s ${index input} input.bam.bai + ln -s ${bionix.samtools.index indexAttrs input} input.bam.bai mosdepth -t $NIX_BUILD_CORES ${optionalString (flags != null) flags} $out/out input.bam ''; } diff --git a/tools/mosdepth-plot.nix b/tools/mosdepth-plot.nix index e6d2c7d..f15e099 100644 --- a/tools/mosdepth-plot.nix +++ b/tools/mosdepth-plot.nix @@ -1,9 +1,9 @@ -{ stdenv -, lib -, mosdepth -, python -, flags ? null}: +{ bionix +, nixpkgs +, flags ? null +}: +with nixpkgs; with lib; { inputs diff --git a/tools/mosdepth.nix b/tools/mosdepth.nix index 447e530..ff940a5 100644 --- a/tools/mosdepth.nix +++ b/tools/mosdepth.nix @@ -1,8 +1,8 @@ { bionix, nixpkgs }: -with nixpkgs; +with bionix; { - depth = attrs: callPackage ./mosdepth-depth.nix attrs; - plot = attrs: callPackage ./mosdepth-plot.nix attrs; + depth = callBionix ./mosdepth-depth.nix; + plot = callBionix ./mosdepth-plot.nix; } diff --git a/tools/platypus-callVariants.nix b/tools/platypus-callVariants.nix index 3e150d2..c0204dc 100644 --- a/tools/platypus-callVariants.nix +++ b/tools/platypus-callVariants.nix @@ -1,10 +1,8 @@ -{ stdenv -, callPackage -, lib -, platypus +{ bionix +, nixpkgs , ref -, index ? callPackage ./samtools-faidx.nix {} -, bamIndex ? callPackage ./samtools-index.nix {} +, indexAttrs ? {} +, bamIndexAttrs ? {} , flags ? null }: @@ -19,9 +17,9 @@ in stdenv.mkDerivation { buildInputs = [ platypus ]; buildCommand = '' ln -s ${ref} ref.fa - ln -s ${index ref} ref.fa.fai + ln -s ${bionix.samtools.faix indexAttrs ref} ref.fa.fai ${concatMapStringsSep "\n" (p: "ln -s ${p} ${filename p}.bam") inputs} - ${concatMapStringsSep "\n" (p: "ln -s ${bamIndex p} ${filename p}.bai") inputs} + ${concatMapStringsSep "\n" (p: "ln -s ${bionix.samtools.index bamIndexAttrs p} ${filename p}.bai") inputs} ls -l platypus callVariants \ --nCPU=$NIX_BUILD_CORES \ diff --git a/tools/samtools-faidx.nix b/tools/samtools-faidx.nix index a399857..72116b8 100644 --- a/tools/samtools-faidx.nix +++ b/tools/samtools-faidx.nix @@ -1,12 +1,11 @@ -{ stdenv -, callPackage -, lib -, samtools +{ bionix +, nixpkgs , flags ? null }: input: +with nixpkgs; with lib; stdenv.mkDerivation { diff --git a/tools/samtools-flagstat.nix b/tools/samtools-flagstat.nix index 790eeb4..ae36c94 100644 --- a/tools/samtools-flagstat.nix +++ b/tools/samtools-flagstat.nix @@ -1,11 +1,10 @@ -{ stdenv -, callPackage -, lib -, samtools +{ bionix +, nixpkgs }: input: +with nixpkgs; with lib; stdenv.mkDerivation { diff --git a/tools/samtools-index.nix b/tools/samtools-index.nix index 2fd066f..4e09dc7 100644 --- a/tools/samtools-index.nix +++ b/tools/samtools-index.nix @@ -1,12 +1,11 @@ -{ stdenv -, callPackage -, lib -, samtools +{ bionix +, nixpkgs , flags ? null }: input: +with nixpkgs; with lib; stdenv.mkDerivation { diff --git a/tools/samtools-sort.nix b/tools/samtools-sort.nix index 1a79c9f..2de579e 100644 --- a/tools/samtools-sort.nix +++ b/tools/samtools-sort.nix @@ -1,13 +1,12 @@ -{ stdenv -, callPackage -, lib -, samtools +{ bionix +, nixpkgs , nameSort ? false , flags ? null }: input: +with nixpkgs; with lib; stdenv.mkDerivation { diff --git a/tools/samtools.nix b/tools/samtools.nix index 77e3815..6b08c6e 100644 --- a/tools/samtools.nix +++ b/tools/samtools.nix @@ -1,10 +1,10 @@ { bionix, nixpkgs }: -with nixpkgs; +with bionix; { - faidx = attrs: callPackage ./samtools-faidx.nix attrs; - flagstat = attrs: callPackage ./samtools-flagstat.nix attrs; - index = attrs: callPackage ./samtools-index.nix attrs; - sort = attrs: callPackage ./samtools-sort.nix attrs; + faidx = callBionix ./samtools-faidx.nix; + flagstat = callBionix ./samtools-flagstat.nix; + index = callBionix ./samtools-index.nix; + sort = callBionix ./samtools-sort.nix; } diff --git a/tools/strelka-call.nix b/tools/strelka-call.nix index ec7a764..e7fbb58 100644 --- a/tools/strelka-call.nix +++ b/tools/strelka-call.nix @@ -1,15 +1,14 @@ -{ stdenv -, callPackage -, lib -, strelka +{ bionix +, nixpkgs , ref -, index ? callPackage ./samtools-faidx.nix {} -, bamIndex ? callPackage ./samtools-index.nix {} +, indexAttrs ? {} +, bamIndexAttrs ? {} , flags ? null }: {normal, tumour}: +with nixpkgs; with lib; let @@ -21,9 +20,9 @@ in stdenv.mkDerivation { buildInputs = [ strelka ]; buildCommand = '' ln -s ${ref} ref.fa - ln -s ${index ref} ref.fa.fai + ln -s ${bionix.samtools.faidx indexAttrs ref} ref.fa.fai ${concatMapStringsSep "\n" (p: "ln -s ${p} ${filename p}.bam") inputs} - ${concatMapStringsSep "\n" (p: "ln -s ${bamIndex p} ${filename p}.bai") inputs} + ${concatMapStringsSep "\n" (p: "ln -s ${bionix.samtools.index bamIndexAttrs p} ${filename p}.bai") inputs} configureStrelkaSomaticWorkflow.py \ --normalBam ${filename normal}.bam \ diff --git a/tools/strelka.nix b/tools/strelka.nix index a115740..767c270 100644 --- a/tools/strelka.nix +++ b/tools/strelka.nix @@ -1,7 +1,7 @@ { bionix, nixpkgs }: -with nixpkgs; +with bionix; { - call = attrs: callPackage ./strelka-call.nix attrs; + call = callBionix ./strelka-call.nix; } |