2 # BioPerl module for Bio::Matrix::IO::scoring
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Jason Stajich <jason-at-bioperl-dot-org>
8 # Copyright Jason Stajich
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Matrix::IO::scoring - A parser for PAM/BLOSUM matricies
21 my $parser = Bio::Matrix::IO->new(-format => 'scoring',
23 my $matrix = $parser->next_matrix;
27 Describe the object here
33 User feedback is an integral part of the evolution of this and other
34 Bioperl modules. Send your comments and suggestions preferably to
35 the Bioperl mailing list. Your participation is much appreciated.
37 bioperl-l@bioperl.org - General discussion
38 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
42 Please direct usage questions or support issues to the mailing list:
44 I<bioperl-l@bioperl.org>
46 rather than to the module maintainer directly. Many experienced and
47 reponsive experts will be able look at the problem and quickly
48 address it. Please include a thorough description of the problem
49 with code and data examples if at all possible.
53 Report bugs to the Bioperl bug tracking system to help us keep track
54 of the bugs and their resolution. Bug reports can be submitted via
57 https://github.com/bioperl/bioperl-live/issues
59 =head1 AUTHOR - Jason Stajich
61 Email jason-at-bioperl-dot-org
65 The rest of the documentation details each of the object methods.
66 Internal methods are usually preceded with a _
71 # Let the code begin...
74 package Bio
::Matrix
::IO
::scoring
;
77 use Bio
::Matrix
::Scoring
;
78 use base
qw(Bio::Matrix::IO);
83 Usage : my $obj = Bio::Matrix::IO::scoring->new();
84 Function: Builds a new Bio::Matrix::IO::scoring object
85 Returns : an instance of Bio::Matrix::IO::scoring
94 Usage : my $matrux = $parser->next_matrix
95 Function: parses a scoring matrix (BLOSUM,PAM styles)
96 Returns : L<Bio::Matrix::Scoring>
105 my (@matrix,@cols,@rows,%extras,$inmatrix);
106 while( defined ( $_ = $self->_readline ) ) {
110 $self->_pushback($_);
113 if( m
/Entropy\s
+\
=\s
+(\S
+)\
,\s
+
114 Expected\s
+\
=\s
+(\S
+)/ox
) {
115 $extras{'-entropy'} = $1;
116 $extras{'-expected'} = $2;
117 } elsif ( m
/Expected\s
+score\s
+\
=\s
+(\S
+)\
,
118 \s
+Entropy\s
+\
=\s
+(\S
+)/xo
){
119 $extras{'-entropy'} = $2;
120 $extras{'-expected'} = $1;
121 } elsif( m
/(PAM\s
+\d
+)\s
+substitution
.+
122 scale\s
+\
=\s
+(\S
+)\s
+\
=\s
+(\S
+)/ox
) {
123 $extras{'-matrix_name'} = $1;
124 $extras{'-scale'} = $2;
125 $extras{'-scale_value'} = $3;
126 } elsif( /Blocks Database\s+\=\s+(\S+)/o ) {
127 $extras{'-database'} = $1;
128 } elsif( m/(\S+)\s+Bit\s+Units/ox ) {
129 $extras{'-scale'} = $1;
130 } elsif( m
/Lowest score\s
+\
=\s
+(\S
+)\
,\s
+
131 Highest score\s
+\
=\s
+(\S
+)/ox
) {
132 $extras{'-lowest_score'} = $1;
133 $extras{'-highest_score'} = $2;
134 } elsif( m
/(Lambda
)\s
+\
=\s
+(\S
+)\s
+bits\
,
135 \s
+(H
)\s
+\
=\s
+(\S
+)/ox
) {
136 # This is a DNA matrix
140 } elsif( s/^\s+(\S+)/$1/ ) {
142 if( $cols[0] ne 'A' ) {
143 $self->warn("Unrecognized first line of matrix, we might not have parsed it correctly");
146 } elsif( $inmatrix ) {
147 if( ! /^(\S+)/ ) { $inmatrix = 0; next }
148 my ($rowname,@row) = split;
149 push @rows, $rowname;
150 push @matrix, [@row];
155 my $matrix = Bio
::Matrix
::Scoring
->new(-values => \
@matrix,
164 Usage : $matio->write_matrix($matrix)
165 Function: Write out a matrix in the BLOSUM/PAM format
167 Args : L<Bio::Matrix::Scoring>
173 my ($self,@args) = @_;
174 $self->warn("cannot actually use this function yet - it isn't finished");