3 # BioPerl module for Bio::Network::Interaction
5 # You may distribute this module under the same terms as perl itself
6 # POD documentation - main docs before the code
10 Bio::Network::Interaction - describes a protein-protein interaction
14 # Add an interaction with some attributes
15 use Bio::Network::Interaction;
17 my $interx = Bio::Network::Interaction->new(-weight => $score,
19 $gr->add_interaction(-nodes => [($node1,$node2)],
20 -interaction => $interx);
22 # Retrieve an interaction using an identifier
23 my $interaction = $gr->get_interaction_by_id($id);
25 my $id = $interaction->primary_id;
26 my $wt = $interaction->weight;
27 my @nodes = $interaction->nodes;
31 This class contains information about a bi-molecular interaction.
32 At present it just contains data about a weight (optional) and an
33 identifier. Subclasses could hold more specific information. A pair
34 of nodes can have more than one Interaction object associated with it.
40 User feedback is an integral part of the evolution of this and other
41 Bioperl modules. Send your comments and suggestions preferably to one
42 of the Bioperl mailing lists. Your participation is much appreciated.
44 bioperl-l@bioperl.org - General discussion
45 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
49 Please direct usage questions or support issues to the mailing list:
51 I<bioperl-l@bioperl.org>
53 rather than to the module maintainer directly. Many experienced and
54 reponsive experts will be able look at the problem and quickly
55 address it. Please include a thorough description of the problem
56 with code and data examples if at all possible.
60 Report bugs to the Bioperl bug tracking system to help us keep track
61 the bugs and their resolution. Bug reports can be submitted via the
64 http://bugzilla.open-bio.org/
68 Brian Osborne bosborne at alum.mit.edu
69 Richard Adams richard.adams@ed.ac.uk
71 Maintained by Brian Osborne
76 package Bio
::Network
::Interaction
;
77 use base
qw(Bio::Root::Root Bio::AnnotatableI Bio::Annotation::Collection);
83 Purpose : Constructor for an Interaction object
84 Usage : my $interx = Bio::Network::Interaction->new(-id => $id);
85 Returns : A new Bio::Network::Interaction object
86 Arguments : -id => interaction id
87 -weight (optional) => weight score
92 my ($caller,@args) = @_;
93 my $class = ref ($caller) || $caller;
95 bless ($self, $class);
97 my ($weight,$id) = $self->_rearrange([qw( WEIGHT ID )], @args);
98 $self->{_weight
} = defined($weight) ?
$weight : undef;
99 $self->{_id
} = defined($id) ?
$id : undef;
106 Purpose : Get or set a weight or score
107 Usage : my $weight = $interx->weight()
111 Arguments : Nothing or a number
117 $self->{_weight
} = shift if @_;
118 return defined($self->{_weight
}) ?
$self->{_weight
} : undef;
124 Purpose : Get or set the primary_id
125 Usage : my $id = $interx->primary_id()
127 $interx->primary_id("SIB4")
128 Returns : A string identifier
129 Arguments : Nothing or an identifier
137 $self->throw ("Primary interaction ID must be a text value, not a [" .
138 ref($v). "].") if (ref ($v));
141 return defined($self->{_id
}) ?
$self->{_id
} : undef;
147 Purpose : Get the pair of nodes for an Interaction
148 Usage : my $count = $interx->nodes
150 my @nodes = $interx->nodes
151 Returns : Gets an array of 2 Nodes or a count of the number of
154 Notes : Getting a count of the number of Nodes in an Interaction
155 will almost always return 2, but there is a formal possibility
156 that a Node could interact with itself, returning 1
162 my @nodes = @
{$self->{_nodes
}};
163 wantarray ?
return @nodes : return scalar @nodes;
169 Usage : my $annotation = $ix->annotation
171 $ix->annotation($annotation)
172 Function: Gets or sets the annotation
173 Returns : Bio::AnnotationCollectionI object
174 Args : None or Bio::AnnotationCollectionI object
176 See L<Bio::AnnotationCollectionI> and L<Bio::Annotation::Collection>
182 my ($obj,$value) = @_;
183 if ( defined $value ) {
184 $obj->throw("Object of class " . ref($value) . " does not implement ".
185 "Bio::AnnotationCollectionI.")
186 unless $value->isa("Bio::AnnotationCollectionI");
187 $obj->{'_annotation'} = $value;
188 } elsif( ! defined $obj->{'_annotation'}) {
189 $obj->{'_annotation'} = Bio
::Annotation
::Collection
->new();
191 return $obj->{'_annotation'};
197 Purpose : Alias to primary_id
198 Usage : my $id = $edge->object_id()
205 $id ?
$self->primary_id($id) : return $self->primary_id;