aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2020-02-09 17:57:54 +1100
committerJustin Bedo <cu@cua0.org>2020-02-09 17:57:54 +1100
commitb8caa245cb6bb4616318173b81e9207aee414859 (patch)
treebb003911613d8a64b736a1d73c472b0e1aa27043
parent4084db9f31aa2b2b6701e0f7261f4dfcd86eaa74 (diff)
lastal: init
-rw-r--r--default.nix1
-rw-r--r--test-tnpair.nix1
-rw-r--r--tools/last-align.nix39
-rw-r--r--tools/last-index.nix21
-rw-r--r--tools/last.nix8
5 files changed, 70 insertions, 0 deletions
diff --git a/default.nix b/default.nix
index 41ad190..12ca5b3 100644
--- a/default.nix
+++ b/default.nix
@@ -44,6 +44,7 @@ let
manta = callBionix ./tools/manta.nix {};
delly = callBionix ./tools/delly.nix {};
lumpy = callBionix ./tools/lumpy.nix {};
+ lastal = callBionix ./tools/last.nix {};
slurm = attrs: bionix.extend (self: super: with self; rec {
slurmDefs = { ppn = 1; mem = 1; walltime = "24:00:00"; partition = null; slurmFlags = null; salloc = "/usr/bin/salloc"; srun = "/usr/bin/srun"; } // attrs;
diff --git a/test-tnpair.nix b/test-tnpair.nix
index 38eb509..38e3333 100644
--- a/test-tnpair.nix
+++ b/test-tnpair.nix
@@ -53,6 +53,7 @@ let
alignments = {
"bowtie-normal.bam" = bowtie.align {inherit ref;} tnpair.normal.files;
+ "last.maf" = lastal.align {inherit ref;} tnpair.normal.files;
"bwa-mem.bam" = bwa.mem {inherit ref;} tnpair.normal.files;
"bwa-mem2.bam" = bwa.mem2 {inherit ref;} tnpair.normal.files;
"minimap2-normal.bam" = minimap2.align {inherit ref; preset = "sr"; } tnpair.normal.files;
diff --git a/tools/last-align.nix b/tools/last-align.nix
new file mode 100644
index 0000000..b2c8460
--- /dev/null
+++ b/tools/last-align.nix
@@ -0,0 +1,39 @@
+{ bionix
+, ref
+, flags ? null
+, indexAttrs ? {}
+}:
+
+{ input1
+, input2 ? null
+}:
+
+with bionix;
+with lib;
+with types;
+
+let
+ fa = f: matchFiletype "last-ref" { fa = _: f; } f;
+ fq = f: matchFiletype "last-input" { fq = _: f; } f;
+ fqfa = f: matchFiletype "last-input" { fq = _: f; fa = _: f; } f;
+ Q = f: matchFiletype "last-input" { fq = _: 1; fa = _: 0; } f;
+ parallel = f: matchFiletype "last-input" { fq = _: "parallel-fastq"; fa = _: "parallel-fasta"; } f;
+
+in stage {
+ name = "last-align";
+ buildInputs = with pkgs; [ last ];
+ buildCommand = ''
+ ${if (input2 != null) then "fastq-interleave ${fq input1} ${fq input2}" else "cat ${fa input1}"} | \
+ ${parallel input1} -j $NIX_BUILD_CORES \
+ lastal -Q${toString (Q input1)} \
+ ${optionalString (input2 != null) "-i1"} \
+ ${optionalString (flags != null) flags} \
+ ${bionix.lastal.index indexAttrs ref}/index \
+ > tmp
+ '' + (if input2 == null then ''
+ cp tmp $out
+ '' else ''
+ last-pair-probs tmp > $out
+ '');
+ passthru.multicore = true;
+}
diff --git a/tools/last-index.nix b/tools/last-index.nix
new file mode 100644
index 0000000..af74f65
--- /dev/null
+++ b/tools/last-index.nix
@@ -0,0 +1,21 @@
+{ bionix
+, flags ? null
+}:
+
+ref:
+
+with bionix;
+with lib;
+with types;
+
+assert (matchFiletype "last-index" { fa = _: true; } ref);
+
+stage {
+ name = "last-index";
+ buildInputs = with pkgs; [ last ];
+ buildCommand = ''
+ ln -s ${ref} ref.fa
+ mkdir $out
+ lastdb ${optionalString (flags != null) flags} $out/index ref.fa
+ '';
+}
diff --git a/tools/last.nix b/tools/last.nix
new file mode 100644
index 0000000..4e40a65
--- /dev/null
+++ b/tools/last.nix
@@ -0,0 +1,8 @@
+{ bionix }:
+
+with bionix;
+
+rec {
+ align = callBionixE ./last-align.nix;
+ index = callBionixE ./last-index.nix;
+}