File Coverage

Bio/Phenotype/Correlate.pm
Criterion Covered Total %
statement 63 66 95.4
branch 23 26 88.4
condition n/a
subroutine 12 12 100.0
pod 8 8 100.0
total 106 112 94.6


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::Phenotype::Correlate
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Christian M. Zmasek or
7             #
8             # (c) Christian M. Zmasek, czmasek-at-burnham.org, 2002.
9             # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
10             #
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.
15             #
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.
19             #
20             # You may distribute this module under the same terms as perl itself
21              
22             # POD documentation - main docs before the code
23              
24             =head1 NAME
25              
26             Bio::Phenotype::Correlate - Representation of a correlating phenotype in a given species
27              
28             =head1 SYNOPSIS
29              
30             use Bio::Phenotype::Correlate;
31              
32             $co = Bio::Phenotype::Correlate->new( -name => "4(Tas1r3)",
33             -description => "mouse correlate of human phenotype MIM 605865",
34             -species => $mouse,
35             -type => "homolog",
36             -comment => "type=homolog is putative" );
37              
38             print $co->name();
39             print $co->description();
40             print $co->species()->binomial();
41             print $co->type();
42             print $co->comment();
43              
44             print $co->to_string();
45              
46             =head1 DESCRIPTION
47              
48             This class models correlating phenotypes.
49             Its creation was inspired by the OMIM database where many human phenotypes
50             have a correlating mouse phenotype. Therefore, this class is intended
51             to be used together with a phenotype class.
52              
53              
54             =head1 FEEDBACK
55              
56             =head2 Mailing Lists
57              
58             User feedback is an integral part of the evolution of this and other
59             Bioperl modules. Send your comments and suggestions preferably to one
60             of the Bioperl mailing lists. Your participation is much appreciated.
61              
62             bioperl-l@bioperl.org - General discussion
63             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
64              
65             =head2 Support
66              
67             Please direct usage questions or support issues to the mailing list:
68              
69             I
70              
71             rather than to the module maintainer directly. Many experienced and
72             reponsive experts will be able look at the problem and quickly
73             address it. Please include a thorough description of the problem
74             with code and data examples if at all possible.
75              
76             =head2 Reporting Bugs
77              
78             Report bugs to the Bioperl bug tracking system to help us keep track
79             the bugs and their resolution. Bug reports can be submitted via the
80             web:
81              
82             https://github.com/bioperl/bioperl-live/issues
83              
84             =head1 AUTHOR
85              
86             Christian M. Zmasek
87              
88             Email: czmasek-at-burnham.org or cmzmasek@yahoo.com
89              
90             WWW: http://monochrome-effect.net/
91              
92             Address:
93              
94             Genomics Institute of the Novartis Research Foundation
95             10675 John Jay Hopkins Drive
96             San Diego, CA 92121
97              
98             =head1 APPENDIX
99              
100             The rest of the documentation details each of the object
101             methods.
102              
103             =cut
104              
105              
106             # Let the code begin...
107              
108             package Bio::Phenotype::Correlate;
109 4     4   420 use strict;
  4         4  
  4         89  
110 4     4   275 use Bio::Species;
  4         5  
  4         73  
111              
112 4     4   12 use base qw(Bio::Root::Root);
  4         4  
  4         2169  
113              
114              
115             =head2 new
116              
117             Title : new
118             Usage : $co = Bio::Phenotype::Correlate->new( -name => "4(Tas1r3)",
119             -description => "mouse correlate of human phenotype MIM 605865",
120             -species => $mouse,
121             -type => "homolog",
122             -comment => "type=homolog is putative" );
123             Function: Creates a new Correlate object.
124             Returns : A new Correlate object.
125             Args : -name => a name or id
126             -description => a description
127             -species => the species of this correlating phenotype [Bio::Species]
128             -type => the type of correlation
129             -comment => a comment
130              
131             =cut
132              
133             sub new {
134              
135 7     7 1 28 my( $class, @args ) = @_;
136            
137 7         32 my $self = $class->SUPER::new( @args );
138            
139 7         35 my ( $name, $desc, $species, $type, $comment )
140             = $self->_rearrange( [ qw( NAME
141             DESCRIPTION
142             SPECIES
143             TYPE
144             COMMENT ) ], @args );
145            
146 7         18 $self->init();
147            
148 7 100       29 $name && $self->name( $name );
149 7 100       18 $desc && $self->description( $desc );
150 7 100       14 $species && $self->species( $species );
151 7 100       13 $type && $self->type( $type );
152 7 100       13 $comment && $self->comment( $comment );
153            
154 7         14 return $self;
155            
156             } # new
157              
158              
159              
160              
161             =head2 init
162              
163             Title : init()
164             Usage : $co->init();
165             Function: Initializes this Correlate to all "".
166             Returns :
167             Args :
168              
169             =cut
170              
171             sub init {
172              
173 8     8 1 10 my( $self ) = @_;
174              
175 8         16 $self->name( "" );
176 8         15 $self->description( "" );
177 8         23 my $species = Bio::Species->new();
178 8         19 $species->classification( qw( species Undetermined ) );
179 8         20 $self->species( $species );
180 8         16 $self->type( "" );
181 8         17 $self->comment( "" );
182            
183             } # init
184              
185              
186              
187              
188             =head2 name
189              
190             Title : name
191             Usage : $co->name( "4(Tas1r3)" );
192             or
193             print $co->name();
194             Function: Set/get for the name or id of this Correlate.
195             Returns : The name or id of this Correlate.
196             Args : The name or id of this Correlate (optional).
197              
198             =cut
199              
200             sub name {
201 21     21 1 1657 my ( $self, $value ) = @_;
202              
203 21 100       48 if ( defined $value ) {
204 14         27 $self->{ "_name" } = $value;
205             }
206              
207 21         44 return $self->{ "_name" };
208              
209             } # name
210              
211              
212              
213              
214             =head2 description
215              
216             Title : description
217             Usage : $co->description( "mouse correlate of human phenotype MIM 03923" );
218             or
219             print $co->description();
220             Function: Set/get for the description of this Correlate.
221             Returns : A description of this Correlate.
222             Args : A description of this Correlate (optional).
223              
224             =cut
225              
226             sub description {
227 13     13 1 14 my ( $self, $value ) = @_;
228              
229 13 100       26 if ( defined $value ) {
230 10         12 $self->{ "_description" } = $value;
231             }
232              
233 13         21 return $self->{ "_description" };
234              
235             } # description
236              
237              
238              
239              
240             =head2 species
241              
242             Title : species
243             Usage : $co->species( $species );
244             or
245             $species = $co->species();
246             Function: Set/get for the species of this Correlate.
247             Returns : The Bio::Species of this Correlate [Bio::Species].
248             Args : The Bio::Species of this Correlate [Bio::Species] (optional).
249              
250             =cut
251              
252             sub species {
253              
254 15     15 1 18 my ( $self, $value ) = @_;
255              
256 15 100       31 if ( defined $value ) {
257 11         22 $self->_check_ref_type( $value, "Bio::Species" );
258 11         17 $self->{ "_species" } = $value;
259             }
260            
261 15         33 return $self->{ "_species" };
262            
263             } # species
264              
265              
266              
267              
268             =head2 type
269              
270             Title : type
271             Usage : $co->type( "homolog" );
272             or
273             print $co->type();
274             Function: Set/get for the type of this Correlate.
275             Returns : The type of this Correlate.
276             Args : The type of this Correlate (optional).
277              
278             =cut
279              
280             sub type {
281 17     17 1 65 my ( $self, $value ) = @_;
282              
283 17 100       34 if ( defined $value ) {
284 12         15 $self->{ "_type" } = $value;
285             }
286              
287 17         36 return $self->{ "_type" };
288              
289             } # type
290              
291              
292              
293              
294             =head2 comment
295              
296             Title : comment
297             Usage : $co->comment( "doubtful" );
298             or
299             print $co->comment();
300             Function: Set/get for an arbitrary comment about this Correlate.
301             Returns : A comment.
302             Args : A comment (optional).
303              
304             =cut
305              
306             sub comment {
307 13     13 1 16 my ( $self, $value ) = @_;
308              
309 13 100       27 if ( defined $value ) {
310 10         15 $self->{ "_comment" } = $value;
311             }
312            
313 13         22 return $self->{ "_comment" };
314            
315             } # comment
316              
317              
318              
319             =head2 to_string
320              
321             Title : to_string()
322             Usage : print $co->to_string();
323             Function: To string method for Correlate objects.
324             Returns : A string representations of this Correlate.
325             Args :
326              
327             =cut
328              
329             sub to_string {
330              
331 1     1 1 806 my ( $self ) = @_;
332              
333 1         2 my $s = "";
334            
335 1         2 $s .= "-- Name:\n";
336 1         2 $s .= $self->name()."\n";
337 1         2 $s .= "-- Description:\n";
338 1         2 $s .= $self->description()."\n";
339 1         17 $s .= "-- Species:\n";
340 1         3 $s .= $self->species()->binomial()."\n";
341 1         3 $s .= "-- Type of correlation:\n";
342 1         4 $s .= $self->type()."\n";
343 1         3 $s .= "-- Comment:\n";
344 1         3 $s .= $self->comment();
345            
346 1         6 return $s;
347            
348             } # to_string
349              
350              
351              
352              
353             # Title : _check_ref_type
354             # Function: Checks for the correct type.
355             # Returns :
356             # Args : The value to be checked, the expected class.
357             sub _check_ref_type {
358 11     11   30 my ( $self, $value, $expected_class ) = @_;
359              
360 11 50       57 if ( ! defined( $value ) ) {
    50          
    50          
361 0           $self->throw( ( caller( 1 ) )[ 3 ] .": Found [undef"
362             ."] where [$expected_class] expected" );
363             }
364             elsif ( ! ref( $value ) ) {
365 0           $self->throw( ( caller( 1 ) )[ 3 ] .": Found scalar"
366             ." where [$expected_class] expected" );
367             }
368             elsif ( ! $value->isa( $expected_class ) ) {
369 0           $self->throw( ( caller( 1 ) )[ 3 ] .": Found [". ref( $value )
370             ."] where [$expected_class] expected" );
371             }
372             } # _check_ref_type
373              
374              
375              
376             1;