File Coverage

blib/lib/OBO/Util/TermSet.pm
Criterion Covered Total %
statement 21 21 100.0
branch 5 6 83.3
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 33 34 97.0


line stmt bran cond sub pod time code
1             # $Id: TermSet.pm 2014-09-29 erick.antezana $
2             #
3             # Module : TermSet.pm
4             # Purpose : Term set.
5             # License : Copyright (c) 2006-2014 by Erick Antezana. All rights reserved.
6             # This program is free software; you can redistribute it and/or
7             # modify it under the same terms as Perl itself.
8             # Contact : Erick Antezana
9             #
10             package OBO::Util::TermSet;
11              
12             our @ISA = qw(OBO::Util::ObjectSet);
13 8     8   5275 use OBO::Util::ObjectSet;
  8         11  
  8         190  
14              
15 8     8   30 use strict;
  8         8  
  8         167  
16 8     8   33 use warnings;
  8         9  
  8         900  
17              
18             =head2 contains_id
19              
20             Usage - $set->contains_id($element_id)
21             Returns - true if this set contains an element with the given ID
22             Args - the ID to be checked
23             Function - checks if this set constains an element with the given ID
24            
25             =cut
26              
27             sub contains_id {
28 2     2 1 4 my ($self, $id) = @_;
29 2 100       9 return ($self->{MAP}->{$id})?1:0;
30             }
31              
32             =head2 contains_name
33              
34             Usage - $set->contains_name($element_name)
35             Returns - true if this set contains an element with the given name
36             Args - the name to be checked
37             Function - checks if this set constains an element with the given name
38            
39             =cut
40              
41             sub contains_name {
42 2     2 1 7 my $self = shift;
43 2         2 my $result = 0;
44 2 50       4 if (@_) {
45 2         4 my $term_id = shift;
46            
47 2         2 foreach my $ele (sort values %{$self->{MAP}}){
  2         16  
48 12 100       20 if ($ele->name() eq $term_id) {
49 1         2 $result = 1;
50 1         1 last;
51             }
52             }
53             }
54 2         6 return $result;
55             }
56              
57             1;
58              
59             __END__