annotate Length_Distibution.pl @ 19:e0884a4b996b draft

Uploaded
author big-tiandm
date Wed, 05 Nov 2014 01:17:26 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
1 #!/usr/bin/perl -w
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
2 #==========================================================================================
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
3 # Date:
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
4 # Title:
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
5 # Comment: Program to plot gene structure
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
6 # Input: 1. input file of Gene region annotation which format like GenePred
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
7 # 2. input file of Transcripts region annotation which format like GenePred
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
8 # 3. input file of gene snp detail info
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
9 # Output: output file of gene structure graph by html or svg formt
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
10 # Test Usage:
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
11 #========================================================================================
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
12 #use strict;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
13 my $version=1.00;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
14 use SVG;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
15 use Getopt::Long;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
16 my %opt;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
17 GetOptions(\%opt,"i=s","o=s",,"h");
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
18 if (!(defined $opt{i} and defined $opt{o}) || defined $opt{h}) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
19 &usage;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
20 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
21 #===============================Define Attribute==========================================
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
22 my %attribute=(
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
23 canvas=>{
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
24 'width'=>1500,
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
25 'height'=>1800
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
26 },
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
27 text=>{
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
28 'stroke'=>"#000000",
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
29 'fill'=>"none",
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
30 'stroke-width'=>0.5
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
31 #'stroke-width2'=>1
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
32 },
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
33 line=>{
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
34 'stroke'=>"black",
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
35 'stroke-width'=>1
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
36 },
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
37 font=>{
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
38 'fill'=>"#000000",
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
39 'font-size'=>12,
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
40 'font-size2'=>10,
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
41 'font-weight'=>'bold',
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
42 'font-family'=>"Arial"
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
43 #'font-family2'=>"ArialNarrow-bold"
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
44 },
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
45 rect=>{
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
46 'fill'=>"lightgreen",
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
47 'stroke'=>"black",
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
48 'stroke-width'=>0.5
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
49 },
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
50 readwidth=>0.5
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
51 );
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
52 #my $Xscale=600/$length;#定义X轴比例尺 1:1000 x轴的坐标长度都要按照此比例尺换算
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
53 #========================================data============================
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
54 open(IN,"$opt{i}")||die"cannot open the file $opt{i}";
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
55 my @R_length;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
56 my @T_length;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
57 my $R_number=0;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
58 my $T_number=0;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
59 my $R_max=0;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
60 my $T_max=0;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
61
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
62 my $title=<IN>;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
63 chomp $title;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
64 my @title=split/\t/,$title;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
65 my @mark=split/\s+/,$title[1];
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
66 my $sample_number=@mark;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
67 while (my $aline=<IN>) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
68 if ($aline=~/^\s/) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
69 my $T_title=<IN>;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
70 chomp $T_title;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
71 while (my $a_aline=<IN>) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
72 chomp $a_aline;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
73 my @temp=split/\t/,$a_aline;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
74 my @number=split/\s+/,$temp[1];
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
75 for (my $i=0;$i<@number ;$i++) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
76 if ($R_max<$number[$i]) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
77 $R_max=$number[$i];
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
78 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
79 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
80 push @R_length,[$temp[0],@number];
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
81 $R_number++;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
82 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
83 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
84 else {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
85 chomp $aline;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
86 my @temp=split/\t/,$aline;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
87 my @number=split/\s+/,$temp[1];
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
88 for (my $i=0;$i<@number ;$i++) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
89 if ($T_max<$number[$i]) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
90 $T_max=$number[$i];
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
91 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
92 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
93 push @T_length,[$temp[0],@number];
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
94 $T_number++;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
95 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
96 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
97 close IN;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
98 print "Tag max: $T_max\nRead max: $R_max\n";
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
99 my $kd_number=5;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
100 ##=======================Reads 纵坐标刻度==========================
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
101 my $r=1;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
102 my $rr=1;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
103 my $R=$R_max;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
104 while ($R>10) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
105 $R=$R/10;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
106 $r=$r*10;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
107 $rr++;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
108 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
109 $R=int($R+0.5);
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
110 my $R_xg=$R/$kd_number*$r;#纵坐标一小格大小(一共10格)
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
111 my $R_kedu_scale_x=6*$rr;#纵坐标刻度文字
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
112 ##=======================Tags 纵坐标刻度==========================
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
113 my $t=1;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
114 my $tt=1;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
115 my $T=$T_max;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
116 while ($T>10) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
117 $T=$T/10;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
118 $t=$t*10;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
119 $tt++;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
120 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
121 $T=int($T+0.5);
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
122 my $T_xg=$T/$kd_number*$t;#纵坐标一小格大小(一共10格)
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
123 my $T_kedu_scale_x=6*$tt;#纵坐标刻度文字
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
124
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
125 #############################s#define start coordinate and scale
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
126 my $XOFFSET=50;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
127 my $YOFFSET=60;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
128 my $width=800;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
129 my $heigth=800;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
130 my $X_width=600;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
131 #my $height=1600;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
132 #### Starting ####
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
133 #新建画布
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
134 my $svg=SVG->new(width=>$width,height=>$heigth);
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
135 ####坐标轴
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
136 my $axisL=300;#read 纵坐标长度
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
137 my $x_margin = 50;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
138 #=========Reads number setting==========================================
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
139 my $Y_R_title=30;#标题的纵向宽度
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
140 my $Y_R_0=$YOFFSET+$axisL+$Y_R_title;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
141 my $X_R_0=$XOFFSET+$x_margin;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
142 my $R_Yscale=$axisL/$R_xg/$kd_number;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
143 my $R_Xscale=$X_width/$R_number/($sample_number+1);
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
144 #=====================================Reads Y axis======================
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
145 $svg->line('x1',$X_R_0,'y1',$Y_R_0,'x2',$X_R_0,'y2',$Y_R_0-$axisL,'stroke',$attribute{line}{'stroke'},'stroke-width',$attribute{line}{'stroke-width'});
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
146 for (my $i=1;$i<$kd_number ;$i++) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
147 $svg->line('x1',$X_R_0-5,'y1',$Y_R_0-$i*$R_xg*$R_Yscale,'x2',$X_R_0,'y2',$Y_R_0-$i*$R_xg*$R_Yscale,'stroke',$attribute{line}{'stroke'},'stroke-width',$attribute{line}{'stroke-width'});
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
148 $svg->text('x',$X_R_0-$R_kedu_scale_x,'y',$Y_R_0-$i*$R_xg*$R_Yscale+4,'style','fill:black;text-anchor:middle','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',6,'font-family',$attribute{font}{'font-family'},'-cdata',$i*$R_xg);
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
149 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
150 #=====================================Reads X axis======================
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
151 $svg->line('x1',$X_R_0,'y1',$Y_R_0,'x2',$X_R_0+$X_width,'y2',$Y_R_0,'stroke',$attribute{line}{'stroke'},'stroke-width',$attribute{line}{'stroke-width'});
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
152
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
153 #print "$R_number\t$sample_number\n";
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
154 for ($i=0;$i<$R_number ;$i++) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
155 for (my $j=1;$j<$sample_number+1 ;$j++) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
156 my $red=$j/$sample_number*255;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
157 $svg->rect('x',$X_R_0+($j+$i*($sample_number+1))*$R_Xscale,'y',$Y_R_0-$R_length[$i][$j]*$R_Yscale,'width',$R_Xscale,'height',$R_length[$i][$j]*$R_Yscale,'stroke',"black",'stroke-width',"0.5",'fill',"rgb($red,125,0)");
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
158 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
159 $svg->text('x',$X_R_0+(1+$sample_number/2+$i*($sample_number+1))*$R_Xscale,'y',$Y_R_0+15,'style','fill:black;text-anchor:middle','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',6,'font-family',$attribute{font}{'font-family'},'-cdata',$R_length[$i][0]);
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
160 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
161 #===Reads number title
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
162 $svg->text('x',$XOFFSET+400,'y',$YOFFSET,'style','fill:black;text-anchor:middle','stroke',$attribute{text}{'stroke'},'stroke-width',"1",'font-size',15,'font-family',$attribute{font}{'font-family'},'-cdata',"Reads Length Distribution");
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
163 #===Reads
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
164 for (my $i=0;$i<$sample_number ;$i++) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
165 my $red=($i+1)/$sample_number*255;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
166 $svg->rect('x',$X_R_0+550,'y',$YOFFSET+$Y_R_title+20*$i,'width',15,'height',10,'stroke',"black",'stroke-width',"0.5",'fill',"rgb($red,125,0)");
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
167 $svg->text('x',$X_R_0+550+30,'y',$YOFFSET+$Y_R_title+20*$i+10,'style','fill:black;text-anchor:middle','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',10,'font-family',$attribute{font}{'font-family'},'-cdata',$mark[$i]);
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
168 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
169 ####==================================================================================
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
170 #=========================================Tag s
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
171 my $Y_T_title=30;#标题的纵向宽度
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
172 my $Y_T_0=$Y_R_0+$axisL+$Y_R_title+50;#length size
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
173 my $X_T_0=$XOFFSET+$x_margin;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
174 my $T_Yscale=$axisL/$T_xg/$kd_number;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
175 my $T_Xscale=$X_width/$T_number/($sample_number+1);
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
176 #=====================================Tags Y axis======================
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
177 $svg->line('x1',$X_T_0,'y1',$Y_T_0,'x2',$X_T_0,'y2',$Y_T_0-$axisL,'stroke',$attribute{line}{'stroke'},'stroke-width',$attribute{line}{'stroke-width'});
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
178 for (my $i=1;$i<$kd_number ;$i++) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
179 $svg->line('x1',$X_T_0-5,'y1',$Y_T_0-$i*$T_xg*$T_Yscale,'x2',$X_T_0,'y2',$Y_T_0-$i*$T_xg*$T_Yscale,'stroke',$attribute{line}{'stroke'},'stroke-width',$attribute{line}{'stroke-width'});
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
180 $svg->text('x',$X_T_0-$T_kedu_scale_x,'y',$Y_T_0-$i*$T_xg*$T_Yscale+4,'style','fill:black;text-anchor:middle','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',6,'font-family',$attribute{font}{'font-family'},'-cdata',$i*$T_xg);
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
181 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
182 #=====================================Tags X axis======================
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
183 $svg->line('x1',$X_T_0,'y1',$Y_T_0,'x2',$X_T_0+$X_width,'y2',$Y_T_0,'stroke',$attribute{line}{'stroke'},'stroke-width',$attribute{line}{'stroke-width'});
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
184
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
185 #print "$R_number\t$sample_number\n";
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
186 for ($i=0;$i<$T_number ;$i++) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
187 for (my $j=1;$j<$sample_number+1 ;$j++) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
188 my $red=$j/$sample_number*255;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
189 $svg->rect('x',$X_T_0+($j+$i*($sample_number+1))*$T_Xscale,'y',$Y_T_0-$T_length[$i][$j]*$T_Yscale,'width',$T_Xscale,'height',$T_length[$i][$j]*$T_Yscale,'stroke',"black",'stroke-width',"0.5",'fill',"rgb($red,125,0)");
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
190 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
191 $svg->text('x',$X_T_0+(1+$sample_number/2+$i*($sample_number+1))*$T_Xscale,'y',$Y_T_0+15,'style','fill:black;text-anchor:middle','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',6,'font-family',$attribute{font}{'font-family'},'-cdata',$T_length[$i][0]);
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
192 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
193 #===Reads number title
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
194 $svg->text('x',$XOFFSET+400,'y',$Y_R_0+30+$Y_T_title,'style','fill:black;text-anchor:middle','stroke',$attribute{text}{'stroke'},'stroke-width',"1",'font-size',15,'font-family',$attribute{font}{'font-family'},'-cdata',"Tags Length Distribution");
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
195 #===Reads
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
196 for (my $i=0;$i<$sample_number ;$i++) {
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
197 my $red=($i+1)/$sample_number*255;
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
198 $svg->rect('x',$X_T_0+550,'y',$Y_R_0+30+$Y_T_title+20*$i,'width',15,'height',10,'stroke',"black",'stroke-width',"0.5",'fill',"rgb($red,125,0)");
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
199 $svg->text('x',$X_T_0+550+30,'y',$Y_R_0+30+$Y_T_title+20*$i+10,'style','fill:black;text-anchor:middle','stroke',$attribute{text}{'stroke'},'stroke-width',$attribute{text}{'stroke-width'},'font-size',10,'font-family',$attribute{font}{'font-family'},'-cdata',$mark[$i]);
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
200 }
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
201
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
202
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
203
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
204
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
205 open (OUT,">$opt{o}");
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
206 print OUT $svg->xmlify();
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
207
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
208 sub usage{
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
209 print <<"USAGE";
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
210 Version $version
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
211 Usage:
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
212 $0
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
213 options:
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
214 -i
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
215 -o svg output
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
216 -h help
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
217 USAGE
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
218 exit(1);
e0884a4b996b Uploaded
big-tiandm
parents:
diff changeset
219 }