Bio-Phylo
view release on metacpan or search on metacpan
lib/Bio/Phylo/Mediators/TaxaMediator.pm view on Meta::CPAN
sub set_link {
my $self = shift;
my %opt = @_;
my ( $one, $many ) = ( $opt{'-one'}, $opt{'-many'} );
my ( $one_id, $many_id ) = ( $one->get_id, $many->get_id );
$one_to_one{$many_id} = $one_id;
$one_to_many{$one_id} = {} unless $one_to_many{$one_id};
# once other objects start referring to the taxon we want
# these references to keep the taxon "alive" until all other
# objects pointing to it have gone out of scope, in which
# case the reference must be weakened again, so that it
# might get cleaned up also
if (isweak($object[$one_id]) ) {
my $strong = $object[$one_id];
$object[$one_id] = $strong;
}
$one_to_many{$one_id}->{$many_id} = $many->_type;
return $self;
lib/Bio/Phylo/NeXML/Writable.pm view on Meta::CPAN
# this deserves an explanation. the issue is as follows: for the package
# bio-phylo-megatree we have node objects that are persisted in a database
# and accessed through an object-relational mapping provided by DBIx::Class.
# these node objects are created and destroyed on the fly as a set of node
# records (i.e. a tree) is traversed. this is the whole point of the package,
# because it means large trees don't ever have to be kept in memory. however,
# as a consequence, every time one of those ORM-backed nodes goes out of scope,
# this destructor is called and all the @fields are cleaned up again. this
# precludes computation and caching of node coordinates (or any other semantic
# annotation) on such ORM-backed objects. the terrible, terrible fix for now is
# to just assume that i) these annotations need to stay alive ii) we're not going
# to have ID clashes (!!!!!), so iii) we just don't clean up after ourselves.
# as a note to my future self: it would be a good idea to have a triple store-like
# table to store the annotations, so they are persisted in the same way as the
# node objects, bypassing this malarkey.
if ( not $self->isa('DBIx::Class::Core') ) {
my $id = $self->get_id;
for my $field (@fields) {
delete $field->{$id};
}
}
( run in 0.505 second using v1.01-cache-2.11-cpan-39bf76dae61 )