1
#---------------------------------------------------------
2
# $Id: ProtPsm.pm,v 1.8.4.1 2006/10/02 23:10:22 sendu Exp $
4
#ISA ProtMatrix, HAS InstanceSite
8
Bio::Matrix::PSM::ProtPsm - handle combination of site matricies
12
use Bio::Matrix::PSM::IO;
14
#To get a ProtPsm object from a file use the Psm parser:
15
my $psmIO = new Bio::Matrix::PSM::IO(-format=>'psiblast', -file=>$file);
17
# Now go through all entities in the file with next_psm, which
18
# returns a Psm object see Bio::Matrix::PSM::IO for detailed
19
# documentation (matrix predictions or matrix sequence matches or
22
while (my $psm=$psmIO->next_psm) {
23
my %psm_header = $psm->header;
24
my $ic = $psm_header{IC};
25
my $sites = $psm_header{sites};
26
my $width = $psm_header{width};
27
my $score = $psm_header{e_val};
28
my $IUPAC = $psm->IUPAC;
29
my $instances = $psm->instances;
30
foreach my $instance (@{$instances}) {
31
my $id = $instance->primary_id;
32
#Do something with the id
38
To handle a combination of site matrices and/or their corresponding sequence
39
matches (instances). This object inherits from Bio::Matrix::PSM::ProtMatrix, so
40
you can methods from that class. It may hold also an array of
41
Bio::Matrix::PSM::InstanceSite object, but you will have to retrieve these
42
through Bio::Matrix::PSM::ProtPsm-E<gt>instances method (see below). To some
43
extent this is an expanded ProtMatrix object, holding data from analysis that
44
also deal with sequence matches of a particular matrix.
49
This does not make too much sense to me I am mixing PSM with PSM sequence
50
matches Though they are very closely related, I am not satisfied by the way
51
this is implemented here. Heikki suggested different objects when one has
52
something like meme But does this mean we have to write a different objects for
53
mast, meme, transfac, theiresias, etc.? To me the best way is to return
54
SiteMatrix object + arrray of InstanceSite objects and then mast will return
55
undef for SiteMatrix and transfac will return undef for InstanceSite. Probably
56
I cannot see some other design issues that might arise from such approach, but
57
it seems more straightforward. Hilmar does not like this beacause it is an
58
exception from the general BioPerl rules. Should I leave this as an option?
59
Also the header rightfully belongs the driver object, and could be retrieved as
60
hashes. I do not think it can be done any other way, unless we want to create
61
even one more object with very unclear content.
67
User feedback is an integral part of the evolution of this
68
and other Bioperl modules. Send your comments and suggestions preferably
69
to one of the Bioperl mailing lists.
70
Your participation is much appreciated.
72
bioperl-l@bioperl.org - General discussion
73
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
77
Report bugs to the Bioperl bug tracking system to help us keep track
78
the bugs and their resolution. Bug reports can be submitted via the
81
http://bugzilla.open-bio.org/
83
=head1 AUTHOR - James Thompson
85
Email tex@biosysadmin.com
90
This software is provided "as is" without warranty of any kind.
94
ProtMatrix, meme, transfac, psiblast, InstanceSite
101
# Let the code begin...
102
package Bio::Matrix::PSM::ProtPsm;
103
use Bio::Matrix::PSM::InstanceSite;
106
use base qw(Bio::Matrix::PSM::ProtMatrix Bio::Matrix::PSM::PsmI Bio::Annotation::Collection);
108
@Bio::Matrix::PSM::Psm::HEADER = qw(e_val sites IC width);
113
Usage : my $psm = Bio::Matrix::PSM::ProtPsm->new(
114
-pS => [ '0', '33', '0', '16', '1', '12', '11', '25' ],
115
-pF => [ '0', '0', '2', '0', '3', '0', '0', '0' ],
116
-pT => [ '0', '8', '7', '10', '1', '2', '7', '8' ],
117
-pN => [ '0', '0', '2', '13', '0', '36', '1', '4' ],
118
-pK => [ '0', '5', '0', '13', '1', '15', '0', '2' ],
119
-pY => [ '0', '0', '0', '0', '0', '0', '0', '0' ],
120
-pE => [ '0', '41', '1', '12', '0', '0', '0', '15' ],
121
-pV => [ '0', '3', '9', '0', '2', '0', '3', '1' ],
122
-pQ => [ '0', '0', '0', '15', '0', '4', '0', '3' ],
123
-pM => [ '100', '0', '66', '0', '2', '0', '0', '0' ],
124
-pC => [ '0', '0', '0', '0', '0', '0', '0', '0' ],
125
-pL => [ '0', '0', '8', '0', '25', '0', '4', '0' ],
126
-pA => [ '0', '10', '1', '9', '2', '0', '22', '16' ],
127
-pW => [ '0', '0', '0', '0', '0', '0', '0', '0' ],
128
-pP => [ '0', '0', '0', '0', '3', '1', '45', '0' ],
129
-pH => [ '0', '0', '0', '0', '0', '0', '1', '0' ],
130
-pD => [ '0', '0', '1', '7', '2', '2', '0', '22' ],
131
-pR => [ '0', '0', '0', '3', '0', '27', '0', '0' ],
132
-pI => [ '0', '0', '3', '0', '59', '1', '2', '3' ],
133
-pG => [ '0', '0', '0', '1', '0', '0', '4', '1' ],
138
-instances => $instances,
141
Function: Creates a new Bio::Matrix::PSM::ProtPsm object
144
Returns : Bio::Matrix::PSM::Psm object
151
my ($caller,@args) = @_;
152
my $class = ref($caller) || $caller;
153
my $self = $class->SUPER::new(@args);
154
$self->{'_annotation'} = {}; #Init from Annotation::Collection
155
$self->_typemap(Bio::Annotation::TypeManager->new()); #same
156
($self->{instances})=$self->_rearrange(['INSTANCES'], @args);
164
Usage : my @instances=@{$psm->instances};
165
Function: Gets/sets the instances (Bio::Matrix::PSM::InstanceSite objects)
166
associated with the Psm object
169
Returns : array reference (Bio::Matrix::PSM::InstanceSite objects)
170
Args : array reference (Bio::Matrix::PSM::InstanceSite objects)
176
my $prev = $self->{instances};
177
if (@_) { $self->{instances} = shift; }
185
Usage : my %header=$psm->header;
186
my $ic=$psm->header('IC');
187
Function: Gets the general information, common for most files,
188
dealing with PSM such as information content (IC), score
189
(e-value, etc.), number of sites (sites) and width. This
190
list may expand. The current list should be in
191
@Bio::Matrix::PSM::Psm::HEADER. Returns an epty list if an
192
argument is supplied that is not in
193
@Bio::Matrix::PSM::meme::HEADER.
196
Returns : hash or string
197
Args : string (IC, e_val...)
203
return if ($self->{end});
205
if (@_) {my $key=shift; return $self->{$key}; }
206
foreach my $key (@Bio::Matrix::PSM::ProtPsm::HEADER) {
207
$header{$key}=$self->{$key};
216
Usage : my $matrix = $psm->matrix;
217
Function: Gets/sets the SiteMatrix related information
220
Returns : Bio::Matrix::PSM::SiteMatrix objects
221
Args : Bio::Matrix::PSM::SiteMatrix objects
231
my @alphabet = $self->alphabet;
233
foreach my $char (@alphabet) {
234
$self->{"log$char"} = $matrix->{"log$char"};
235
$self->{"prob$char"} = $matrix->{"prob$char"};
237
$self->{IC} = $matrix->IC;
238
$self->{e_val} = $matrix->e_val;
239
$self->{id} = $matrix->id;