sync w/ main trunk
[bioperl-live.git] / Bio / Ontology / Path.pm
blob72fb1cb5395582ea4d557f566ab60abc23374678
1 # $Id$
3 # BioPerl module for Path
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Hilmar Lapp <hlapp at gmx.net>
9 # (c) Hilmar Lapp, hlapp at gmx.net, 2003.
10 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2003.
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
25 =head1 NAME
27 Bio::Ontology::Path - a path for an ontology term graph
29 =head1 SYNOPSIS
31 $path = Bio::Ontology::Path->new( -identifier => "16847",
32 -subject_term => $subj,
33 -object_term => $obj,
34 -predicate_term => $pred,
35 -distance => 3 );
37 =head1 DESCRIPTION
39 This is a basic implementation of Bio::Ontology::PathI.
41 Essiantially this is a very thin extension of
42 L<Bio::Ontology::Relationship>. It basically adds a method distance().
44 =head1 FEEDBACK
46 =head2 Mailing Lists
48 User feedback is an integral part of the evolution of this and other
49 Bioperl modules. Send your comments and suggestions preferably to the
50 Bioperl mailing lists Your participation is much appreciated.
52 bioperl-l@bioperl.org - General discussion
53 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
55 =head2 Support
57 Please direct usage questions or support issues to the mailing list:
59 L<bioperl-l@bioperl.org>
61 rather than to the module maintainer directly. Many experienced and
62 reponsive experts will be able look at the problem and quickly
63 address it. Please include a thorough description of the problem
64 with code and data examples if at all possible.
66 =head2 Reporting Bugs
68 Report bugs to the Bioperl bug tracking system to help us keep track
69 the bugs and their resolution. Bug reports can be submitted via
70 the web:
72 http://bugzilla.open-bio.org/
74 =head1 AUTHOR
76 Hilmar Lapp <hlapp@gmx.net>
78 =head1 APPENDIX
80 The rest of the documentation details each of the object
81 methods. Internal methods are usually preceded with a _
83 =cut
86 # Let the code begin...
89 package Bio::Ontology::Path;
90 use strict;
92 use base qw(Bio::Ontology::Relationship Bio::Ontology::PathI);
97 =head2 new
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
113 =cut
115 sub new {
117 my( $class, @args ) = @_;
119 my $self = $class->SUPER::new( @args );
121 my ( $distance ) =
122 $self->_rearrange( [qw( DISTANCE)
123 ], @args );
125 $distance && $self->distance($distance);
127 return $self;
129 } # new
133 =head2 init
135 Title : init()
136 Usage : $rel->init();
137 Function: Initializes this Path to all undef.
138 Returns :
139 Args :
141 =cut
143 sub init {
144 my $self = shift;
146 $self->SUPER::init(@_);
147 $self->{ "_distance" } = undef;
149 } # init
152 =head2 distance
154 Title : distance
155 Usage : $obj->distance($newval)
156 Function: Get/set the distance between the two terms connected
157 by this path.
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.
164 Example :
165 Returns : value of distance (a scalar)
166 Args : on set, new value (a scalar or undef, optional)
168 =cut
170 sub distance{
171 my $self = shift;
173 return $self->{'_distance'} = shift if @_;
174 return $self->{'_distance'};
177 =head2 to_string
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 :
185 =cut
187 sub to_string {
188 my( $self ) = @_;
190 my $s = $self->SUPER::to_string();
191 $s .= "-- Distance:\n";
192 $s .= $self->distance() if defined($self->distance());
193 $s .= "\n";
195 return $s;
197 } # to_string