diff options
-rw-r--r-- | test.nix | 45 | ||||
-rw-r--r-- | tools/bwa-mem.nix | 3 | ||||
-rw-r--r-- | tools/platypus-callVariants.nix | 2 |
3 files changed, 28 insertions, 22 deletions
@@ -1,28 +1,35 @@ -{pkgs ? import <nixpkgs> {}}: +{pkgs ? import <nixpkgs> {} +,bionix ? import <bionix> {}}: with pkgs; with lib; +with bionix; let - ref = ./example/ref.fa; - alignWithRG = rg: callPackage ./tools/bwa.nix { inherit ref; flags = "-R'@RG\\tID:${rg}\\tSM:${rg}'";}; - sort = callPackage ./tools/samtools-sort.nix { }; - callVariants = callPackage ./tools/platypus.nix { inherit ref; }; + inherit (types) filetype tagFiletype; - samples = [ {name = "mysample1"; files = {input1 = ./example/sample1-1.fq; input2 = ./example/sample1-2.fq;};} - {name = "mysample2"; files = {input1 = ./example/sample2-1.fq; input2 = ./example/sample2-1.fq;};} ]; + fetchLocal = path: stdenv.mkDerivation { + name = baseNameOf path; + buildCommand = "ln -s ${path} $out"; + }; + tagfq = path: tagFiletype (filetype.fq {}) (fetchLocal path); + tagfa = path: tagFiletype (filetype.fa {}) (fetchLocal path); - alignments = map (i: sort (alignWithRG i.name i.files)) samples; - variants = callVariants alignments; + ref = tagfa ./example/ref.fa; + alignWithRG = rg: bwa.align { inherit ref; flags = "-R'@RG\\tID:${rg}\\tSM:${rg}'";}; - testNaming = stdenv.mkDerivation { - name = "test-naming"; - buildCommand = '' - mkdir $out - ln -s ${variants} $out/myfancyname - mkdir $out/alignments - ${concatStringsSep "\n" (zipListsWith (s: a: "ln -s ${a} $out/alignments/${s.name}.bam") samples alignments)} - ''; - }; + samples = [ {name = "mysample1"; files = {input1 = tagfq ./example/sample1-1.fq; input2 = tagfq ./example/sample1-2.fq;};} + {name = "mysample2"; files = {input1 = tagfq ./example/sample2-1.fq; input2 = tagfq ./example/sample2-1.fq;};} ]; + + alignments = map (i: samtools.sort {} (alignWithRG i.name i.files)) samples; + variants = platypus.call {} alignments; -in testNaming +in stdenv.mkDerivation { + name = "myproject"; + buildCommand = '' + mkdir $out + ln -s ${variants} $out/platypus.vcf + mkdir $out/alignments + ${concatStringsSep "\n" (zipListsWith (s: a: "ln -s ${a} $out/alignments/${s.name}.bam") samples alignments)} + ''; +} diff --git a/tools/bwa-mem.nix b/tools/bwa-mem.nix index 0d0f7d8..3208e48 100644 --- a/tools/bwa-mem.nix +++ b/tools/bwa-mem.nix @@ -29,8 +29,7 @@ in stdenv.mkDerivation { done cores=$(echo $NIX_BUILD_CORES ${optionalString bamOutput "- 1"} | bc) if [[ $cores -lt 1 ]] ; then - >&2 echo "not enough build cores" - exit 1 + cores=1 fi bwa mem ${optionalString (flags != null) flags} -t $cores ref.fa ${fq input1} \ ${optionalString (input2 != null) (fq input2)} \ diff --git a/tools/platypus-callVariants.nix b/tools/platypus-callVariants.nix index a3e3a65..a57aa83 100644 --- a/tools/platypus-callVariants.nix +++ b/tools/platypus-callVariants.nix @@ -14,7 +14,7 @@ with bionix.types; let filename = path: last (splitString "/" path); - getref = f: matchFiletype "platypus-callVariants" { bam = r: r; } f; + getref = f: matchFiletype "platypus-callVariants" { bam = {ref, ...}: ref; } f; refs = map getref inputs; ref = head refs; in |