annotate fastx_toolkit-0.0.6/scripts/fastq_quality_boxplot_graph.sh @ 3:997f5136985f draft default tip

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