문제

I am trying to plot SNPs onto a gene (or below). The code I have is the following:

#!/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;

Whenever I run this script, I only get printed one line. enter image description here

Where is the mistake in order to print all values in @SNPs? In addition, is there a way of printing ^ instead of a block?

도움이 되었습니까?

해결책

In this line

 my @SNPs = "408777 408900 409100 409480";

You're just creating an array with a single element of that whole string.

Try

my @SNPs = qw(408777 408900 409100 409480);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top