BioPerl / BioGraphics只打印一个值而不是全部

时间:2014-04-30 12:59:29

标签: perl bioinformatics bioperl

我试图将SNP绘制到一个基因(或下面)上。我的代码如下:

#!/usr/bin/perl

use strict;
use warnings;

use Bio::Graphics;
use Bio::SeqFeature::Generic;


my @SNPs = "408777 408900 409100 409480";
my $gene_name = "GSTd10";
my $scaffold = "KB668289";
my $gene_start = 408763;
my $gene_end = 409489;
my $length = $gene_end - $gene_start + 50;

open my $png,  ">", "$gene_name.png" or die "Cannot open $gene_name.png: $!\n";

    #Create a panel for the image#
my $panel=Bio::Graphics::Panel->new(-offset => $gene_start, -length => $length, -width => 1000, -pad_left => 100, -pad_right => 10, -pad_top => 10);

my $track_whole=$panel->add_track(-glyph => 'graded_segments', -label => 1, -bgcolor => 'black', -font2color => 'black',);
my $feature= Bio::SeqFeature::Generic->new(-display_name => $gene_name, -start => $gene_start, -end => $gene_end,);
$track_whole->add_feature($feature);

my $track=$panel->add_track(-glyph => 'graded_segments', -label => 1, -bgcolor =>'blue', -min_score => 0, -max_score => 30, -font2color => 'black');
foreach my $SNP (@SNPs)
{
    my $feature= Bio::SeqFeature::Generic->new(-label => $SNP, -start => $SNP, -end => $SNP);
    $track->add_feature($feature);
}

#This will print out the final panel i.e. you must have created an object called $panel above
print $png $panel -> png;

每当我运行这个脚本时,我只会打印一行。 enter image description here

为了打印@SNPs中的所有值,错误在哪里?另外,有没有办法打印^而不是块?

1 个答案:

答案 0 :(得分:0)

在这一行

 my @SNPs = "408777 408900 409100 409480";

你只是创建一个包含整个字符串的单个元素的数组。

尝试

my @SNPs = qw(408777 408900 409100 409480);