annotate tools/solid_tools/qualsolid_boxplot_graph.sh @ 2:c2a356708570

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:45:42 -0500
parents 9071e359b9a3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 #!/bin/sh
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 # Modified fastq_quality_boxplot_graph.sh from FASTX-toolkit - FASTA/FASTQ preprocessing tools.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 # Copyright (C) 2009 A. Gordon (gordon@cshl.edu)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5 #
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 # published by the Free Software Foundation, either version 3 of the
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 # License, or (at your option) any later version.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10 #
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 # GNU Affero General Public License for more details.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 #
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19 function usage()
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21 echo "SOLiD-Quality BoxPlot plotter"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22 echo "Generates a SOLiD quality score box-plot graph "
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 echo
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
24 echo "Usage: $0 [-i INPUT.TXT] [-t TITLE] [-p] [-o OUTPUT]"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 echo
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26 echo " [-p] - Generate PostScript (.PS) file. Default is PNG image."
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27 echo " [-i INPUT.TXT] - Input file. Should be the output of \"solid_qual_stats\" program."
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28 echo " [-o OUTPUT] - Output file name. default is STDOUT."
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29 echo " [-t TITLE] - Title (usually the solid file name) - will be plotted on the graph."
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
30 echo
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 exit
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34 #
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35 # Input Data columns: #pos cnt min max sum mean Q1 med Q3 IQR lW rW
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
36 # As produced by "solid_qual_stats" program
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
37
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
38 TITLE="" # default title is empty
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
39 FILENAME=""
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
40 OUTPUTTERM="set term png size 800,600"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
41 OUTPUTFILE="/dev/stdout" # Default output file is simply "stdout"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
42 while getopts ":t:i:o:ph" Option
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
43 do
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
44 case $Option in
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
45 # w ) CMD=$OPTARG; FILENAME="PIMSLogList.txt"; TARGET="logfiles"; ;;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
46 t ) TITLE="for $OPTARG" ;;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
47 i ) FILENAME=$OPTARG ;;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
48 o ) OUTPUTFILE="$OPTARG" ;;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
49 p ) OUTPUTTERM="set term postscript enhanced color \"Helvetica\" 4" ;;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
50 h ) usage ;;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
51 * ) echo "unrecognized argument. use '-h' for usage information."; exit -1 ;;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
52 esac
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
53 done
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
54 shift $(($OPTIND - 1))
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
55
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
56
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
57 if [ "$FILENAME" == "" ]; then
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
58 usage
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
59 fi
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
60
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
61 if [ ! -r "$FILENAME" ]; then
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
62 echo "Error: can't open input file ($1)." >&2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
63 exit 1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
64 fi
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
65
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
66 #Read number of cycles from the stats file (each line is a cycle, minus the header line)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
67 #But for the graph, I want xrange to reach (num_cycles+1), so I don't subtract 1 now.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
68 NUM_CYCLES=$(cat "$FILENAME" | wc -l)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
69
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
70 GNUPLOTCMD="
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
71 $OUTPUTTERM
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
72 set boxwidth 0.8
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
73 set size 1,1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
74 set key Left inside
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
75 set xlabel \"read position\"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
76 set ylabel \"Quality Score \"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
77 set title \"Quality Scores $TITLE\"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
78 #set auto x
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
79 set bars 4.0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
80 set xrange [ 0: $NUM_CYCLES ]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
81 set yrange [-2:45]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
82 set y2range [-2:45]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
83 set xtics 1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
84 set x2tics 1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
85 set ytics 2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
86 set y2tics 2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
87 set tics out
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
88 set grid ytics
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
89 set style fill empty
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
90 plot '$FILENAME' using 1:7:11:12:9 with candlesticks lt 1 lw 1 title 'Quartiles' whiskerbars, \
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
91 '' using 1:8:8:8:8 with candlesticks lt -1 lw 2 title 'Medians'
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
92 "
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
93
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
94 echo "$GNUPLOTCMD" | gnuplot > "$OUTPUTFILE"