diff options
author | Justin Bedo <cu@cua0.org> | 2019-01-10 11:47:05 +1100 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2019-01-10 11:47:05 +1100 |
commit | 5cb6f6001ea3aefd52ebaf42c1714343d51a8822 (patch) | |
tree | 34235ce75e24e5754946813c263ace635e1ea532 /tools | |
parent | 1b5e2b206d00967100e4ddf48c48ba0662bb0eb9 (diff) |
cnvkit: init
Diffstat (limited to 'tools')
-rw-r--r-- | tools/cnvkit-app.nix | 102 | ||||
-rw-r--r-- | tools/cnvkit-batch.nix | 41 | ||||
-rw-r--r-- | tools/cnvkit.nix | 8 |
3 files changed, 151 insertions, 0 deletions
diff --git a/tools/cnvkit-app.nix b/tools/cnvkit-app.nix new file mode 100644 index 0000000..d44c508 --- /dev/null +++ b/tools/cnvkit-app.nix @@ -0,0 +1,102 @@ +{ lib +, fetchurl +, rPackages +, rWrapper +, buildPythonPackage +, fetchPypi +, biopython +, six +, numpy +, scipy +, pandas +, matplotlib +, reportlab +, zlib +, bzip2 +, htslib +, libjpeg +, pkgconfig +, futures +}: + +let pyfaidx = buildPythonPackage rec { + pname = "pyfaidx"; + version = "0.5.3.1"; + + src = fetchPypi { + inherit pname version; + sha256 = "0mjbksbj9hh2cf0yjr951cjahhn0lg7p71kd3kvbnscqyxa44kfr"; + }; + + propagatedBuildInputs = [ six ]; + }; + + pysam = buildPythonPackage rec { + pname = "pysam"; + version = "0.14"; + + src = fetchPypi { + inherit pname version; + sha256 = "11snrwl5pn6knarf0c7zcpkhc7rijb6cfpw8sl3pdvnynj1fmj69"; + }; + + buildInputs = [ zlib ]; + + preConfigure = '' + export HTSLIB_MODE="external" + export HTSLIB_LIBRARY_DIR=${htslib}/lib + export HTSLIB_INCLUDE_DIR=${htslib}/include + ''; + + }; + + future = buildPythonPackage rec { + pname = "future"; + version = "0.16.0"; + + doCheck = false; + + src = fetchPypi { + inherit pname version; + sha256 = "1nzy1k4m9966sikp0qka7lirh8sqrsyainyf8rk97db7nwdfv773"; + }; + }; + + pillow = buildPythonPackage rec { + pname = "Pillow"; + version = "5.0.0"; + + doCheck = false; + + src = fetchPypi { + inherit pname version; + sha256 = "1fz1n1cq65dqdbiwy1cn8l21amqbzq18rdmmcr670ks24dn9vwhj"; + }; + + buildInputs = [ zlib libjpeg pkgconfig ]; + }; + + cghFLasso = rPackages.buildRPackage rec { + name = "cghFLasso-${version}"; + version = "0.2-1"; + src = fetchurl { + url = "https://cran.r-project.org/src/contrib/Archive/cghFLasso/cghFLasso_${version}.tar.gz"; + sha256 = "0b1hnjf9g0v47hbz0dy9m6jhcl1ky20yyhhmm8myng2sndcpjsbf"; + }; + }; + + cnvR = rWrapper.override { + packages = with rPackages; [ DNAcopy cghFLasso ]; + }; + +in buildPythonPackage rec { + pname = "CNVkit"; + version = "0.9.5"; + + src = fetchPypi { + inherit pname version; + sha256 = "1sa70bmnxj1lzp33pbj3axk6n77czswwj9cirimxh2qrn84i7vs3"; + }; + + propagatedBuildInputs = [ biopython numpy scipy pandas matplotlib reportlab pyfaidx pysam futures future pillow cnvR ]; +} diff --git a/tools/cnvkit-batch.nix b/tools/cnvkit-batch.nix new file mode 100644 index 0000000..6b69f1a --- /dev/null +++ b/tools/cnvkit-batch.nix @@ -0,0 +1,41 @@ +{bionix +,normals ? [] +,targets ? null +,annotations ? null +,flags ? null +,indexAttrs ? {}}: + +{normals ? normals, tumours}: + +with bionix; +with lib; +with types; + +let + getref = f: matchFiletype "cnvkit-batch" { bam = {ref, ...}: ref; } f; + refs = map getref normals ++ map getref tumours; + ref = head refs; + sorted = matchFileSorting "cnvkit-batch" { coord = _: true; }; +in + +assert (length (unique refs) == 1); +assert (all sorted (normals ++ tumours)); + +stage { + name = "cnvkit"; + buildInputs = [ cnvkit.app ]; + buildCommand = '' + ln -s ${ref} ref.fa + ln -s ${samtools.faidx indexAttrs ref} ref.fa.fai + cnvkit.py batch ${concatStringsSep " " tumours} \ + ${optionalString (normals != []) ("-n " + concatStringsSep " " normals)} \ + ${optionalString (annotations != null) annotations} \ + ${if targets != null then "--targets ${targets}" else "-m wgs"} \ + -f ref.fa \ + -p $NIX_BUILD_CORES \ + -d $TMPDIR \ + ${optionalString (flags != null) flags} + mkdir $out + cp * $out + ''; +} diff --git a/tools/cnvkit.nix b/tools/cnvkit.nix new file mode 100644 index 0000000..610b18c --- /dev/null +++ b/tools/cnvkit.nix @@ -0,0 +1,8 @@ +{bionix}: + +with bionix; + +{ +app = lib.callPackageWith (pkgs // pkgs.pythonPackages) ./cnvkit-app.nix {}; + callCNV = callBionixE ./cnvkit-batch.nix; +} |