Skip to content

Commit

Permalink
Add color for results zscore ! Add package and doc html! Need to fill it
Browse files Browse the repository at this point in the history
  • Loading branch information
dridk committed Apr 16, 2015
1 parent f11fb91 commit 3e6130a
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 38 deletions.
70 changes: 42 additions & 28 deletions IonWisecondor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import subprocess
from multiprocessing.pool import Pool
import glob

import pickle
from django.template import Context, Template
from django.conf import settings
settings.configure()
Expand All @@ -19,29 +19,18 @@ class IonWisecondor(IonPlugin):
envDict = dict(os.environ)




def launch(self, data=None):
print("Launch started...")

#For debugging...
if "RESULTS_DIR" not in os.environ:
self.outputDir = "/home/ionadmin/result_dir"
self.rootDir="/home/ionadmin/root_dir"
else:
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



print(os.environ["PLUGINCONFIG__COUNT"])



#=================Set files dictionnary to send to html report template

# ================ 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

# ================ GET INSTANCE PARAMETERS AND STORE THEM IN A LIST
fileCount = int(os.environ["PLUGINCONFIG__COUNT"])
files = []
for i in range(fileCount):
Expand All @@ -55,39 +44,64 @@ def launch(self, data=None):
item["barcode"] = barcode
item["key"] = key
item["path"] = path
# item["name"] = os.path.splitext(os.path.basename(path))[0]
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)

# ====================Start Computation

# ================ 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)
print(cmd)
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"

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 HTML






# ================ GENERATE RESULTS HTML FROM DJANGO TEMPLATE SYSTEM

source = open(os.environ["RUNINFO__PLUGIN__PATH"] + "/block_template.html", "r").read()
t = Template(source)
# Pass files arguments to the template
c = Context({'files': files})
html = t.render(c)

# Output html render
f = open(self.outputDir+"/resultat_block.html","w")
f.write(html)
f.close()


def scoreOf(self, testedFile, chrom):
with open(testedFile) as file:
data = pickle.loads(file.read())
zScores = data["zSmoothDict"][chrom]
score = -1
try:
score = sum(zScores) / len(zScores)
except :
score = -1

return round(score,2)




Expand Down
17 changes: 17 additions & 0 deletions about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<body>
<h2>Run Transfer Plugin</h2>
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.
<ul>
<li>1.wells
<li>analysis.bfmask.bin
<li>analysis.bfmask.stat
<li>average_nuke_trace*.txt
<li>Bead_density_*.png
</ul>
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.
</body>
</html>
46 changes: 39 additions & 7 deletions block_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,48 @@
<link href="/site_media/resources/kendo/styles/kendo.common.min.css" rel="stylesheet">
<link href="/site_media/resources/less/kendo.tb.min.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="/site_media/resources/styles/tb-styles.min.css">
<script type="text/javascript" src="/site_media/jquery/js/jquery-1.7.2.min.js"></script>

<style type="text/css">
p, ul{font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;}
.zebra { background-color: #E1EFFA;}
.table_hover{ color: #009; background-color: #6DBCEE;}
.zebra { background-color: #E1EFFA;}
.table_hover {color: #009;background-color: #6DBCEE;}
.k-grid td {text-align: center;}

.green {color:#39B54A;}
.orange {color:#F7941D;}
.red {color:#ED1C24;}

.k-grid td {
text-align: center;
}

</style>
</head>

<body style="background:white">

<script>
$( document ).ready(function() {

$('.zscore').each(function() {
var zscore =parseFloat($(this).text()) ;
console.debug(zscore);

if (zscore < 1.96)
$(this).addClass('green');

if (zscore >= 1.96 && zscore < 1.96 * 2)
$(this).addClass('orange');

if (zscore >= 1.96*2)
$(this).addClass('red');

});

});



</script>


<table>
<tr><td>Wisecondor version 0.1</td> <td>0.1</td></tr>
Expand All @@ -44,7 +71,10 @@
<tr>
<th><span class="help" title="Sample name">Barcode Name</span></th>
<th><span class="help" title="Number of called variants">Sample</span></th>
<th><span class="help" title="Results">Results</span></th>
<th><span class="help" title="Chrom21">chrom 21</span></th>
<th><span class="help" title="Chrom18">chrom 18</span></th>
<th><span class="help" title="Chrom13">chrom 13</span></th>

<th><span class="help" title="Download links">Download Links</span></th>

</tr>
Expand All @@ -59,7 +89,9 @@

<td>{{i.sample}}</td>

<td>sdfsdfsdfsdf</td>
<td class="zscore">{{i.s21}}</td>
<td class="zscore">{{i.s18}}</td>
<td class="zscore">{{i.s13}}</td>

<td style="text-align:center"><a class="btn" href="{{ i.pickle }}">PICKLE</a>
<a class="btn" href="{{ i.tested }}">TESTED</a>
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"icon":"etc/icon.png","documentation":"etc/IonWisecondor.pdf","screenshot":"etc/screenshot.png"}

8 changes: 5 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash
file_path=$1
dest_path=$2
plugin_path=$3


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
filename=`basename $file_path`
basename=${filename%.*}

Expand Down

0 comments on commit 3e6130a

Please sign in to comment.