Mercurial > repos > xilinxu > xilinxu
comparison fastx_toolkit-0.0.6/scripts/fastx_nucleotide_distribution_graph.sh @ 3:997f5136985f draft default tip
Uploaded
author | xilinxu |
---|---|
date | Thu, 14 Aug 2014 04:52:17 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:dfe9332138cf | 3:997f5136985f |
---|---|
1 #!/bin/sh | |
2 | |
3 # FASTX-toolkit - FASTA/FASTQ preprocessing tools. | |
4 # Copyright (C) 2009 A. Gordon (gordon@cshl.edu) | |
5 # | |
6 # This program is free software: you can redistribute it and/or modify | |
7 # it under the terms of the GNU Affero General Public License as | |
8 # published by the Free Software Foundation, either version 3 of the | |
9 # License, or (at your option) any later version. | |
10 # | |
11 # This program is distributed in the hope that it will be useful, | |
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 # GNU Affero General Public License for more details. | |
15 # | |
16 # You should have received a copy of the GNU Affero General Public License | |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 usage() | |
20 { | |
21 echo "FASTA/Q Nucleotide Distribution Plotter" | |
22 echo | |
23 echo "Usage: $0 [-i INPUT.TXT] [-t TITLE] [-p] [-o OUTPUT]" | |
24 echo | |
25 echo " [-p] - Generate PostScript (.PS) file. Default is PNG image." | |
26 echo " [-i INPUT.TXT] - Input file. Should be the output of \"fastx_quality_statistics\" program." | |
27 echo " [-o OUTPUT] - Output file name. default is STDOUT." | |
28 echo " [-t TITLE] - Title - will be plotted on the graph." | |
29 echo | |
30 exit | |
31 } | |
32 | |
33 # | |
34 # 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 | |
35 # As produced by "fastq_quality_statistics" program | |
36 | |
37 TITLE="" # default title is empty | |
38 FILENAME="" | |
39 OUTPUTTERM="set term png size 1048,768" # default output terminal is "PNG" | |
40 OUTPUTFILE="/dev/stdout" # Default output file is simply "stdout" | |
41 while getopts ":t:i:o:ph" Option | |
42 do | |
43 case $Option in | |
44 t ) TITLE="for $OPTARG" ;; | |
45 i ) FILENAME=$OPTARG ;; | |
46 o ) OUTPUTFILE="$OPTARG" ;; | |
47 p ) OUTPUTTERM="set term postscript enhanced color \"Helvetica\" 8" ;; | |
48 h ) usage ;; | |
49 * ) echo "unrecognized argument. use '-h' for usage information."; exit -1 ;; | |
50 esac | |
51 done | |
52 shift $(($OPTIND - 1)) | |
53 | |
54 | |
55 if [ -z "$FILENAME" ]; then | |
56 usage | |
57 fi | |
58 | |
59 if [ ! -r "$FILENAME" ]; then | |
60 echo "Error: can't open input file ($1)." >&2 | |
61 exit 1 | |
62 fi | |
63 | |
64 GNUPLOTCMD=" | |
65 $OUTPUTTERM | |
66 set boxwidth 0.75 absolute | |
67 set size 1,1 | |
68 set style fill solid 1.00 border -1 | |
69 set xlabel \"read position\" | |
70 set title \"Nucleotides distribution $TITLE\" | |
71 set ylabel \"% of total (per read position)\" | |
72 #set grid noxtics nomxtics ytics nomytics noztics nomztics \ | |
73 # nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics | |
74 #set grid layerdefault linetype 0 linewidth 1.000, linetype 0 linewidth 1.000 | |
75 set key outside right top vertical Left reverse enhanced autotitles columnhead nobox | |
76 set key invert samplen 4 spacing 1 width 0 height 0 | |
77 set style histogram rowstacked | |
78 set style data histograms | |
79 set noytics | |
80 set xtics 1 | |
81 set yrange [ 0.00000 : 100.000 ] noreverse nowriteback | |
82 | |
83 plot '$FILENAME' using (100.*column(13)/column(18)):xtic(1) title \"A\" lt rgb \"#5050ff\", \ | |
84 '' using (100.*column(14)/column(18)) title \"C\" lt rgb \"#e00000\", \ | |
85 '' using (100.*column(15)/column(18)) title \"G\" lt rgb \"#00c000\", \ | |
86 '' using (100.*column(16)/column(18)) title \"T\" lt rgb \"#e6e600\", \ | |
87 '' using (100.*column(17)/column(18)) title \"N\" lt rgb \"pink\" | |
88 " | |
89 | |
90 echo "$GNUPLOTCMD" | gnuplot > "$OUTPUTFILE" |