small update
[bioperl-live.git] / Bio / Phenotype / Correlate.pm
blob80dceea66f9e8fdbf9de0f2de9035c8f2f17f900
1 # $Id$
3 # BioPerl module for Bio::Phenotype::Correlate
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::Correlate - Representation of a correlating phenotype in a given species
27 =head1 SYNOPSIS
29 use Bio::Phenotype::Correlate;
31 $co = Bio::Phenotype::Correlate->new( -name => "4(Tas1r3)",
32 -description => "mouse correlate of human phenotype MIM 605865",
33 -species => $mouse,
34 -type => "homolog",
35 -comment => "type=homolog is putative" );
37 print $co->name();
38 print $co->description();
39 print $co->species()->binomial();
40 print $co->type();
41 print $co->comment();
43 print $co->to_string();
45 =head1 DESCRIPTION
47 This class models correlating phenotypes.
48 Its creation was inspired by the OMIM database where many human phenotypes
49 have a correlating mouse phenotype. Therefore, this class is intended
50 to be used together with a phenotype class.
53 =head1 FEEDBACK
55 =head2 Mailing Lists
57 User feedback is an integral part of the evolution of this and other
58 Bioperl modules. Send your comments and suggestions preferably to one
59 of the Bioperl mailing lists. Your participation is much appreciated.
61 bioperl-l@bioperl.org - General discussion
62 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
64 =head2 Reporting Bugs
66 Report bugs to the Bioperl bug tracking system to help us keep track
67 the bugs and their resolution. Bug reports can be submitted via the
68 web:
70 http://bugzilla.open-bio.org/
72 =head1 AUTHOR
74 Christian M. Zmasek
76 Email: czmasek@gnf.org or cmzmasek@yahoo.com
78 WWW: http://www.genetics.wustl.edu/eddy/people/zmasek/
80 Address:
82 Genomics Institute of the Novartis Research Foundation
83 10675 John Jay Hopkins Drive
84 San Diego, CA 92121
86 =head1 APPENDIX
88 The rest of the documentation details each of the object
89 methods.
91 =cut
94 # Let the code begin...
96 package Bio::Phenotype::Correlate;
97 use strict;
98 use Bio::Species;
100 use base qw(Bio::Root::Root);
103 =head2 new
105 Title : new
106 Usage : $co = Bio::Phenotype::Correlate->new( -name => "4(Tas1r3)",
107 -description => "mouse correlate of human phenotype MIM 605865",
108 -species => $mouse,
109 -type => "homolog",
110 -comment => "type=homolog is putative" );
111 Function: Creates a new Correlate object.
112 Returns : A new Correlate object.
113 Args : -name => a name or id
114 -description => a description
115 -species => the species of this correlating phenotype [Bio::Species]
116 -type => the type of correlation
117 -comment => a comment
119 =cut
121 sub new {
123 my( $class, @args ) = @_;
125 my $self = $class->SUPER::new( @args );
127 my ( $name, $desc, $species, $type, $comment )
128 = $self->_rearrange( [ qw( NAME
129 DESCRIPTION
130 SPECIES
131 TYPE
132 COMMENT ) ], @args );
134 $self->init();
136 $name && $self->name( $name );
137 $desc && $self->description( $desc );
138 $species && $self->species( $species );
139 $type && $self->type( $type );
140 $comment && $self->comment( $comment );
142 return $self;
144 } # new
149 =head2 init
151 Title : init()
152 Usage : $co->init();
153 Function: Initializes this Correlate to all "".
154 Returns :
155 Args :
157 =cut
159 sub init {
161 my( $self ) = @_;
163 $self->name( "" );
164 $self->description( "" );
165 my $species = Bio::Species->new();
166 $species->classification( qw( species Undetermined ) );
167 $self->species( $species );
168 $self->type( "" );
169 $self->comment( "" );
171 } # init
176 =head2 name
178 Title : name
179 Usage : $co->name( "4(Tas1r3)" );
181 print $co->name();
182 Function: Set/get for the name or id of this Correlate.
183 Returns : The name or id of this Correlate.
184 Args : The name or id of this Correlate (optional).
186 =cut
188 sub name {
189 my ( $self, $value ) = @_;
191 if ( defined $value ) {
192 $self->{ "_name" } = $value;
195 return $self->{ "_name" };
197 } # name
202 =head2 description
204 Title : description
205 Usage : $co->description( "mouse correlate of human phenotype MIM 03923" );
207 print $co->description();
208 Function: Set/get for the description of this Correlate.
209 Returns : A description of this Correlate.
210 Args : A description of this Correlate (optional).
212 =cut
214 sub description {
215 my ( $self, $value ) = @_;
217 if ( defined $value ) {
218 $self->{ "_description" } = $value;
221 return $self->{ "_description" };
223 } # description
228 =head2 species
230 Title : species
231 Usage : $co->species( $species );
233 $species = $co->species();
234 Function: Set/get for the species of this Correlate.
235 Returns : The Bio::Species of this Correlate [Bio::Species].
236 Args : The Bio::Species of this Correlate [Bio::Species] (optional).
238 =cut
240 sub species {
242 my ( $self, $value ) = @_;
244 if ( defined $value ) {
245 $self->_check_ref_type( $value, "Bio::Species" );
246 $self->{ "_species" } = $value;
249 return $self->{ "_species" };
251 } # species
256 =head2 type
258 Title : type
259 Usage : $co->type( "homolog" );
261 print $co->type();
262 Function: Set/get for the type of this Correlate.
263 Returns : The type of this Correlate.
264 Args : The type of this Correlate (optional).
266 =cut
268 sub type {
269 my ( $self, $value ) = @_;
271 if ( defined $value ) {
272 $self->{ "_type" } = $value;
275 return $self->{ "_type" };
277 } # type
282 =head2 comment
284 Title : comment
285 Usage : $co->comment( "doubtful" );
287 print $co->comment();
288 Function: Set/get for an arbitrary comment about this Correlate.
289 Returns : A comment.
290 Args : A comment (optional).
292 =cut
294 sub comment {
295 my ( $self, $value ) = @_;
297 if ( defined $value ) {
298 $self->{ "_comment" } = $value;
301 return $self->{ "_comment" };
303 } # comment
307 =head2 to_string
309 Title : to_string()
310 Usage : print $co->to_string();
311 Function: To string method for Correlate objects.
312 Returns : A string representations of this Correlate.
313 Args :
315 =cut
317 sub to_string {
319 my ( $self ) = @_;
321 my $s = "";
323 $s .= "-- Name:\n";
324 $s .= $self->name()."\n";
325 $s .= "-- Description:\n";
326 $s .= $self->description()."\n";
327 $s .= "-- Species:\n";
328 $s .= $self->species()->binomial()."\n";
329 $s .= "-- Type of correlation:\n";
330 $s .= $self->type()."\n";
331 $s .= "-- Comment:\n";
332 $s .= $self->comment();
334 return $s;
336 } # to_string
341 # Title : _check_ref_type
342 # Function: Checks for the correct type.
343 # Returns :
344 # Args : The value to be checked, the expected class.
345 sub _check_ref_type {
346 my ( $self, $value, $expected_class ) = @_;
348 if ( ! defined( $value ) ) {
349 $self->throw( ( caller( 1 ) )[ 3 ] .": Found [undef"
350 ."] where [$expected_class] expected" );
352 elsif ( ! ref( $value ) ) {
353 $self->throw( ( caller( 1 ) )[ 3 ] .": Found scalar"
354 ." where [$expected_class] expected" );
356 elsif ( ! $value->isa( $expected_class ) ) {
357 $self->throw( ( caller( 1 ) )[ 3 ] .": Found [". ref( $value )
358 ."] where [$expected_class] expected" );
360 } # _check_ref_type