From 86bf208929da439cb68f4d97bb7aae641d876c2c Mon Sep 17 00:00:00 2001 From: acormier Date: Thu, 3 Mar 2016 11:01:13 +0100 Subject: [PATCH] Installation improvement and doc update --- IonWisecondor.py | 65 +++++++++++++++++++----------------------------- about.html | 17 +++---------- run.sh | 32 ++++++++++++------------ 3 files changed, 45 insertions(+), 69 deletions(-) diff --git a/IonWisecondor.py b/IonWisecondor.py index 4be7b5d..760fb63 100644 --- a/IonWisecondor.py +++ b/IonWisecondor.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python from ion.plugin import * import os import sys @@ -9,27 +9,25 @@ import pickle from django.template import Context, Template from django.conf import settings -settings.configure() - class IonWisecondor(IonPlugin): - version = "0.1" + """ IonWisecondor """ + version = "1.0.1" allow_autorun = False author = "sacha@labsquare.org" envDict = dict(os.environ) - def launch(self, data=None): print("Launch started...") - - + # ================ GET GLOBAL PATH self.outputDir = os.environ["RESULTS_DIR"]; # The wisecondor results directory self.analysisDir = os.environ["ANALYSIS_DIR"]; self.pluginDir = os.environ["PLUGIN_PATH"]; self.urlRoot = os.environ["URL_ROOT"] # /output/Home/X/ self.urlPlugin = os.environ["TSP_URLPATH_PLUGIN_DIR"] # /output/Home/X/plugin_out/IonWisecondor - + self.date = os.environ["TSP_ANALYSIS_DATE"] + # ================ GET INSTANCE PARAMETERS AND STORE THEM IN A LIST fileCount = int(os.environ["PLUGINCONFIG__COUNT"]) files = [] @@ -38,47 +36,40 @@ def launch(self, data=None): key = "PLUGINCONFIG__ITEMS__"+str(i) barcode = os.environ[key+"__BARCODE"] sample = os.environ[key+"__SAMPLE"] - path = self.analysisDir +"/" + barcode + "_rawlib.bam" - + input = self.analysisDir +"/" + barcode + "_rawlib.bam" + item["sample"] = sample item["barcode"] = barcode - item["key"] = key - item["path"] = path - item["pickle"] = self.urlPlugin + "/" + barcode +"_rawlib.pickle" - item["gcc"] = self.urlPlugin + "/" + barcode +"_rawlib.gcc" - item["tested"] = self.urlPlugin + "/" + barcode +"_rawlib.tested" - item["pdf"] = self.urlPlugin + "/" + barcode +"_rawlib.pdf" - - files.append(item) - + item["key"] = key + item["input"] = input + item["pickle"] = self.urlPlugin + "/" + sample + "_" + self.date +".pickle" + item["gcc"] = self.urlPlugin + "/" + sample + "_" + self.date +".gcc" + item["tested"] = self.urlPlugin + "/" + sample + "_" + self.date +".tested" + item["pdf"] = self.urlPlugin + "/" + sample + "_" + self.date +".pdf" + + files.append(item) + # ================ LOOP ON EACH FILES AND START COMPUTATION for item in files: # Launch run.sh - cmd = self.pluginDir+"/run.sh %s %s %s" % (item["path"], self.outputDir, self.pluginDir) + cmd = self.pluginDir+"/run.sh %s %s %s %s %s" % (item["input"], self.outputDir, self.pluginDir, item["sample"], self.date) p1 = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) stdout, stderr = p1.communicate() # Check error if p1.returncode == 0: - # Compute average of zSmoothDict from barcode_rawlib.tested - - filePath = os.environ["RESULTS_DIR"] + "/" + item["barcode"] + "_rawlib.tested" - + # Compute average of zSmoothDict from sample_rawlib.tested + filePath = os.environ["RESULTS_DIR"] + "/" + item["sample"] + "_" + self.date + ".tested" + item["s21"] = self.scoreOf(filePath, "21") item["s18"] = self.scoreOf(filePath, "18") item["s13"] = self.scoreOf(filePath, "13") - + print(stdout) else: raise Exception(stderr) - - - - - - - + # ================ GENERATE RESULTS HTML FROM DJANGO TEMPLATE SYSTEM - + settings.configure() source = open(os.environ["RUNINFO__PLUGIN__PATH"] + "/block_template.html", "r").read() t = Template(source) # Pass files arguments to the template @@ -89,7 +80,6 @@ def launch(self, data=None): f.write(html) f.close() - def scoreOf(self, testedFile, chrom): with open(testedFile) as file: data = pickle.loads(file.read()) @@ -99,12 +89,7 @@ def scoreOf(self, testedFile, chrom): score = sum(zScores) / len(zScores) except : score = -1 - return round(score,2) - - - if __name__ == "__main__": - PluginCLI(IonWisecondor()) - + PluginCLI() diff --git a/about.html b/about.html index 9a2aeb3..798a3de 100644 --- a/about.html +++ b/about.html @@ -1,17 +1,8 @@ -

Run Transfer Plugin

-This plugin transfers signal processing output files to another Torrent Server and launches a re-analysis -of the dataset on that server. The files that are transferred are Basecaller Input Files. - -Proton datasets will transfer block-level files when the thumbnail option is unchecked. When thumbnail option is checked, -only the thumbnail files will be transferred. +

IonWisecondor Plugin

+

WIthin-SamplE COpy Number aberration DetectOR

+

Detect fetal trisomies and smaller CNV's in a maternal plasma sample using whole-genome data.

- \ No newline at end of file + diff --git a/run.sh b/run.sh index 8b07686..0cf634e 100755 --- a/run.sh +++ b/run.sh @@ -4,30 +4,30 @@ file_path=$1 # BAM file path which you want to test dest_path=$2 # Destination folder where results will be stored plugin_path=$3 # wisecondor parent PATH to run script from anywhere +sample_name=$4 # Sample name +run_date=$5 # date of the run sequencing filename=`basename $file_path` basename=${filename%.*} - - # echo $filename TO $basename.pickle -echo pickle > $2/$basename.pickle -samtools view $file_path|python $3/wisecondor/consam.py $2/$basename.pickle +echo pickle > $2/$sample_name.pickle +samtools view $file_path | python $3/wisecondor/consam.py $2/$sample_name.pickle # echo $basename.pickle TO $basename.gcc -echo gcc > $2/$basename.gcc -python $3/wisecondor/gcc.py $2/$basename.pickle $3/data/hg19.gccount $2/$basename.gcc +echo gcc > $2/$sample_name.gcc +python $3/wisecondor/gcc.py $2/$sample_name.pickle $3/data/hg19.gccount $2/$sample_name.gcc # echo $basename.gcc TO $basename.tested -echo tested > $2/$basename.tested -python $3/wisecondor/test.py $2/$basename.gcc $3/data/reftable $2/$basename.tested +echo tested > $2/$sample_name.tested +python $3/wisecondor/test.py $2/$sample_name.gcc $3/data/reftable $2/$sample_name.tested # echo $basename.tested TO $basename.pdf -echo pdf > $2/$basename.pdf -python $3/wisecondor/plot.py $2/$basename.tested $2/$basename - - - - - - +echo pdf > $2/$sample_name.pdf +python $3/wisecondor/plot.py $2/$sample_name.tested $2/$sample_name + +#rename output file to add the run date +mv $2/$sample_name.pickle $2/$sample_name"_"$run_date.pickle +mv $2/$sample_name.gcc $2/$sample_name"_"$run_date.gcc +mv $2/$sample_name.tested $2/$sample_name"_"$run_date.tested +mv $2/$sample_name.pdf $2/$sample_name"_"$run_date.pdf \ No newline at end of file