这个test.txt的内容 NM_152739--19648 HOXA9 chr7 - 27169746,27168581 NM_152739--19648 BG753004 chr7 - 27169706,27169721,27169725,27169775,27169775,27169784,27169789,27169878,27169878,27169898,27169898,27169985,27171021,27171111,27171284,27171631 NM_152739--19648 BX348940 chr7 - 27169223,27169238,27169240,27169301,27169302,27169398,27169399,27169406,27169407,27169413,27169414,27169985,27171021,27171071,27171072,27171153,27171154,27171158,27171159,27171168,27171169,27171175 NM_152739--19648 CR740711 chr7 - 27169038,27169754 NM_152739--19648 BE898704 chr7 - 27169265,27169275,27169276,27169286,27169296,27169326,27169327,27169341,27169342,27169372,27169372,27169385,27169385,27169985,27171021,27171120 NM_152739--19648 BE872936 chr7 - 27169674,27169683,27169693,27169700,27169702,27169712,27169718,27169723,27169725,27169758,27169759,27169778,27169785,27169804,27169805,27169833,27169834,27169838,27169839,27169846,27169847,27169907,27169907,27169919,27169920,27169985,27171021,27171046,27171047,27171111,27171284,27171296,27171297,27171644 NM_152739--19648 BE899575 chr7 - 27169467,27169555,27169556,27169985,27171021,27171127,27171128,27171140 NM_152739--19648 BG717723 chr7 - 27169702,27169720,27169724,27169985,27171021,27171395,27171866,27171871 NM_152739--19648 BF132466 chr7 - 27168977,27168988,27168990,27168996,27168997,27169001,27169020,27169032,27169033,27169050,27169051,27169070,27169071,27169116,27169117,27169122,27169122,27169145,27169145,27169172,27169172,27169221,27169222,27169267,27169268,27169319,27169320,27169414,27169414,27169538,27169539,27169552,27169553,27169650 NM_152739--19648 BX359846 chr7 - 27169562,27169588,27169589,27169600,27169606,27169620,27169672,27169806,27169807,27169853,27169853,27169858,27169859,27169960,27171043,27171560 NM_152739--19648 BI760357 chr7 - 27169717,27169729,27169741,27169897,27169897,27169985,27171021,27171111,27171284,27171387,27171387,27171443,27171443,27171608 NM_152739--19648 BF801662 chr7 - 27169434,27169798 NM_152739--19648 BQ224521 chr7 - 27168994,27169148,27169229,27169541 NM_152739--19648 BQ422016 chr7 - 27169721,27169746,27169746,27169985,27171021,27171623 NM_152739--19648 BF801692 chr7 - 27169435,27169498,27169498,27169862 NM_152739--19648 BG505954 chr7 - 27169450,27169461,27169462,27169487,27169488,27169498,27169515,27169528,27169533,27169549,27169549,27169555,27169556,27169592,27169592,27169630,27169630,27169639,27169640,27169680,27169680,27169703,27169704,27169833,27169834,27169985,27171021,27171111,27176574,27176642 NM_152739--19648 AI650301 chr7 - 27168605,27168796,27168796,27168804 NM_152739--19648 BF131719 chr7 - 27168969,27169016,27169017,27169056,27169056,27169097,27169097,27169114,27169114,27169267,27169268,27169280,27169281,27169514 NM_152739--19648 BX348939 chr7 - 27169246,27169360,27169361,27169368,27169368,27169985,27171021,27171095,27171096,27171156,27171157,27171164,27171165,27171179 NM_152739--19648 CB216862 chr7 - 27169473,27170050 NM_152739--19648 BG748550 chr7 - 27169701,27169714,27169715,27169865,27169865,27169985,27171021,27171111,27171284,27171656,27171656,27171670
On Nov 2, 8:43 pm, zhihua zheng <[email protected]> wrote: > 把你的text.txt再发上来看看\、|? > > 2009/11/3 zhihua zheng <[email protected]> > > > > > 你的text.txt是不是有问题| 要不怎么读不进去? > > > 2009/11/3 chunjiang he <[email protected]> > > > 我用GD画图的时候,能不能读取一个文件中的数据然后画图呢,我这样做了,但是出现internal server error错误。 > >> 如果不从文件中读取,而是把数据放在程序中,就没有问题,请大家指教 > > >> 下面是我从文件中读取数据然后画图的程序: > > >> #!d:/perl/bin/perl > > >> use GD; > > >> print "Content-type: image/png\n\n"; > > >> my $file="test.txt"; > > >> sub min{ > >> my @a...@_; > >> my $s=pop @a;; > >> @a=map {$_-$s} @a; > >> return @a; > > >> } > > >> my @new; > > >> open(FILE,$file) or die; > >> while(my $line=<FILE>){ > >> chomp $line; > >> my @num=split /,/$dd[4]; > >> push @new,@num; > >> } > > >> close(FILE); > > >> @new=sort {$a<=>$b} @new; > > >> my $cha=$new[-1]-$new[0]; > > >> my $bei=$cha/700; > >> #my $bei=int ($cha/600); > >> my $size=$cha/$bei; > > >> # create a new image 图片大小按压缩之后X1.1倍 > >> my $im = new GD::Image($size*1.1+100,100); > > >> # allocate some colors > >> my $white = $im->colorAllocate(255,255,255); > >> my $black = $im->colorAllocate(0,0,0); > >> my $red = $im->colorAllocate(255,0,0); > >> my $blue = $im->colorAllocate(0,0,255); > > >> # make the background transparent and interlaced > >> $im->transparent($white); > >> $im->interlaced('true'); > > >> my $one=0; > >> my $two=20; > >> my $three=10; > >> my $four=5; > > >> open(FILE,$file) or die; > >> while(my $line=<FILE>){ > >> chomp $line; > >> my @dd=split /\t/,$line; > >> my $name=$dd[1]; > >> my @num=split /,/,$dd[4]; > >> @num=sort {$a<=>$b} @num; > > >> @num= &min(@num,$new[0]); ##传递参数给子程序的时候,会将所有参数存为一个数组 @_ > > >> for(my $i=0;$i<@num;){ > > >> $im->rectangle($num[$i]/$bei+100,$one,$num[$i+1]/$bei+100,$two, > >> $black); > > >> $im->fill($num[$i]/$bei+100+($num[$i+1]/$bei-$num[$i]/$bei)/2,$three, > >> $black); > >> $i=$i+2; > >> } > >> for(my $i=1;$i<@num-1;){ > > >> $im->line($num[$i]/$bei+100,$three,$num[$i+1]/$bei+100,$three, > >> $black); > >> $i=$i+2; > >> } > > >> $im->string(gdLargeFont,0,$four,$name,$black); > > >> # make sure we are writing to a binary stream > >> binmode STDOUT; > > >> # Convert the image to PNG and print it on standard output > >> print $im->png; > > >> $one=$one+40; > >> $two=$two+40; > >> $three=$three+40; > >> $four=$four+35; > > >> } > > >> close(FILE); --~--~---------~--~----~------------~-------~--~----~ 您收到此信息是由于您订阅了 Google 论坛“PerlChina Mongers 讨论组”论坛。 要在此论坛发帖,请发电子邮件到 [email protected] 要退订此论坛,请发邮件至 [email protected] 更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛 -~----------~----~----~----~------~----~------~--~---
