0
|
1 #!/bin/bash
|
|
2 dir="$(cd "$(dirname "$0")" && pwd)"
|
|
3
|
|
4 input=$1
|
|
5 output=$2
|
|
6 outdir=$3
|
1
|
7 title=$4
|
0
|
8 mkdir $outdir
|
|
9
|
|
10 unzip $input -d $PWD/files/ > $PWD/unziplog.log
|
|
11 cat $PWD/files/*/1_* > $PWD/summary.txt
|
|
12 cat $PWD/files/*/7_* > $PWD/mutationanalysis.txt
|
|
13 cat $PWD/files/*/8_* > $PWD/mutationstats.txt
|
|
14 cat $PWD/files/*/10_* > $PWD/hotspots.txt
|
|
15
|
|
16 mkdir $outdir/identification/
|
|
17 python $dir/gene_identification.py --input $PWD/summary.txt --outdir $outdir/identification/
|
|
18 genes=(ca ca1 ca2 cg cg1 cg2 cg3 cg4 cm)
|
|
19 tmp=$PWD/tmp
|
|
20 tmp2=$PWD/tmp2
|
|
21 hotspottmp=$PWD/hotspottmp
|
|
22 mutationtmp=$PWD/mutationtmp
|
|
23 touch $outdir/mutationandhotspot.txt
|
|
24 for gene in ${genes[@]}
|
|
25 do
|
|
26 echo "Running $gene <br />" >> $output
|
|
27 mkdir $outdir/$gene
|
|
28 echo "Filtering input..." >> $output
|
|
29 Rscript $dir/filter.r $PWD/summary.txt $outdir/identification/${gene}.txt $outdir/$gene/summary.txt
|
|
30 Rscript $dir/filter.r $PWD/mutationanalysis.txt $outdir/identification/${gene}.txt $outdir/$gene/mutationanalysis.txt
|
|
31 Rscript $dir/filter.r $PWD/mutationstats.txt $outdir/identification/${gene}.txt $outdir/$gene/mutationstats.txt
|
|
32 Rscript $dir/filter.r $PWD/hotspots.txt $outdir/identification/${gene}.txt $outdir/$gene/hotspots.txt
|
|
33 echo "done <br />" >> $output
|
|
34
|
|
35 echo "Running R script on $gene..." >> $output
|
|
36 Rscript --verbose $dir/mutation_analysis.r $outdir/$gene/mutationstats.txt $outdir/$gene/summary.txt $outdir/$gene/ 2>&1
|
|
37 echo "done <br />" >> $output
|
|
38
|
|
39 echo "Running Python script..." >> $output
|
|
40 python $dir/mutation_analysis.py --mutationfile $outdir/$gene/mutationanalysis.txt --hotspotfile $outdir/$gene/hotspots.txt --output $outdir/$gene/hotspot_analysis.txt
|
|
41 echo "done <br />" >> $output
|
|
42 echo "Done with $gene <br />" >> $output
|
|
43 cut $outdir/$gene/mutations.txt -d, -f2,3,4 > $mutationtmp
|
|
44 cut $outdir/$gene/hotspot_analysis.txt -d, -f2,3,4 > $hotspottmp
|
|
45 cat $mutationtmp $hotspottmp > $tmp
|
|
46 paste $outdir/mutationandhotspot.txt -d, $tmp > $tmp2
|
|
47 cat $tmp2 > $outdir/mutationandhotspot.txt
|
|
48 done
|
|
49
|
|
50 Rscript --verbose $dir/mutation_analysis.r $PWD/mutationstats.txt $PWD/summary.txt $outdir/ 2>&1
|
|
51 python $dir/mutation_analysis.py --mutationfile $PWD/mutationanalysis.txt --hotspotfile $PWD/hotspots.txt --output $outdir/hotspot_analysis.txt
|
|
52
|
|
53 cut $outdir/mutations.txt -d, -f2,3,4 > $mutationtmp
|
|
54 cut $outdir/hotspot_analysis.txt -d, -f2,3,4 > $hotspottmp
|
|
55 cat $mutationtmp $hotspottmp > $tmp
|
|
56 paste $outdir/mutationandhotspot.txt -d, $tmp > $tmp2
|
|
57 cat $tmp2 > $outdir/mutationandhotspot.txt
|
|
58
|
|
59 cut $outdir/ca1/mutations.txt -d, -f1 > $mutationtmp
|
|
60 cut $outdir/ca1/hotspot_analysis.txt -d, -f1 > $hotspottmp
|
|
61 cat $mutationtmp $hotspottmp > $tmp
|
|
62 paste $tmp $outdir/mutationandhotspot.txt -d, > $tmp2
|
|
63 cat $tmp2 | tr -s "," > $outdir/mutationandhotspot.txt
|
|
64
|
|
65 ca_n=`cat $outdir/ca/n.txt`
|
|
66 ca1_n=`cat $outdir/ca1/n.txt`
|
|
67 ca2_n=`cat $outdir/ca2/n.txt`
|
|
68 cg_n=`cat $outdir/cg/n.txt`
|
|
69 cg1_n=`cat $outdir/cg1/n.txt`
|
|
70 cg2_n=`cat $outdir/cg2/n.txt`
|
|
71 cg3_n=`cat $outdir/cg3/n.txt`
|
|
72 cg4_n=`cat $outdir/cg4/n.txt`
|
|
73 cm_n=`cat $outdir/cm/n.txt`
|
|
74 #all_n=$((ca_n + cg_n + cm_n))
|
|
75 all_n=`cat $outdir/n.txt`
|
|
76
|
|
77
|
1
|
78 echo "<html><center><h1>$title</h1></center><table border='1'>" > $output
|
0
|
79 echo "<tr><th>info</th>" >> $output
|
|
80 echo "<th><a href='identification/ca.txt'>ca (N = $ca_n)</a></th>" >> $output
|
|
81 echo "<th><a href='identification/ca1.txt'>ca1 (N = $ca1_n)</a></th>" >> $output
|
|
82 echo "<th><a href='identification/ca2.txt'>ca2 (N = $ca2_n)</a></th>" >> $output
|
|
83 echo "<th><a href='identification/cg.txt'>cg (N = $cg_n)</a></th>" >> $output
|
|
84 echo "<th><a href='identification/cg1.txt'>cg1 (N = $cg1_n)</a></th>" >> $output
|
|
85 echo "<th><a href='identification/cg2.txt'>cg2 (N = $cg2_n)</a></th>" >> $output
|
|
86 echo "<th><a href='identification/cg3.txt'>cg3 (N = $cg3_n)</a></th>" >> $output
|
|
87 echo "<th><a href='identification/cg4.txt'>cg4 (N = $cg4_n)</a></th>" >> $output
|
|
88 echo "<th><a href='identification/cm.txt'>cm (N = $cm_n)</a></th>" >> $output
|
|
89 echo "<th>all (N = $all_n)</th></tr>" >> $output
|
|
90 while IFS=, read name cax cay caz ca1x ca1y ca1z ca2x ca2y ca2z cgx cgy cgz cg1x cg1y cg1z cg2x cg2y cg2z cg3x cg3y cg3z cg4x cg4y cg4z cmx cmy cmz allx ally allz
|
|
91 do
|
|
92 echo "<tr><td>$name</td><td>${cax}/${cay} (${caz}%)</td><td>${ca1x}/${ca1y} (${ca1z}%)</td><td>${ca2x}/${ca2y} (${ca2z}%)</td><td>${cgx}/${cgy} (${cgz}%)</td><td>${cg1x}/${cg1y} (${cg1z}%)</td><td>${cg2x}/${cg2y} (${cg2z}%)</td><td>${cg3x}/${cg3y} (${cg3z}%)</td><td>${cg4x}/${cg4y} (${cg4z}%)</td><td>${cmx}/${cmy} (${cmz}%)</td><td>${allx}/${ally} (${allz}%)</td></tr>" >> $output
|
|
93 done < $outdir/mutationandhotspot.txt
|
|
94 echo "</table>" >> $output
|
|
95 echo "<a href='identification/unmatched.txt'>umatched</a><br />" >> $output
|
|
96
|
|
97 Rscript $dir/piechart.r "${ca_n},${cg_n},${cm_n}" "IgA - ${ca_n},IgG - ${cg_n},IgM? - ${cm_n}" "Ig* (N = $all_n)" $outdir/all.png 2>&1
|
|
98 Rscript $dir/piechart.r "${ca1_n},${ca2_n}" "IgA1 - ${ca1_n},IgA2 - ${ca2_n}" "IgA (N = $ca_n)" $outdir/ca.png 2>&1
|
|
99 Rscript $dir/piechart.r "${cg1_n},${cg2_n},${cg3_n},${cg4_n}" "IgG1 - ${cg1_n},IgG2 - ${cg2_n},IgG3 - ${cg3_n},IgG4 - ${cg4_n}" "IgG (N = $cg_n)" $outdir/cg.png 2>&1
|
|
100
|
|
101 echo "<img src='all.png'/>" >> $output
|
|
102 echo "<img src='ca.png'/>" >> $output
|
|
103 echo "<img src='cg.png'/>" >> $output
|
|
104
|
|
105 for gene in ${genes[@]}
|
|
106 do
|
|
107 echo "<table border='1'><caption>$gene transition table</caption>" >> $output
|
|
108 while IFS=, read from a c g t
|
|
109 do
|
|
110 echo "<tr><td>$from</td><td>$a</td><td>$c</td><td>$g</td><td>$t</td></tr>" >> $output
|
|
111 done < $outdir/$gene/transitions.txt
|
|
112 echo "</table>" >> $output
|
|
113 done
|
|
114
|
|
115 echo "<table border='1'><caption>All transition table</caption>" >> $output
|
|
116 while IFS=, read from a c g t
|
|
117 do
|
|
118 echo "<tr><td>$from</td><td>$a</td><td>$c</td><td>$g</td><td>$t</td></tr>" >> $output
|
|
119 done < $outdir/transitions.txt
|
|
120 echo "</table>" >> $output
|
|
121
|
|
122 echo "</html>" >> $output
|