Rendering BLAST Output (version 3)

What if we want the scores displayed?

  #!/net/bin/perl -w
  # file: blast3.pl

  use strict;
  use Bio::Graphics;
  use Bio::SeqFeature::Generic;

  my $panel = Bio::Graphics::Panel->new(-length => 1000,
                                        -width  => 800,
                                        -pad_left => 10,
                                        -pad_right => 10,
                                       );

  my $full_length = Bio::SeqFeature::Generic->new(-start=>1,-end=>1000);
  $panel->add_track($full_length,
                    -glyph   => 'arrow',
                    -tick    => 2,
                    -fgcolor => 'black',
                    -double  => 1,
                   );

  my $track = $panel->add_track(-glyph => 'graded_segments',
                                -label  => 1,
                                -bgcolor => 'blue',
                                -min_score => 0,
                                -max_score => 1000,
                                -font2color     => 'red',
                                -sort_order     => 'high_score',
                                -description => sub {
                                  my $feature = shift;
                                  my $score   = $feature->score;
                                  return "score=$score";
                                 });

  while (<>) { # read blast file
    chomp;
    next if /^\#/;  # ignore comments
    my($name,$score,$start,$end) = split /\s+/;
    my $feature = Bio::SeqFeature::Generic->new(-score     => $score,
                                                -display_name => $name,
                                                -start        => $start,
                                                -end          => $end);
    $track->add_feature($feature);
  }

  print $panel->png;

New features:

  1. Sort the blast hits inside the track by their score, using the -sort_order option.
  2. Add a description line below each glyph by passing an anonymous subroutine (a code reference) to the -description option.

Here's the new display.

(~) 51% blast3.pl blast_hits.txt | display -

The output will look like this:


<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Wed Oct 22 22:03:44 EDT 2003