1
# $Id: Edge.pm,v 1.11.4.1 2006/10/02 23:10:18 sendu Exp $
3
# BioPerl module for Bio::Graph::Edge
5
# You may distribute this module under the same terms as perl itself
6
# POD documentation - main docs before the code
10
Bio::Graph::Edge - encapsulation of an interaction between 2 Bio::Seq objects
14
## get an interaction between two nodes ##
16
my $edge = $gr->edge( $gr->nodes_by_id('P12345'),
17
$gr->nodes_by_id('P23456'));
18
my $id = $edge->object_id();
19
my $wt = $edge->weight();
20
my @nodes = $edge->nodes();
24
This class contains information about a bimolecular interaction.
25
At present it just contains data about its component node, a weight
26
(if set) and an identifier. Subclasses could hold more specific
33
User feedback is an integral part of the evolution of this and other
34
Bioperl modules. Send your comments and suggestions preferably to one
35
of the Bioperl mailing lists. Your participation is much appreciated.
37
bioperl-l@bioperl.org - General discussion
38
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
42
Report bugs to the Bioperl bug tracking system to help us keep track
43
the bugs and their resolution. Bug reports can be submitted via the
46
http://bugzilla.open-bio.org/
48
=head1 AUTHOR - Richard Adams
50
Email richard.adams@ed.ac.uk
55
package Bio::Graph::Edge;
56
use base qw(Bio::Root::Root Bio::IdentifiableI);
62
Purpose : constructor for an edge object
63
Usage : my $edge = Bio::Graph::Edge->new(nodes => [$node1,$node2]
65
$graph->add_edge($edge);
66
Returns : a new Bio::Graph::Edge object
67
Arguments : hash nodes => array reference of 2 nodes
69
weight(optional) => weight score.
74
##array based, not hash based ##..., therefore does not use
75
#Bio::Root::Root->new().
77
my ($caller, @args) = @_;
78
my $class = ref ($caller) || $caller;
80
bless ($self, $class);
82
my ($weight, $id, $nodes) = $self->_rearrange([qw( WEIGHT ID NODES)], @args);
83
$self->[0] = $nodes->[0];
84
$self->[1] = $nodes->[1];
85
$self->[2] = defined($weight)?$weight:undef;
86
$self->[3] = defined($id)?$id:undef;
94
Purpose : get/setter for weight score
95
Usage : my $weight = $edge->weight();
97
Arguments : void/ a number
103
if (@_) {$self->[2] = shift;}
104
return defined($self->[2])?$self->[2]:undef;
110
Purpose : get/setter for object_id
111
Usage : my $id = $edge->object_id();
112
Returns : a string identifier
113
Arguments : void/ an identifier
122
$self->throw ("Edge ID must be a text value, not a [".
127
return defined($self->[3])?$self->[3]:undef;
133
Purpose : get/setter for nodes
134
Usage : my @nodes = $edge->nodes();
135
Returns : a 2 element list of nodes /void
136
Arguments : void/ a 2 element list of nodes.
141
my ($self, @args) = @_;
143
$self->[0] = $args[0];
144
$self->[1] = $args[1];
146
return ($self->[0], $self->[1]);