~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to Bio/Graph/Edge.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: Edge.pm,v 1.11.4.1 2006/10/02 23:10:18 sendu Exp $
 
2
#
 
3
# BioPerl module for Bio::Graph::Edge
 
4
#
 
5
# You may distribute this module under the same terms as perl itself
 
6
# POD documentation - main docs before the code
 
7
 
 
8
=head1 NAME
 
9
 
 
10
Bio::Graph::Edge - encapsulation of an interaction between 2 Bio::Seq objects
 
11
 
 
12
=head1 SYNOPSIS
 
13
 
 
14
  ## get an interaction between two nodes ##
 
15
 
 
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();
 
21
 
 
22
=head1 DESCRIPTION
 
23
 
 
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 
 
27
information.
 
28
 
 
29
=head1 FEEDBACK
 
30
 
 
31
=head2 Mailing Lists
 
32
 
 
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.
 
36
 
 
37
  bioperl-l@bioperl.org                  - General discussion
 
38
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
 
39
 
 
40
=head2 Reporting Bugs
 
41
 
 
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
 
44
web:
 
45
 
 
46
  http://bugzilla.open-bio.org/
 
47
 
 
48
=head1 AUTHOR - Richard Adams
 
49
 
 
50
Email richard.adams@ed.ac.uk
 
51
 
 
52
=cut
 
53
 
 
54
use strict;
 
55
package Bio::Graph::Edge;
 
56
use base qw(Bio::Root::Root Bio::IdentifiableI);
 
57
 
 
58
 
 
59
=head2 new
 
60
 
 
61
 Name       : new
 
62
 Purpose    : constructor for an edge object
 
63
 Usage      : my $edge = Bio::Graph::Edge->new(nodes => [$node1,$node2]
 
64
                                               id => $id);
 
65
              $graph->add_edge($edge);
 
66
 Returns    : a new Bio::Graph::Edge object 
 
67
 Arguments  : hash nodes            => array reference of 2 nodes
 
68
                   id               => edge id
 
69
                   weight(optional) => weight score.
 
70
 
 
71
=cut
 
72
 
 
73
sub new {
 
74
      ##array based, not hash based ##..., therefore does not use 
 
75
      #Bio::Root::Root->new().
 
76
 
 
77
        my ($caller, @args) = @_;
 
78
        my $class  = ref ($caller) || $caller;
 
79
        my $self    = [];
 
80
        bless ($self, $class);
 
81
 
 
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; 
 
87
        return $self;
 
88
 
 
89
}
 
90
 
 
91
=head2 weight
 
92
 
 
93
 Name      : weight
 
94
 Purpose   : get/setter for weight score
 
95
 Usage     : my $weight = $edge->weight();
 
96
 Returns   : anumber
 
97
 Arguments : void/ a number
 
98
 
 
99
=cut
 
100
 
 
101
sub weight {
 
102
        my $self = shift;
 
103
        if (@_) {$self->[2] = shift;}
 
104
        return defined($self->[2])?$self->[2]:undef;
 
105
}
 
106
 
 
107
=head2 object_id
 
108
 
 
109
 Name      : object_id
 
110
 Purpose   : get/setter for object_id
 
111
 Usage     : my $id = $edge->object_id();
 
112
 Returns   : a string identifier
 
113
 Arguments : void/ an identifier 
 
114
 
 
115
=cut
 
116
 
 
117
sub object_id {
 
118
        my $self            = shift;
 
119
        if (@_) {
 
120
                my $v  = shift;
 
121
                if (ref ($v)) {
 
122
                        $self->throw ("Edge ID must be a text value, not a [".
 
123
                                                        ref($v). "].");
 
124
                        } 
 
125
                $self->[3] = shift;
 
126
        }
 
127
        return defined($self->[3])?$self->[3]:undef;
 
128
}
 
129
 
 
130
=head2  nodes
 
131
 
 
132
 Name      : nodes
 
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. 
 
137
 
 
138
=cut
 
139
 
 
140
sub nodes {
 
141
        my ($self, @args) = @_;
 
142
        if (@args >= 2 ) {
 
143
                $self->[0] =  $args[0];
 
144
                $self->[1] =  $args[1];
 
145
                }
 
146
        return ($self->[0], $self->[1]);
 
147
}
 
148
 
 
149
1;