The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bio::Phylo::Dictionary - Container for annotations, attaches to other objects

SYNOPSIS

 use Bio::Phylo::Factory;
 my $fac = Bio::Phylo::Factory->new;
 # there are several data types: string, integer, float, uri, any, etc.
 # refer to nexml.org for a complete list
 my $dic = $fac->create_dictionary( -tag => 'string' );
 my $ann = $fac->create_annotation( -value => 'This is a description' );
 $dic->insert( $ann );
 print $dic->to_xml;

 # prints: <dict><string id="string2">This is a description</string></dict>

DESCRIPTION

To comply with the NeXML standard (http://www.nexml.org), Bio::Phylo implements dictionary annotations, which consist conceptually of key/value pairs where the key is an xml id (which is either autogenerated or can be set using the set_xml_id method) and the value is the containing element (whose name specifies the data type of its text contents, i.e. string, integer, float and so on).

This class implements a container for a set of key/value pairs. The container can also hold other containers, thereby creating a recursive data structure. For the syntax of each individual key/value pair, refer to Bio::Phylo::Annotation.

METHODS

CONSTRUCTOR

new()

Factory constructor.

 Type    : Constructor
 Title   : new
 Usage   : my $dict = Bio::Phylo::Dictionary->new;
 Function: Initializes a Bio::Phylo::Dictionary object.
 Returns : A Bio::Phylo::Dictionary object.
 Args    : optional constructor arguments are key/value
                   pairs where the key corresponds with any of
                   the methods that starts with set_ (i.e. mutators) 
                   and the value is the permitted argument for such 
                   a method. The method name is changed such that,
                   in order to access the set_value($val) method
                   in the constructor, you would pass -value => $val

MUTATORS

add_dictionary()

This method is here as an override of the method by the same name in Bio::Phylo::Util::XMLWritable. This is here to ensure that dictionaries are not attached to other dictionaries. They can be inserted, recursively, into other dictionaries (but that's not the same thing! User the insert() method for that). If you call add_dictionary to an dictionary an exception of type Bio::Phylo::Util::Exceptions::BadArgs will be thrown (see exceptions: Bio::Phylo::Util::Exceptions).

SEE ALSO

Bio::Phylo::Annotation

An annotation object is a key/value pair inside a dictionary.

Bio::Phylo::Listable

This object inherits from Bio::Phylo::Listable, so methods defined there are also applicable here.

Bio::Phylo::Manual

Also see the manual: Bio::Phylo::Manual and http://rutgervos.blogspot.com.

REVISION

 $Id: Dictionary.pm 844 2009-03-05 00:07:26Z rvos $