~ubuntu-branches/ubuntu/oneiric/bioperl/oneiric

« back to all changes in this revision

Viewing changes to Bio/Matrix/PSM/ProtPsm.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2007-09-21 22:52:22 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070921225222-tt20m2yy6ycuy2d8
Tags: 1.5.2.102-1
* Developer release.
* Upgraded source package to debhelper 5 and standards-version 3.7.2.
* Added libmodule-build-perl and libtest-harness-perl to
  build-depends-indep.
* Disabled automatic CRAN download.
* Using quilt instead of .diff.gz to manage modifications.
* Updated Recommends list for the binary package.
* Moved the "production-quality" scripts to /usr/bin/.
* New maintainer: Debian-Med packaging team mailing list.
* New uploaders: Charles Plessy and Steffen Moeller.
* Updated Depends, Recommends and Suggests.
* Imported in Debian-Med's SVN repository on Alioth.
* Executing the regression tests during package building.
* Moved the Homepage: field out from the package's description.
* Updated watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#---------------------------------------------------------
 
2
# $Id: ProtPsm.pm,v 1.8.4.1 2006/10/02 23:10:22 sendu Exp $
 
3
 
 
4
#ISA ProtMatrix, HAS InstanceSite
 
5
 
 
6
=head1 NAME
 
7
 
 
8
Bio::Matrix::PSM::ProtPsm - handle combination of site matricies
 
9
 
 
10
=head1 SYNOPSIS
 
11
 
 
12
  use Bio::Matrix::PSM::IO;
 
13
 
 
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);
 
16
 
 
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
 
20
  # both):
 
21
 
 
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
 
33
     }
 
34
   }
 
35
 
 
36
=head1 DESCRIPTION
 
37
 
 
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.
 
45
 
 
46
 
 
47
=head2 DESIGN ISSUES
 
48
 
 
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.
 
62
 
 
63
=head1 FEEDBACK
 
64
 
 
65
=head2 Mailing Lists
 
66
 
 
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.
 
71
 
 
72
  bioperl-l@bioperl.org                  - General discussion
 
73
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
 
74
 
 
75
=head2 Reporting Bugs
 
76
 
 
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
 
79
web:
 
80
 
 
81
  http://bugzilla.open-bio.org/
 
82
 
 
83
=head1 AUTHOR - James Thompson
 
84
 
 
85
Email tex@biosysadmin.com
 
86
 
 
87
 
 
88
=head1 DISCLAIMER
 
89
 
 
90
This software is provided "as is" without warranty of any kind.
 
91
 
 
92
=head1 SEE ALSO
 
93
 
 
94
ProtMatrix, meme, transfac, psiblast, InstanceSite
 
95
 
 
96
=head1 APPENDIX
 
97
 
 
98
=cut
 
99
 
 
100
 
 
101
# Let the code begin...
 
102
package Bio::Matrix::PSM::ProtPsm;
 
103
use Bio::Matrix::PSM::InstanceSite;
 
104
use strict;
 
105
 
 
106
use base qw(Bio::Matrix::PSM::ProtMatrix Bio::Matrix::PSM::PsmI Bio::Annotation::Collection);
 
107
 
 
108
@Bio::Matrix::PSM::Psm::HEADER = qw(e_val sites IC width);
 
109
 
 
110
=head2 new
 
111
 
 
112
 Title   : new
 
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' ],
 
134
              -IC => $ic,
 
135
              -sites => $istes,
 
136
              -width => $width,
 
137
              -e_val => $e_val, 
 
138
              -instances => $instances, 
 
139
           }
 
140
 
 
141
 Function: Creates a new Bio::Matrix::PSM::ProtPsm object
 
142
 Throws  :
 
143
 Example :
 
144
 Returns :  Bio::Matrix::PSM::Psm object
 
145
 Args    :  hash
 
146
 
 
147
 
 
148
=cut
 
149
 
 
150
sub new {
 
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);
 
157
    return $self;
 
158
}
 
159
 
 
160
 
 
161
=head2 instances
 
162
 
 
163
 Title   : instances
 
164
 Usage   :   my @instances=@{$psm->instances};
 
165
 Function: Gets/sets the instances (Bio::Matrix::PSM::InstanceSite objects)
 
166
        associated with the Psm object
 
167
 Throws  :
 
168
 Example :
 
169
 Returns :  array reference (Bio::Matrix::PSM::InstanceSite objects)
 
170
 Args    :  array reference (Bio::Matrix::PSM::InstanceSite objects)
 
171
 
 
172
=cut
 
173
 
 
174
sub instances {
 
175
    my $self = shift;
 
176
    my $prev = $self->{instances};
 
177
    if (@_) { $self->{instances} = shift; }
 
178
    return $prev;
 
179
}
 
180
 
 
181
 
 
182
=head2 header
 
183
 
 
184
 Title   : header
 
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.
 
194
 Throws  :
 
195
 Example :
 
196
 Returns :  hash or string
 
197
 Args    :  string (IC, e_val...)
 
198
 
 
199
=cut
 
200
 
 
201
sub header {
 
202
    my $self = shift;
 
203
    return  if ($self->{end});
 
204
    my %header;
 
205
    if (@_) {my $key=shift; return $self->{$key}; }
 
206
    foreach my $key (@Bio::Matrix::PSM::ProtPsm::HEADER) {
 
207
        $header{$key}=$self->{$key};
 
208
    }
 
209
    return %header;
 
210
}
 
211
 
 
212
 
 
213
=head2 matrix
 
214
 
 
215
 Title   :  matrix
 
216
 Usage   :  my $matrix = $psm->matrix;
 
217
 Function:  Gets/sets the SiteMatrix related information
 
218
 Throws  :
 
219
 Example :
 
220
 Returns :  Bio::Matrix::PSM::SiteMatrix objects
 
221
 Args    :  Bio::Matrix::PSM::SiteMatrix objects
 
222
 
 
223
=cut
 
224
 
 
225
 
 
226
sub matrix {
 
227
   my $self = shift;
 
228
 
 
229
   if (@_) {
 
230
      my $matrix = shift;
 
231
      my @alphabet = $self->alphabet;
 
232
 
 
233
      foreach my $char (@alphabet) {
 
234
         $self->{"log$char"}  = $matrix->{"log$char"};
 
235
         $self->{"prob$char"} = $matrix->{"prob$char"};
 
236
      }
 
237
      $self->{IC}    = $matrix->IC;
 
238
      $self->{e_val} = $matrix->e_val;
 
239
      $self->{id}    = $matrix->id;
 
240
    }
 
241
 
 
242
    return $self;
 
243
}
 
244
 
 
245
1;