3 # BioPerl module for Bio::Phenotype::Phenotype
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Christian M. Zmasek <czmasek@gnf.org> or <cmzmasek@yahoo.com>
9 # (c) Christian M. Zmasek, czmasek@gnf.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
27 Bio::Phenotype::Phenotype - A class for modeling phenotypes
31 #get Bio::Phenotype::PhenotypeI somehow
33 print $phenotype->name(), "\n";
34 print $phenotype->description(), "\n";
36 my @keywords = ( "achondroplasia", "dwarfism" );
37 $phenotype->add_keywords( @keywords );
38 foreach my $keyword ( $phenotype->each_keyword() ) {
41 $phenotype->remove_keywords();
44 foreach my $gene_symbol ( $phenotype->each_gene_symbol() ) {
45 print $gene_symbol, "\n";
48 foreach my $corr ( $phenotype->each_Correlate() ) {
49 # Do something with $corr
52 foreach my $var ( $phenotype->each_Variant() ) {
53 # Do something with $var (mutation)
56 foreach my $measure ( $phenotype->each_Measure() ) {
57 # Do something with $measure
63 This superclass implements common methods for classes modelling phenotypes.
64 Bio::Phenotype::OMIM::OMIMentry is an example of an instantiable phenotype
65 class (the design of this interface was partially guided by the need
66 to model OMIM entries).
67 Please note. This class provides methods to associate mutations
68 (methods "each_Variant", ...) and genotypes (methods "each_Genotype", ...)
69 with phenotypes. Yet, these aspects might need some future enhancements,
70 especially since there is no "genotype" class yet.
76 User feedback is an integral part of the evolution of this and other
77 Bioperl modules. Send your comments and suggestions preferably to the
78 Bioperl mailing lists Your participation is much appreciated.
80 bioperl-l@bioperl.org - General discussion
81 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
85 Please direct usage questions or support issues to the mailing list:
87 L<bioperl-l@bioperl.org>
89 rather than to the module maintainer directly. Many experienced and
90 reponsive experts will be able look at the problem and quickly
91 address it. Please include a thorough description of the problem
92 with code and data examples if at all possible.
96 report bugs to the Bioperl bug tracking system to help us keep track
97 the bugs and their resolution. Bug reports can be submitted via the
100 http://bugzilla.open-bio.org/
106 Email: czmasek@gnf.org or cmzmasek@yahoo.com
108 WWW: http://www.genetics.wustl.edu/eddy/people/zmasek/
112 Genomics Institute of the Novartis Research Foundation
113 10675 John Jay Hopkins Drive
118 The rest of the documentation details each of the object
119 methods. Internal methods are usually preceded with a _
124 # Let the code begin...
127 package Bio
::Phenotype
::Phenotype
;
131 use Bio
::Variation
::VariantI
;
132 use Bio
::Annotation
::DBLink
;
133 use Bio
::Annotation
::Reference
;
134 use Bio
::Phenotype
::Measure
;
135 use Bio
::Phenotype
::Correlate
;
136 use Bio
::Map
::CytoPosition
;
140 use base
qw(Bio::Root::Root Bio::Phenotype::PhenotypeI);
148 Usage : $obj = Bio::Phenotype::Phenotype->new( -name => "XY",
149 -description => "This is ..." );
150 Function: Creates a new Phenotype object.
151 Returns : A new Phenotype object.
152 Args : -name => the name
153 -description => the description of this phenotype
154 -species => ref to the the species
155 -comment => a comment
161 my( $class,@args ) = @_;
163 my $self = $class->SUPER::new
( @args );
169 = $self->_rearrange( [ qw( NAME
172 COMMENT ) ], @args );
176 $name && $self->name( $name );
177 $description && $self->description( $description );
178 $species && $self->species( $species );
179 $comment && $self->comment( $comment );
189 Usage : $obj->init();
190 Function: Initializes this OMIMentry to all "" and empty lists.
202 $self->description( "" );
203 my $species = Bio
::Species
->new();
204 $species->classification( qw( sapiens Homo ) );
205 $self->species( $species );
206 $self->comment( "" );
207 $self->remove_Correlates();
208 $self->remove_References();
209 $self->remove_CytoPositions();
210 $self->remove_gene_symbols();
211 $self->remove_Genotypes();
212 $self->remove_DBLinks();
213 $self->remove_keywords();
214 $self->remove_Variants();
215 $self->remove_Measures();
223 Usage : $obj->name( "r1" );
226 Function: Set/get for the name or id of this phenotype.
227 Returns : A name or id [scalar].
228 Args : A name or id [scalar] (optional).
233 my ( $self, $value ) = @_;
235 if ( defined $value ) {
236 $self->{ "_name" } = $value;
239 return $self->{ "_name" };
247 Usage : $obj->description( "This is ..." );
249 print $obj->description();
250 Function: Set/get for the description of this phenotype.
251 Returns : A description [scalar].
252 Args : A description [scalar] (optional).
258 return $self->{ "_description" } = shift if(@_);
259 return $self->{ "_description" };
265 Usage : $obj->species( $species );
267 $species = $obj->species();
268 Function: Set/get for the species of this phenotype.
269 Returns : A species [Bio::Species].
270 Args : A species [Bio::Species] (optional).
275 my ( $self, $value ) = @_;
277 if ( defined $value ) {
278 $self->_check_ref_type( $value, "Bio::Species" );
279 $self->{ "_species" } = $value;
282 return $self->{ "_species" };
289 Usage : $obj->comment( "putative" );
291 print $obj->comment();
292 Function: Set/get for a comment about this phenotype.
293 Returns : A comment [scalar].
294 Args : A comment [scalar] (optional).
300 return $self->{ "_comment" } = shift if(@_);
301 return $self->{ "_comment" };
305 =head2 each_gene_symbol
307 Title : each_gene_symbol()
308 Usage : @gs = $obj->each_gene_symbol();
309 Function: Returns a list of gene symbols [scalars, most likely Strings]
310 associated with this phenotype.
311 Returns : A list of scalars.
316 sub each_gene_symbol
{
319 return @
{$self->{"_gene_symbols"}} if exists($self->{"_gene_symbols"});
324 =head2 add_gene_symbols
326 Title : add_gene_symbols
327 Usage : $obj->add_gene_symbols( @gs );
329 $obj->add_gene_symbols( $gs );
330 Function: Pushes one or more gene symbols [scalars, most likely Strings]
331 into the list of gene symbols.
337 sub add_gene_symbols
{
338 my ( $self, @values ) = @_;
340 return unless( @values );
342 push( @
{ $self->{ "_gene_symbols" } }, @values );
347 =head2 remove_gene_symbols
349 Usage : $obj->remove_gene_symbols();
350 Function: Deletes (and returns) the list of gene symbols [scalars,
351 most likely Strings] associated with this phenotype.
352 Returns : A list of scalars.
357 sub remove_gene_symbols
{
360 my @a = $self->each_gene_symbol();
361 $self->{ "_gene_symbols" } = [];
364 } # remove_gene_symbols
371 Title : each_Variant()
372 Usage : @vs = $obj->each_Variant();
373 Function: Returns a list of Bio::Variation::VariantI implementing objects
374 associated with this phenotype.
375 This is for representing the actual mutation(s) causing this
377 {* The "variants" data member and its methods will/might need to be
378 changed/improved in one way or another, CZ 09/06/02 *}
379 Returns : A list of Bio::Variation::VariantI implementing objects.
387 return @
{ $self->{ "_variants" } } if exists($self->{ "_variants" });
394 Usage : $obj->add_Variants( @vs );
396 $obj->add_Variants( $v );
397 Function: Pushes one or more Bio::Variation::VariantI implementing objects
398 into the list of Variants.
400 Args : Bio::Variation::VariantI implementing object(s).
405 my ( $self, @values ) = @_;
407 return unless( @values );
409 foreach my $value ( @values ) {
410 $self->_check_ref_type( $value, "Bio::Variation::VariantI" );
413 push( @
{ $self->{ "_variants" } }, @values );
418 =head2 remove_Variants
420 Title : remove_Variants
421 Usage : $obj->remove_Variants();
422 Function: Deletes (and returns) the list of Bio::Variation::VariantI implementing
423 objects associated with this phenotype.
424 Returns : A list of Bio::Variation::VariantI implementing objects.
429 sub remove_Variants
{
432 my @a = $self->each_Variant();
433 $self->{ "_variants" } = [];
441 =head2 each_Reference
443 Title : each_Reference()
444 Usage : @refs = $obj->each_Reference();
445 Function: Returns a list of Bio::Annotation::Reference objects
446 associated with this phenotype.
447 Returns : A list of Bio::Annotation::Reference objects.
455 return @
{ $self->{ "_references" } } if exists($self->{ "_references" });
460 =head2 add_References
462 Title : add_References
463 Usage : $obj->add_References( @refs );
465 $obj->add_References( $ref );
466 Function: Pushes one or more Bio::Annotation::Reference objects
467 into the list of References.
469 Args : Bio::Annotation::Reference object(s).
474 my ( $self, @values ) = @_;
476 return unless( @values );
478 foreach my $value ( @values ) {
479 $self->_check_ref_type( $value, "Bio::Annotation::Reference" );
482 push( @
{ $self->{ "_references" } }, @values );
487 =head2 remove_References
489 Title : remove_References()
490 Usage : $obj->remove_References();
491 Function: Deletes (and returns) the list of Bio::Annotation::Reference objects
492 associated with this phenotype.
493 Returns : A list of Bio::Annotation::Reference objects.
498 sub remove_References
{
501 my @a = $self->each_Reference();
502 $self->{ "_references" } = [];
505 } # remove_References
510 =head2 each_CytoPosition
512 Title : each_CytoPosition()
513 Usage : @cps = $obj->each_CytoPosition();
514 Function: Returns a list of Bio::Map::CytoPosition objects
515 associated with this phenotype.
516 Returns : A list of Bio::Map::CytoPosition objects.
521 sub each_CytoPosition
{
524 return @
{$self->{"_cyto_positions"}} if exists($self->{"_cyto_positions"});
526 } # each_CytoPosition
529 =head2 add_CytoPositions
531 Title : add_CytoPositions
532 Usage : $obj->add_CytoPositions( @cps );
534 $obj->add_CytoPositions( $cp );
535 Function: Pushes one or more Bio::Map::CytoPosition objects
536 into the list of CytoPositions.
538 Args : Bio::Map::CytoPosition object(s).
542 sub add_CytoPositions
{
543 my ( $self, @values ) = @_;
545 return unless( @values );
547 foreach my $value ( @values ) {
548 $self->_check_ref_type( $value, "Bio::Map::CytoPosition" );
551 push( @
{ $self->{ "_cyto_positions" } }, @values );
553 } # add_CytoPositions
556 =head2 remove_CytoPositions
558 Title : remove_CytoPositions
559 Usage : $obj->remove_CytoPositions();
560 Function: Deletes (and returns) the list o fBio::Map::CytoPosition objects
561 associated with this phenotype.
562 Returns : A list of Bio::Map::CytoPosition objects.
567 sub remove_CytoPositions
{
570 my @a = $self->each_CytoPosition();
571 $self->{ "_cyto_positions" } = [];
574 } # remove_CytoPositions
579 =head2 each_Correlate
581 Title : each_Correlate()
582 Usage : @corrs = $obj->each_Correlate();
583 Function: Returns a list of Bio::Phenotype::Correlate objects
584 associated with this phenotype.
585 (Correlates are correlating phenotypes in different species;
586 inspired by mouse correlates of human phenotypes in the OMIM
588 Returns : A list of Bio::Phenotype::Correlate objects.
596 return @
{ $self->{ "_correlates" } } if exists($self->{ "_correlates" });
603 =head2 add_Correlates
605 Title : add_Correlates
606 Usage : $obj->add_Correlates( @corrs );
608 $obj->add_Correlates( $corr );
609 Function: Pushes one or more Bio::Phenotype::Correlate objects
610 into the list of Correlates.
612 Args : Bio::Phenotype::Correlate object(s).
617 my ( $self, @values ) = @_;
619 return unless( @values );
621 foreach my $value ( @values ) {
622 $self->_check_ref_type( $value, "Bio::Phenotype::Correlate" );
625 push( @
{ $self->{ "_correlates" } }, @values );
630 =head2 remove_Correlates
632 Title : remove_Correlates
633 Usage : $obj->remove_Correlates();
634 Function: Deletes (and returns) the list of Bio::Phenotype::Correlate objects
635 associated with this phenotype.
636 Returns : A list of Bio::Phenotype::Correlate objects.
641 sub remove_Correlates
{
644 my @a = $self->each_Correlate();
645 $self->{ "_correlates" } = [];
648 } # remove_Correlates
655 Title : each_Measure()
656 Usage : @ms = $obj->each_Measure();
657 Function: Returns a list of Bio::Phenotype::Measure objects
658 associated with this phenotype.
659 (Measure is for biochemically defined phenotypes
660 or any other types of measures.)
661 Returns : A list of Bio::Phenotype::Measure objects.
669 return @
{ $self->{ "_measures" } } if exists($self->{ "_measures" });
677 Usage : $obj->add_Measures( @ms );
679 $obj->add_Measures( $m );
680 Function: Pushes one or more Bio::Phenotype::Measure objects
681 into the list of Measures.
683 Args : Bio::Phenotype::Measure object(s).
688 my ( $self, @values ) = @_;
690 return unless( @values );
692 foreach my $value ( @values ) {
693 $self->_check_ref_type( $value, "Bio::Phenotype::Measure" );
696 push( @
{ $self->{ "_measures" } }, @values );
701 =head2 remove_Measures
703 Title : remove_Measures
704 Usage : $obj->remove_Measures();
705 Function: Deletes (and returns) the list of Bio::Phenotype::Measure objects
706 associated with this phenotype.
707 Returns : A list of Bio::Phenotype::Measure objects.
712 sub remove_Measures
{
715 my @a = $self->each_Measure();
716 $self->{ "_measures" } = [];
726 Title : each_keyword()
727 Usage : @kws = $obj->each_keyword();
728 Function: Returns a list of key words [scalars, most likely Strings]
729 associated with this phenotype.
730 Returns : A list of scalars.
738 return @
{ $self->{ "_keywords" } } if exists($self->{ "_keywords" });
746 Usage : $obj->add_keywords( @kws );
748 $obj->add_keywords( $kw );
749 Function: Pushes one or more keywords [scalars, most likely Strings]
750 into the list of key words.
757 my ( $self, @values ) = @_;
759 return unless( @values );
761 push( @
{ $self->{ "_keywords" } }, @values );
766 =head2 remove_keywords
768 Title : remove_keywords
769 Usage : $obj->remove_keywords();
770 Function: Deletes (and returns) the list of key words [scalars,
771 most likely Strings] associated with this phenotype.
772 Returns : A list of scalars.
777 sub remove_keywords
{
780 my @a = $self->each_keyword();
781 $self->{ "_keywords" } = [];
791 Title : each_DBLink()
792 Usage : @dbls = $obj->each_DBLink();
793 Function: Returns a list of Bio::Annotation::DBLink objects
794 associated with this phenotype.
795 Returns : A list of Bio::Annotation::DBLink objects.
803 return @
{ $self->{ "_db_links" } } if exists($self->{ "_db_links" });
811 Usage : $obj->add_DBLinks( @dbls );
813 $obj->add_DBLinks( $dbl );
814 Function: Pushes one or more Bio::Annotation::DBLink objects
815 into the list of DBLinks.
817 Args : Bio::Annotation::DBLink object(s).
822 my ( $self, @values ) = @_;
824 return unless( @values );
826 foreach my $value ( @values ) {
827 $self->_check_ref_type( $value, "Bio::Annotation::DBLink" );
830 push( @
{ $self->{ "_db_links" } }, @values );
835 =head2 remove_DBLinks
837 Title : remove_DBLinks
838 Usage : $obj->remove_DBLinks();
839 Function: Deletes (and returns) the list of Bio::Annotation::DBLink objects
840 associated with this phenotype.
841 Returns : A list of Bio::Annotation::DBLink objects.
849 my @a = $self->each_DBLink();
850 $self->{ "_db_links" } = [];
860 Title : each_Reference()
861 Usage : @gts = $obj->each_Reference();
862 Function: Returns a list of "Genotype" objects
863 associated with this phenotype.
864 {* the "genotypes" data member and its methods certainly will/needs to be
865 changed/improved in one way or another since there is
866 no "Genotype" class yet, CZ 09/06/02 *}
867 Returns : A list of "Genotype" objects.
875 return @
{ $self->{ "_genotypes" } } if exists($self->{ "_genotypes" });
882 Title : add_Genotypes
883 Usage : $obj->add_Genotypes( @gts );
885 $obj->add_Genotypes( $gt );
886 Function: Pushes one or more "Genotypes"
887 into the list of "Genotypes".
889 Args : "Genotypes(s)".
894 my ( $self, @values ) = @_;
896 return unless( @values );
898 #foreach my $value ( @values ) {
899 # $self->_check_ref_type( $value, "Bio::GenotypeI" );
902 push( @
{ $self->{ "_genotypes" } }, @values );
907 =head2 remove_Genotypes
909 Title : remove_Genotypes
910 Usage : $obj->remove_Genotypes();
911 Function: Deletes (and returns) the list of "Genotype" objects
912 associated with this phenotype.
913 Returns : A list of "Genotype" objects.
918 sub remove_Genotypes
{
921 my @a = $self->each_Genotype();
922 $self->{ "_genotypes" } = [];
928 =head2 _check_ref_type
930 Title : _check_ref_type
931 Usage : $self->_check_ref_type( $value, "Bio::Annotation::DBLink" );
932 Function: Checks for the correct type.
934 Args : The value to be checked, the expected class.
938 sub _check_ref_type
{
939 my ( $self, $value, $expected_class ) = @_;
941 if ( ! defined( $value ) ) {
942 $self->throw( ( caller( 1 ) )[ 3 ] .": Found [undef"
943 ."] where [$expected_class] expected" );
945 elsif ( ! ref( $value ) ) {
946 $self->throw( ( caller( 1 ) )[ 3 ] .": Found scalar"
947 ." where [$expected_class] expected" );
949 elsif ( ! $value->isa( $expected_class ) ) {
950 $self->throw( ( caller( 1 ) )[ 3 ] .": Found [". ref( $value )
951 ."] where [$expected_class] expected" );