Bio AnnotationCollectionI
Other packages in the module: Bio::DB::HIV::HIVQueryHelper HIVSchema QRY R Q
Package variablesGeneral documentationMethods
Toolbar
WebCvs
Package variables
No package variables defined.
Included modules
Bio::Annotation::SimpleValue
Synopsis
No synopsis!
Description
No description!
Methods
get_valueDescriptionCode
put_valueDescriptionCode
get_keysDescriptionCode
Methods description
get_valuecode    nextTop
 Title   : get_value
Usage : $ac->get_value($tagname) -or-
$ac->get_value( $tag_level1, $tag_level2,... )
Function: access the annotation value assocated with the given tags
Example :
Returns : a scalar
Args : an array of tagnames that descend into the annotation tree
put_valuecodeprevnextTop
 Title   : put_value
Usage : $ac->put_value($tagname, $value) -or-
$ac->put_value([$tag_level1, $tag_level2, ...], $value) -or-
$ac->put_value( [$tag_level1, $tag_level2, ...] )
Function: create a node in an annotation tree, and assign a scalar value to it
if a value is specified
Example :
Returns : scalar or a Bio::AnnotationCollection object
Args : $tagname, $value scalars (can be specified as -KEYS=>$tagname,
-VALUE=>$value) -or-
\@tagnames, $value (or as -KEYS=>\@tagnames, -VALUE=>$value )
Note : If intervening nodes do not exist, put_value creates them, replacing
existing nodes. So if $ac->put_value('x', 10) was done, then later,
$ac->put_value(['x', 'y'], 20), the original value of 'x' is trashed, and $ac->get_value('x') will now return the annotation collection
with tagname 'y'.
get_keyscodeprevnextTop
 Title   : get_keys
Usage : $ac->get_keys($tagname_level_1, $tagname_level_2,...)
Function: Get an array of tagnames underneath the named tag nodes
Example : # prints the values of the members of Category 1...
print map { $ac->get_value($_) } $ac->get_keys('Category 1') ;
Returns : array of tagnames or empty list if the arguments represent a leaf
Args : [array of] tagname[s]
Methods code
get_valuedescriptionprevnextTop
sub get_value {
    local $_;
    my $self = shift;
    my @args = @_;
    my @h;
    return "" unless @_;
    while ($_ = shift @args) {
	@h = $self->get_Annotations($_);
	if (ref($h[0]->{value})) {
	    $self = $h[0]->{value}; # must be another Bio::AnnotationCollectionI
} else { last; } } return $h[0] && $h[0]->{value} ; # now the last value.
}
put_valuedescriptionprevnextTop
sub put_value {
    local $_;
    my $self = shift;
    my @args = @_;
    my ($keys, $value) = $self->_rearrange([qw( KEYS VALUE )], @args);
    my (@keys, $lastkey);
#    $value ||= new Bio::Annotation::Collection;
@keys = (ref($keys) eq 'ARRAY') ? @$keys : ($keys); $lastkey = pop @keys; foreach (@keys) { my $a = $self->get_value($_); if (ref($a) && $a->isa('Bio::Annotation::Collection')) { $self = $a; } else { # replace an old value
$self->remove_Annotations($_) if $a; my $ac = new Bio::Annotation::Collection; $self->add_Annotation(new Bio::Annotation::SimpleValue( -tagname => $_, -value => $ac ) ); $self = $ac; } } if ($self->get_value($lastkey)) { # replace existing value
($self->get_Annotations($lastkey))[0]->{value} = $value; } else { $self->add_Annotation(new Bio::Annotation::SimpleValue( -tagname=>$lastkey, -value=>$value )); } return $value;
}
get_keysdescriptionprevnextTop
sub get_keys {
    my $self = shift;
    my @keys = @_;
    foreach (@keys) {
	my $a = $self->get_value($_);
	if (ref($a) && $a->isa('Bio::Annotation::Collection')) {
	    $self = $a;
	}
	else {
	    return ();
	}
    }
    return $self->get_all_annotation_keys();
}

1;
}
General documentation
No general documentation available.