| Bio::Phylo::Dictionary - Container for annotations, attaches to other objects |
Bio::Phylo::Dictionary - Container for annotations, attaches to other objects
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>
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 the Bio::Phylo::Annotation manpage.
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
add_dictionary()
This method is here as an override of the method by the same name in
the Bio::Phylo::Util::XMLWritable manpage. 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:
the Bio::Phylo::Util::Exceptions manpage).
An annotation object is a key/value pair inside a dictionary.
This object inherits from the Bio::Phylo::Listable manpage, so methods defined there are also applicable here.
Also see the manual: the Bio::Phylo::Manual manpage and http://rutgervos.blogspot.com.
$Id: Dictionary.pm 844 2009-03-05 00:07:26Z rvos $
| Bio::Phylo::Dictionary - Container for annotations, attaches to other objects |