Permalink
Browse files

Implemented hash_tree and get_values. Added more tests.

  • Loading branch information...
1 parent e73df8d commit 5a866c5ddfdae06de07f2f12d30a322a406a65dc @Takadonet Takadonet committed Apr 6, 2011
Showing with 12 additions and 11 deletions.
  1. +8 −11 lib/Bio/Annotation/StructuredValue.pm
  2. +4 −0 t/Annotation/Annotation.t
@@ -38,12 +38,11 @@ class Bio::Annotation::StructuredValue is Bio::AnnotationI {
# =cut
-# method hash_tree{
-# my ($self) = @_;
-
-# my $h = {};
-# $h.{'value'} = $self.value;
-# }
+method hash_tree(){
+ my %h;
+ %h{'value'} = self.value;
+ return %h;
+}
# =head2 tagname
@@ -173,11 +172,9 @@ method !to_text(@arr,$joins,$brackets,$rec_n? is copy) {
# =cut
-# method get_values{
-# my $self = shift;
-
-# return @{$self.{'values'}};
-# }
+method get_values(){
+ return @!values;
+}
# =head2 get_all_values
@@ -163,6 +163,7 @@ is($n, 3);
# annotation of structured simple values (like swissprot''is GN line)
my $ann = Bio::Annotation::StructuredValue.new();
ok($ann ~~ Bio::AnnotationI);
+is $ann.hash_tree.{'value'},'';
$ann.add_value([-1], "val1");
is($ann.value(), "val1");
@@ -175,8 +176,11 @@ is($ann.value(joins => [" AND "]), "val1 AND val2");
$ann.add_value([-1,-1], "val3", "val4");
$ann.add_value([-1,-1], "val5", "val6");
$ann.add_value([-1,-1], "val7");
+
is($ann.value(joins => [" AND "]), "val1 AND val2 AND (val3 AND val4) AND (val5 AND val6) AND val7");
is($ann.value(joins => [" AND ", " OR "]), "val1 AND val2 AND (val3 OR val4) AND (val5 OR val6) AND val7");
+is $ann.hash_tree.{'value'},'val1; val2; (val3; val4); (val5; val6); val7';
+ok($ann.get_values() ~~ Array);
$n = 1;
for ($ann.get_all_values()) {

0 comments on commit 5a866c5

Please sign in to comment.