diff options
author | Justin Bedo <cu@cua0.org> | 2020-11-16 11:59:41 +1100 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2020-11-16 11:59:41 +1100 |
commit | 05da61d166d7d4702001510a5eaa1935102d24f0 (patch) | |
tree | c75febaeeaaa79e1bd109ec28d717d13a5b43dd5 | |
parent | a50933a96096d53c341b30d487362d0913977574 (diff) |
sambamba: init
-rw-r--r-- | default.nix | 1 | ||||
-rw-r--r-- | tools/sambamba-generic.nix | 28 | ||||
-rw-r--r-- | tools/sambamba-sort.nix | 29 | ||||
-rw-r--r-- | tools/sambamba.nix | 15 |
4 files changed, 73 insertions, 0 deletions
diff --git a/default.nix b/default.nix index b04fdc2..32aa232 100644 --- a/default.nix +++ b/default.nix @@ -33,6 +33,7 @@ let platypus = callBionix ./tools/platypus.nix {}; ref = callBionix ./lib/references.nix {}; samtools = callBionix ./tools/samtools.nix {}; + sambamba = callBionix ./tools/sambamba.nix {}; snap = callBionix ./tools/snap.nix {}; snpeff = callBionix ./tools/snpeff.nix {}; strelka = callBionix ./tools/strelka.nix {}; diff --git a/tools/sambamba-generic.nix b/tools/sambamba-generic.nix new file mode 100644 index 0000000..a6be65c --- /dev/null +++ b/tools/sambamba-generic.nix @@ -0,0 +1,28 @@ +{ bionix +, flags ? null +, tool +, region ? null +}: + +input: + +with bionix; +with lib; + +let + inherit (bionix.types) matchFiletype coordSort matchFileSorting; +in + +assert (matchFiletype "sambamba-${tool}" { bam = _: true; } input); + +stage { + name = "sambamba-${tool}"; + buildInputs = [ pkgs.sambamba ]; + buildCommand = '' + sambamba ${tool} -t $NIX_BUILD_CORES \ + ${optionalString (flags != null) flags} \ + ${if tool == "merge" then "$out ${concatStringsSep " " input}" else if tool == "slice" then "${input} ${region} > $out" else if tool == "flagstat" then "${input} > $out" else "${input} $out"} + ''; + passthru.filetype = if tool == "flagstat" || tool == "index" then null else if tool == "merge" then (head input).filetype else input.filetype; + passthru.multicore = true; +} diff --git a/tools/sambamba-sort.nix b/tools/sambamba-sort.nix new file mode 100644 index 0000000..efdd261 --- /dev/null +++ b/tools/sambamba-sort.nix @@ -0,0 +1,29 @@ +{ bionix +, nameSort ? false +, flags ? null +}: + +input: + +with bionix; +with lib; + +let + inherit (bionix.types) matchFiletype coordSort matchFileSorting; +in + +assert (matchFiletype "sambamba-sort" { bam = _: true; } input); + +stage { + name = "sambamba-sort"; + buildInputs = [ pkgs.sambamba ]; + buildCommand = '' + sambamba sort -t $NIX_BUILD_CORES \ + ${optionalString nameSort "-n"} \ + ${optionalString (flags != null) flags} \ + -o $out \ + ${input} + ''; + passthru.filetype = if nameSort then bionix.types.nameSort input.filetype else coordSort input.filetype; + passthru.multicore = true; +} diff --git a/tools/sambamba.nix b/tools/sambamba.nix new file mode 100644 index 0000000..552e6e3 --- /dev/null +++ b/tools/sambamba.nix @@ -0,0 +1,15 @@ +{ bionix }: + +with bionix; + +let + gen = callBionixE ./sambamba-generic.nix; + +in { + sort = callBionixE ./sambamba-sort.nix; + index = def gen {tool = "index"; }; + merge = def gen {tool = "merge"; }; + slice = def gen {tool = "slice"; }; + flagstat = def gen {tool = "flagstat"; }; + markdup = def gen {tool = "markdup"; }; +} |