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 @@
-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 +