【问题标题】:BioPerl/BioGraphics only prints one value instead of allBioPerl/BioGraphics 只打印一个值而不是全部
【发布时间】:2014-05-01 00:19:49
【问题描述】:

我正在尝试将 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;

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

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

【问题讨论】:

标签: perl bioinformatics bioperl


【解决方案1】:

在这一行

 my @SNPs = "408777 408900 409100 409480";

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

试试

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

【讨论】:

  • 非常感谢!我永远不会回头看:/
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-07-30
  • 2018-07-17
  • 1970-01-01
相关资源
最近更新 更多