Bio/Matrix/PSM/Psm.pm

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