Skip to content

Commit

Permalink
Installation improvement and doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
acormier authored and acormier committed Mar 3, 2016
1 parent 3e6130a commit 86bf208
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 69 deletions.
65 changes: 25 additions & 40 deletions IonWisecondor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
from ion.plugin import *
import os
import sys
Expand All @@ -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 = []
Expand All @@ -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
Expand All @@ -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())
Expand All @@ -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()
17 changes: 4 additions & 13 deletions about.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
<!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.
<h2>IonWisecondor Plugin</h2>
<p><b>WIthin-SamplE COpy Number aberration DetectOR</b></p>
<p>Detect fetal trisomies and smaller CNV's in a maternal plasma sample using whole-genome data.</p>
</body>
</html>
</html>
32 changes: 16 additions & 16 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 86bf208

Please sign in to comment.