Entering edit mode
6.4 years ago
jeffrosario92
•
0
I've been having trouble for a while with this and have been trying to get this on my own, but I can't. I'm trying to display the gaps using Bio::Graphics after retrieving my sequences from an alignment file.
The command is ./aln.pl test-bioaln.aln > ll.png My expected output would be a .png file with sequences that are aligned and show gaps as a different color.
#!/usr/bin/perl
use Bio::AlignIO;
use Bio::Graphics;
my $line = shift @ARGV;
my $in = Bio::AlignIO->new(-file=>$line,-format=>"clustalw");
while($aln = $in->next_aln()){
foreach $seqobj($aln->each_seq()){
my $seq = $seqobj->seq;
my $id = $seqobj->id;
my $length = $seqobj->length;
my $seqobj = Bio::SeqFeature::Generic->new(-start =>1, -end=>$length,-display_name=>$id);
push (@seq, $seqobj);
}
foreach $seq(@seq){
my @features = $seq->get_SeqFeatures;
my %sorted_features;
for my $f (@features) {
my $tag = "\-";
push @{$sorted_features{$tag}},$f;
}
my $panel = Bio::Graphics::Panel->new(
-length => $seq->length,
-key_style => 'between',
-width => 800,
-pad_left => 10,
-pad_right => 10,
);
$panel->add_track(generic => Bio::SeqFeature::Generic->new(-start=>1,
-end=>$seq->length),
-glyph => 'generic',
-bgcolor => 'blue',
-label => 1,
);
my @colors = qw(cyan orange blue purple green chartreuse magenta yellow aqua);
my $idx = 0;
for my $tag (sort keys my %sorted_features) {
my $features = $sorted_features{$tag};
$panel->add_track($features,
-glyph => 'generic',
-bgcolor => $colors[$idx++ % @colors],
-fgcolor => 'black',
-font2color => 'red',
-key => "${tag}s",
-bump => +1,
-height => 8,
-label => 1,
-description => 1,
);
}
print $panel->png;
}
}
So far I have fixed the script to attach the sequence features to each sequence. I'm also able to get the ranges of each gap in each sequence. Im not sure how I should attach each of the ranges into the seqfeature though.