This is a test version of Biostars. For the public version, visit https://www.biostars.org.
BioPerl/BioGraphics only prints one value instead of all

I am trying to plot SNPs onto a gene.

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";

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(-start=>$SNP,-end=>$SNP);
    $track->add_feature($feature);}

print $png $panel -> png;

Result:

How can I print all values in @SNPs?

bioperl perl biographics

Modules files are all loaded but removed here to match the character limit!

1 answer

Problem solved.

my @SNPs = "408777 408900 409100 409480";

should be ...

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

Log in to answer this question.