[Bioperl-l] New Annotation interfaces!
Chris Mungall
cjm@fruitfly.bdgp.berkeley.edu
Tue, 30 Oct 2001 23:53:13 -0800 (PST)
On Tue, 30 Oct 2001, Hilmar Lapp wrote:
> Ewan Birney wrote:
> >
> >
> > The second method allows annotations to at least attempt to represent
> > themselves as pure data for storage/display/whatever. The method
> > hash_tree
> >
> > $hash = $annotation->hash_tree();
> >
> > should return an anonymous hash with "XML-like" formatting. The
> > formatting is as follows.
> >
> > (1) For each key in the hash, if the value is a reference'd array -
> >
> > (2) For each element of the array if the value is a object -
>
> So this should better read
>
> For each element
> (2) if the value is an object
> > Assumme the object has the method "hash_tree";
> > (3) else if the value is a referene to a hash
> > Recurse again from point (1)
> > (4) else
> > Assumme the value is a scalar, and handle it directly as text
> >
> > (5) else (if not an array) apply rules 2,3 and 4 to value
>
> The difficulty I see here is how do you cleanly and generically
> tell apart an object from a hash reference in Perl? ref($thingy)
> is true and a string in
if (ref($thingy) eq "HASH") {....}
Ok, it's not all that nice but it works.
> both cases; in fact an object in perl mostly is a hash ref. So I
> would actually
> not allow an 'unblessed hash ref' as a tree node, i.e., if a hash
> ref, it has
> to be blessed into a base class (AnnotationI? AnnotationNode?
> TreeNode?), or
> you instantiate that base class right away and then put any keys
> you want. This also means that that base class must not put its
> own private keys, or you introduce some rule how tree-related keys
> have to start (doesn't sound very sane).
>
> -hilmar
>
> --
> -----------------------------------------------------------------
> Hilmar Lapp email: hilmarl@yahoo.com
> San Diego, Ca. 92130 phone: +1 858 812 1757
> -----------------------------------------------------------------
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>