Squash warning
[bioperl-live.git] / Bio / Phenotype / Measure.pm
blobd6f448787a0f91289ec69068240d13296061a353
1 # $Id$
3 # BioPerl module for Bio::Phenotype::Measure
5 # Cared for by Christian M. Zmasek <czmasek@gnf.org> or <cmzmasek@yahoo.com>
7 # (c) Christian M. Zmasek, czmasek@gnf.org, 2002.
8 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
10 # You may distribute this module under the same terms as perl itself.
11 # Refer to the Perl Artistic License (see the license accompanying this
12 # software package, or see http://www.perl.com/language/misc/Artistic.html)
13 # for the terms under which you may use, modify, and redistribute this module.
15 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
16 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17 # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 # You may distribute this module under the same terms as perl itself
21 # POD documentation - main docs before the code
23 =head1 NAME
25 Bio::Phenotype::Measure - Representation of context/value(-range)/unit triplets
27 =head1 SYNOPSIS
29 use Bio::Phenotype::Measure;
31 my $measure = Bio::Phenotype::Measure->new( -context => "length",
32 -description => "reduced length in 4(Tas1r3)",
33 -start => 0,
34 -end => 15,
35 -unit => "mm",
36 -comment => "see also Miller et al" );
38 print $measure->context();
39 print $measure->description();
40 print $measure->start();
41 print $measure->end();
42 print $measure->unit();
43 print $measure->comment();
45 print $measure->to_string();
47 =head1 DESCRIPTION
49 Measure is for biochemically defined phenotypes or any other types of measures.
51 =head1 FEEDBACK
53 =head2 Mailing Lists
55 User feedback is an integral part of the evolution of this and other
56 Bioperl modules. Send your comments and suggestions preferably to one
57 of the Bioperl mailing lists. Your participation is much appreciated.
59 bioperl-l@bioperl.org - General discussion
60 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
62 =head2 Reporting Bugs
64 Report bugs to the Bioperl bug tracking system to help us keep track
65 the bugs and their resolution. Bug reports can be submitted via the
66 web:
68 http://bugzilla.open-bio.org/
70 =head1 AUTHOR
72 Christian M. Zmasek
74 Email: czmasek@gnf.org or cmzmasek@yahoo.com
76 WWW: http://www.genetics.wustl.edu/eddy/people/zmasek/
78 Address:
80 Genomics Institute of the Novartis Research Foundation
81 10675 John Jay Hopkins Drive
82 San Diego, CA 92121
84 =head1 APPENDIX
86 The rest of the documentation details each of the object
87 methods.
89 =cut
92 # Let the code begin...
94 package Bio::Phenotype::Measure;
95 use strict;
97 use base qw(Bio::Root::Root);
100 =head2 new
102 Title : new
103 Usage : my $me = Bio::Phenotype::Measure->new( -context => "length",
104 -description => "reduced length in 4(Tas1r3)",
105 -start => 0,
106 -end => 15,
107 -unit => "mm",
108 -comment => "see Miller also et al" );
109 Function: Creates a new Measure object.
110 Returns : A new Measure object.
111 Args : -context => the context
112 -description => a description
113 -start => the start value
114 -end => the end value
115 -unit => the unit
116 -comment => a comment
118 =cut
120 sub new {
121 my( $class, @args ) = @_;
123 my $self = $class->SUPER::new( @args );
125 my ( $con, $desc, $start, $end, $unit, $comment )
126 = $self->_rearrange( [ qw( CONTEXT
127 DESCRIPTION
128 START
130 UNIT
131 COMMENT ) ], @args );
133 $self->init();
135 $con && $self->context( $con );
136 $desc && $self->description( $desc );
137 $start && $self->start( $start );
138 $end && $self->end( $end );
139 $unit && $self->unit( $unit );
140 $comment && $self->comment( $comment );
142 return $self;
144 } # new
149 =head2 init
151 Title : init()
152 Usage : $measure->init();
153 Function: Initializes this Measure to all "".
154 Returns :
155 Args :
157 =cut
159 sub init {
160 my( $self ) = @_;
162 $self->context( "" );
163 $self->description( "" );
164 $self->start( "" );
165 $self->end( "" );
166 $self->unit( "" );
167 $self->comment( "" );
169 } # init
174 =head2 context
176 Title : context
177 Usage : $measure->context( "Ca-conc" );
179 print $measure->context();
180 Function: Set/get for the context of this Measure.
181 Returns : The context.
182 Args : The context (optional).
184 =cut
186 sub context {
187 my ( $self, $value ) = @_;
189 if ( defined $value ) {
190 $self->{ "_context" } = $value;
193 return $self->{ "_context" };
195 } # context
200 =head2 description
202 Title : description
203 Usage : $measure->description( "reduced in 4(Tas1r3)" );
205 print $measure->description();
206 Function: Set/get for the description of this Measure.
207 Returns : A description.
208 Args : A description (optional).
210 =cut
212 sub description {
213 my ( $self, $value ) = @_;
215 if ( defined $value ) {
216 $self->{ "_description" } = $value;
219 return $self->{ "_description" };
221 } # description
226 =head2 start
228 Title : start
229 Usage : $measure->start( 330 );
231 print $measure->start();
232 Function: Set/get for the start value of this Measure.
233 Returns : The start value.
234 Args : The start value (optional).
236 =cut
238 sub start {
239 my ( $self, $value ) = @_;
241 if ( defined $value ) {
242 $self->{ "_start" } = $value;
245 return $self->{ "_start" };
247 } # start
252 =head2 end
254 Title : end
255 Usage : $measure->end( 459 );
257 print $measure->end();
258 Function: Set/get for the end value of this Measure.
259 Returns : The end value.
260 Args : The end value (optional).
262 =cut
264 sub end {
265 my ( $self, $value ) = @_;
267 if ( defined $value ) {
268 $self->{ "_end" } = $value;
271 return $self->{ "_end" };
273 } # end
278 =head2 unit
280 Title : unit
281 Usage : $measure->unit( "mM" );
283 print $measure->unit();
284 Function: Set/get for the unit of this Measure.
285 Returns : The unit.
286 Args : The unit (optional).
288 =cut
290 sub unit {
291 my ( $self, $value ) = @_;
293 if ( defined $value ) {
294 $self->{ "_unit" } = $value;
297 return $self->{ "_unit" };
299 } # unit
304 =head2 comment
306 Title : comment
307 Usage : $measure->comment( "see also Miller et al" );
309 print $measure->comment();
310 Function: Set/get for an arbitrary comment about this Measure.
311 Returns : A comment.
312 Args : A comment (optional).
314 =cut
316 sub comment {
317 my ( $self, $value ) = @_;
319 if ( defined $value ) {
320 $self->{ "_comment" } = $value;
323 return $self->{ "_comment" };
325 } # comment
330 =head2 to_string
332 Title : to_string()
333 Usage : print $measure->to_string();
334 Function: To string method for Measure objects.
335 Returns : A string representations of this Measure.
336 Args :
338 =cut
340 sub to_string {
341 my ( $self ) = @_;
343 my $s = "";
345 $s .= "-- Context:\n";
346 $s .= $self->context()."\n";
347 $s .= "-- Description:\n";
348 $s .= $self->description()."\n";
349 $s .= "-- Start:\n";
350 $s .= $self->start()."\n";
351 $s .= "-- End:\n";
352 $s .= $self->end()."\n";
353 $s .= "-- Unit:\n";
354 $s .= $self->unit()."\n";
355 $s .= "-- Comment:\n";
356 $s .= $self->comment();
358 return $s;
360 } # to_string