Mercurial > repos > davidvanzessen > mutation_analysis
diff wrapper.sh @ 110:ade5cf6fd2dc draft
Uploaded
author | davidvanzessen |
---|---|
date | Tue, 02 Aug 2016 08:30:23 -0400 |
parents | 6add3e66f4fa |
children | e7b550d52eb7 |
line wrap: on
line diff
--- a/wrapper.sh Thu Jul 14 07:29:56 2016 -0400 +++ b/wrapper.sh Tue Aug 02 08:30:23 2016 -0400 @@ -1,5 +1,5 @@ #!/bin/bash -set -e +#set -e dir="$(cd "$(dirname "$0")" && pwd)" input=$1 method=$2 @@ -17,13 +17,13 @@ class_filter=${13} mkdir $outdir +tar -xzf $dir/style.tar.gz -C $outdir + echo "---------------- read parameters ----------------" echo "---------------- read parameters ----------------<br />" > $log echo "unpacking IMGT file" - - type="`file $input`" if [[ "$type" == *"Zip archive"* ]] ; then echo "Zip archive" @@ -67,7 +67,11 @@ sequence_index=$(cat $PWD/summary.txt | grep -o -P ".+\tSequence" | grep -o -P "\t" | wc -l) sequence_index=$((sequence_index+1)) - cat $PWD/summary.txt | tail -n+2 | cut -f ${ID_index},${sequence_index} | awk '{print ">" $1 "\n" $2}' > $PWD/sequences.fasta + cat $PWD/summary.txt | tail -n+2 | cut -f ${ID_index},${sequence_index} | awk '{print ">" $1 "\n" $2}' > $PWD/sequences.tmp + + cat $PWD/sequences.tmp | grep -B1 -vE "^$" sequences.fasta #filter out empty sequences + + rm $PWD/sequences.tmp echo -e "qseqid\tsseqid\tpident\tlength\tmismatch\tgapopen\tqstart\tqend\tsstart\tsend\tevalue\tbitscore" > $outdir/identified_genes.txt ${BLASTN_DIR}/blastn -task blastn -db $dir/subclass_definition.db -query $PWD/sequences.fasta -outfmt 6 >> $outdir/identified_genes.txt @@ -149,12 +153,15 @@ echo "---------------- aa_histogram.r ----------------<br />" >> $log Rscript $dir/aa_histogram.r $outdir/aa_id_mutations.txt $outdir/absent_aa_id.txt "ca,cg,cm" $outdir/ 2>&1 -mv $outdir/aa_histogram_.png $outdir/aa_histogram.png -mv $outdir/aa_histogram_.txt $outdir/aa_histogram.txt +if [ -e "$outdir/aa_histogram_.png" ]; then + mv $outdir/aa_histogram_.png $outdir/aa_histogram.png + mv $outdir/aa_histogram_.txt $outdir/aa_histogram.txt +fi genes=(ca ca1 ca2 cg cg1 cg2 cg3 cg4 cm) funcs=(sum mean median) +funcs=(sum) echo "---------------- sequence_overview.r ----------------" echo "---------------- sequence_overview.r ----------------<br />" >> $log @@ -172,6 +179,10 @@ done < $outdir/sequence_overview/ntoverview.txt echo "<html><center><h1>$title</h1></center>" > $output +echo "<script type='text/javascript' src='jquery-1.11.0.min.js'></script>" >> $output +echo "<script type='text/javascript' src='tabber.js'></script>" >> $output +echo "<script type='text/javascript' src='script.js'></script>" >> $output +echo "<link rel='stylesheet' type='text/css' href='style.css'>" >> $output #display the matched/unmatched for clearity @@ -188,6 +199,10 @@ echo "---------------- main tables ----------------" echo "---------------- main tables ----------------<br />" >> $log + +echo "<div class='tabber'>" >> $output +echo "<div class='tabbertab' title='SHM Overview'>" >> $output + for func in ${funcs[@]} do @@ -221,9 +236,84 @@ #echo "<a href='data_${func}.txt'>Download data</a>" >> $output done -echo "---------------- download links ----------------" -echo "---------------- download links ----------------<br />" >> $log +echo "</div>" >> $output #SHM overview tab end + +echo "---------------- images ----------------" +echo "---------------- images ----------------<br />" >> $log + +echo "<div class='tabbertab' title='SHM Frequency'>" >> $output + +if [ -a $outdir/scatter.png ] +then + echo "<img src='scatter.png'/><br />" >> $output + echo "<a href='scatter.txt'>download data</a><br />" >> $output +fi +if [ -a $outdir/frequency_ranges.png ] +then + echo "<img src='frequency_ranges.png'/><br />" >> $output + echo "<a href='frequency_ranges_classes.txt'>download class data</a><br />" >> $output + echo "<a href='frequency_ranges_subclasses.txt'>download subclass data</a><br />" >> $output +fi + +echo "</div>" >> $output #SHM frequency tab end + +echo "<div class='tabbertab' title='Transition tables'>" >> $output + +for gene in ${genes[@]} +do + echo "<table border='1'><caption>$gene transition table</caption>" >> $output + while IFS=, read from a c g t + do + echo "<tr><td>$from</td><td>$a</td><td>$c</td><td>$g</td><td>$t</td></tr>" >> $output + done < $outdir/transitions_${gene}_sum.txt + echo "</table>" >> $output +done +echo "<table border='1'><caption>All transition table</caption>" >> $output +while IFS=, read from a c g t + do + echo "<tr><td>$from</td><td>$a</td><td>$c</td><td>$g</td><td>$t</td></tr>" >> $output +done < $outdir/transitions_all_sum.txt +echo "</table>" >> $output + +echo "</div>" >> $output #transition tables tab end + +echo "<div class='tabbertab' title='Antigen Selection'>" >> $output + +if [ -a $outdir/aa_histogram.png ] +then + echo "<img src='aa_histogram.png'/><br />" >> $output + echo "<a href='aa_histogram.txt'>download data</a><br />" >> $output + echo "<img src='aa_histogram_ca.png'/><br />" >> $output + echo "<a href='aa_histogram_ca.txt'>download data</a><br />" >> $output + echo "<img src='aa_histogram_cg.png'/><br />" >> $output + echo "<a href='aa_histogram_cg.txt'>download data</a><br />" >> $output + echo "<img src='aa_histogram_cm.png'/><br />" >> $output + echo "<a href='aa_histogram_cm.txt'>download data</a><br />" >> $output +fi + +echo "<embed src='baseline_ca.pdf' width='700px' height='1000px'>" >> $output +echo "<embed src='baseline_cg.pdf' width='700px' height='1000px'>" >> $output +echo "<embed src='baseline_cm.pdf' width='700px' height='1000px'>" >> $output + +echo "</div>" >> $output #antigen selection tab end + +echo "<div class='tabbertab' title='CSR'>" >> $output + +if [ -a $outdir/ca.png ] +then + echo "<img src='ca.png'/><br />" >> $output + echo "<a href='ca.txt'>download data</a><br />" >> $output +fi +if [ -a $outdir/cg.png ] +then + echo "<img src='cg.png'/><br />" >> $output + echo "<a href='cg.txt'>download data</a><br />" >> $output +fi + +echo "</div>" >> $output #CSR tab end + +echo "<div class='tabbertab' title='Downloads'>" >> $output echo "<a href='unmatched.txt'>unmatched</a><br />" >> $output echo "<a href='motif_per_seq.txt'>motif per sequence</a><br />" >> $output @@ -250,61 +340,9 @@ echo "<a href='new_IMGT_cg.txz'>Filtered cg IMGT zip</a><br />" >> $output echo "<a href='new_IMGT_cm.txz'>Filtered cm IMGT zip</a><br />" >> $output - -echo "---------------- images ----------------" -echo "---------------- images ----------------<br />" >> $log +echo "</div>" >> $output #downloads tab end -echo "<img src='all.png'/><br />" >> $output -echo "<a href='all.txt'>download data</a><br />" >> $output -if [ -a $outdir/ca.png ] -then - echo "<img src='ca.png'/><br />" >> $output - echo "<a href='ca.txt'>download data</a><br />" >> $output -fi -if [ -a $outdir/cg.png ] -then - echo "<img src='cg.png'/><br />" >> $output - echo "<a href='cg.txt'>download data</a><br />" >> $output -fi -if [ -a $outdir/scatter.png ] -then - echo "<img src='scatter.png'/><br />" >> $output - echo "<a href='scatter.txt'>download data</a><br />" >> $output -fi -if [ -a $outdir/frequency_ranges.png ] -then - echo "<img src='frequency_ranges.png'/><br />" >> $output - echo "<a href='frequency_ranges_classes.txt'>download class data</a><br />" >> $output - echo "<a href='frequency_ranges_subclasses.txt'>download subclass data</a><br />" >> $output -fi -if [ -a $outdir/aa_histogram.png ] -then - echo "<img src='aa_histogram.png'/><br />" >> $output - echo "<a href='aa_histogram.txt'>download data</a><br />" >> $output - echo "<img src='aa_histogram_ca.png'/><br />" >> $output - echo "<a href='aa_histogram_ca.txt'>download data</a><br />" >> $output - echo "<img src='aa_histogram_cg.png'/><br />" >> $output - echo "<a href='aa_histogram_cg.txt'>download data</a><br />" >> $output - echo "<img src='aa_histogram_cm.png'/><br />" >> $output - echo "<a href='aa_histogram_cm.txt'>download data</a><br />" >> $output -fi - -for gene in ${genes[@]} -do - echo "<table border='1'><caption>$gene transition table</caption>" >> $output - while IFS=, read from a c g t - do - echo "<tr><td>$from</td><td>$a</td><td>$c</td><td>$g</td><td>$t</td></tr>" >> $output - done < $outdir/transitions_${gene}_sum.txt - echo "</table>" >> $output -done - -echo "<table border='1'><caption>All transition table</caption>" >> $output -while IFS=, read from a c g t - do - echo "<tr><td>$from</td><td>$a</td><td>$c</td><td>$g</td><td>$t</td></tr>" >> $output -done < $outdir/transitions_all_sum.txt -echo "</table>" >> $output +echo "</div>" >> $output #tabs end echo "</html>" >> $output @@ -368,8 +406,44 @@ mv $log $outdir/log.html -cp $outdir/index.html $log +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)<br />" > $log +echo "<table border = 1>" >> $log +echo "<thead><tr><th>Info</th><th>Sequences</th><th>Percentage</th></tr></thead>" >> $log +tIFS="$TMP" +IFS=$'\t' +while read step seq perc + do + echo "<tr>" >> $log + echo "<td>$step</td>" >> $log + echo "<td>$seq</td>" >> $log + echo "<td>${perc}%</td>" >> $log + echo "</tr>" >> $log +done < $outdir/filtering_steps.txt +echo "</table border></center></html>" >> $log + +IFS="$tIFS" + echo "---------------- Done! ----------------" echo "---------------- Done! ----------------<br />" >> $outdir/log.html + + + + + + + + + + + + + + + + + + + +