tag fourth (and hopefully last) alpha
[bioperl-live.git] / branch-1-6 / Bio / Phenotype / Correlate.pm
blob4e392b161b767f263350ef7948d2b45cd8a594d9
1 # $Id$
3 # BioPerl module for Bio::Phenotype::Correlate
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Christian M. Zmasek <czmasek-at-burnham.org> or <cmzmasek@yahoo.com>
9 # (c) Christian M. Zmasek, czmasek-at-burnham.org, 2002.
10 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
12 # You may distribute this module under the same terms as perl itself.
13 # Refer to the Perl Artistic License (see the license accompanying this
14 # software package, or see http://www.perl.com/language/misc/Artistic.html)
15 # for the terms under which you may use, modify, and redistribute this module.
17 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
18 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 # You may distribute this module under the same terms as perl itself
23 # POD documentation - main docs before the code
25 =head1 NAME
27 Bio::Phenotype::Correlate - Representation of a correlating phenotype in a given species
29 =head1 SYNOPSIS
31 use Bio::Phenotype::Correlate;
33 $co = Bio::Phenotype::Correlate->new( -name => "4(Tas1r3)",
34 -description => "mouse correlate of human phenotype MIM 605865",
35 -species => $mouse,
36 -type => "homolog",
37 -comment => "type=homolog is putative" );
39 print $co->name();
40 print $co->description();
41 print $co->species()->binomial();
42 print $co->type();
43 print $co->comment();
45 print $co->to_string();
47 =head1 DESCRIPTION
49 This class models correlating phenotypes.
50 Its creation was inspired by the OMIM database where many human phenotypes
51 have a correlating mouse phenotype. Therefore, this class is intended
52 to be used together with a phenotype class.
55 =head1 FEEDBACK
57 =head2 Mailing Lists
59 User feedback is an integral part of the evolution of this and other
60 Bioperl modules. Send your comments and suggestions preferably to one
61 of the Bioperl mailing lists. Your participation is much appreciated.
63 bioperl-l@bioperl.org - General discussion
64 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
66 =head2 Support
68 Please direct usage questions or support issues to the mailing list:
70 I<bioperl-l@bioperl.org>
72 rather than to the module maintainer directly. Many experienced and
73 reponsive experts will be able look at the problem and quickly
74 address it. Please include a thorough description of the problem
75 with code and data examples if at all possible.
77 =head2 Reporting Bugs
79 Report bugs to the Bioperl bug tracking system to help us keep track
80 the bugs and their resolution. Bug reports can be submitted via the
81 web:
83 http://bugzilla.open-bio.org/
85 =head1 AUTHOR
87 Christian M. Zmasek
89 Email: czmasek-at-burnham.org or cmzmasek@yahoo.com
91 WWW: http://monochrome-effect.net/
93 Address:
95 Genomics Institute of the Novartis Research Foundation
96 10675 John Jay Hopkins Drive
97 San Diego, CA 92121
99 =head1 APPENDIX
101 The rest of the documentation details each of the object
102 methods.
104 =cut
107 # Let the code begin...
109 package Bio::Phenotype::Correlate;
110 use strict;
111 use Bio::Species;
113 use base qw(Bio::Root::Root);
116 =head2 new
118 Title : new
119 Usage : $co = Bio::Phenotype::Correlate->new( -name => "4(Tas1r3)",
120 -description => "mouse correlate of human phenotype MIM 605865",
121 -species => $mouse,
122 -type => "homolog",
123 -comment => "type=homolog is putative" );
124 Function: Creates a new Correlate object.
125 Returns : A new Correlate object.
126 Args : -name => a name or id
127 -description => a description
128 -species => the species of this correlating phenotype [Bio::Species]
129 -type => the type of correlation
130 -comment => a comment
132 =cut
134 sub new {
136 my( $class, @args ) = @_;
138 my $self = $class->SUPER::new( @args );
140 my ( $name, $desc, $species, $type, $comment )
141 = $self->_rearrange( [ qw( NAME
142 DESCRIPTION
143 SPECIES
144 TYPE
145 COMMENT ) ], @args );
147 $self->init();
149 $name && $self->name( $name );
150 $desc && $self->description( $desc );
151 $species && $self->species( $species );
152 $type && $self->type( $type );
153 $comment && $self->comment( $comment );
155 return $self;
157 } # new
162 =head2 init
164 Title : init()
165 Usage : $co->init();
166 Function: Initializes this Correlate to all "".
167 Returns :
168 Args :
170 =cut
172 sub init {
174 my( $self ) = @_;
176 $self->name( "" );
177 $self->description( "" );
178 my $species = Bio::Species->new();
179 $species->classification( qw( species Undetermined ) );
180 $self->species( $species );
181 $self->type( "" );
182 $self->comment( "" );
184 } # init
189 =head2 name
191 Title : name
192 Usage : $co->name( "4(Tas1r3)" );
194 print $co->name();
195 Function: Set/get for the name or id of this Correlate.
196 Returns : The name or id of this Correlate.
197 Args : The name or id of this Correlate (optional).
199 =cut
201 sub name {
202 my ( $self, $value ) = @_;
204 if ( defined $value ) {
205 $self->{ "_name" } = $value;
208 return $self->{ "_name" };
210 } # name
215 =head2 description
217 Title : description
218 Usage : $co->description( "mouse correlate of human phenotype MIM 03923" );
220 print $co->description();
221 Function: Set/get for the description of this Correlate.
222 Returns : A description of this Correlate.
223 Args : A description of this Correlate (optional).
225 =cut
227 sub description {
228 my ( $self, $value ) = @_;
230 if ( defined $value ) {
231 $self->{ "_description" } = $value;
234 return $self->{ "_description" };
236 } # description
241 =head2 species
243 Title : species
244 Usage : $co->species( $species );
246 $species = $co->species();
247 Function: Set/get for the species of this Correlate.
248 Returns : The Bio::Species of this Correlate [Bio::Species].
249 Args : The Bio::Species of this Correlate [Bio::Species] (optional).
251 =cut
253 sub species {
255 my ( $self, $value ) = @_;
257 if ( defined $value ) {
258 $self->_check_ref_type( $value, "Bio::Species" );
259 $self->{ "_species" } = $value;
262 return $self->{ "_species" };
264 } # species
269 =head2 type
271 Title : type
272 Usage : $co->type( "homolog" );
274 print $co->type();
275 Function: Set/get for the type of this Correlate.
276 Returns : The type of this Correlate.
277 Args : The type of this Correlate (optional).
279 =cut
281 sub type {
282 my ( $self, $value ) = @_;
284 if ( defined $value ) {
285 $self->{ "_type" } = $value;
288 return $self->{ "_type" };
290 } # type
295 =head2 comment
297 Title : comment
298 Usage : $co->comment( "doubtful" );
300 print $co->comment();
301 Function: Set/get for an arbitrary comment about this Correlate.
302 Returns : A comment.
303 Args : A comment (optional).
305 =cut
307 sub comment {
308 my ( $self, $value ) = @_;
310 if ( defined $value ) {
311 $self->{ "_comment" } = $value;
314 return $self->{ "_comment" };
316 } # comment
320 =head2 to_string
322 Title : to_string()
323 Usage : print $co->to_string();
324 Function: To string method for Correlate objects.
325 Returns : A string representations of this Correlate.
326 Args :
328 =cut
330 sub to_string {
332 my ( $self ) = @_;
334 my $s = "";
336 $s .= "-- Name:\n";
337 $s .= $self->name()."\n";
338 $s .= "-- Description:\n";
339 $s .= $self->description()."\n";
340 $s .= "-- Species:\n";
341 $s .= $self->species()->binomial()."\n";
342 $s .= "-- Type of correlation:\n";
343 $s .= $self->type()."\n";
344 $s .= "-- Comment:\n";
345 $s .= $self->comment();
347 return $s;
349 } # to_string
354 # Title : _check_ref_type
355 # Function: Checks for the correct type.
356 # Returns :
357 # Args : The value to be checked, the expected class.
358 sub _check_ref_type {
359 my ( $self, $value, $expected_class ) = @_;
361 if ( ! defined( $value ) ) {
362 $self->throw( ( caller( 1 ) )[ 3 ] .": Found [undef"
363 ."] where [$expected_class] expected" );
365 elsif ( ! ref( $value ) ) {
366 $self->throw( ( caller( 1 ) )[ 3 ] .": Found scalar"
367 ." where [$expected_class] expected" );
369 elsif ( ! $value->isa( $expected_class ) ) {
370 $self->throw( ( caller( 1 ) )[ 3 ] .": Found [". ref( $value )
371 ."] where [$expected_class] expected" );
373 } # _check_ref_type