Bio/Matrix/PSM/ProtPsm.pm

filter: Statementstmt 27.2% 12 / 44 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 42.8% 3 / 7 Podpod 100% 4 / 4 totaltotal 27.9% 19 / 68 CC 8 SCAR 23.2
CC
8
Cov
22%
header
20.0
matrix
12.0
new
6.0
CRAP 10.2
« Bio/DB/Fasta.pm ↑ Summary Bio/SeqIO/asciitree.pm »
1 #---------------------------------------------------------
2  
3 #ISA ProtMatrix, HAS InstanceSite
4  
5 =head1 NAME
6  
7 Bio::Matrix::PSM::ProtPsm - handle combination of site matricies
8  
9 =head1 SYNOPSIS
10  
11 use Bio::Matrix::PSM::IO;
12  
13 #To get a ProtPsm object from a file use the Psm parser:
14 my $psmIO = Bio::Matrix::PSM::IO->new(-format=>'psiblast', -file=>$file);
15  
16 # Now go through all entities in the file with next_psm, which
17 # returns a Psm object see Bio::Matrix::PSM::IO for detailed
18 # documentation (matrix predictions or matrix sequence matches or
19 # both):
20  
21 while (my $psm=$psmIO->next_psm) {
22 my %psm_header = $psm->header;
23 my $ic = $psm_header{IC};
24 my $sites = $psm_header{sites};
25 my $width = $psm_header{width};
26 my $score = $psm_header{e_val};
27 my $IUPAC = $psm->IUPAC;
28 my $instances = $psm->instances;
29 foreach my $instance (@{$instances}) {
30 my $id = $instance->primary_id;
31 #Do something with the id
32 }
33 }
34  
35 =head1 DESCRIPTION
36  
37 To handle a combination of site matrices and/or their corresponding sequence
38 matches (instances). This object inherits from Bio::Matrix::PSM::ProtMatrix, so
39 you can methods from that class. It may hold also an array of
40 Bio::Matrix::PSM::InstanceSite object, but you will have to retrieve these
41 through Bio::Matrix::PSM::ProtPsm-E<gt>instances method (see below). To some
42 extent this is an expanded ProtMatrix object, holding data from analysis that
43 also deal with sequence matches of a particular matrix.
44  
45  
46 =head2 DESIGN ISSUES
47  
48 This does not make too much sense to me I am mixing PSM with PSM sequence
49 matches Though they are very closely related, I am not satisfied by the way
50 this is implemented here. Heikki suggested different objects when one has
51 something like meme But does this mean we have to write a different objects for
52 mast, meme, transfac, theiresias, etc.? To me the best way is to return
53 SiteMatrix object + arrray of InstanceSite objects and then mast will return
54 undef for SiteMatrix and transfac will return undef for InstanceSite. Probably
55 I cannot see some other design issues that might arise from such approach, but
56 it seems more straightforward. Hilmar does not like this because it is an
57 exception from the general BioPerl rules. Should I leave this as an option?
58 Also the header rightfully belongs the driver object, and could be retrieved as
59 hashes. I do not think it can be done any other way, unless we want to create
60 even one more object with very unclear content.
61  
62 =head1 FEEDBACK
63  
64 =head2 Mailing Lists
65  
66 User feedback is an integral part of the evolution of this
67 and other Bioperl modules. Send your comments and suggestions preferably
68 to one of the Bioperl mailing lists.
69 Your participation is much appreciated.
70  
71 bioperl-l@bioperl.org - General discussion
72 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
73  
74 =head2 Support
75  
76 Please direct usage questions or support issues to the mailing list:
77  
78 I<bioperl-l@bioperl.org>
79  
80 rather than to the module maintainer directly. Many experienced and
81 reponsive experts will be able look at the problem and quickly
82 address it. Please include a thorough description of the problem
83 with code and data examples if at all possible.
84  
85 =head2 Reporting Bugs
86  
87 Report bugs to the Bioperl bug tracking system to help us keep track
88 the bugs and their resolution. Bug reports can be submitted via the
89 web:
90  
91 https://github.com/bioperl/bioperl-live/issues
92  
93 =head1 AUTHOR - James Thompson
94  
95 Email tex@biosysadmin.com
96  
97  
98 =head1 DISCLAIMER
99  
100 This software is provided "as is" without warranty of any kind.
101  
102 =head1 SEE ALSO
103  
104 ProtMatrix, meme, transfac, psiblast, InstanceSite
105  
106 =head1 APPENDIX
107  
108 =cut
109  
110  
111 # Let the code begin...
112 package Bio::Matrix::PSM::ProtPsm;
113 1 $Bio::Matrix::PSM::ProtPsm::VERSION = '1.7.8';
114 1 ▶use Bio::Matrix::PSM::InstanceSite;
Subroutine BEGIN: called CC=1 SCAR=0.0
115 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
116  
117 1 ▶use base qw(Bio::Matrix::PSM::ProtMatrix Bio::Matrix::PSM::PsmI Bio::Annotation::Collection);
Subroutine BEGIN: called CC=1 SCAR=0.0
118  
119 1 @Bio::Matrix::PSM::Psm::HEADER = qw(e_val sites IC width);
120  
121 =head2 new
122  
123 Title : new
124 Usage : my $psm = Bio::Matrix::PSM::ProtPsm->new(
125 -pS => [ '0', '33', '0', '16', '1', '12', '11', '25' ],
126 -pF => [ '0', '0', '2', '0', '3', '0', '0', '0' ],
127 -pT => [ '0', '8', '7', '10', '1', '2', '7', '8' ],
128 -pN => [ '0', '0', '2', '13', '0', '36', '1', '4' ],
129 -pK => [ '0', '5', '0', '13', '1', '15', '0', '2' ],
130 -pY => [ '0', '0', '0', '0', '0', '0', '0', '0' ],
131 -pE => [ '0', '41', '1', '12', '0', '0', '0', '15' ],
132 -pV => [ '0', '3', '9', '0', '2', '0', '3', '1' ],
133 -pQ => [ '0', '0', '0', '15', '0', '4', '0', '3' ],
134 -pM => [ '100', '0', '66', '0', '2', '0', '0', '0' ],
135 -pC => [ '0', '0', '0', '0', '0', '0', '0', '0' ],
136 -pL => [ '0', '0', '8', '0', '25', '0', '4', '0' ],
137 -pA => [ '0', '10', '1', '9', '2', '0', '22', '16' ],
138 -pW => [ '0', '0', '0', '0', '0', '0', '0', '0' ],
139 -pP => [ '0', '0', '0', '0', '3', '1', '45', '0' ],
140 -pH => [ '0', '0', '0', '0', '0', '0', '1', '0' ],
141 -pD => [ '0', '0', '1', '7', '2', '2', '0', '22' ],
142 -pR => [ '0', '0', '0', '3', '0', '27', '0', '0' ],
143 -pI => [ '0', '0', '3', '0', '59', '1', '2', '3' ],
144 -pG => [ '0', '0', '0', '1', '0', '0', '4', '1' ],
145 -IC => $ic,
146 -sites => $istes,
147 -width => $width,
148 -e_val => $e_val,
149 -instances => $instances,
150 }
151  
152 Function: Creates a new Bio::Matrix::PSM::ProtPsm object
153 Throws :
154 Example :
155 Returns : Bio::Matrix::PSM::Psm object
156 Args : hash
157  
158  
159 =cut
160  
161 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
162 0 my ($caller,@args) = @_;
163 0 ▶ my $class = ref($caller) || $caller;
Condition0%0/3
ref $caller || $caller
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $caller || $caller
ref $caller $caller
Truth table0%0/3
A || B
A= ref $callerB= $caller
ABresult
1X1
011
000
164 0 my $self = $class->SUPER::new(@args);
165 0 $self->{'_annotation'} = {}; #Init from Annotation::Collection
166 0 $self->_typemap(Bio::Annotation::TypeManager->new()); #same
167 0 ($self->{instances})=$self->_rearrange(['INSTANCES'], @args);
168 0 return $self;
169 }
170  
171  
172 =head2 instances
173  
174 Title : instances
175 Usage : my @instances=@{$psm->instances};
176 Function: Gets/sets the instances (Bio::Matrix::PSM::InstanceSite objects)
177 associated with the Psm object
178 Throws :
179 Example :
180 Returns : array reference (Bio::Matrix::PSM::InstanceSite objects)
181 Args : array reference (Bio::Matrix::PSM::InstanceSite objects)
182  
183 =cut
184  
185 0 ▶sub instances {
Subroutine instances: not called CC=2 SCAR=17.9
Pod documented
186 0 my $self = shift;
187 0 my $prev = $self->{instances};
188 0 ▶ if (@_) { $self->{instances} = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
189 0 return $prev;
190 }
191  
192  
193 =head2 header
194  
195 Title : header
196 Usage : my %header=$psm->header;
197 my $ic=$psm->header('IC');
198 Function: Gets the general information, common for most files,
199 dealing with PSM such as information content (IC), score
200 (e-value, etc.), number of sites (sites) and width. This
201 list may expand. The current list should be in
202 @Bio::Matrix::PSM::Psm::HEADER. Returns an epty list if an
203 argument is supplied that is not in
204 @Bio::Matrix::PSM::meme::HEADER.
205 Throws :
206 Example :
207 Returns : hash or string
208 Args : string (IC, e_val...)
209  
210 =cut
211  
212 0 ▶sub header {
Subroutine header: not called CC=4 SCAR=30.0
Pod documented
213 0 my $self = shift;
214 0 ▶ return if ($self->{end});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"end"} 0 0 0
215 0 my %header;
216 0 ▶ if (@_) {my $key=shift; return $self->{$key}; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
217 0 foreach my $key (@Bio::Matrix::PSM::ProtPsm::HEADER) {
218 0 $header{$key}=$self->{$key};
219 }
220 0 return %header;
221 }
222  
223  
224 =head2 matrix
225  
226 Title : matrix
227 Usage : my $matrix = $psm->matrix;
228 Function: Gets/sets the SiteMatrix related information
229 Throws :
230 Example :
231 Returns : Bio::Matrix::PSM::SiteMatrix objects
232 Args : Bio::Matrix::PSM::SiteMatrix objects
233  
234 =cut
235  
236  
237 0 ▶sub matrix {
Subroutine matrix: not called CC=3 SCAR=24.8
Pod documented
238 0 my $self = shift;
239  
240 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
241 0 my $matrix = shift;
242 0 my @alphabet = $self->alphabet;
243  
244 0 foreach my $char (@alphabet) {
245 0 $self->{"log$char"} = $matrix->{"log$char"};
246 0 $self->{"prob$char"} = $matrix->{"prob$char"};
247 }
248 0 $self->{IC} = $matrix->IC;
249 0 $self->{e_val} = $matrix->e_val;
250 0 $self->{id} = $matrix->id;
251 }
252  
253 0 return $self;
254 }
255  
256 1 1;
« Bio/DB/Fasta.pm ↑ Summary Bio/SeqIO/asciitree.pm »