diff wrapper.sh @ 0:c5ac9a871b26 draft

Uploaded
author davidvanzessen
date Thu, 19 Jun 2014 10:39:41 -0400
parents
children c0110597898e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wrapper.sh	Thu Jun 19 10:39:41 2014 -0400
@@ -0,0 +1,132 @@
+#!/bin/bash
+
+inputFile=$1
+outputFile=$2
+outputDir=$3
+
+dir="$(cd "$(dirname "$0")" && pwd)"
+mkdir $outputDir
+
+Rscript --verbose $dir/RScript.r $inputFile $outputDir 2>&1
+cp $dir/jquery-1.11.0.min.js $outputDir
+cp $dir/script.js $outputDir
+cp $dir/style.css $outputDir
+cp $dir/tabber.js $outputDir
+
+echo "<html><center><h1><a href='index.html'>Click here for the results</a></h1>Tip: Open it in a new tab (middle mouse button or right mouse button -> 'open in new tab' on the link above)</center></html>" > $outputFile
+
+cd $outputDir
+
+html="index.html"
+echo "<html><head><title>Result</title>" > $html
+echo "<script type='text/javascript' src='jquery-1.11.0.min.js'></script>" >> $html
+echo "<script type='text/javascript' src='tabber.js'></script>" >> $html
+echo "<script type='text/javascript' src='script.js'></script>" >> $html
+echo "<script type='text/javascript' src='jquery.tablesorter.min.js'></script>" >> $html
+echo "<link rel='stylesheet' type='text/css' href='style.css'></head>" >> $html
+echo "<div id='hidden_div' style='display: none;'></div>" >> $html
+echo "<div class='tabber'>" >> $html
+while read patient sample1 sample2
+do
+	echo "$patient"
+	oldLocus=""
+	sample1="$(echo ${sample1} | tr -d '\r' | tr -d '\n')"
+	sample2="$(echo ${sample2} | tr -d '\r' | tr -d '\n')"
+	tail -n+2 ${patient}_freq.txt | sed "s/>//" > tmp.txt
+	echo "<div class='tabbertab' title='$patient'>" >> $html
+	echo "<div class='tabber'>" >> $html
+	echo "<div class='tabbertab' title='Data frequency'>" >> $html
+	echo "<table><tr><td style='vertical-align:top;'>" >> $html
+	echo "<table border = 1 class='result_table summary_table' id='summary_table_${patient}_freq'>" >> $html
+	echo "<thead><th>Ig/TCR gene rearrangement type</th><th>Proximal gene segment</th><th>Distal gene segment</th><th>Cut off value</th><th>Number of sequences ${patient}_Both</th><th>Number of sequences_$sample1</th><th>Read Count $sample1</th><th>Number of sequences_$sample2</th><th>Read Count $sample2</th><th>Sum number of sequences $patient</th><th>Percentage of sequences ${patient}_both</th></thead>" >> $html
+	echo "<tbody>" >> $html
+	while read locus j_segment v_segment cut_off_value both one read_count1 two read_count2 sum percent
+	do
+		if [ "$locus" != "$oldLocus" ] ; then
+			echo "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr>" >> $html
+			echo "<tr><td><b>$locus</b></td>" >> $html
+		else
+			echo "<td></td>" >> $html
+		fi
+		echo "<td>$v_segment</td>" >> $html
+		echo "<td>$j_segment</td>" >> $html
+		echo "<td>>$cut_off_value</td>" >> $html 
+		if [ "$both" != "0" ] ; then
+			echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$both</td>" >> $html
+		else
+			echo "<td>$both</td>" >> $html
+		fi
+		if [ "$one" != "0" ] && [ "$cut_off_value" != "0" ] ; then
+			echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$one</td>" >> $html
+		else
+			echo "<td>$one</td>" >> $html
+		fi
+		echo "<td>$read_count1</td>" >> $html
+		if [ "$two" != "0" ] && [ "$cut_off_value" != "0" ] ; then
+			echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$two</td>" >> $html
+		else
+			echo "<td>$two</td>" >> $html
+		fi
+		echo "<td>$read_count2</td>" >> $html
+		echo "<td>$sum</td>" >> $html
+		echo "<td>${percent}&#37;</td>" >> $html
+		echo "</tr>" >> $html
+		oldLocus="$locus"
+	done < tmp.txt
+	echo "</tbody></table>" >> $html
+	echo "</td><td style='vertical-align:top;'><div id='result_div_${patient}_freq'></div></td></tr></table></div>" >> $html
+	echo "<div class='tabbertab' title='Graphs frequency'>" >> $html
+	echo "<a href='${patient}_freq.png'><img src='${patient}_freq.png' width='1280' height='720' /></a><br />" >> $html
+	echo "<a href='${patient}_freq_both.png'><img src='${patient}_freq_both.png' width='1280' height='720' /></a><br />" >> $html
+	echo "<a href='${patient}_percent_freq.png'><img src='${patient}_percent_freq.png' width='1280' height='720' /></a></div>" >> $html
+	
+	tail -n+2 ${patient}_reads.txt | sed "s/>//" > tmp.txt
+	echo "<div class='tabbertab' title='Data reads'>" >> $html
+	echo "<table><tr><td style='vertical-align:top;'>" >> $html
+	echo "<table border = 1 class='result_table summary_table' id='summary_table_${patient}_reads'>" >> $html
+	echo "<thead><th>Ig/TCR gene rearrangement type</th><th>Proximal gene segment</th><th>Distal gene segment</th><th>Cut off value</th><th>Number of sequences ${patient}_Both</th><th>Number of sequences_$sample1</th><th>Read Count $sample1</th><th>Number of sequences_$sample2</th><th>Read Count $sample2</th><th>Sum number of sequences $patient</th><th>Percentage of sequences ${patient}_both</th></thead>" >> $html
+	echo "<tbody>" >> $html
+	while read locus j_segment v_segment cut_off_value both one read_count1 two read_count2 sum percent
+	do
+		if [ "$locus" != "$oldLocus" ] ; then
+			echo "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr>" >> $html
+			echo "<tr><td><b>$locus</b></td>" >> $html
+		else
+			echo "<td></td>" >> $html
+		fi
+		echo "<td>$v_segment</td>" >> $html
+		echo "<td>$j_segment</td>" >> $html
+		echo "<td>>$cut_off_value</td>" >> $html 
+		if [ "$both" != "0" ] ; then
+			echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${sample1}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$both</td>" >> $html
+		else
+			echo "<td>$both</td>" >> $html
+		fi
+		if [ "$one" != "0" ] && [ "$cut_off_value" != "0" ] ; then
+			echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$one</td>" >> $html
+		else
+			echo "<td>$one</td>" >> $html
+		fi
+		echo "<td>$read_count1</td>" >> $html
+		if [ "$two" != "0" ] && [ "$cut_off_value" != "0" ] ; then
+			echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$two</td>" >> $html
+		else
+			echo "<td>$two</td>" >> $html
+		fi
+		echo "<td>$read_count2</td>" >> $html
+		echo "<td>$sum</td>" >> $html
+		echo "<td>${percent}&#37;</td>" >> $html
+		echo "</tr>" >> $html
+		oldLocus="$locus"
+	done < tmp.txt
+	echo "</tbody></table>" >> $html
+	echo "</td><td style='vertical-align:top;'><div id='result_div_${patient}_reads'></div></td></tr></table></div>" >> $html
+	echo "<div class='tabbertab' title='Graphs reads'>" >> $html
+	echo "<a href='${patient}_reads.png'><img src='${patient}_reads.png' width='1280' height='720' /></a><br />" >> $html
+	echo "<a href='${patient}_reads_both.png'><img src='${patient}_reads_both.png' width='1280' height='720' /></a><br />" >> $html
+	echo "<a href='${patient}_percent_reads.png'><img src='${patient}_percent_reads.png' width='1280' height='720' /></a></div>" >> $html
+	echo "</div>" >> $html	
+	echo "</div>" >> $html
+done < patients.txt
+echo "</div></html>" >> $html
+rm tmp.txt