2014-04-30 27 views
0

我试图将SNP绘制到一个基因(或以下)上。我的代码如下:BioPerl/BioGraphics只打印一个值而不是全部

#!/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中的所有值,错在哪里?另外,有没有办法打印^而不是块?

+0

你应该问biostars:https://www.biostars.org – Pierre

+0

https://www.biostars.org/p/99412/ ......我会后回答一旦解决。 – fsimkovic

回答

0

在这一行

my @SNPs = "408777 408900 409100 409480"; 

你只是建立与整个字符串的单一元素的数组。

尝试

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

非常感谢你!我永远不会回头看:/ – fsimkovic

相关问题