[Bioperl-l] RE: Passing extra arguments to method references in
Bio::Graphics::Panel::add_track
Lincoln Stein
lstein at cshl.edu
Mon May 23 12:55:33 EDT 2005
$start = 23;
add_track(...
-label => sub { gene_description($start, at _) }
...
);
In other words, pass an anonymous subroutine in which the $start variable
(which has *ALREADY* been assigned) is passed to gene_description in front of
the other variables. If $start is going to change dynamically, you will have
to use a global or something similar, because once $start is incorporated
into the anonymous subroutine, it is stuck there.
Lincoln
On Monday 09 May 2005 11:30 am, michael watson (IAH-C) wrote:
> Hi
>
> Sorry, a bit hasty on the trigger....
>
> I am on bioperl-1.5.
>
> I'm using the following code to create some rather tasty images:
>
> $panel->add_track(transcript2 => \@includeCDS,
> -bgcolor => 'blue',
> -fgcolor => 'black',
> -key => 'CDS',
> -bump => 0,
> -height => 10,
> -label => \&gene_description,
> -description=> \&gene_label,
> );
>
> This is fairly standard, and @includeCDS is a bunch of feature objects.
>
> What I want to do is pass extra arguments to &gene_description, and then
> within &gene_description check to see if the feature start is greater
> than a certain value (the extra argument). If it is, then I want to
> return an empty string, if it isn't I want to return the gene
> description. Something like:
>
> -label => \&gene_description($start)
>
> But when I tried that it didn't work ;-(.
>
> So is it possible to pass extra arguments to those functions I am
> referencing above?
>
> Many thanks
>
> Mick
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
--
Lincoln D. Stein
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
More information about the Bioperl-l
mailing list