[Bioperl-l] First commit of Bio::Structure objects

Ewan Birney birney@ebi.ac.uk
Tue, 20 Nov 2001 10:36:35 +0000 (GMT)


On Tue, 20 Nov 2001, Kris Boulez wrote:

> 
> The graph object you describe, is this available somewhere ? I looked at
> http://www.informatics.jax.org/go/ (which I think is the GO browser you
> are referrig to), but could find no link to source code.
> 
> On CPAN I found a Graph package (Graph-0.201), which seems pretty
> complete at first sight. It does require an other external package
> (Heap). Thus adding two more external packages one needs to install to
> get BioPerl running.
> 
> Another option might be to do something pretty basic ourselves. Storing the
> child-parent relations in a hash ( $c_p{$child} = $parent ) and the
> parent-child relations in a hash to array refs 
> ( $p_c{$parent} = \@children ). It looks basic, but workable to me.
> 
> 
> We (my collegues and I) still think that having methods like
> 
> $atom->residue
> $residue->chain
> $chain->residue
> 
> would make working with the objects more natural. To accomplish this we
> only need a reference from every child object (at whatever layer) to the
> grand parent ('holder object' in Ewan speak). Thus allowing the residue
> method in Atom (first example) to translate the call to
> 
> $self->_grand_parent->get_residue($atom) 
> 
> The only thing that is needed is a DESTROY method on the grand parent 
> which deletes the graph(s), thus breaking all circular refs.

This still doesn't work - if the children hold onto the grandparents then
it wont release.

you need to have weak references here for the $self->_grand_parent



I still think you should go with Chris' proposal. Having a slightly more
clumsy interface to work around Perl's garbage colleciton problems is
better than leaking memory.