- 论坛徽章:
- 0
|
各位大虾:
小弟偶得一段程序,如下。请问如何输出到一个.png的文件。(现在运行结果为乱码,在windows下)
use strict;
use warnings;
use Bio::Graphics;
use Bio::SeqIO;
use Bio::SeqFeature::Generic;
my $file = "E:\\perl_test\\AB07769.gbk" or die "provide a sequence file as the argument";
my $outfile=">e:\\perl_test\\gra.png";
my $io = Bio::SeqIO->new(-file=>$file);
my $out= Bio::SeqIO->new(-file=>">e:\\perl_test\\gra" ;
my $seq = $io->next_seq;
my @features = $seq->all_SeqFeatures;
# sort features by their primary tags
my %sorted_features;
for my $f (@features) {
my $tag = $f->primary_tag;
push @{$sorted_features{$tag}},$f;}
my $panel = Bio::Graphics: anel->new(
-length => $seq->length,
-key_style => 'between',
-width => 800,
-pad_left => 10,
-pad_right => 10);
$panel->add_track(arrow =>Bio::SeqFeature::Generic->new(-start => 1,-end => $seq->length),
-bump => 0,
-double=>1,
-tick => 2);
$panel->add_track(generic =>Bio::SeqFeature::Generic->new(-start => 1,
-end => $seq->length,
-bgcolor => 'blue',
-label => 1));
# general case
my @colors = qw(cyan orange blue purple green
chartreuse magenta yellow aqua);
my $idx = 0;
for my $tag (sort keys %sorted_features) {
my $features = $sorted_features{$tag};
$panel->add_track($features,
-glyph => 'generic',
-bgcolor => $colors[$idx++ % @colors],
-fgcolor => 'black',
-font2color => 'red',
-key => "${tag}s",
-bump => +1,
-height => 8,
-label => 1,
-description => 1,);
}
print $panel->png; |
|