aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2022-01-12 11:08:26 +1100
committerJustin Bedo <cu@cua0.org>2022-01-12 11:08:26 +1100
commit66f5dfcfab677acc429c2b346e15aa54d48dfedd (patch)
treebff46a5b9835d45fb402209286d0abe16cbf5549
parentfc09e84a593aaedc1a23b17f0b1d8dda2df606df (diff)
gridss.filterSomatic: missing file
-rw-r--r--tools/gridss-somatic-filter.nix85
1 files changed, 85 insertions, 0 deletions
diff --git a/tools/gridss-somatic-filter.nix b/tools/gridss-somatic-filter.nix
new file mode 100644
index 0000000..2e3f5ea
--- /dev/null
+++ b/tools/gridss-somatic-filter.nix
@@ -0,0 +1,85 @@
+{ bionix, normalName, genomeVersion ? "hg38" }:
+vcf:
+
+with bionix;
+with pkgs;
+
+let
+ refMap = with rPackages; {
+ hg38 = BSgenome_Hsapiens_UCSC_hg38;
+ hg19 = BSgenome_Hsapiens_UCSC_hg19;
+ };
+
+ renv = rWrapper.override {
+ packages = with rPackages; [
+ (refMap."${genomeVersion}" or (abort "unsupported reference"))
+ Biobase
+ BiocGenerics
+ Biostrings
+ DelayedArray
+ IRanges
+ S4Vectors
+ StructuralVariantAnnotation
+ VariantAnnotation
+ XVector
+ argparser
+ ggplot2
+ matrixStats
+ readr
+ rtracklayer
+ stringdist
+ stringr
+ testthat
+ tidyverse
+ ];
+ };
+
+ script = stdenvNoCC.mkDerivation {
+ name = "gridss-somatic-filtering-scripts";
+ src = fetchFromGitHub {
+ owner = "PapenfussLab";
+ repo = "gridss";
+ rev = "a6b230a78179869c0210dc878490811be813d2fb";
+ sha256 = "sha256-b+b6BEvjZbKYR+pJ/Z8yQpcZpairpSUoMHtRRTuRUls=";
+
+ };
+
+ doBuild = false;
+ nativeBuildInputs = [ makeWrapper ];
+
+ installPhase = ''
+ mkdir -p $out/libexec/gridss
+ cp scripts/{gridss.config.R,libgridss.R,gridss_somatic_filter} $out/libexec/gridss
+ mkdir -p $out/bin
+ makeWrapper ${renv}/bin/Rscript $out/bin/gridss_somatic_filter \
+ --add-flags $out/libexec/gridss/gridss_somatic_filter \
+ --add-flags "--ref BSgenome.Hsapiens.UCSC.${genomeVersion}" \
+ --add-flags "--scriptdir $out/libexec/gridss"
+ '';
+ };
+
+ findNormal = writeText "find-normal.awk" ''
+ /^#C/{
+ for(i = 10; i <= NF && $i != "${normalName}"; i++);
+ if(i > NF){
+ print "findNormal: could not match name" > /dev/stderr
+ exit(1)
+ }
+ printf("%s", i - 9)
+ exit(0)
+ }
+ '';
+
+in
+stage {
+ name = "gridss-somatic";
+ buildCommand = ''
+ NORM=$(awk -f ${findNormal} ${vcf})
+ ln -s ${vcf} in.vcf
+ ${script}/bin/gridss_somatic_filter \
+ --output ./out \
+ --input in.vcf \
+ --normalordinal $NORM
+ gunzip < out.bgz > $out
+ '';
+}