* sync with trunk
[bioperl-live.git] / Bio / Search / GenericStatistics.pm
blobeb4776c08e0e87efb0139e06ccfa2413585186a9
1 #
3 # BioPerl module for wrapping statistics
5 # Cared for by Chad Matsalla (bioinformatics1 at dieselwurks dot com)
7 # Copyright Chad Matsalla
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
13 =head1 NAME
15 Bio::Search::GenericStatistics - An object for statistics
17 =head1 SYNOPSIS
19 my $void = $obj->set_statistic("statistic_name","statistic_value");
20 my $value = $obj->get_statistic("statistic_name");
22 =head1 DESCRIPTION
24 This is a basic container to hold the statistics returned from a program.
26 =head1 FEEDBACK
28 =head2 Mailing Lists
30 User feedback is an integral part of the evolution of this and other
31 Bioperl modules. Send your comments and suggestions preferably to
32 the Bioperl mailing list. Your participation is much appreciated.
34 bioperl-l@bioperl.org - General discussion
35 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
37 =head2 Reporting Bugs
39 Report bugs to the Bioperl bug tracking system to help us keep track
40 of the bugs and their resolution. Bug reports can be submitted via the
41 web:
43 http://bugzilla.open-bio.org/
45 =head1 AUTHOR - Chad Matsalla
47 Email bioinformatics1 at dieselwurks dot com
49 =head1 CONTRIBUTORS
51 Sendu Bala, bix@sendu.me.uk
53 =head1 APPENDIX
55 The rest of the documentation details each of the object methods.
56 Internal methods are usually preceded with a _
58 =cut
60 # Let the code begin...
62 package Bio::Search::GenericStatistics;
63 use strict;
66 use base qw(Bio::Root::Root Bio::Search::StatisticsI);
68 sub new {
69 my ($class, @args) = @_;
70 my $self = $class->SUPER::new(@args);
71 return $self;
74 =head2 get_statistic
76 Title : get_statistic
77 Usage : $statistic_object->get_statistic($statistic_name);
78 Function: Get the value of a statistic named $statistic_name
79 Returns : A scalar that should be a string
80 Args : A scalar that should be a string
82 =cut
84 sub get_statistic {
85 my ($self,$arg) = @_;
86 return $self->{stats}->{$arg};
89 =head2 set_statistic
91 Title : set_statistic
92 Usage : $statistic_object->set_statistic($statistic_name => $statistic_value);
93 Function: Set the value of a statistic named $statistic_name to $statistic_value
94 Returns : Void
95 Args : A hash containing name=>value pairs
97 =cut
99 sub set_statistic {
100 my ($self,$name,$value) = @_;
101 $self->{stats}->{$name} = $value;
104 =head2 available_statistics
106 Title : available_statistics
107 Usage : my @statnames = $statistic_object->available_statistics
108 Function: Returns the names of the available statistics
109 Returns : list of available statistic names
110 Args : none
112 =cut
114 sub available_statistics {
115 my $self = shift;
116 return keys %{$self->{stats}};