Node.pm

filter: Statementstmt 94.2% 65 / 69 Branchbran 69.5% 32 / 46 Conditioncond 55.5% 5 / 9 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 85.7% 6 / 7 Podpod 100% 5 / 5 totaltotal 80.9% 115 / 142 CC 32 SCAR 23.7
CC
32
Cov
82%
new
17.0
subunit_number
8.3
is_complex
6.4
CRAP 10.7
« Interaction.pm ↑ Summary Edge.pm »
1 #
2 # BioPerl module for Bio::Network::Node
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::Node - describe a Node, either a protein or protein
10 complex
11  
12 =head1 SYNOPSIS
13  
14 use Bio::Network::Node;
15  
16 my $node = Bio::Network::Node->new(-protein => [($seq1,$seq2)]);
17  
18 # or get nodes from a network:
19 my @nodes = $graph->nodes;
20 for my $node (@nodes) {
21 my @proteins = $node->proteins
22 for my $protein (@proteins) {
23 print "Sequence is ", $protein->seq;
24 }
25 }
26  
27 =head1 DESCRIPTION
28  
29 This class describes nodes in a network of interactions. A node is either
30 a protein, a Sequence object, or a protein complex, which is a collection
31 of Sequence objects.
32  
33 =head1 FEEDBACK
34  
35 =head2 Mailing Lists
36  
37 User feedback is an integral part of the evolution of this and other
38 Bioperl modules. Send your comments and suggestions preferably to one
39 of the Bioperl mailing lists. Your participation is much appreciated.
40  
41 bioperl-l@bioperl.org - General discussion
42 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
43  
44 =head2 Support
45  
46 Please direct usage questions or support issues to the mailing list:
47  
48 I<bioperl-l@bioperl.org>
49  
50 rather than to the module maintainer directly. Many experienced and
51 reponsive experts will be able look at the problem and quickly
52 address it. Please include a thorough description of the problem
53 with code and data examples if at all possible.
54  
55 =head2 Reporting Bugs
56  
57 Report bugs to the Bioperl bug tracking system to help us keep track
58 the bugs and their resolution. Bug reports can be submitted via the
59 web:
60  
61 http://bugzilla.open-bio.org/
62  
63 =head1 AUTHORS
64  
65 Brian Osborne bosborne at alum.mit.edu
66  
67 Maintained by Brian Osborne
68  
69 =cut
70  
71 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 package Bio::Network::Node;
73 4 ▶use base 'Bio::Root::Root';
Subroutine BEGIN: called CC=1 SCAR=0.0
74  
75 =head2 new
76  
77 Name : new
78 Purpose : Constructor for an Node object
79 Usage : my $node = Bio::Network::Node->new(-protein => $seqobj)
80 or
81 my $node = Bio::Network::Node->new(-protein => [($seqobj1,$seqobj2)])
82 or
83 my $node = Bio::Network::Node->new(-protein =>
84 [ [(2, $seqobj1)],
85 [(1, $seqobj2)],
86 [(3, $seqobj3)] ];
87 Returns : A new Bio::Network::Node object
88 Arguments : -protein => 1 Sequence object
89 or
90 -protein => Reference to an array containing 1 or more
91 Sequence objects
92 or
93 -protein => Reference to an array of arrays where the elements are
94 arrays containing a number denoting the number of subunits of
95 a protein in the protein complex and a Sequence object
96 Notes :
97  
98 =cut
99  
100 10 ▶sub new {
Subroutine new: called CC=16 SCAR=28.3
Pod documented
101 10 my ($caller,@args) = @_;
102 10 ▶ my $class = ref ($caller) || $caller;
Condition33%1/3
ref $caller || $caller
l!l&&r!l&&!r
0100
MC/DC0%0/2
ref $caller || $caller
ref $caller $caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
ABresult
1X1
011
000
103 10 my $self = {};
104 10 bless ($self,$class);
105 10 my $count = 1;
106  
107 # Defaults
108 10 $self->{_is_complex} = 0; # 1 protein, not a protein complex
109  
110 10 my ($protein) = $self->_rearrange([qw( PROTEIN )], @args);
111 10 ▶ $self->throw("No proteins specified when making a Node")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $protein 0 10 10
112 unless defined($protein);
113
114 10 ▶ if ( ref($protein) eq "ARRAY" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $protein eq 'ARRAY') { } 7 3 10
115 7 ▶ $self->throw("No Sequence objects passed to Bio::Network::Node::new")
Branch: 1 branch
BranchTrueFalseTotal
if scalar @$protein == 0 0 7 7
116 if scalar @$protein == 0;
117 # If an array of arrays is passed...
118 7 ▶ if (ref($$protein[0]) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $protein->[0] eq 'ARRAY') { } 3 4 7
119 3 for my $ref (@{$protein}) {
120 6 ▶ $self->throw("Must pass a Sequence object to Bio::Network::Node::new")
Branch: 1 branch
BranchTrueFalseTotal
unless $ref->[0]->isa("Bio::Seq") 0 6 6
121 unless $ref->[0]->isa("Bio::Seq");
122 6 $self->{_protein}->{$count}->{_subunit} = $ref->[0];
123 6 ▶ $self->{_protein}->{$count}->{_number} = $ref->[1] if $ref->[1];
Branch: 1 branch
BranchTrueFalseTotal
if $ref->[1] 6 0 6
124 6 ▶ $self->{_is_complex} = 1 if ($ref->[1] && $ref->[1] > 2);
Branch: 1 branch
BranchTrueFalseTotal
if $ref->[1] and $ref->[1] > 2 1 5 6
Condition66%2/3
$ref->[1] and $ref->[1] > 2
!ll&&!rl&&r
051
MC/DC50%1/2
$ref->[1] and $ref->[1] > 2
$ref->[1] $ref->[1] > 2
Truth table66%2/3
A and B
A= $ref->[1]B= $ref->[1] > 2
ABresult
0X0
100
111
125 6 $count++;
126 }
127 3 ▶ $self->{_is_complex} = 1 if ($count > 2);
Branch: 1 branch
BranchTrueFalseTotal
if $count > 2 2 1 3
128 } else {
129 # If an array of Sequence objects is passed...
130 4 for my $protein (@{$protein}) {
131 8 ▶ $self->throw("Must pass a Sequence object to Bio::Network::Node::new")
Branch: 1 branch
BranchTrueFalseTotal
unless $protein->isa("Bio::Seq") 0 8 8
132 unless $protein->isa("Bio::Seq");
133 # Seq object must be value, not key
134 8 $self->{_protein}->{$count}->{_subunit} = $protein;
135 8 $self->{_protein}->{$count}->{_number} = undef;
136 8 $count++;
137 }
138 4 ▶ $self->{_is_complex} = 1 if ($count > 2);
Branch: 1 branch
BranchTrueFalseTotal
if $count > 2 3 1 4
139 }
140 } else {
141 # A single Sequence object is passed
142 3 ▶ $self->throw("Must pass a Sequence object to Bio::Network::Node::new")
Branch: 1 branch
BranchTrueFalseTotal
unless $protein->isa("Bio::Seq") 0 3 3
143 unless $protein->isa("Bio::Seq");
144 # Seq object must be value, not key
145 3 $self->{_protein}->{$count}->{_subunit} = $protein;
146 3 $self->{_protein}->{$count}->{_number} = undef;
147 }
148 10 $self;
149 }
150  
151 =head2 proteins
152  
153 Name : proteins
154 Purpose : Get the proteins in a Node or get a count of proteins in the Node
155 Usage : my $count = $node->proteins
156 or
157 my @proteins = $node->proteins
158 Returns : Gets an array of Sequence objects or a count of
159 the number of Sequence objects
160 Arguments : None
161  
162 =cut
163  
164 8 ▶sub proteins {
Subroutine proteins: called CC=4 SCAR=13.9
Pod documented
165 8 my $self = shift;
166 8 ▶ $self->throw("Only a Node object can call the Node::proteins() method")
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isa("Bio::Network::Node") 0 8 8
167 unless $self->isa("Bio::Network::Node");
168 8 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 3 5 8
169 3 my @proteins;
170 3 for my $count (keys %{$self->{_protein}}) {
171 7 push @proteins,$self->{_protein}->{$count}->{_subunit};
172 }
173 3 return @proteins;
174 }
175 5 scalar keys %{$self->{_protein}};
176 }
177  
178 =head2 next_protein
179  
180 Name :
181 Purpose :
182 Usage :
183 Returns :
184 Arguments :
185  
186 =cut
187  
188 0 ▶sub next_protein {
Subroutine next_protein: not called CC=2 SCAR=17.9
Pod documented
189 0 my $self = shift;
190 0 ▶ $self->throw("Only a Node object can call the Node::next_protein() method")
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isa("Bio::Network::Node") 0 0 0
191 unless $self->isa("Bio::Network::Node");
192  
193  
194 }
195  
196 =head2 is_complex
197  
198 Name : is_complex
199 Purpose : Get or set whether a node is a protein or a protein complex
200 Usage : if ($node->is_complex){ ... }
201 or
202 $node->is_complex(1)
203 Returns : 1 if the Node has more than 1 proteins, 0 if not
204 Arguments : None
205  
206 =cut
207  
208 8 ▶sub is_complex {
Subroutine is_complex: called CC=6 SCAR=18.6
Pod documented
209 8 my ($self,$arg) = @_;
210 8 ▶ $self->throw("Only a Node object can call the Node::is_complex() method")
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isa("Bio::Network::Node") 0 8 8
211 unless $self->isa("Bio::Network::Node");
212 8 ▶ if (defined $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $arg) { } 1 7 8
213 1 ▶ if ($arg == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($arg == 1) { } 0 1 1
elsif ($arg == 0) { } 1 0 1
214 0 $self->{_is_complex} = 1;
215 } elsif ($arg == 0) {
216 1 $self->{_is_complex} = 0;
217 }
218 } else {
219 7 ▶ return 1 if ($self->{_is_complex});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_is_complex"} 3 4 7
220 4 return 0;
221 }
222 }
223  
224 =head2 subunit_number
225  
226 Name : subunit_number
227 Purpose : Get or set the number of a given protein in a protein
228 complex.
229 Usage : $num = $node->subunit_number($protein)
230 or
231 $node->subunit_number($protein,$number)
232 Returns : A number, whether get or set
233 Arguments : None or a Sequence object in a given Node
234  
235 =cut
236  
237 11 ▶sub subunit_number {
Subroutine subunit_number: called CC=8 SCAR=21.2
Pod documented
238 11 my ($self,$protein,$num) = @_;
239 11 ▶ $self->throw("Only a Node object can call the Node::subunit_number() method")
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isa("Bio::Network::Node") 0 11 11
240 unless $self->isa("Bio::Network::Node");
241 11 ▶ if ($protein && $num) {
Branch: 1 branch
BranchTrueFalseTotal
if ($protein and $num) { } 2 9 11
Condition66%2/3
$protein and $num
!ll&&!rl&&r
092
MC/DC50%1/2
$protein and $num
$protein $num
Truth table66%2/3
A and B
A= $proteinB= $num
ABresult
0X0
100
111
242 2 for my $key (keys %{$self->{_protein}}) {
243 2 ▶ if ($self->{_protein}->{$key}->{_subunit} == $protein) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_protein"}{$key}{"_subunit"} == $protein) 2 0 2
244 2 $self->{_protein}->{$key}->{_number} = $num;
245 2 return $num;
246 }
247 }
248 0 $self->throw("Protein ",$protein," not found, cannot set subunit_number");
249 } else {
250 9 for my $key (keys %{$self->{_protein}}) {
251 return $self->{_protein}->{$key}->{_number}
252 15 ▶ if $self->{_protein}->{$key}->{_subunit} eq $protein;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_protein"}{$key}{"_subunit"} eq $protein 9 6 15
253 }
254 }
255 }
256  
257 4 1;
258  
259 __END__
« Interaction.pm ↑ Summary Edge.pm »