annotate Length_Distibution.pl @ 53:f5a2e8308836 draft default tip

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