[Bioperl-l] Re: BioGraphics tutorial problem

Scott Cain cain at cshl.org
Fri Aug 8 15:03:28 EDT 2003


Laurence and Wes,

The cold was of the 24-hour variety so my head has cleared, and I have a
solution for the BioGraphics tutorial problem.  While it will not work
exactly as written in Lincoln's tutorial with BioPerl 1.2.2, it will
work with BioPerl 1.3 (when it is released).  I've created a perl script
that generates similar output via callbacks that works with BioPerl
1.2.2.  I added a few bells and whistles--my script also puts a
description (a secondary label) and colored the glyphs according to
score.

Here's the script:
#!/usr/local/bin/perl -w

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

my $panel= Bio::Graphics::Panel->new(-length =>1000,-width =>800);
my $track=$panel->add_track(-glyph      =>'generic',
                            -label      => sub{my $self=shift;
                                               return $self->seq_id;},
                            -description=> sub{my $self=shift;
                                               return $self->score;},
                            -bgcolor    => sub{my $self=shift;
                                               my $score = $self->score;
                                               if ($score >= 1000) {
                                                  return 'red';
                                                } else {
                                                  return 'green';
                                                }
                                               });

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

print $panel->png;
 
__DATA__
#hit    score   start   end
truc1   381     2       200
truc2   210     2       210
truc3   800     2       200
truc4   1000    380     921
truc5   812     402     972
truc6   1200    400     970
bum     400     300     620
pres1   127     310     700
-------------------------------------------------

Scott

On Thu, 2003-08-07 at 05:08, Laurence Amilhat wrote:
> Dear Scott, 
> 
> Thank you very much for your answer.
> The http://www.gmod.org/BioGraphicsTest.png is what am I expecting.
> I installed the BioPerl-1.2.2 version. I used the tutorial from
> Lincoln Stein at :
> http://stein.cshl.org/genome_informatics/BioGraphics
> 
> So, the only way to get my script working is to use bio-perl-live from
> CVS?
> I saw that I need a secure ssh (I have one), a CVS and an account to
> run script on bioperl live.
> but I don't know what is CVS?
> 
> Thank you,
> 
> Sincerely,
> 
> Laurence
> 
> 
> 
> 
> 
> 
> At 15:52 06/08/2003 -0400, you wrote:
> > Laurence,
> > 
> > I ran a script very similar to what you are using (the code I used
> > is
> > below), and I didn't have any problems, at least not if what is
> > expected
> > is the same as this: http://www.gmod.org/BioGraphicsTest.png.
> > 
> > I suspect you are having a version problem.  I am using bioperl-live
> > (from CVS), but when I installed bioperl-1.2.2, it failed in the way
> > you
> > describe.  Where is the tutorial you are reading?  Perhaps it is not
> > in
> > sync with the most recent version of released bioperl.
> > 
> > Here is the script I used:
> > #!/usr/local/bin/perl -w
> > 
> > use strict;
> > use Bio::Graphics;
> > use Bio::SeqFeature::Generic;
> > 
> > my $panel= Bio::Graphics::Panel->new(-length =>1000,-width =>800);
> > my $track=$panel->add_track(-glyph =>'generic',-label =>1);
> > 
> > while (<DATA>)
> > {
> >          chomp;
> >          next if /^\#/;
> >          my ($name,$score,$start,$end)=split /\s+/;
> >          warn "$name\n";
> >          my $feature=
> > Bio::SeqFeature::Generic->new(-display_name=>$name,-score=>$score,-start=>$start,-end=>$end);
> >          $track->add_feature($feature);
> > }
> > 
> > print $panel->png;
> > 
> > __DATA__
> > #hit    score   start   end
> > truc1   381     2       200
> > truc2   210     2       210
> > truc3   800     2       200
> > truc4   1000    380     921
> > truc5   812     402     972
> > truc6   1200    400     970
> > bum     400     300     620
> > pres1   127     310     700
> > 
> > Scott
> > 
> > On Wed, 2003-08-06 at 13:31, bioperl-l-request at portal.open-bio.org
> > wrote:
> > > I try to learn how to use the module Bio::Graphics.
> > > I found he How To from Lincoln Stein on the web. I try to practice
> > with the 
> > > examples, it's working except for the labels of the features that
> > don't 
> > > appear on my figure.
> > > Does anybody ever use this module?
> > 
> > -- 
> > ------------------------------------------------------------------------
> > Scott Cain, Ph. D.                                        
> > cain at cshl.org
> > GMOD Coordinator (http://www.gmod.org/)                    
> > 216-392-3087
> > Cold Spring Harbor Laboratory
> 
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> INRA, UMR INRA/UBP Amélioration et Santé des Plantes
> 234 avenue du Brézet
> 63039 Clermont-Ferrand Cedex 2
> 
> Tel 04 73 62 48 37
> Fax 04 73 62 44 53
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- 
------------------------------------------------------------------------
Scott Cain, Ph. D.                                         cain at cshl.org
GMOD Coordinator (http://www.gmod.org/)                     216-392-3087
Cold Spring Harbor Laboratory



More information about the Bioperl-l mailing list