| 1 | # | ||||||||||
| 2 | # BioPerl module for Path | ||||||||||
| 3 | # | ||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||
| 5 | # | ||||||||||
| 6 | # Cared for by Hilmar Lapp <hlapp at gmx.net> | ||||||||||
| 7 | # | ||||||||||
| 8 | # (c) Hilmar Lapp, hlapp at gmx.net, 2003. | ||||||||||
| 9 | # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2003. | ||||||||||
| 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::Ontology::Path - a path for an ontology term graph | ||||||||||
| 27 | |||||||||||
| 28 | =head1 SYNOPSIS | ||||||||||
| 29 | |||||||||||
| 30 | $path = Bio::Ontology::Path->new( -identifier => "16847", | ||||||||||
| 31 | -subject_term => $subj, | ||||||||||
| 32 | -object_term => $obj, | ||||||||||
| 33 | -predicate_term => $pred, | ||||||||||
| 34 | -distance => 3 ); | ||||||||||
| 35 | |||||||||||
| 36 | =head1 DESCRIPTION | ||||||||||
| 37 | |||||||||||
| 38 | This is a basic implementation of Bio::Ontology::PathI. | ||||||||||
| 39 | |||||||||||
| 40 | Essiantially this is a very thin extension of | ||||||||||
| 41 | L<Bio::Ontology::Relationship>. It basically adds a method distance(). | ||||||||||
| 42 | |||||||||||
| 43 | =head1 FEEDBACK | ||||||||||
| 44 | |||||||||||
| 45 | =head2 Mailing Lists | ||||||||||
| 46 | |||||||||||
| 47 | User feedback is an integral part of the evolution of this and other | ||||||||||
| 48 | Bioperl modules. Send your comments and suggestions preferably to the | ||||||||||
| 49 | Bioperl mailing lists Your participation is much appreciated. | ||||||||||
| 50 | |||||||||||
| 51 | bioperl-l@bioperl.org - General discussion | ||||||||||
| 52 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||
| 53 | |||||||||||
| 54 | =head2 Support | ||||||||||
| 55 | |||||||||||
| 56 | Please direct usage questions or support issues to the mailing list: | ||||||||||
| 57 | |||||||||||
| 58 | I<bioperl-l@bioperl.org> | ||||||||||
| 59 | |||||||||||
| 60 | rather than to the module maintainer directly. Many experienced and | ||||||||||
| 61 | reponsive experts will be able look at the problem and quickly | ||||||||||
| 62 | address it. Please include a thorough description of the problem | ||||||||||
| 63 | with code and data examples if at all possible. | ||||||||||
| 64 | |||||||||||
| 65 | =head2 Reporting Bugs | ||||||||||
| 66 | |||||||||||
| 67 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||
| 68 | the bugs and their resolution. Bug reports can be submitted via | ||||||||||
| 69 | the web: | ||||||||||
| 70 | |||||||||||
| 71 | https://github.com/bioperl/bioperl-live/issues | ||||||||||
| 72 | |||||||||||
| 73 | =head1 AUTHOR | ||||||||||
| 74 | |||||||||||
| 75 | Hilmar Lapp <hlapp@gmx.net> | ||||||||||
| 76 | |||||||||||
| 77 | =head1 APPENDIX | ||||||||||
| 78 | |||||||||||
| 79 | The rest of the documentation details each of the object | ||||||||||
| 80 | methods. Internal methods are usually preceded with a _ | ||||||||||
| 81 | |||||||||||
| 82 | =cut | ||||||||||
| 83 | |||||||||||
| 84 | |||||||||||
| 85 | # Let the code begin... | ||||||||||
| 86 | |||||||||||
| 87 | |||||||||||
| 88 | package Bio::Ontology::Path; | ||||||||||
| 89 | 1 | $Bio::Ontology::Path::VERSION = '1.7.8'; | |||||||||
| 90 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 91 | |||||||||||
| 92 | 1 | ▶ | use base qw(Bio::Ontology::Relationship Bio::Ontology::PathI); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 93 | |||||||||||
| 94 | |||||||||||
| 95 | |||||||||||
| 96 | |||||||||||
| 97 | =head2 new | ||||||||||
| 98 | |||||||||||
| 99 | Title : new | ||||||||||
| 100 | Usage : $rel = Bio::Ontology::Path->new(-identifier => "16847", | ||||||||||
| 101 | -subject_term => $subject, | ||||||||||
| 102 | -object_term => $object, | ||||||||||
| 103 | -predicate_term => $type ); | ||||||||||
| 104 | -distance => 3 ); | ||||||||||
| 105 | Function: Creates a new Bio::Ontology::Path. | ||||||||||
| 106 | Returns : A new Bio::Ontology::Path object. | ||||||||||
| 107 | Args : -identifier => the identifier of this relationship [scalar] | ||||||||||
| 108 | -subject_term => the subject term [Bio::Ontology::TermI] | ||||||||||
| 109 | -object_term => the object term [Bio::Ontology::TermI] | ||||||||||
| 110 | -predicate_term => the predicate term [Bio::Ontology::TermI] | ||||||||||
| 111 | -distance => the distance between subject and object | ||||||||||
| 112 | |||||||||||
| 113 | =cut | ||||||||||
| 114 | |||||||||||
| 115 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 116 | |||||||||||
| 117 | 0 | my( $class, @args ) = @_; | |||||||||
| 118 | |||||||||||
| 119 | 0 | my $self = $class->SUPER::new( @args ); | |||||||||
| 120 | |||||||||||
| 121 | 0 | my ( $distance ) = | |||||||||
| 122 | $self->_rearrange( [qw( DISTANCE) | ||||||||||
| 123 | ], @args ); | ||||||||||
| 124 | |||||||||||
| 125 | 0 | ▶ | $distance && $self->distance($distance); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 126 | |||||||||||
| 127 | 0 | return $self; | |||||||||
| 128 | |||||||||||
| 129 | } # new | ||||||||||
| 130 | |||||||||||
| 131 | |||||||||||
| 132 | |||||||||||
| 133 | =head2 init | ||||||||||
| 134 | |||||||||||
| 135 | Title : init() | ||||||||||
| 136 | Usage : $rel->init(); | ||||||||||
| 137 | Function: Initializes this Path to all undef. | ||||||||||
| 138 | Returns : | ||||||||||
| 139 | Args : | ||||||||||
| 140 | |||||||||||
| 141 | =cut | ||||||||||
| 142 | |||||||||||
| 143 | 0 | ▶ | sub init { | ||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 144 | 0 | my $self = shift; | |||||||||
| 145 | |||||||||||
| 146 | 0 | $self->SUPER::init(@_); | |||||||||
| 147 | 0 | $self->{ "_distance" } = undef; | |||||||||
| 148 | |||||||||||
| 149 | } # init | ||||||||||
| 150 | |||||||||||
| 151 | |||||||||||
| 152 | =head2 distance | ||||||||||
| 153 | |||||||||||
| 154 | Title : distance | ||||||||||
| 155 | Usage : $obj->distance($newval) | ||||||||||
| 156 | Function: Get/set the distance between the two terms connected | ||||||||||
| 157 | by this path. | ||||||||||
| 158 | |||||||||||
| 159 | Note that modifying the distance may not be meaningful. The | ||||||||||
| 160 | implementation here is not connected to any graph engine, | ||||||||||
| 161 | so changing an existing value may simply render the | ||||||||||
| 162 | attribute's value wrong. | ||||||||||
| 163 | |||||||||||
| 164 | Example : | ||||||||||
| 165 | Returns : value of distance (a scalar) | ||||||||||
| 166 | Args : on set, new value (a scalar or undef, optional) | ||||||||||
| 167 | |||||||||||
| 168 | =cut | ||||||||||
| 169 | |||||||||||
| 170 | 0 | ▶ | sub distance{ | ||||||||
|
Subroutine
distance: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 171 | 0 | my $self = shift; | |||||||||
| 172 | |||||||||||
| 173 | 0 | ▶ | return $self->{'_distance'} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 174 | 0 | return $self->{'_distance'}; | |||||||||
| 175 | } | ||||||||||
| 176 | |||||||||||
| 177 | =head2 to_string | ||||||||||
| 178 | |||||||||||
| 179 | Title : to_string() | ||||||||||
| 180 | Usage : print $rel->to_string(); | ||||||||||
| 181 | Function: to_string method for Path. | ||||||||||
| 182 | Returns : A string representation of this Path. | ||||||||||
| 183 | Args : | ||||||||||
| 184 | |||||||||||
| 185 | =cut | ||||||||||
| 186 | |||||||||||
| 187 | 0 | ▶ | sub to_string { | ||||||||
|
Subroutine
to_string: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 188 | 0 | my( $self ) = @_; | |||||||||
| 189 | |||||||||||
| 190 | 0 | my $s = $self->SUPER::to_string(); | |||||||||
| 191 | 0 | $s .= "-- Distance:\n"; | |||||||||
| 192 | 0 | ▶ | $s .= $self->distance() if defined($self->distance()); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 193 | 0 | $s .= "\n"; | |||||||||
| 194 | |||||||||||
| 195 | 0 | return $s; | |||||||||
| 196 | |||||||||||
| 197 | } # to_string | ||||||||||
| 198 | |||||||||||
| 199 | |||||||||||
| 200 | |||||||||||
| 201 | 1 | 1; | |||||||||