0
|
1 #!/bin/bash
|
|
2
|
|
3 inputFile=$1
|
|
4 outputFile=$2
|
|
5 outputDir=$3
|
|
6
|
|
7 dir="$(cd "$(dirname "$0")" && pwd)"
|
|
8 mkdir $outputDir
|
|
9
|
|
10 Rscript --verbose $dir/RScript.r $inputFile $outputDir 2>&1
|
|
11 cp $dir/jquery-1.11.0.min.js $outputDir
|
|
12 cp $dir/script.js $outputDir
|
|
13 cp $dir/style.css $outputDir
|
|
14 cp $dir/tabber.js $outputDir
|
|
15
|
|
16 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
|
|
17
|
|
18 cd $outputDir
|
|
19
|
|
20 html="index.html"
|
|
21 echo "<html><head><title>Result</title>" > $html
|
|
22 echo "<script type='text/javascript' src='jquery-1.11.0.min.js'></script>" >> $html
|
|
23 echo "<script type='text/javascript' src='tabber.js'></script>" >> $html
|
|
24 echo "<script type='text/javascript' src='script.js'></script>" >> $html
|
|
25 echo "<script type='text/javascript' src='jquery.tablesorter.min.js'></script>" >> $html
|
|
26 echo "<link rel='stylesheet' type='text/css' href='style.css'></head>" >> $html
|
|
27 echo "<div id='hidden_div' style='display: none;'></div>" >> $html
|
|
28 echo "<div class='tabber'>" >> $html
|
|
29 while read patient sample1 sample2
|
|
30 do
|
|
31 echo "$patient"
|
|
32 oldLocus=""
|
|
33 sample1="$(echo ${sample1} | tr -d '\r' | tr -d '\n')"
|
|
34 sample2="$(echo ${sample2} | tr -d '\r' | tr -d '\n')"
|
|
35 tail -n+2 ${patient}_freq.txt | sed "s/>//" > tmp.txt
|
|
36 echo "<div class='tabbertab' title='$patient'>" >> $html
|
|
37 echo "<div class='tabber'>" >> $html
|
|
38 echo "<div class='tabbertab' title='Data frequency'>" >> $html
|
|
39 echo "<table><tr><td style='vertical-align:top;'>" >> $html
|
|
40 echo "<table border = 1 class='result_table summary_table' id='summary_table_${patient}_freq'>" >> $html
|
2
|
41 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>Normalized Read Count $sample1</th><th>Number of sequences_$sample2</th><th>Normalized Read Count $sample2</th><th>Sum number of sequences $patient</th><th>Percentage of sequences ${patient}_both</th></thead>" >> $html
|
0
|
42 echo "<tbody>" >> $html
|
2
|
43 readsumtable="<table class='result_table summary_table'><thead><tr><th>Ig/TCR gene rearrangement type</th><th>Proximal gene segment</th><th>Distal gene segment</th><th>Total normalized read count for $sample1</th><th>Total normalized read count for $sample2</th></tr></thead>"
|
|
44 while read locus j_segment v_segment cut_off_value both one read_count1 two read_count2 sum percent locusreadsum1 locusreadsum2
|
0
|
45 do
|
|
46 if [ "$locus" != "$oldLocus" ] ; then
|
|
47 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
|
|
48 echo "<tr><td><b>$locus</b></td>" >> $html
|
2
|
49 readsumtable="${readsumtable}<tr><td>$locus</td><td>$v_segment</td><td>$j_segment</td><td>$locusreadsum1</td><td>$locusreadsum2</td></tr>"
|
0
|
50 else
|
|
51 echo "<td></td>" >> $html
|
|
52 fi
|
|
53 echo "<td>$v_segment</td>" >> $html
|
|
54 echo "<td>$j_segment</td>" >> $html
|
|
55 echo "<td>>$cut_off_value</td>" >> $html
|
|
56 if [ "$both" != "0" ] ; then
|
|
57 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$both</td>" >> $html
|
|
58 else
|
|
59 echo "<td>$both</td>" >> $html
|
|
60 fi
|
|
61 if [ "$one" != "0" ] && [ "$cut_off_value" != "0" ] ; then
|
|
62 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$one</td>" >> $html
|
|
63 else
|
|
64 echo "<td>$one</td>" >> $html
|
|
65 fi
|
|
66 echo "<td>$read_count1</td>" >> $html
|
|
67 if [ "$two" != "0" ] && [ "$cut_off_value" != "0" ] ; then
|
|
68 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$two</td>" >> $html
|
|
69 else
|
|
70 echo "<td>$two</td>" >> $html
|
|
71 fi
|
|
72 echo "<td>$read_count2</td>" >> $html
|
|
73 echo "<td>$sum</td>" >> $html
|
|
74 echo "<td>${percent}%</td>" >> $html
|
|
75 echo "</tr>" >> $html
|
2
|
76 oldLocus="$locus"
|
0
|
77 done < tmp.txt
|
|
78 echo "</tbody></table>" >> $html
|
2
|
79 echo "</td><td style='vertical-align:top;'><div id='result_div_${patient}_freq'></div></td></tr></table>" >> $html
|
|
80 echo "${readsumtable}</table></div>" >> $html
|
0
|
81 echo "<div class='tabbertab' title='Graphs frequency'>" >> $html
|
|
82 echo "<a href='${patient}_freq.png'><img src='${patient}_freq.png' width='1280' height='720' /></a><br />" >> $html
|
|
83 echo "<a href='${patient}_freq_both.png'><img src='${patient}_freq_both.png' width='1280' height='720' /></a><br />" >> $html
|
|
84 echo "<a href='${patient}_percent_freq.png'><img src='${patient}_percent_freq.png' width='1280' height='720' /></a></div>" >> $html
|
|
85
|
|
86 tail -n+2 ${patient}_reads.txt | sed "s/>//" > tmp.txt
|
|
87 echo "<div class='tabbertab' title='Data reads'>" >> $html
|
|
88 echo "<table><tr><td style='vertical-align:top;'>" >> $html
|
|
89 echo "<table border = 1 class='result_table summary_table' id='summary_table_${patient}_reads'>" >> $html
|
|
90 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
|
|
91 echo "<tbody>" >> $html
|
2
|
92 readsumtable="<table class='result_table summary_table'><thead><tr><th>Ig/TCR gene rearrangement type</th><th>Proximal gene segment</th><th>Distal gene segment</th><th>Total normalized read count for $sample1</th><th>Total normalized read count for $sample2</th></tr></thead>"
|
|
93 while read locus j_segment v_segment cut_off_value both one read_count1 two read_count2 sum percent locusreadsum1 locusreadsum2
|
0
|
94 do
|
|
95 if [ "$locus" != "$oldLocus" ] ; then
|
|
96 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
|
|
97 echo "<tr><td><b>$locus</b></td>" >> $html
|
2
|
98 readsumtable="${readsumtable}<tr><td>$locus</td><td>$v_segment</td><td>$j_segment</td><td>$locusreadsum1</td><td>$locusreadsum2</td></tr>"
|
0
|
99 else
|
|
100 echo "<td></td>" >> $html
|
|
101 fi
|
|
102 echo "<td>$v_segment</td>" >> $html
|
|
103 echo "<td>$j_segment</td>" >> $html
|
|
104 echo "<td>>$cut_off_value</td>" >> $html
|
|
105 if [ "$both" != "0" ] ; then
|
1
|
106 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$both</td>" >> $html
|
0
|
107 else
|
|
108 echo "<td>$both</td>" >> $html
|
|
109 fi
|
|
110 if [ "$one" != "0" ] && [ "$cut_off_value" != "0" ] ; then
|
|
111 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$one</td>" >> $html
|
|
112 else
|
|
113 echo "<td>$one</td>" >> $html
|
|
114 fi
|
|
115 echo "<td>$read_count1</td>" >> $html
|
|
116 if [ "$two" != "0" ] && [ "$cut_off_value" != "0" ] ; then
|
|
117 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$two</td>" >> $html
|
|
118 else
|
|
119 echo "<td>$two</td>" >> $html
|
|
120 fi
|
|
121 echo "<td>$read_count2</td>" >> $html
|
|
122 echo "<td>$sum</td>" >> $html
|
|
123 echo "<td>${percent}%</td>" >> $html
|
|
124 echo "</tr>" >> $html
|
|
125 oldLocus="$locus"
|
|
126 done < tmp.txt
|
|
127 echo "</tbody></table>" >> $html
|
2
|
128 echo "</td><td style='vertical-align:top;'><div id='result_div_${patient}_reads'></div></td></tr></table>" >> $html
|
|
129 echo "${readsumtable}</table></div>" >> $html
|
0
|
130 echo "<div class='tabbertab' title='Graphs reads'>" >> $html
|
|
131 echo "<a href='${patient}_reads.png'><img src='${patient}_reads.png' width='1280' height='720' /></a><br />" >> $html
|
|
132 echo "<a href='${patient}_reads_both.png'><img src='${patient}_reads_both.png' width='1280' height='720' /></a><br />" >> $html
|
|
133 echo "<a href='${patient}_percent_reads.png'><img src='${patient}_percent_reads.png' width='1280' height='720' /></a></div>" >> $html
|
2
|
134 echo "</div>" >> $html
|
0
|
135 echo "</div>" >> $html
|
|
136 done < patients.txt
|
|
137 echo "</div></html>" >> $html
|
|
138 rm tmp.txt
|