Access the parent of a Bio::DB::SeqFeature within a gbrowse config callback function

View: New views
3 Messages — Rating Filter:   Alert me  

Access the parent of a Bio::DB::SeqFeature within a gbrowse config callback function

by Daniel Lang-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm looking for an efficient way (hack) to access the parent of a given
feature within a callback function in a gbrowse config. Currently I do
it like this:
if ($feature->get_tag_values('parent_id')) {


        my $store= $parent->object_store;


        if ($store and $store->can_store_parentage) {

                do {


                my @p   = $parent->get_tag_values('parent_id');


                if (@p) {


                $parent = @{ [ grep {$_ and $_->seq_id eq
$feature->seq_id and $_->location->contains($feature->location)}
$store->get_features_by_alias($p[0])] }[0];

                        }


               else { last; }
                        }


                until ($parent and ($name = $parent->name));


        }
}
The callback is used in to produce popups within a link attribute
(ggbmenu.js).
The problems with this approach are a)effciency and b) if a feature on
the same region exists with the same ID.

So I wonder if there is some "magic" object/variable in the scope of the
callback I could use? I originally hoped that this would work with
something like $GBROWSE...

Additionally, it would be great if someone could point me to code that
uses these "meta variables" (e.g. access browser or track or panel
objects) to generate content.

Thanks in advance,

Daniel

--

Daniel Lang
University of Freiburg, Plant Biotechnology
Schaenzlestr. 1, D-79104 Freiburg
fax: +49 761 203 6945
phone: +49 761 203 6974
homepage:  http://www.plant-biotech.net/
e-mail: daniel.lang@...

#################################################
My software never has bugs.
It just develops random features.
#################################################




-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Gmod-gbrowse mailing list
Gmod-gbrowse@...
https://lists.sourceforge.net/lists/listinfo/gmod-gbrowse

Re: Access the parent of a Bio::DB::SeqFeature within a gbrowse config callback function

by Lincoln Stein :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The objects are set up without parent pointers in order to avoid circular references, which make memory management a nightmare. It's a bit ugly, but if you set all_callbacks to true, then the callback will be invoked on the parent object as well, and you can simply store it into a global variable for access from the child. The operation is depth first, so the callback will be invoked on the child immediately after the parent.

A better long-term solution would be to add a method such that the parent is available by making a method call on the glyph object. I'll have a look.

Lincoln

On 6/1/07, Daniel Lang <daniel.lang@...> wrote:
Hi,

I'm looking for an efficient way (hack) to access the parent of a given
feature within a callback function in a gbrowse config. Currently I do
it like this:
if ($feature->get_tag_values('parent_id')) {


        my $store= $parent->object_store;


        if ($store and $store->can_store_parentage) {

                do {


                        my @p   = $parent->get_tag_values('parent_id');


                        if (@p) {


                                $parent = @{ [ grep {$_ and $_->seq_id eq
$feature->seq_id and $_->location->contains($feature->location)}
$store->get_features_by_alias($p[0])] }[0];

                        }


                        else { last; }
                        }


                until ($parent and ($name = $parent->name));


        }
}
The callback is used in to produce popups within a link attribute
(ggbmenu.js).
The problems with this approach are a)effciency and b) if a feature on
the same region exists with the same ID.

So I wonder if there is some "magic" object/variable in the scope of the
callback I could use? I originally hoped that this would work with
something like $GBROWSE...

Additionally, it would be great if someone could point me to code that
uses these "meta variables" ( e.g. access browser or track or panel
objects) to generate content.

Thanks in advance,

Daniel

--

Daniel Lang
University of Freiburg, Plant Biotechnology
Schaenzlestr. 1, D-79104 Freiburg
fax: +49 761 203 6945
phone: +49 761 203 6974
homepage:  http://www.plant-biotech.net/
e-mail: daniel.lang@...

#################################################
My software never has bugs.
It just develops random features.
#################################################




-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Gmod-gbrowse mailing list
Gmod-gbrowse@...
https://lists.sourceforge.net/lists/listinfo/gmod-gbrowse



--
Lincoln D. Stein
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
(516) 367-8380 (voice)
(516) 367-8389 (fax)
FOR URGENT MESSAGES & SCHEDULING,
PLEASE CONTACT MY ASSISTANT,
SANDRA MICHELSEN, AT michelse@...
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Gmod-gbrowse mailing list
Gmod-gbrowse@...
https://lists.sourceforge.net/lists/listinfo/gmod-gbrowse

Re: Access the parent of a Bio::DB::SeqFeature within a gbrowse config callback function

by Lincoln Stein :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

This issue has come up again recently and I am posting a fix that is better than the one suggested in the original email thread.

Callbacks actually take five arguments, although most people ignore all but the first. The fifth argument is the glyph, and you can get the parent feature from that. Here's the code:

 bgcolor = sub {
     my ($feature, $option_name, $part_no, $total_parts, $glyph) = @_;
     my $parent_feature = $glyph->parent_feature;
     # do something on the parent feature
 }

You can pass arguments to $glyph->parent_feature() to get the grandparent, great-grandparent, etc.

Lincoln

On Fri, Jun 1, 2007 at 11:11 AM, Lincoln Stein <lstein@...> wrote:
The objects are set up without parent pointers in order to avoid circular references, which make memory management a nightmare. It's a bit ugly, but if you set all_callbacks to true, then the callback will be invoked on the parent object as well, and you can simply store it into a global variable for access from the child. The operation is depth first, so the callback will be invoked on the child immediately after the parent.

A better long-term solution would be to add a method such that the parent is available by making a method call on the glyph object. I'll have a look.

Lincoln


On 6/1/07, Daniel Lang <daniel.lang@...> wrote:
Hi,

I'm looking for an efficient way (hack) to access the parent of a given
feature within a callback function in a gbrowse config. Currently I do
it like this:
if ($feature->get_tag_values('parent_id')) {


        my $store= $parent->object_store;


        if ($store and $store->can_store_parentage) {

                do {


                        my @p   = $parent->get_tag_values('parent_id');


                        if (@p) {


                                $parent = @{ [ grep {$_ and $_->seq_id eq
$feature->seq_id and $_->location->contains($feature->location)}
$store->get_features_by_alias($p[0])] }[0];

                        }


                        else { last; }
                        }


                until ($parent and ($name = $parent->name));


        }
}
The callback is used in to produce popups within a link attribute
(ggbmenu.js).
The problems with this approach are a)effciency and b) if a feature on
the same region exists with the same ID.

So I wonder if there is some "magic" object/variable in the scope of the
callback I could use? I originally hoped that this would work with
something like $GBROWSE...

Additionally, it would be great if someone could point me to code that
uses these "meta variables" ( e.g. access browser or track or panel
objects) to generate content.

Thanks in advance,

Daniel

--

Daniel Lang
University of Freiburg, Plant Biotechnology
Schaenzlestr. 1, D-79104 Freiburg
fax: +49 761 203 6945
phone: +49 761 203 6974
homepage:  http://www.plant-biotech.net/
e-mail: daniel.lang@...

#################################################
My software never has bugs.
It just develops random features.
#################################################




-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Gmod-gbrowse mailing list
Gmod-gbrowse@...
https://lists.sourceforge.net/lists/listinfo/gmod-gbrowse



--
Lincoln D. Stein
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
(516) 367-8380 (voice)
(516) 367-8389 (fax)
FOR URGENT MESSAGES & SCHEDULING,
PLEASE CONTACT MY ASSISTANT,
SANDRA MICHELSEN, AT michelse@...



--
Lincoln D. Stein
Director, Informatics and Biocomputing Platform
Ontario Institute for Cancer Research
101 College St., Suite 800
Toronto, ON, Canada M5G0A3
416 673-8514
Assistant: Renata Musa <Renata.Musa@...>

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Gmod-gbrowse mailing list
Gmod-gbrowse@...
https://lists.sourceforge.net/lists/listinfo/gmod-gbrowse