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
|
|
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>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
|
|
42 echo "<tbody>" >> $html
|
|
43 while read locus j_segment v_segment cut_off_value both one read_count1 two read_count2 sum percent
|
|
44 do
|
|
45 if [ "$locus" != "$oldLocus" ] ; then
|
|
46 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
|
|
47 echo "<tr><td><b>$locus</b></td>" >> $html
|
|
48 else
|
|
49 echo "<td></td>" >> $html
|
|
50 fi
|
|
51 echo "<td>$v_segment</td>" >> $html
|
|
52 echo "<td>$j_segment</td>" >> $html
|
|
53 echo "<td>>$cut_off_value</td>" >> $html
|
|
54 if [ "$both" != "0" ] ; then
|
|
55 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$both</td>" >> $html
|
|
56 else
|
|
57 echo "<td>$both</td>" >> $html
|
|
58 fi
|
|
59 if [ "$one" != "0" ] && [ "$cut_off_value" != "0" ] ; then
|
|
60 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$one</td>" >> $html
|
|
61 else
|
|
62 echo "<td>$one</td>" >> $html
|
|
63 fi
|
|
64 echo "<td>$read_count1</td>" >> $html
|
|
65 if [ "$two" != "0" ] && [ "$cut_off_value" != "0" ] ; then
|
|
66 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"freq\")'>$two</td>" >> $html
|
|
67 else
|
|
68 echo "<td>$two</td>" >> $html
|
|
69 fi
|
|
70 echo "<td>$read_count2</td>" >> $html
|
|
71 echo "<td>$sum</td>" >> $html
|
|
72 echo "<td>${percent}%</td>" >> $html
|
|
73 echo "</tr>" >> $html
|
|
74 oldLocus="$locus"
|
|
75 done < tmp.txt
|
|
76 echo "</tbody></table>" >> $html
|
|
77 echo "</td><td style='vertical-align:top;'><div id='result_div_${patient}_freq'></div></td></tr></table></div>" >> $html
|
|
78 echo "<div class='tabbertab' title='Graphs frequency'>" >> $html
|
|
79 echo "<a href='${patient}_freq.png'><img src='${patient}_freq.png' width='1280' height='720' /></a><br />" >> $html
|
|
80 echo "<a href='${patient}_freq_both.png'><img src='${patient}_freq_both.png' width='1280' height='720' /></a><br />" >> $html
|
|
81 echo "<a href='${patient}_percent_freq.png'><img src='${patient}_percent_freq.png' width='1280' height='720' /></a></div>" >> $html
|
|
82
|
|
83 tail -n+2 ${patient}_reads.txt | sed "s/>//" > tmp.txt
|
|
84 echo "<div class='tabbertab' title='Data reads'>" >> $html
|
|
85 echo "<table><tr><td style='vertical-align:top;'>" >> $html
|
|
86 echo "<table border = 1 class='result_table summary_table' id='summary_table_${patient}_reads'>" >> $html
|
|
87 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
|
|
88 echo "<tbody>" >> $html
|
|
89 while read locus j_segment v_segment cut_off_value both one read_count1 two read_count2 sum percent
|
|
90 do
|
|
91 if [ "$locus" != "$oldLocus" ] ; then
|
|
92 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
|
|
93 echo "<tr><td><b>$locus</b></td>" >> $html
|
|
94 else
|
|
95 echo "<td></td>" >> $html
|
|
96 fi
|
|
97 echo "<td>$v_segment</td>" >> $html
|
|
98 echo "<td>$j_segment</td>" >> $html
|
|
99 echo "<td>>$cut_off_value</td>" >> $html
|
|
100 if [ "$both" != "0" ] ; then
|
1
|
101 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$both</td>" >> $html
|
0
|
102 else
|
|
103 echo "<td>$both</td>" >> $html
|
|
104 fi
|
|
105 if [ "$one" != "0" ] && [ "$cut_off_value" != "0" ] ; then
|
|
106 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample1}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$one</td>" >> $html
|
|
107 else
|
|
108 echo "<td>$one</td>" >> $html
|
|
109 fi
|
|
110 echo "<td>$read_count1</td>" >> $html
|
|
111 if [ "$two" != "0" ] && [ "$cut_off_value" != "0" ] ; then
|
|
112 echo "<td data-patient='${patient}' style='cursor:pointer' onclick='javascript:loadfile(\"${sample2}_${locus}_${cut_off_value}.txt\", \"$patient\", \"reads\")'>$two</td>" >> $html
|
|
113 else
|
|
114 echo "<td>$two</td>" >> $html
|
|
115 fi
|
|
116 echo "<td>$read_count2</td>" >> $html
|
|
117 echo "<td>$sum</td>" >> $html
|
|
118 echo "<td>${percent}%</td>" >> $html
|
|
119 echo "</tr>" >> $html
|
|
120 oldLocus="$locus"
|
|
121 done < tmp.txt
|
|
122 echo "</tbody></table>" >> $html
|
|
123 echo "</td><td style='vertical-align:top;'><div id='result_div_${patient}_reads'></div></td></tr></table></div>" >> $html
|
|
124 echo "<div class='tabbertab' title='Graphs reads'>" >> $html
|
|
125 echo "<a href='${patient}_reads.png'><img src='${patient}_reads.png' width='1280' height='720' /></a><br />" >> $html
|
|
126 echo "<a href='${patient}_reads_both.png'><img src='${patient}_reads_both.png' width='1280' height='720' /></a><br />" >> $html
|
|
127 echo "<a href='${patient}_percent_reads.png'><img src='${patient}_percent_reads.png' width='1280' height='720' /></a></div>" >> $html
|
|
128 echo "</div>" >> $html
|
|
129 echo "</div>" >> $html
|
|
130 done < patients.txt
|
|
131 echo "</div></html>" >> $html
|
|
132 rm tmp.txt
|