aboutsummaryrefslogtreecommitdiff
path: root/test.nix
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2018-09-20 13:57:12 +1000
committerJustin Bedo <cu@cua0.org>2018-09-20 14:34:36 +1000
commit33a121a7bad5b2608cc41ce60ab3d65676541fa6 (patch)
treedbbce4154a85988f3bfd9b13d42ad5d37f04e18a /test.nix
parentf0a8a4de59ea79f56e074ddd16eff0ce1782dfe8 (diff)
Wrap some tools and make an example pipeline
Diffstat (limited to 'test.nix')
-rw-r--r--test.nix89
1 files changed, 20 insertions, 69 deletions
diff --git a/test.nix b/test.nix
index c59f786..6c158c6 100644
--- a/test.nix
+++ b/test.nix
@@ -1,77 +1,28 @@
{pkgs ? import <nixpkgs> {}}:
with pkgs;
+with lib;
let
- conda = callPackage ./conda.nix {};
-
- qsub = drv: lib.overrideDerivation drv ({ ppn ? 1, mem ? 1, walltime ? "24:00:00", args, builder, ... }: {
- builder = "/bin/bash";
- args = let
- script = writeScript "qsub-script" ''
- #!${stdenv.shell}
- while [ ! -e /stornext/HPCScratch/$PBS_JOBID ] ; do
- sleep 5
- done
- set -a
- . /stornext/HPCScratch/$PBS_JOBID
- set +a
- TMPDIR=/tmp/$PBS_JOBID
- TEMP=$TMPDIR
- TMP=$TMPDIR
- NIX_BUILD_TOP=$TMPDIR
- mkdir $TMPDIR
- cd $TMPDIR
- rm /stornext/HPCScratch/$PBS_JOBID
- ${builder} ${lib.escapeShellArgs args} && touch /stornext/HPCScratch/$PBS_JOBID
- cd /
- rm -rf $TMPDIR
- '';
-
- qsub = writeScript "qsub" ''
- #!/bin/bash
- PATH=/usr/bin:/bin:/usr/sbin:/sbin
- SHELL=/bin/sh
- NIX_BUILD_CORES=${toString ppn}
- id=$(qsub -l nodes=1:ppn=${toString ppn},mem=${toString mem}gb,walltime=${walltime} ${script})
- set > /stornext/HPCScratch/$id
- while qstat ''${id%%.} 2> /dev/null > /dev/null ; do
- sleep 5
- done
- if [[ -e /stornext/HPCScratch/$id ]] ; then
- rm /stornext/HPCScratch/$id
- exit 0
- fi
- exit 1
- '';
-
- in [ "-c" qsub ];
- });
-
- qstat = stdenv.mkDerivation rec {
- name = "qstat";
- buildCommand = "/usr/bin/qstat > $out";
- };
-
- grep = x: stdenv.mkDerivation rec {
- name = "grep";
- buildInputs = [ bwa ];
- buildCommand = "/usr/bin/grep distefano.l ${x} > $out";
- };
-
- dummy = x: stdenv.mkDerivation rec {
- name = "dummy";
- buildCommand = "sleep 5 && echo ${toString x} > $out";
- };
-
- condaEnv = conda.buildCondaEnv {
- run = ''
- conda config --add channels bioconda
- conda install -y bwa
+ ref = ../bioshake/examples/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; };
+
+ 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;};} ];
+
+ alignments = map (i: sort (alignWithRG i.name i.files)) samples;
+ variants = callVariants alignments;
+
+ 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)}
'';
};
- condaTest = conda.inCondaEnv condaEnv "bwa";
-
-
-in condaTest
+in testNaming