aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2018-09-26 11:24:18 +1000
committerJustin Bedo <cu@cua0.org>2018-09-26 11:24:18 +1000
commit91e6ec3f53b9183082f56c0e52931436d069528e (patch)
treee9d7fef5af4d151f80c85a781b1bbae2ff65a92e
parent98672cb1bba7221c5c8ecc363243cb47fcd13f47 (diff)
Add flagstat and fastqc
-rw-r--r--default.nix1
-rw-r--r--test-tnpair.nix9
-rw-r--r--tools/fastqc-app.nix24
-rw-r--r--tools/fastqc-check.nix20
-rw-r--r--tools/fastqc.nix7
-rw-r--r--tools/samtools-flagstat.nix15
-rw-r--r--tools/samtools.nix3
7 files changed, 78 insertions, 1 deletions
diff --git a/default.nix b/default.nix
index a9fb72b..a5c9f3f 100644
--- a/default.nix
+++ b/default.nix
@@ -5,6 +5,7 @@ let
let callBionix = file: import file { bionix = self; nixpkgs = nixpkgs; };
in with self; {
bwa = callBionix ./tools/bwa.nix;
+ fastqc = callBionix ./tools/fastqc.nix;
mosdepth = callBionix ./tools/mosdepth.nix;
platypus = callBionix ./tools/platypus.nix;
ref = callBionix ./references.nix;
diff --git a/test-tnpair.nix b/test-tnpair.nix
index 31570ee..ef2af1b 100644
--- a/test-tnpair.nix
+++ b/test-tnpair.nix
@@ -6,6 +6,8 @@ let
ref = ./example/ref.fa;
alignWithRG = rg: bwa.align { inherit ref; flags = "-R'@RG\\tID:${rg}\\tSM:${rg}'";};
sort = samtools.sort { };
+ flagstat = samtools.flagstat {};
+ check = fastqc.check {};
callVariants = strelka.call { inherit ref; };
tnpair = { tumour = {name = "mysample1"; files = {input1 = ./example/sample1-1.fq; input2 = ./example/sample1-2.fq;};};
@@ -26,6 +28,13 @@ let
mkdir $out/alignments
ln -s ${tnpairResult.alignments.tumour} $out/alignments/${tnpair.tumour.name}.bam
ln -s ${tnpairResult.alignments.normal} $out/alignments/${tnpair.normal.name}.bam
+ ln -s ${flagstat tnpairResult.alignments.tumour} $out/alignments/${tnpair.tumour.name}.flagstat
+ ln -s ${flagstat tnpairResult.alignments.normal} $out/alignments/${tnpair.normal.name}.flagstat
+ mkdir $out/fastqc
+ ln -s ${check tnpair.tumour.files.input1} $out/fastqc/${tnpair.tumour.name}.1
+ ln -s ${check tnpair.tumour.files.input2} $out/fastqc/${tnpair.tumour.name}.2
+ ln -s ${check tnpair.normal.files.input1} $out/fastqc/${tnpair.normal.name}.1
+ ln -s ${check tnpair.normal.files.input2} $out/fastqc/${tnpair.normal.name}.2
'';
};
diff --git a/tools/fastqc-app.nix b/tools/fastqc-app.nix
new file mode 100644
index 0000000..40fd7ec
--- /dev/null
+++ b/tools/fastqc-app.nix
@@ -0,0 +1,24 @@
+{ stdenv, unzip, perl, fetchurl, jre }:
+
+stdenv.mkDerivation rec {
+ name = "fastqc-${version}";
+ version = "0.11.7";
+
+ src = fetchurl {
+ url = "https://www.bioinformatics.babraham.ac.uk/projects/fastqc/fastqc_v0.11.7.zip";
+ sha256 = "04hifbfrh60s5kzqr7n46bcviaiymr1rx67b88s3cpxydf3m1ksr";
+ };
+
+ buildInputs = [ unzip perl ];
+
+ phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
+
+ installPhase = ''
+ mkdir -p $out/libexec/fastqc
+ cp -r . $out/libexec/fastqc
+ mkdir $out/bin
+ ln -s $out/libexec/fastqc/fastqc $out/bin
+ substituteInPlace $out/bin/fastqc --replace "my \$java_bin = 'java'" "my \$java_bin = '${jre}/bin/java'"
+ chmod 755 $out/libexec/fastqc/fastqc
+ '';
+}
diff --git a/tools/fastqc-check.nix b/tools/fastqc-check.nix
new file mode 100644
index 0000000..e13ce2a
--- /dev/null
+++ b/tools/fastqc-check.nix
@@ -0,0 +1,20 @@
+{ stdenv
+, lib
+, fastqc
+, flags ? null}:
+
+with lib;
+
+input:
+
+stdenv.mkDerivation {
+ name = "fastqc-check";
+ buildInputs = [ fastqc ];
+ buildCommand = ''
+ mkdir $out
+ fastqc \
+ -o $out \
+ ${optionalString (flags != null) flags} \
+ ${input}
+ '';
+}
diff --git a/tools/fastqc.nix b/tools/fastqc.nix
new file mode 100644
index 0000000..2034c91
--- /dev/null
+++ b/tools/fastqc.nix
@@ -0,0 +1,7 @@
+{ bionix, nixpkgs }:
+
+with nixpkgs;
+
+{
+ check = attrs: callPackage ./fastqc-check.nix attrs;
+}
diff --git a/tools/samtools-flagstat.nix b/tools/samtools-flagstat.nix
new file mode 100644
index 0000000..790eeb4
--- /dev/null
+++ b/tools/samtools-flagstat.nix
@@ -0,0 +1,15 @@
+{ stdenv
+, callPackage
+, lib
+, samtools
+}:
+
+input:
+
+with lib;
+
+stdenv.mkDerivation {
+ name = "samtools-index";
+ buildInputs = [ samtools ];
+ buildCommand = "samtools flagstat -@ $NIX_BUILD_CORES ${input} > $out";
+}
diff --git a/tools/samtools.nix b/tools/samtools.nix
index 6fdbef5..77e3815 100644
--- a/tools/samtools.nix
+++ b/tools/samtools.nix
@@ -3,7 +3,8 @@
with nixpkgs;
{
+ 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 = attrs: callPackage ./samtools-faidx.nix attrs;
}