1
# $Id: scoring.pm,v 1.1 2003/08/08 20:23:17 jason Exp $
3
# BioPerl module for Bio::Matrix::IO::scoring
5
# Cared for by Jason Stajich <jason-at-bioperl-dot-org>
7
# Copyright Jason Stajich
9
# You may distribute this module under the same terms as perl itself
11
# POD documentation - main docs before the code
15
Bio::Matrix::IO::scoring - A parser for PAM/BLOSUM matricies
20
my $parser = new Bio::Matrix::IO(-format => 'scoring',
22
my $matrix = $parser->next_matrix;
26
Describe the object here
32
User feedback is an integral part of the evolution of this and other
33
Bioperl modules. Send your comments and suggestions preferably to
34
the Bioperl mailing list. Your participation is much appreciated.
36
bioperl-l@bioperl.org - General discussion
37
http://bioperl.org/MailList.shtml - About the mailing lists
41
Report bugs to the Bioperl bug tracking system to help us keep track
42
of the bugs and their resolution. Bug reports can be submitted via
45
http://bugzilla.bioperl.org/
47
=head1 AUTHOR - Jason Stajich
49
Email jason-at-bioperl-dot-org
51
Describe contact details here
55
Additional contributors names and emails here
59
The rest of the documentation details each of the object methods.
60
Internal methods are usually preceded with a _
65
# Let the code begin...
68
package Bio::Matrix::IO::scoring;
72
# Object preamble - inherits from Bio::Root::Root
75
use Bio::Matrix::Scoring
77
@ISA = qw(Bio::Matrix::IO);
82
Usage : my $obj = new Bio::Matrix::IO::scoring();
83
Function: Builds a new Bio::Matrix::IO::scoring object
84
Returns : an instance of Bio::Matrix::IO::scoring
93
Usage : my $matrux = $parser->next_matrix
94
Function: parses a scoring matrix (BLOSUM,PAM styles)
95
Returns : L<Bio::Matrix::Scoring>
104
my (@matrix,@cols,@rows,%extras,$inmatrix);
105
while( defined ( $_ = $self->_readline ) ) {
109
$self->_pushback($_);
112
if( m/Entropy\s+\=\s+(\S+)\,\s+
113
Expected\s+\=\s+(\S+)/ox ) {
114
$extras{'-entropy'} = $1;
115
$extras{'-expected'} = $2;
116
} elsif ( m/Expected\s+score\s+\=\s+(\S+)\,
117
\s+Entropy\s+\=\s+(\S+)/xo ){
118
$extras{'-entropy'} = $2;
119
$extras{'-expected'} = $1;
120
} elsif( m/(PAM\s+\d+)\s+substitution.+
121
scale\s+\=\s+(\S+)\s+\=\s+(\S+)/ox ) {
122
$extras{'-matrix_name'} = $1;
123
$extras{'-scale'} = $2;
124
$extras{'-scale_value'} = $3;
125
} elsif( /Blocks Database\s+\=\s+(\S+)/o ) {
126
$extras{'-database'} = $1;
127
} elsif( m/(\S+)\s+Bit\s+Units/ox ) {
128
$extras{'-scale'} = $1;
129
} elsif( m/Lowest score\s+\=\s+(\S+)\,\s+
130
Highest score\s+\=\s+(\S+)/ox ) {
131
$extras{'-lowest_score'} = $1;
132
$extras{'-highest_score'} = $2;
133
} elsif( m/(Lambda)\s+\=\s+(\S+)\s+bits\,
134
\s+(H)\s+\=\s+(\S+)/ox ) {
135
# This is a DNA matrix
139
} elsif( s/^\s+(\S+)/$1/ ) {
141
if( $cols[0] ne 'A' ) {
142
$self->warn("Unrecognized first line of matrix, we might not have parsed it correctly");
145
} elsif( $inmatrix ) {
146
if( ! /^(\S+)/ ) { $inmatrix = 0; next }
147
my ($rowname,@row) = split;
148
push @rows, $rowname;
149
push @matrix, [@row];
154
my $matrix = new Bio::Matrix::Scoring(-values => \@matrix,
163
Usage : $matio->write_matrix($matrix)
164
Function: Write out a matrix in the BLOSUM/PAM format
166
Args : L<Bio::Matrix::Scoring>
172
my ($self,@args) = @_;
173
$self->warn("cannot actually use this function yet - it isn't finished");