[BCS] Bio::Chado::Schema many_to_many introspection

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[BCS] Bio::Chado::Schema many_to_many introspection

Bob MacCallum
Mostly for Rob...

I have been playing a bit with introspection on BCS objects (while
figuring out how to serialize them (to JSON) including one or more
levels of related objects).

You can get a list of relationships with this
  @rels = $feature->relationships
but it doesn't tell you about many_to_many relationships, such as
parent_features and child_features (which are added manually; I am
going to be adding all the many_to_many relationships for NatDiv and
related classes soon - stay tuned to
http://github.com/bobular/Bio-Chado-Schema).

There's a plugin which does it though, it's called
DBIx::Class::IntrospectableM2M

We just need to add this before the first many_to_many definition.
 __PACKAGE__->load_components(qw/IntrospectableM2M/);

and then the m2m relationships and their get/set/add/remove method
names can be obtained, not through $object->relationships, but another
method, but it works.

So the question is, should I add this extra dependency (to a module
that may not continue to be compatible) and complexity for one
potential very specialised use case (that could probably be done
another way...any ideas...)?

cheers,
Bob.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Gmod-schema mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-schema
Reply | Threaded
Open this post in threaded view
|

Re: [BCS] Bio::Chado::Schema many_to_many introspection

Robert Buels
Bob MacCallum wrote:
> I have been playing a bit with introspection on BCS objects (while
> figuring out how to serialize them (to JSON) including one or more
> levels of related objects).

I think Josh Goodman was looking at doing something very similar,
looking at using BCS as part of the next generation replacement for
XORT.  You guys might compare notes.  He's usually in #gmod on
irc.perl.org, that would probably be a good place to discuss it if you
guys can get the timezones worked out.

> You can get a list of relationships with this
>   @rels = $feature->relationships
> but it doesn't tell you about many_to_many relationships, such as
> parent_features and child_features (which are added manually; I am
> going to be adding all the many_to_many relationships for NatDiv and
> related classes soon - stay tuned to
> http://github.com/bobular/Bio-Chado-Schema).

Oh wow.  If you do that, you are a beast!  But a friendly one, like a
teddy bear with big scythe-like claws of code.

> There's a plugin which does it though, it's called
> DBIx::Class::IntrospectableM2M
>
> We just need to add this before the first many_to_many definition.
>  __PACKAGE__->load_components(qw/IntrospectableM2M/);
>
> and then the m2m relationships and their get/set/add/remove method
> names can be obtained, not through $object->relationships, but another
> method, but it works.
>
> So the question is, should I add this extra dependency (to a module
> that may not continue to be compatible) and complexity for one
> potential very specialised use case (that could probably be done
> another way...any ideas...)?

We probably shouldn't add this to BCS core, or at least not have it on
by default.  Depending on exactly how you're serializing, you probably
need to work with the underlying simple relationships anyway, I would
think?  But, if you really need the additional many-to-many
introspection, there is probably a way to make it an option when loading
BCS.

Rob


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Gmod-schema mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-schema
Reply | Threaded
Open this post in threaded view
|

Re: [BCS] Bio::Chado::Schema many_to_many introspection

Josh Goodman
Hi Rob and Bob,

Many to many relationships are not something I run into a lot because of how I use Chado.  When
dumping data that is used to produce the website we tend to start from the view point of a
particular object/data class (e.g. gene, allele, transcript, protein, etc.) and Chado table
(feature, library, pub, etc.) and then branch out from there.  Thus, for my use case the one to many
relationships are all I need.  Unless I misunderstood your question I don't think I have any advice
to offer you, sorry.

Josh

On 10/27/2010 01:50 PM, Robert Buels wrote:

> Bob MacCallum wrote:
>> I have been playing a bit with introspection on BCS objects (while
>> figuring out how to serialize them (to JSON) including one or more
>> levels of related objects).
>
> I think Josh Goodman was looking at doing something very similar,
> looking at using BCS as part of the next generation replacement for
> XORT.  You guys might compare notes.  He's usually in #gmod on
> irc.perl.org, that would probably be a good place to discuss it if you
> guys can get the timezones worked out.
>
>> You can get a list of relationships with this
>>   @rels = $feature->relationships
>> but it doesn't tell you about many_to_many relationships, such as
>> parent_features and child_features (which are added manually; I am
>> going to be adding all the many_to_many relationships for NatDiv and
>> related classes soon - stay tuned to
>> http://github.com/bobular/Bio-Chado-Schema).
>
> Oh wow.  If you do that, you are a beast!  But a friendly one, like a
> teddy bear with big scythe-like claws of code.
>
>> There's a plugin which does it though, it's called
>> DBIx::Class::IntrospectableM2M
>>
>> We just need to add this before the first many_to_many definition.
>>  __PACKAGE__->load_components(qw/IntrospectableM2M/);
>>
>> and then the m2m relationships and their get/set/add/remove method
>> names can be obtained, not through $object->relationships, but another
>> method, but it works.
>>
>> So the question is, should I add this extra dependency (to a module
>> that may not continue to be compatible) and complexity for one
>> potential very specialised use case (that could probably be done
>> another way...any ideas...)?
>
> We probably shouldn't add this to BCS core, or at least not have it on
> by default.  Depending on exactly how you're serializing, you probably
> need to work with the underlying simple relationships anyway, I would
> think?  But, if you really need the additional many-to-many
> introspection, there is probably a way to make it an option when loading
> BCS.
>
> Rob
>
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Gmod-schema mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gmod-schema

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Gmod-schema mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-schema
Reply | Threaded
Open this post in threaded view
|

Re: [BCS] Bio::Chado::Schema many_to_many introspection

Siddhartha Basu
In reply to this post by Bob MacCallum
Hi Bob,

On Wed, 27 Oct 2010, Bob MacCallum wrote:

> Mostly for Rob...
>
> I have been playing a bit with introspection on BCS objects (while
> figuring out how to serialize them (to JSON) including one or more
> levels of related objects).

Just wondering how you are approaching for BCS -> JSON conversion. One
of them could be using the HashRefInflator. As far as m2m goes here is a
interesting discussion from dbic mailing list ....
http://dbix-class.35028.n2.nabble.com/RecursiveUpdate-and-many-to-many-tt1122619.html#none
IMHO,  if you need m2m introspection for getting JSON and willing to
give up the accessor name generated by many_to_many method,  the
relationship can be easily infered by looking through has_many <->
belongs_to <-> has_many bridge.
So far i have done it the other way for my modware project,  that is
inflating my object to perl hashes to feed the create(multicreate) method of bcs/dbic.
Going from resultset to json might be also useful for web apps also. If it
sounds overlapping let me know,  we might help out each other.

thanks,
-siddhartha


>
> You can get a list of relationships with this
>   @rels = $feature->relationships
> but it doesn't tell you about many_to_many relationships, such as
> parent_features and child_features (which are added manually; I am
> going to be adding all the many_to_many relationships for NatDiv and
> related classes soon - stay tuned to
> http://github.com/bobular/Bio-Chado-Schema).
>
> There's a plugin which does it though, it's called
> DBIx::Class::IntrospectableM2M
>
> We just need to add this before the first many_to_many definition.
>  __PACKAGE__->load_components(qw/IntrospectableM2M/);
>
> and then the m2m relationships and their get/set/add/remove method
> names can be obtained, not through $object->relationships, but another
> method, but it works.
>
> So the question is, should I add this extra dependency (to a module
> that may not continue to be compatible) and complexity for one
> potential very specialised use case (that could probably be done
> another way...any ideas...)?
>
> cheers,
> Bob.
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Gmod-schema mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gmod-schema

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Gmod-schema mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-schema
Reply | Threaded
Open this post in threaded view
|

Re: [BCS] Bio::Chado::Schema many_to_many introspection

Bob MacCallum
On Sat, Oct 30, 2010 at 4:21 AM, Siddhartha Basu <[hidden email]> wrote:

> Hi Bob,
>
> On Wed, 27 Oct 2010, Bob MacCallum wrote:
>
>> Mostly for Rob...
>>
>> I have been playing a bit with introspection on BCS objects (while
>> figuring out how to serialize them (to JSON) including one or more
>> levels of related objects).
>
> Just wondering how you are approaching for BCS -> JSON conversion. One
> of them could be using the HashRefInflator.

At the moment everything is very tentative and prototypic... but I've
simply used { $object->get_columns } to hashify the object. Haven't
really taken care of any kind of relationship yet!  HashRefInflator
sounds useful, except that I think we will work with vanilla DBIC
objects in our API and (primarily HTML) web application and then in
the View::JSON do the serialisation (as I described above, or some
other way) of the catalyst stash.  HashRefInflator might work if only
resultsets were in the stash though.

I haven't finished reading up on all the existing ways to do web
services in Catalyst though...

> As far as m2m goes here is a
> interesting discussion from dbic mailing list ....
> http://dbix-class.35028.n2.nabble.com/RecursiveUpdate-and-many-to-many-tt1122619.html#none
> IMHO,  if you need m2m introspection for getting JSON and willing to
> give up the accessor name generated by many_to_many method,  the
> relationship can be easily infered by looking through has_many <->
> belongs_to <-> has_many bridge.
> So far i have done it the other way for my modware project,  that is
> inflating my object to perl hashes to feed the create(multicreate) method of bcs/dbic.
> Going from resultset to json might be also useful for web apps also. If it
> sounds overlapping let me know,  we might help out each other.
>

I hope so.  Thanks for your reply.  I still need to give more thought
to the m2m stuff, and indeed the standard relationships and also
serialising resultsets.

cheers,
Bob.

> thanks,
> -siddhartha
>
>
>>
>> You can get a list of relationships with this
>>   @rels = $feature->relationships
>> but it doesn't tell you about many_to_many relationships, such as
>> parent_features and child_features (which are added manually; I am
>> going to be adding all the many_to_many relationships for NatDiv and
>> related classes soon - stay tuned to
>> http://github.com/bobular/Bio-Chado-Schema).
>>
>> There's a plugin which does it though, it's called
>> DBIx::Class::IntrospectableM2M
>>
>> We just need to add this before the first many_to_many definition.
>>  __PACKAGE__->load_components(qw/IntrospectableM2M/);
>>
>> and then the m2m relationships and their get/set/add/remove method
>> names can be obtained, not through $object->relationships, but another
>> method, but it works.
>>
>> So the question is, should I add this extra dependency (to a module
>> that may not continue to be compatible) and complexity for one
>> potential very specialised use case (that could probably be done
>> another way...any ideas...)?
>>
>> cheers,
>> Bob.
>>
>> ------------------------------------------------------------------------------
>> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
>> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
>> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
>> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
>> http://p.sf.net/sfu/nokia-dev2dev
>> _______________________________________________
>> Gmod-schema mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/gmod-schema
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Gmod-schema mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gmod-schema
>

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Gmod-schema mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-schema
Reply | Threaded
Open this post in threaded view
|

Re: [BCS] Bio::Chado::Schema many_to_many introspection

Robert Buels
Bob MacCallum wrote:
> I haven't finished reading up on all the existing ways to do web
> services in Catalyst though...

Well, Catalyst::Controller::REST and company would be my first stop for
that.  See http://search.cpan.org/~bobtfish/Catalyst-Action-REST-0.86/

Rob

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Gmod-schema mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-schema