Add tests for bug #88, spliced_seq()
[bioperl-live.git] / Bio / Phenotype / Measure.pm
blobc9d967a75bd0d907f74968414c652c403d13005e
2 # BioPerl module for Bio::Phenotype::Measure
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Christian M. Zmasek <czmasek-at-burnham.org> or <cmzmasek@yahoo.com>
8 # (c) Christian M. Zmasek, czmasek-at-burnham.org, 2002.
9 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
11 # You may distribute this module under the same terms as perl itself.
12 # Refer to the Perl Artistic License (see the license accompanying this
13 # software package, or see http://www.perl.com/language/misc/Artistic.html)
14 # for the terms under which you may use, modify, and redistribute this module.
16 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
17 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18 # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 # You may distribute this module under the same terms as perl itself
22 # POD documentation - main docs before the code
24 =head1 NAME
26 Bio::Phenotype::Measure - Representation of context/value(-range)/unit triplets
28 =head1 SYNOPSIS
30 use Bio::Phenotype::Measure;
32 my $measure = Bio::Phenotype::Measure->new( -context => "length",
33 -description => "reduced length in 4(Tas1r3)",
34 -start => 0,
35 -end => 15,
36 -unit => "mm",
37 -comment => "see also Miller et al" );
39 print $measure->context();
40 print $measure->description();
41 print $measure->start();
42 print $measure->end();
43 print $measure->unit();
44 print $measure->comment();
46 print $measure->to_string();
48 =head1 DESCRIPTION
50 Measure is for biochemically defined phenotypes or any other types of measures.
52 =head1 FEEDBACK
54 =head2 Mailing Lists
56 User feedback is an integral part of the evolution of this and other
57 Bioperl modules. Send your comments and suggestions preferably to one
58 of the Bioperl mailing lists. Your participation is much appreciated.
60 bioperl-l@bioperl.org - General discussion
61 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
63 =head2 Support
65 Please direct usage questions or support issues to the mailing list:
67 I<bioperl-l@bioperl.org>
69 rather than to the module maintainer directly. Many experienced and
70 reponsive experts will be able look at the problem and quickly
71 address it. Please include a thorough description of the problem
72 with code and data examples if at all possible.
74 =head2 Reporting Bugs
76 Report bugs to the Bioperl bug tracking system to help us keep track
77 the bugs and their resolution. Bug reports can be submitted via the
78 web:
80 https://github.com/bioperl/bioperl-live/issues
82 =head1 AUTHOR
84 Christian M. Zmasek
86 Email: czmasek-at-burnham.org or cmzmasek@yahoo.com
88 WWW: http://monochrome-effect.net/
90 Address:
92 Genomics Institute of the Novartis Research Foundation
93 10675 John Jay Hopkins Drive
94 San Diego, CA 92121
96 =head1 APPENDIX
98 The rest of the documentation details each of the object
99 methods.
101 =cut
104 # Let the code begin...
106 package Bio::Phenotype::Measure;
107 use strict;
109 use base qw(Bio::Root::Root);
112 =head2 new
114 Title : new
115 Usage : my $me = Bio::Phenotype::Measure->new( -context => "length",
116 -description => "reduced length in 4(Tas1r3)",
117 -start => 0,
118 -end => 15,
119 -unit => "mm",
120 -comment => "see Miller also et al" );
121 Function: Creates a new Measure object.
122 Returns : A new Measure object.
123 Args : -context => the context
124 -description => a description
125 -start => the start value
126 -end => the end value
127 -unit => the unit
128 -comment => a comment
130 =cut
132 sub new {
133 my( $class, @args ) = @_;
135 my $self = $class->SUPER::new( @args );
137 my ( $con, $desc, $start, $end, $unit, $comment )
138 = $self->_rearrange( [ qw( CONTEXT
139 DESCRIPTION
140 START
142 UNIT
143 COMMENT ) ], @args );
145 $self->init();
147 $con && $self->context( $con );
148 $desc && $self->description( $desc );
149 $start && $self->start( $start );
150 $end && $self->end( $end );
151 $unit && $self->unit( $unit );
152 $comment && $self->comment( $comment );
154 return $self;
156 } # new
161 =head2 init
163 Title : init()
164 Usage : $measure->init();
165 Function: Initializes this Measure to all "".
166 Returns :
167 Args :
169 =cut
171 sub init {
172 my( $self ) = @_;
174 $self->context( "" );
175 $self->description( "" );
176 $self->start( "" );
177 $self->end( "" );
178 $self->unit( "" );
179 $self->comment( "" );
181 } # init
186 =head2 context
188 Title : context
189 Usage : $measure->context( "Ca-conc" );
191 print $measure->context();
192 Function: Set/get for the context of this Measure.
193 Returns : The context.
194 Args : The context (optional).
196 =cut
198 sub context {
199 my ( $self, $value ) = @_;
201 if ( defined $value ) {
202 $self->{ "_context" } = $value;
205 return $self->{ "_context" };
207 } # context
212 =head2 description
214 Title : description
215 Usage : $measure->description( "reduced in 4(Tas1r3)" );
217 print $measure->description();
218 Function: Set/get for the description of this Measure.
219 Returns : A description.
220 Args : A description (optional).
222 =cut
224 sub description {
225 my ( $self, $value ) = @_;
227 if ( defined $value ) {
228 $self->{ "_description" } = $value;
231 return $self->{ "_description" };
233 } # description
238 =head2 start
240 Title : start
241 Usage : $measure->start( 330 );
243 print $measure->start();
244 Function: Set/get for the start value of this Measure.
245 Returns : The start value.
246 Args : The start value (optional).
248 =cut
250 sub start {
251 my ( $self, $value ) = @_;
253 if ( defined $value ) {
254 $self->{ "_start" } = $value;
257 return $self->{ "_start" };
259 } # start
264 =head2 end
266 Title : end
267 Usage : $measure->end( 459 );
269 print $measure->end();
270 Function: Set/get for the end value of this Measure.
271 Returns : The end value.
272 Args : The end value (optional).
274 =cut
276 sub end {
277 my ( $self, $value ) = @_;
279 if ( defined $value ) {
280 $self->{ "_end" } = $value;
283 return $self->{ "_end" };
285 } # end
290 =head2 unit
292 Title : unit
293 Usage : $measure->unit( "mM" );
295 print $measure->unit();
296 Function: Set/get for the unit of this Measure.
297 Returns : The unit.
298 Args : The unit (optional).
300 =cut
302 sub unit {
303 my ( $self, $value ) = @_;
305 if ( defined $value ) {
306 $self->{ "_unit" } = $value;
309 return $self->{ "_unit" };
311 } # unit
316 =head2 comment
318 Title : comment
319 Usage : $measure->comment( "see also Miller et al" );
321 print $measure->comment();
322 Function: Set/get for an arbitrary comment about this Measure.
323 Returns : A comment.
324 Args : A comment (optional).
326 =cut
328 sub comment {
329 my ( $self, $value ) = @_;
331 if ( defined $value ) {
332 $self->{ "_comment" } = $value;
335 return $self->{ "_comment" };
337 } # comment
342 =head2 to_string
344 Title : to_string()
345 Usage : print $measure->to_string();
346 Function: To string method for Measure objects.
347 Returns : A string representations of this Measure.
348 Args :
350 =cut
352 sub to_string {
353 my ( $self ) = @_;
355 my $s = "";
357 $s .= "-- Context:\n";
358 $s .= $self->context()."\n";
359 $s .= "-- Description:\n";
360 $s .= $self->description()."\n";
361 $s .= "-- Start:\n";
362 $s .= $self->start()."\n";
363 $s .= "-- End:\n";
364 $s .= $self->end()."\n";
365 $s .= "-- Unit:\n";
366 $s .= $self->unit()."\n";
367 $s .= "-- Comment:\n";
368 $s .= $self->comment();
370 return $s;
372 } # to_string