[Bioperl-l] Sorting Bio:Graphics::Glyphs

Oliver Burren oliver.burren at cimr.cam.ac.uk
Wed Dec 3 11:01:49 EST 2003


Lincoln,

Thanks for pointing this out.

My fault I was using perldoc on the wrong version of Glyph.pm (1.2) to
clear up confusion.

Works perfectly now,

Apologies,

Olly

On Wed, 2003-12-03 at 15:25, Lincoln Stein wrote:
> I'm confused that the POD documentation tells you to use $a and $b.  In my 
> version of 1.3, the docs say this:
> 
> >>>>>>>>>>>>>>>>>>
> Finally, a subroutine coderef with a $$ prototype can be provided.  It
> will receive two B<glyph> as arguments and should return -1, 0 or 1
> (see Perl's sort() function for more information).  For example, to
> sort a set of database search hits by bits (stored in the features'
> "score" fields), scaled by the log of the alignment length (with
> "start" position breaking any ties):
> 
>   sort_order = sub ($$) {
>     my ($glyph1,$glyph2) = @_;
>     my $a = $glyph1->feature;
>     my $b = $glyph2->feature;
>     ( $b->score/log($b->length)
>           <=>
>       $a->score/log($a->length) )
>           ||
>     ( $a->start <=> $b->start )
>   }
> 
> It is important to remember to use the $$ prototype as shown in the
> example.  Otherwise Bio::Graphics will quit with an exception. The
> arguments are subclasses of Bio::Graphics::Glyph, not the features
> themselves.  While glyphs implement some, but not all, of the feature
> methods, to be safe call the two glyphs' feature() methods in order to
> convert them into the actual features.
> <<<<<<<<<<<<<<<
> 
> This, of course, also explains the main problem you are having.
> 
> Lincoln
> 
> 
> On Wednesday 03 December 2003 09:14 am, Oliver Burren wrote:
> > Hi,
> >
> > I have a lot of transcripts that I'm rendering using the excellent
> > Bio::Graphics module. I want to sort these by the last two characters in
> > the display_name attribute. I used the following callback
> >
> > sub sort_trans($$){substr($_[0]->display_name,-2)<=>
> >                   substr($_[1]->display_name,-2)}
> > # the last two chars are numbers therefore using <=>
> >
> > I then added
> > the following  track glyph
> >
> > my $ttrack=$panel->add_track(\@transcripts,
> >                         -glyph=>'transcript',
> >                         #......more options here
> >                         -sort_order=>&sort_trans # should this be
> > # \&sort_trans ?
> >                         );
> >
> > If i then run this I get the following error
> >
> > Can't call method "display_name" on unblessed reference at gene_page.cgi
> > line 93, <DATA> line 191.
> >
> > In the pod documentation for Glyphs it says to use $a and $b vars if I
> > use these though i get an exception that tells me to use a ($$)
> > prototype (which I think I'm doing by using a call back with
> > prototype).
> >
> > I'm using Version 1.3 of bioperl.
> >
> > Can anyone point out what I should be doing or am doing wrong ?
> >
> > Thanks,
> >
> > Olly Burren
-- 
-------------------------------------------------------------------------------
JDRF/WT Diabetes and Inflammation Laboratory
Cambridge Institute for Medical Research
Addenbrooke's Hospital Site
Hills Road,
Cambridge
CB2 2XY
Tel. +44 (0)1223 762598 Fax. +44 (0)1223 762102
-------------------------------------------------------------------------------





More information about the Bioperl-l mailing list