Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Ontology/Path.pm @ 0:1f6dce3d34e0
Uploaded
| author | mahtabm |
|---|---|
| date | Thu, 11 Apr 2013 02:01:53 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:1f6dce3d34e0 |
|---|---|
| 1 # $Id: Path.pm,v 1.1.2.2 2003/03/27 10:07:56 lapp Exp $ | |
| 2 # | |
| 3 # BioPerl module for Path | |
| 4 # | |
| 5 # Cared for by Hilmar Lapp <hlapp at gmx.net> | |
| 6 # | |
| 7 # (c) Hilmar Lapp, hlapp at gmx.net, 2003. | |
| 8 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2003. | |
| 9 # | |
| 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. | |
| 14 # | |
| 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. | |
| 18 # | |
| 19 # You may distribute this module under the same terms as perl itself | |
| 20 | |
| 21 # POD documentation - main docs before the code | |
| 22 | |
| 23 =head1 NAME | |
| 24 | |
| 25 Path - a path for an ontology term graph | |
| 26 | |
| 27 =head1 SYNOPSIS | |
| 28 | |
| 29 $path = Bio::Ontology::Path->new( -identifier => "16847", | |
| 30 -subject_term => $subj, | |
| 31 -object_term => $obj, | |
| 32 -predicate_term => $pred, | |
| 33 -distance => 3 ); | |
| 34 | |
| 35 =head1 DESCRIPTION | |
| 36 | |
| 37 This is a basic implementation of Bio::Ontology::PathI. | |
| 38 | |
| 39 Essiantially this is a very thin extension of | |
| 40 L<Bio::Ontology::Relationship>. It basically adds a method distance(). | |
| 41 | |
| 42 =head1 FEEDBACK | |
| 43 | |
| 44 =head2 Mailing Lists | |
| 45 | |
| 46 User feedback is an integral part of the evolution of this and other | |
| 47 Bioperl modules. Send your comments and suggestions preferably to the | |
| 48 Bioperl mailing lists Your participation is much appreciated. | |
| 49 | |
| 50 bioperl-l@bioperl.org - General discussion | |
| 51 http://bio.perl.org/MailList.html - About the mailing lists | |
| 52 | |
| 53 =head2 Reporting Bugs | |
| 54 | |
| 55 report bugs to the Bioperl bug tracking system to help us keep track | |
| 56 the bugs and their resolution. Bug reports can be submitted via | |
| 57 email or the web: | |
| 58 | |
| 59 bioperl-bugs@bio.perl.org | |
| 60 http://bugzilla.bioperl.org/ | |
| 61 | |
| 62 =head1 AUTHOR | |
| 63 | |
| 64 Hilmar Lapp <hlapp@gmx.net> | |
| 65 | |
| 66 =head1 APPENDIX | |
| 67 | |
| 68 The rest of the documentation details each of the object | |
| 69 methods. Internal methods are usually preceded with a _ | |
| 70 | |
| 71 =cut | |
| 72 | |
| 73 | |
| 74 # Let the code begin... | |
| 75 | |
| 76 | |
| 77 package Bio::Ontology::Path; | |
| 78 use vars qw( @ISA ); | |
| 79 use strict; | |
| 80 use Bio::Ontology::PathI; | |
| 81 use Bio::Ontology::Relationship; | |
| 82 | |
| 83 @ISA = qw( Bio::Ontology::Relationship | |
| 84 Bio::Ontology::PathI ); | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 =head2 new | |
| 90 | |
| 91 Title : new | |
| 92 Usage : $rel = Bio::Ontology::Path->new(-identifier => "16847", | |
| 93 -subject_term => $subject, | |
| 94 -object_term => $object, | |
| 95 -predicate_term => $type ); | |
| 96 -distance => 3 ); | |
| 97 Function: Creates a new Bio::Ontology::Path. | |
| 98 Returns : A new Bio::Ontology::Path object. | |
| 99 Args : -identifier => the identifier of this relationship [scalar] | |
| 100 -subject_term => the subject term [Bio::Ontology::TermI] | |
| 101 -object_term => the object term [Bio::Ontology::TermI] | |
| 102 -predicate_term => the predicate term [Bio::Ontology::TermI] | |
| 103 -distance => the distance between subject and object | |
| 104 | |
| 105 =cut | |
| 106 | |
| 107 sub new { | |
| 108 | |
| 109 my( $class, @args ) = @_; | |
| 110 | |
| 111 my $self = $class->SUPER::new( @args ); | |
| 112 | |
| 113 my ( $distance ) = | |
| 114 $self->_rearrange( [qw( DISTANCE) | |
| 115 ], @args ); | |
| 116 | |
| 117 $distance && $self->distance($distance); | |
| 118 | |
| 119 return $self; | |
| 120 | |
| 121 } # new | |
| 122 | |
| 123 | |
| 124 | |
| 125 =head2 init | |
| 126 | |
| 127 Title : init() | |
| 128 Usage : $rel->init(); | |
| 129 Function: Initializes this Path to all undef. | |
| 130 Returns : | |
| 131 Args : | |
| 132 | |
| 133 =cut | |
| 134 | |
| 135 sub init { | |
| 136 my $self = shift; | |
| 137 | |
| 138 $self->SUPER::init(@_); | |
| 139 $self->{ "_distance" } = undef; | |
| 140 | |
| 141 } # init | |
| 142 | |
| 143 | |
| 144 =head2 distance | |
| 145 | |
| 146 Title : distance | |
| 147 Usage : $obj->distance($newval) | |
| 148 Function: Get/set the distance between the two terms connected | |
| 149 by this path. | |
| 150 | |
| 151 Note that modifying the distance may not be meaningful. The | |
| 152 implementation here is not connected to any graph engine, | |
| 153 so changing an existing value may simply render the | |
| 154 attribute's value wrong. | |
| 155 | |
| 156 Example : | |
| 157 Returns : value of distance (a scalar) | |
| 158 Args : on set, new value (a scalar or undef, optional) | |
| 159 | |
| 160 | |
| 161 =cut | |
| 162 | |
| 163 sub distance{ | |
| 164 my $self = shift; | |
| 165 | |
| 166 return $self->{'_distance'} = shift if @_; | |
| 167 return $self->{'_distance'}; | |
| 168 } | |
| 169 | |
| 170 =head2 to_string | |
| 171 | |
| 172 Title : to_string() | |
| 173 Usage : print $rel->to_string(); | |
| 174 Function: to_string method for Path. | |
| 175 Returns : A string representation of this Path. | |
| 176 Args : | |
| 177 | |
| 178 =cut | |
| 179 | |
| 180 sub to_string { | |
| 181 my( $self ) = @_; | |
| 182 | |
| 183 my $s = $self->SUPER::to_string(); | |
| 184 $s .= "-- Distance:\n"; | |
| 185 $s .= $self->distance() if defined($self->distance()); | |
| 186 $s .= "\n"; | |
| 187 | |
| 188 return $s; | |
| 189 | |
| 190 } # to_string | |
| 191 | |
| 192 | |
| 193 | |
| 194 1; |
