Interaction.pm

filter: Statementstmt 41.6% 15 / 36 Branchbran 8.3% 2 / 24 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 37.5% 3 / 8 Podpod 100% 6 / 6 totaltotal 34.1% 27 / 79 CC 14 SCAR 24.3
CC
14
Cov
29%
primary_id
20.0
annotation
20.0
weight
12.0
CRAP 11.4
« IO/psi10.pm ↑ Summary Node.pm »
1 #
2 # BioPerl module for Bio::Network::Interaction
3 #
4 # You may distribute this module under the same terms as perl itself
5 # POD documentation - main docs before the code
6  
7 =head1 NAME
8  
9 Bio::Network::Interaction - describes a protein-protein interaction
10  
11 =head1 SYNOPSIS
12  
13 # Add an interaction with some attributes
14 use Bio::Network::Interaction;
15  
16 my $interx = Bio::Network::Interaction->new(-weight => $score,
17 -id => $id);
18 $gr->add_interaction(-nodes => [($node1,$node2)],
19 -interaction => $interx);
20  
21 # Retrieve an interaction using an identifier
22 my $interaction = $gr->get_interaction_by_id($id);
23  
24 my $id = $interaction->primary_id;
25 my $wt = $interaction->weight;
26 my @nodes = $interaction->nodes;
27  
28 =head1 DESCRIPTION
29  
30 This class contains information about a bi-molecular interaction.
31 At present it just contains data about a weight (optional) and an
32 identifier. Subclasses could hold more specific information. A pair
33 of nodes can have more than one Interaction object associated with it.
34  
35 =head1 FEEDBACK
36  
37 =head2 Mailing Lists
38  
39 User feedback is an integral part of the evolution of this and other
40 Bioperl modules. Send your comments and suggestions preferably to one
41 of the Bioperl mailing lists. Your participation is much appreciated.
42  
43 bioperl-l@bioperl.org - General discussion
44 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
45  
46 =head2 Support
47  
48 Please direct usage questions or support issues to the mailing list:
49  
50 I<bioperl-l@bioperl.org>
51  
52 rather than to the module maintainer directly. Many experienced and
53 reponsive experts will be able look at the problem and quickly
54 address it. Please include a thorough description of the problem
55 with code and data examples if at all possible.
56  
57 =head2 Reporting Bugs
58  
59 Report bugs to the Bioperl bug tracking system to help us keep track
60 the bugs and their resolution. Bug reports can be submitted via the
61 web:
62  
63 http://bugzilla.open-bio.org/
64  
65 =head1 AUTHORS
66  
67 Brian Osborne bosborne at alum.mit.edu
68 Richard Adams richard.adams@ed.ac.uk
69  
70 Maintained by Brian Osborne
71  
72 =cut
73  
74 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 package Bio::Network::Interaction;
76 3 ▶use base qw(Bio::Root::Root Bio::AnnotatableI Bio::Annotation::Collection);
Subroutine BEGIN: called CC=1 SCAR=0.0
77  
78  
79 =head2 new
80  
81 Name : new
82 Purpose : Constructor for an Interaction object
83 Usage : my $interx = Bio::Network::Interaction->new(-id => $id);
84 Returns : A new Bio::Network::Interaction object
85 Arguments : -id => interaction id
86 -weight (optional) => weight score
87  
88 =cut
89  
90 1 ▶sub new {
Subroutine new: called CC=4 SCAR=14.6
Pod documented
91 1 my ($caller,@args) = @_;
92 1 ▶ my $class = ref ($caller) || $caller;
Condition33%1/3
ref $caller || $caller
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $caller || $caller
ref $caller $caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
ABresult
1X1
011
000
93 1 my $self = {};
94 1 bless ($self, $class);
95  
96 1 my ($weight,$id) = $self->_rearrange([qw( WEIGHT ID )], @args);
97 1 ▶ $self->{_weight} = defined($weight) ? $weight : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $weight ? : 1 0 1
98 1 ▶ $self->{_id} = defined($id) ? $id : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $id ? : 1 0 1
99 1 return $self;
100 }
101  
102 =head2 weight
103  
104 Name : weight
105 Purpose : Get or set a weight or score
106 Usage : my $weight = $interx->weight()
107 or
108 $interx->weight(3)
109 Returns : a number
110 Arguments : Nothing or a number
111  
112 =cut
113  
114 0 ▶sub weight {
Subroutine weight: not called CC=3 SCAR=24.8
Pod documented
115 0 my $self = shift;
116 0 ▶ $self->{_weight} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
117 0 ▶ return defined($self->{_weight}) ? $self->{_weight} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'_weight'} ? : 0 0 0
118 }
119  
120 =head2 primary_id
121  
122 Name : primary_id
123 Purpose : Get or set the primary_id
124 Usage : my $id = $interx->primary_id()
125 or
126 $interx->primary_id("SIB4")
127 Returns : A string identifier
128 Arguments : Nothing or an identifier
129  
130 =cut
131  
132 0 ▶sub primary_id {
Subroutine primary_id: not called CC=4 SCAR=30.0
Pod documented
133 0 my $self = shift;
134 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
135 0 my $v = shift;
136 0 ▶ $self->throw ("Primary interaction ID must be a text value, not a [" .
Branch: 1 branch
BranchTrueFalseTotal
if ref $v 0 0 0
137 ref($v). "].") if (ref ($v));
138 0 $self->{_id} = $v;
139 }
140 0 ▶ return defined($self->{_id}) ? $self->{_id} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'_id'} ? : 0 0 0
141 }
142  
143 =head2 nodes
144  
145 Name : nodes
146 Purpose : Get the pair of nodes for an Interaction
147 Usage : my $count = $interx->nodes
148 or
149 my @nodes = $interx->nodes
150 Returns : Gets an array of 2 Nodes or a count of the number of
151 Nodes
152 Arguments :
153 Notes : Getting a count of the number of Nodes in an Interaction
154 will almost always return 2, but there is a formal possibility
155 that a Node could interact with itself, returning 1
156  
157 =cut
158  
159 0 ▶sub nodes {
Subroutine nodes: not called CC=2 SCAR=17.9
Pod documented
160 0 my $self = shift;
161 0 my @nodes = @{$self->{_nodes}};
162 0 ▶ wantarray ? return @nodes : return scalar @nodes;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
163 }
164  
165 =head2 annotation
166  
167 Title : annotation
168 Usage : my $annotation = $ix->annotation
169 or
170 $ix->annotation($annotation)
171 Function: Gets or sets the annotation
172 Returns : Bio::AnnotationCollectionI object
173 Args : None or Bio::AnnotationCollectionI object
174  
175 See L<Bio::AnnotationCollectionI> and L<Bio::Annotation::Collection>
176 for more information
177  
178 =cut
179  
180 0 ▶sub annotation {
Subroutine annotation: not called CC=4 SCAR=30.0
Pod documented
181 0 my ($obj,$value) = @_;
182 0 ▶ if ( defined $value ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $value) { } 0 0 0
elsif (not defined $obj->{'_annotation'}) { } 0 0 0
183 0 ▶ $obj->throw("Object of class " . ref($value) . " does not implement ".
Branch: 1 branch
BranchTrueFalseTotal
unless $value->isa("Bio::AnnotationCollectionI") 0 0 0
184 "Bio::AnnotationCollectionI.")
185 unless $value->isa("Bio::AnnotationCollectionI");
186 0 $obj->{'_annotation'} = $value;
187 } elsif( ! defined $obj->{'_annotation'}) {
188 0 $obj->{'_annotation'} = Bio::Annotation::Collection->new();
189 }
190 0 return $obj->{'_annotation'};
191 }
192  
193 =head2 object_id
194  
195 Name : object_id
196 Purpose : Alias to primary_id
197 Usage : my $id = $edge->object_id()
198 Notes : Deprecated
199  
200 =cut
201  
202 0 ▶sub object_id {
Subroutine object_id: not called CC=2 SCAR=17.9
Pod documented
203 0 my ($self,$id) = @_;
204 0 ▶ $id ? $self->primary_id($id) : return $self->primary_id;
Branch: 1 branch
BranchTrueFalseTotal
$id ? : 0 0 0
205 }
206  
207 3 1;
208  
209 __END__
« IO/psi10.pm ↑ Summary Node.pm »