aboutsummaryrefslogtreecommitdiff
path: root/examples/ex-tnpair
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2019-04-30 09:47:49 +1000
committerJustin Bedo <cu@cua0.org>2019-04-30 09:47:49 +1000
commita1d18efc18772a233aa759b622c3a9960824f109 (patch)
treec8e4028b4b634cfe7002c79539563256894e0d48 /examples/ex-tnpair
parente9b908b0cdc22a7b43301e63a23c7911aa371721 (diff)
cleanup examples and stray files
Diffstat (limited to 'examples/ex-tnpair')
-rwxr-xr-xexamples/ex-tnpair/tnpair58
-rw-r--r--examples/ex-tnpair/tnpair.nix26
2 files changed, 84 insertions, 0 deletions
diff --git a/examples/ex-tnpair/tnpair b/examples/ex-tnpair/tnpair
new file mode 100755
index 0000000..5b84d5c
--- /dev/null
+++ b/examples/ex-tnpair/tnpair
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+set -e
+
+if [[ $# -ne 5 ]] ; then
+ echo "Usage: $0 ref normal1 normal2 tumour1 tumour2"
+ exit 1
+fi
+
+function cleanup {
+ if [[ -e tnpair-$$ ]]; then
+ rm tnpair-$$
+ fi
+}
+trap cleanup INT TERM EXIT
+
+ref=`readlink -f $1`
+norm1=`readlink -f $2`
+norm2=`readlink -f $3`
+tumour1=`readlink -f $4`
+tumour2=`readlink -f $5`
+
+refhash=`nix-hash --base32 --type sha256 --flat $ref`
+norm1hash=`nix-hash --base32 --type sha256 --flat $norm1`
+norm2hash=`nix-hash --base32 --type sha256 --flat $norm2`
+tumour1hash=`nix-hash --base32 --type sha256 --flat $tumour1`
+tumour2hash=`nix-hash --base32 --type sha256 --flat $tumour2`
+
+cat > tnpair-$$ <<EOF
+import ./tnpair.nix {
+ normal = {
+ input1={
+ url="file://$norm1";
+ sha256="$norm1hash";
+ };
+ input2={
+ url="file://$norm2";
+ sha256="$norm2hash";
+ };
+ };
+ tumour = {
+ input1={
+ url = "file://$tumour1";
+ sha256 = "$tumour1hash";
+ };
+ input2={
+ url = "file://$tumour2";
+ sha256 = "$tumour2hash";
+ };
+ };
+ ref = {
+ url = "file://$ref";
+ sha256 = "$refhash";
+ };
+}
+EOF
+
+nix build --keep-going "(import ./tnpair-$$)"
diff --git a/examples/ex-tnpair/tnpair.nix b/examples/ex-tnpair/tnpair.nix
new file mode 100644
index 0000000..2939db4
--- /dev/null
+++ b/examples/ex-tnpair/tnpair.nix
@@ -0,0 +1,26 @@
+# This is an example tumour-normal calling pipeline using strelka
+{ bionix ? import <bionix> {}
+, normal
+, tumour
+, ref
+}:
+
+with bionix;
+with lib;
+
+let
+ input = mapAttrs (_: fetchFastQGZ);
+
+ preprocess = pipe [
+ input
+ (bwa.align { ref = fetchFastA ref; })
+ (samtools.fixmate {})
+ (samtools.sort {})
+ (samtools.markdup {})
+ ];
+
+in linkDrv [
+ (ln (strelka.call {} {normal = preprocess normal; tumour = preprocess tumour;}) "strelka")
+ (ln (preprocess normal) "normal.bam")
+ (ln (preprocess tumour) "tumour.bam")
+]