Mercurial > repos > davidvanzessen > mutation_analysis
comparison wrapper.sh @ 0:74d2bc479bee draft
Uploaded
| author | davidvanzessen |
|---|---|
| date | Mon, 18 Aug 2014 04:04:37 -0400 |
| parents | |
| children | 856b5b718d21 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:74d2bc479bee |
|---|---|
| 1 #!/bin/bash | |
| 2 dir="$(cd "$(dirname "$0")" && pwd)" | |
| 3 | |
| 4 input=$1 | |
| 5 output=$2 | |
| 6 outdir=$3 | |
| 7 mkdir $outdir | |
| 8 | |
| 9 unzip $input -d $PWD/files/ > $PWD/unziplog.log | |
| 10 cat $PWD/files/*/1_* > $PWD/summary.txt | |
| 11 cat $PWD/files/*/7_* > $PWD/mutationanalysis.txt | |
| 12 cat $PWD/files/*/8_* > $PWD/mutationstats.txt | |
| 13 cat $PWD/files/*/10_* > $PWD/hotspots.txt | |
| 14 | |
| 15 mkdir $outdir/identification/ | |
| 16 python $dir/gene_identification.py --input $PWD/summary.txt --outdir $outdir/identification/ | |
| 17 genes=(ca ca1 ca2 cg cg1 cg2 cg3 cg4 cm) | |
| 18 tmp=$PWD/tmp | |
| 19 tmp2=$PWD/tmp2 | |
| 20 hotspottmp=$PWD/hotspottmp | |
| 21 mutationtmp=$PWD/mutationtmp | |
| 22 touch $outdir/mutationandhotspot.txt | |
| 23 for gene in ${genes[@]} | |
| 24 do | |
| 25 echo "Running $gene <br />" >> $output | |
| 26 mkdir $outdir/$gene | |
| 27 echo "Filtering input..." >> $output | |
| 28 Rscript $dir/filter.r $PWD/summary.txt $outdir/identification/${gene}.txt $outdir/$gene/summary.txt | |
| 29 Rscript $dir/filter.r $PWD/mutationanalysis.txt $outdir/identification/${gene}.txt $outdir/$gene/mutationanalysis.txt | |
| 30 Rscript $dir/filter.r $PWD/mutationstats.txt $outdir/identification/${gene}.txt $outdir/$gene/mutationstats.txt | |
| 31 Rscript $dir/filter.r $PWD/hotspots.txt $outdir/identification/${gene}.txt $outdir/$gene/hotspots.txt | |
| 32 echo "done <br />" >> $output | |
| 33 | |
| 34 echo "Running R script on $gene..." >> $output | |
| 35 Rscript --verbose $dir/mutation_analysis.r $outdir/$gene/mutationstats.txt $outdir/$gene/summary.txt $outdir/$gene/ 2>&1 | |
| 36 echo "done <br />" >> $output | |
| 37 | |
| 38 echo "Running Python script..." >> $output | |
| 39 python $dir/mutation_analysis.py --mutationfile $outdir/$gene/mutationanalysis.txt --hotspotfile $outdir/$gene/hotspots.txt --output $outdir/$gene/hotspot_analysis.txt | |
| 40 echo "done <br />" >> $output | |
| 41 echo "Done with $gene <br />" >> $output | |
| 42 cut $outdir/$gene/mutations.txt -d, -f2,3,4 > $mutationtmp | |
| 43 cut $outdir/$gene/hotspot_analysis.txt -d, -f2,3,4 > $hotspottmp | |
| 44 cat $mutationtmp $hotspottmp > $tmp | |
| 45 paste $outdir/mutationandhotspot.txt -d, $tmp > $tmp2 | |
| 46 cat $tmp2 > $outdir/mutationandhotspot.txt | |
| 47 done | |
| 48 | |
| 49 Rscript --verbose $dir/mutation_analysis.r $PWD/mutationstats.txt $PWD/summary.txt $outdir/ 2>&1 | |
| 50 python $dir/mutation_analysis.py --mutationfile $PWD/mutationanalysis.txt --hotspotfile $PWD/hotspots.txt --output $outdir/hotspot_analysis.txt | |
| 51 | |
| 52 cut $outdir/mutations.txt -d, -f2,3,4 > $mutationtmp | |
| 53 cut $outdir/hotspot_analysis.txt -d, -f2,3,4 > $hotspottmp | |
| 54 cat $mutationtmp $hotspottmp > $tmp | |
| 55 paste $outdir/mutationandhotspot.txt -d, $tmp > $tmp2 | |
| 56 cat $tmp2 > $outdir/mutationandhotspot.txt | |
| 57 | |
| 58 cut $outdir/ca1/mutations.txt -d, -f1 > $mutationtmp | |
| 59 cut $outdir/ca1/hotspot_analysis.txt -d, -f1 > $hotspottmp | |
| 60 cat $mutationtmp $hotspottmp > $tmp | |
| 61 paste $tmp $outdir/mutationandhotspot.txt -d, > $tmp2 | |
| 62 cat $tmp2 | tr -s "," > $outdir/mutationandhotspot.txt | |
| 63 | |
| 64 ca_n=`cat $outdir/ca/n.txt` | |
| 65 ca1_n=`cat $outdir/ca1/n.txt` | |
| 66 ca2_n=`cat $outdir/ca2/n.txt` | |
| 67 cg_n=`cat $outdir/cg/n.txt` | |
| 68 cg1_n=`cat $outdir/cg1/n.txt` | |
| 69 cg2_n=`cat $outdir/cg2/n.txt` | |
| 70 cg3_n=`cat $outdir/cg3/n.txt` | |
| 71 cg4_n=`cat $outdir/cg4/n.txt` | |
| 72 cm_n=`cat $outdir/cm/n.txt` | |
| 73 #all_n=$((ca_n + cg_n + cm_n)) | |
| 74 all_n=`cat $outdir/n.txt` | |
| 75 | |
| 76 | |
| 77 echo "<html><table border='1'>" > $output | |
| 78 echo "<tr><th>info</th>" >> $output | |
| 79 echo "<th><a href='identification/ca.txt'>ca (N = $ca_n)</a></th>" >> $output | |
| 80 echo "<th><a href='identification/ca1.txt'>ca1 (N = $ca1_n)</a></th>" >> $output | |
| 81 echo "<th><a href='identification/ca2.txt'>ca2 (N = $ca2_n)</a></th>" >> $output | |
| 82 echo "<th><a href='identification/cg.txt'>cg (N = $cg_n)</a></th>" >> $output | |
| 83 echo "<th><a href='identification/cg1.txt'>cg1 (N = $cg1_n)</a></th>" >> $output | |
| 84 echo "<th><a href='identification/cg2.txt'>cg2 (N = $cg2_n)</a></th>" >> $output | |
| 85 echo "<th><a href='identification/cg3.txt'>cg3 (N = $cg3_n)</a></th>" >> $output | |
| 86 echo "<th><a href='identification/cg4.txt'>cg4 (N = $cg4_n)</a></th>" >> $output | |
| 87 echo "<th><a href='identification/cm.txt'>cm (N = $cm_n)</a></th>" >> $output | |
| 88 echo "<th>all (N = $all_n)</th></tr>" >> $output | |
| 89 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 | |
| 90 do | |
| 91 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 | |
| 92 done < $outdir/mutationandhotspot.txt | |
| 93 echo "</table>" >> $output | |
| 94 echo "<a href='identification/unmatched.txt'>umatched</a><br />" >> $output | |
| 95 | |
| 96 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 | |
| 97 Rscript $dir/piechart.r "${ca1_n},${ca2_n}" "IgA1 - ${ca1_n},IgA2 - ${ca2_n}" "IgA (N = $ca_n)" $outdir/ca.png 2>&1 | |
| 98 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 | |
| 99 | |
| 100 echo "<img src='all.png'/>" >> $output | |
| 101 echo "<img src='ca.png'/>" >> $output | |
| 102 echo "<img src='cg.png'/>" >> $output | |
| 103 | |
| 104 for gene in ${genes[@]} | |
| 105 do | |
| 106 echo "<table border='1'><caption>$gene transition table</caption>" >> $output | |
| 107 while IFS=, read from a c g t | |
| 108 do | |
| 109 echo "<tr><td>$from</td><td>$a</td><td>$c</td><td>$g</td><td>$t</td></tr>" >> $output | |
| 110 done < $outdir/$gene/transitions.txt | |
| 111 echo "</table>" >> $output | |
| 112 done | |
| 113 | |
| 114 echo "<table border='1'><caption>All transition table</caption>" >> $output | |
| 115 while IFS=, read from a c g t | |
| 116 do | |
| 117 echo "<tr><td>$from</td><td>$a</td><td>$c</td><td>$g</td><td>$t</td></tr>" >> $output | |
| 118 done < $outdir/transitions.txt | |
| 119 echo "</table>" >> $output | |
| 120 | |
| 121 echo "</html>" >> $output |
