bug 2549; fixed small bug in Bio::Taxon which doesn't catch -common_name
[bioperl-live.git] / Bio / Expression / FeatureGroup.pm
blobc4ee50c0ece3494f67d75e74c2aa8ccde146ec2f
1 # $Id$
2 # BioPerl module for Bio::Expression::FeatureGroup
4 # Copyright Allen Day <allenday@ucla.edu>, Stanley Nelson <snelson@ucla.edu>
5 # Human Genetics, UCLA Medical School, University of California, Los Angeles
7 # POD documentation - main docs before the code
9 =head1 NAME
11 Bio::Expression::FeatureGroup - a set of DNA/RNA features. ISA
12 Bio::Expression::FeatureI
14 =head1 SYNOPSIS
18 =head1 DESCRIPTION
20 A set of DNA/RNA features.
22 =head1 FEEDBACK
24 =head2 Mailing Lists
26 User feedback is an integral part of the evolution of this and other
27 Bioperl modules. Send your comments and suggestions preferably to one
28 of the Bioperl mailing lists. Your participation is much appreciated.
30 bioperl-l@bioperl.org - General discussion
31 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
33 =head2 Reporting Bugs
35 Report bugs to the Bioperl bug tracking system to help us keep track
36 the bugs and their resolution. Bug reports can be submitted via the
37 web:
39 http://bugzilla.open-bio.org/
41 =head1 AUTHOR
43 Allen Day E<lt>allenday@ucla.eduE<gt>
45 =head1 APPENDIX
47 The rest of the documentation details each of the object
48 methods. Internal methods are usually preceded with a _
50 =cut
52 # Let the code begin...
53 package Bio::Expression::FeatureGroup;
55 use strict;
57 use base qw(Bio::Root::Root Bio::Expression::FeatureI);
58 use vars qw($DEBUG);
60 =head2 new
62 Title : new
63 Usage : $featuregroup = Bio::Expression::FeatureGroup->new(%args);
64 Function: create a new featuregroup object
65 Returns : a Bio::Expression::FeatureGroup object
66 Args : an optional hash of parameters to be used in initialization:
67 -id -- the featuregroup ID
68 -type -- the featuregroup type
70 =cut
72 sub new {
73 my($class,@args) = @_;
74 my $self = bless {}, $class;
75 $self->_initialize(@args);
76 return $self;
79 =head2 _initialize
81 Title : _initialize
82 Usage : $featuregroup->_initialize(@args);
83 Function: initialize the featuregroup object
84 Returns : nothing
85 Args : @args
87 =cut
89 sub _initialize{
90 my ($self,@args) = @_;
91 my %param = @args;
93 $self->type($param{-type});
94 $self->id($param{-id} );
96 $self->SUPER::_initialize(@args);
97 $DEBUG = 1 if( ! defined $DEBUG && $self->verbose > 0);
100 =head2 type
102 Title : type
103 Usage : $featuregroup->type($optional_arg);
104 Function: get/set the type of the featuregroup
105 Comments: this is probably going to be a string like
106 "quality control", "mismatch blah blah", etc.
107 Returns : the featuregroup type
108 Args : a new value for the featuregroup type
110 =cut
112 sub type {
113 my $self = shift;
114 $self->{type} = shift if @_;
115 return $self->{type};
118 =head2 id
120 Title : id
121 Usage : $featuregroup->id($optional_arg);
122 Function: get/set the id of the featuregroup
123 Returns : the featuregroup id
124 Args : a new value for the featuregroup id
126 =cut
128 sub id {
129 my $self = shift;
130 $self->{id} = shift if @_;
131 return $self->{id};
135 =head2 standard_deviation
137 Title : standard_deviation
138 Usage : $featuregroup->standard_deviation($optional_arg);
139 Function: get/set the standard deviation of the featuregroup value
140 Returns : the featuregroup standard deviation
141 Args : a new value for the featuregroup standard deviation
142 Notes : this method does no calculation, it merely holds a value
144 =cut
146 sub standard_deviation {
147 my $self = shift;
148 $self->{standard_deviation} = shift if @_;
149 return $self->{standard_deviation};
152 =head2 quantitation
154 Title : quantitation
155 Usage : $featuregroup->quantitation($optional_arg);
156 Function: get/set the quantitation of the featuregroup
157 Returns : the featuregroup's quantitated value
158 Args : a new value for the featuregroup's quantitated value
159 Notes : this method does no calculation, it merely holds a value
161 =cut
163 sub quantitation {
164 my $self = shift;
165 $self->{quantitation} = shift if @_;
166 return $self->{quantitation};
169 =head2 quantitation_units
171 Title : quantitation_units
172 Usage : $featuregroup->quantitation_units($optional_arg);
173 Function: get/set the quantitation units of the featuregroup
174 Returns : the featuregroup's quantitated value units
175 Args : a new value for the featuregroup's quantitated value units
177 =cut
179 sub quantitation_units {
180 my $self = shift;
181 $self->{quantitation_units} = shift if @_;
182 return $self->{quantitation_units};
185 =head2 presence
187 Title : presence
188 Usage : $featuregroup->presence($optional_arg);
189 Function: get/set the presence call of the featuregroup
190 Returns : the featuregroup's presence call
191 Args : a new value for the featuregroup's presence call
193 =cut
195 sub presence {
196 my $self = shift;
197 $self->{presence} = shift if @_;
198 return $self->{presence};
201 =head2 add_feature
203 Title : add_feature
204 Usage : $feature_copy = $featuregroup->add_feature($feature);
205 Function: add a feature to the featuregroup
206 Returns : see this_feature()
207 Args : a Bio::Expression::FeatureI compliant object
209 =cut
211 sub add_feature {
212 my($self,@args) = @_;
213 foreach my $feature (@args){
214 $self->throw('Features must be Bio::Expression::FeatureI compliant') unless $feature->isa('Bio::Expression::FeatureI');
215 push @{$self->{features}}, $feature;
218 return $self->{features} ? $self->{features}->[-1] : undef;
221 =head2 this_feature
223 Title : this_feature
224 Usage : $feature = $featuregroup->this_feature
225 Function: access the last feature added to the featuregroup
226 Returns : the last feature added to the featuregroup
227 Args : none
229 =cut
231 sub this_feature {
232 my $self = shift;
233 return $self->{features} ? $self->{features}->[-1] : undef;
236 =head2 each_feature
238 Title : each_feature
239 Usage : @features = $featuregroup->each_feature
240 Function: returns a list of Bio::Expression::FeatureI compliant
241 objects
242 Returns : a list of objects
243 Args : none
245 =cut
247 sub each_feature {
248 my $self = shift;
249 return @{$self->{features}} if defined($self->{features});
250 return ();
253 =head2 each_feature_quantitation
255 Title : each_feature_quantitation
256 Usage : @featurequantitions = $featuregroup->each_feature_quantitation;
257 Function: returns an list of quantitations of the features in the featuregroup
258 Returns : a list of numeric values
259 Args : none
261 =cut
263 sub each_feature_quantitation {
264 my $self = shift;
265 my @values = ();
266 push @values, $_->value foreach $self->each_feature;
267 return @values;
270 =head2 is_qc
272 Title : is_qc
273 Usage : $is_quality_control = $featuregroup->is_qc
274 Function: get/set whether or not the featuregroup is used for quality control purposes
275 Returns : a boolean (equivalent)
276 Args : a new value
278 =cut
280 sub is_qc {
281 my $self = shift;
282 $self->{is_qc} = shift if defined @_;
283 return $self->{is_qc};