diff options
author | l-d-s <distefano.l@wehi.edu.au> | 2018-12-11 14:17:22 +1100 |
---|---|---|
committer | l-d-s <distefano.l@wehi.edu.au> | 2018-12-11 14:17:22 +1100 |
commit | f0357e09b8c473b55d22c4632692fcc79021570d (patch) | |
tree | 9c92993d1f0c788a162159e6440ea958eae3e35d /tools/bowtie-align.nix | |
parent | 6742864b8f92f5d7d56da4901486b7e83a271e23 (diff) | |
parent | 10bdecf6c1338d7f531ddf7b41da14dfe4a4ac33 (diff) |
Merge branch 'master' of https://github.com/PapenfussLab/bionix
Diffstat (limited to 'tools/bowtie-align.nix')
-rw-r--r-- | tools/bowtie-align.nix | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/bowtie-align.nix b/tools/bowtie-align.nix new file mode 100644 index 0000000..456747a --- /dev/null +++ b/tools/bowtie-align.nix @@ -0,0 +1,36 @@ +{ bionix +, nixpkgs +, ref +, bamOutput ? true +, flags ? null +, indexAttrs ? {} +}: + +{ input1 +, input2 ? null +}: + +with nixpkgs; +with lib; +with bionix.types; +with bionix.compression; + +let + fa = f: matchFiletype "bowtie2-ref" { fa = _: f; } f; + fq = f: matchFiletype "bowtie2-input" { fq = _: f; gz = matchFiletype' "bowtie2-input" { fq = _: f; }; } f; + +in stdenv.mkDerivation { + name = "bowtie2-align"; + buildInputs = [ bowtie2 bc ] ++ optional bamOutput samtools; + buildCommand = '' + cores=$(echo $NIX_BUILD_CORES ${optionalString bamOutput "- 1"} | bc) + if [[ $cores -lt 1 ]] ; then + cores=1 + fi + bowtie2 -x ${bionix.bowtie.index indexAttrs ref}/ref ${optionalString (flags != null) flags} --threads $cores \ + ${if input2 != null then "-1 " + fq input1 + " -2 " + fq input2 else "-U " + fq input1} \ + ${optionalString bamOutput "| samtools view -b"} \ + > $out + ''; + passthru.filetype = if bamOutput then filetype.bam {ref = ref; sorting = sort.name {};} else filetype.sam {ref = ref; sorting = sort.name {};}; +} |