| 1 | # | ||||||||||||||||||||||||||||||||||
| 2 | # BioPerl module for Bio::Matrix::IO::scoring | ||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||
| 6 | # Cared for by Jason Stajich <jason-at-bioperl-dot-org> | ||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||
| 8 | # Copyright Jason Stajich | ||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||
| 10 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | Bio::Matrix::IO::scoring - A parser for PAM/BLOSUM matricies | ||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | use Bio::Matrix::IO; | ||||||||||||||||||||||||||||||||||
| 21 | my $parser = Bio::Matrix::IO->new(-format => 'scoring', | ||||||||||||||||||||||||||||||||||
| 22 | -file => 'BLOSUM50'); | ||||||||||||||||||||||||||||||||||
| 23 | my $matrix = $parser->next_matrix; | ||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | Describe the object here | ||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 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. | ||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||||
| 38 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | =head2 Support | ||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||
| 42 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||
| 44 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||
| 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. | ||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||
| 55 | the web: | ||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||
| 57 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | =head1 AUTHOR - Jason Stajich | ||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | Email jason-at-bioperl-dot-org | ||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||
| 63 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||
| 65 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||||||||
| 66 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | =cut | ||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | # Let the code begin... | ||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||
| 74 | package Bio::Matrix::IO::scoring; | ||||||||||||||||||||||||||||||||||
| 75 | 2 | $Bio::Matrix::IO::scoring::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||||
| 76 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||
| 78 | 2 | ▶ | use Bio::Matrix::Scoring; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 79 | 2 | ▶ | use base qw(Bio::Matrix::IO); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||
| 81 | =head2 new | ||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | Title : new | ||||||||||||||||||||||||||||||||||
| 84 | Usage : my $obj = Bio::Matrix::IO::scoring->new(); | ||||||||||||||||||||||||||||||||||
| 85 | Function: Builds a new Bio::Matrix::IO::scoring object | ||||||||||||||||||||||||||||||||||
| 86 | Returns : an instance of Bio::Matrix::IO::scoring | ||||||||||||||||||||||||||||||||||
| 87 | Args : | ||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||
| 90 | =cut | ||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||
| 92 | =head2 next_matrix | ||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||
| 94 | Title : next_matrix | ||||||||||||||||||||||||||||||||||
| 95 | Usage : my $matrux = $parser->next_matrix | ||||||||||||||||||||||||||||||||||
| 96 | Function: parses a scoring matrix (BLOSUM,PAM styles) | ||||||||||||||||||||||||||||||||||
| 97 | Returns : L<Bio::Matrix::Scoring> | ||||||||||||||||||||||||||||||||||
| 98 | Args : none | ||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||
| 101 | =cut | ||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||
| 103 | 2 | ▶ | sub next_matrix{ | ||||||||||||||||||||||||||||||||
|
Subroutine
next_matrix: called CC=16 SCAR=30.2
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 104 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 105 | 2 | local ($_); | |||||||||||||||||||||||||||||||||
| 106 | 2 | my (@matrix,@cols,@rows,%extras,$inmatrix); | |||||||||||||||||||||||||||||||||
| 107 | 2 | ▶ | while( defined ( $_ = $self->_readline ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 108 | 65 | ▶ | next if ( /^\s*$/); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 109 | 65 | ▶ | if( /^\#/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 110 | 15 | ▶ | if( $inmatrix ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 111 | 0 | $self->_pushback($_); | |||||||||||||||||||||||||||||||||
| 112 | 0 | last; | |||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||
| 114 | 15 | ▶ | if( m/Entropy\s+\=\s+(\S+)\,\s+ | ||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||
| 115 | Expected\s+\=\s+(\S+)/ox ) { | ||||||||||||||||||||||||||||||||||
| 116 | 1 | $extras{'-entropy'} = $1; | |||||||||||||||||||||||||||||||||
| 117 | 1 | $extras{'-expected'} = $2; | |||||||||||||||||||||||||||||||||
| 118 | } elsif ( m/Expected\s+score\s+\=\s+(\S+)\, | ||||||||||||||||||||||||||||||||||
| 119 | \s+Entropy\s+\=\s+(\S+)/xo ){ | ||||||||||||||||||||||||||||||||||
| 120 | 1 | $extras{'-entropy'} = $2; | |||||||||||||||||||||||||||||||||
| 121 | 1 | $extras{'-expected'} = $1; | |||||||||||||||||||||||||||||||||
| 122 | } elsif( m/(PAM\s+\d+)\s+substitution.+ | ||||||||||||||||||||||||||||||||||
| 123 | scale\s+\=\s+(\S+)\s+\=\s+(\S+)/ox ) { | ||||||||||||||||||||||||||||||||||
| 124 | 1 | $extras{'-matrix_name'} = $1; | |||||||||||||||||||||||||||||||||
| 125 | 1 | $extras{'-scale'} = $2; | |||||||||||||||||||||||||||||||||
| 126 | 1 | $extras{'-scale_value'} = $3; | |||||||||||||||||||||||||||||||||
| 127 | } elsif( /Blocks Database\s+\=\s+(\S+)/o ) { | ||||||||||||||||||||||||||||||||||
| 128 | 1 | $extras{'-database'} = $1; | |||||||||||||||||||||||||||||||||
| 129 | } elsif( m/(\S+)\s+Bit\s+Units/ox ) { | ||||||||||||||||||||||||||||||||||
| 130 | 1 | $extras{'-scale'} = $1; | |||||||||||||||||||||||||||||||||
| 131 | } elsif( m/Lowest score\s+\=\s+(\S+)\,\s+ | ||||||||||||||||||||||||||||||||||
| 132 | Highest score\s+\=\s+(\S+)/ox ) { | ||||||||||||||||||||||||||||||||||
| 133 | 0 | $extras{'-lowest_score'} = $1; | |||||||||||||||||||||||||||||||||
| 134 | 0 | $extras{'-highest_score'} = $2; | |||||||||||||||||||||||||||||||||
| 135 | } elsif( m/(Lambda)\s+\=\s+(\S+)\s+bits\, | ||||||||||||||||||||||||||||||||||
| 136 | \s+(H)\s+\=\s+(\S+)/ox ) { | ||||||||||||||||||||||||||||||||||
| 137 | # This is a DNA matrix | ||||||||||||||||||||||||||||||||||
| 138 | 0 | $extras{$1} = $2; | |||||||||||||||||||||||||||||||||
| 139 | 0 | $extras{$3} = $4; | |||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||
| 141 | } elsif( s/^\s+(\S+)/$1/ ) { | ||||||||||||||||||||||||||||||||||
| 142 | 2 | @cols = split; | |||||||||||||||||||||||||||||||||
| 143 | 2 | ▶ | if( $cols[0] ne 'A' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 144 | 0 | $self->warn("Unrecognized first line of matrix, we might not have parsed it correctly"); | |||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||
| 146 | 2 | $inmatrix = 1; | |||||||||||||||||||||||||||||||||
| 147 | } elsif( $inmatrix ) { | ||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if( ! /^(\S+)/ ) { $inmatrix = 0; next } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 149 | 48 | my ($rowname,@row) = split; | |||||||||||||||||||||||||||||||||
| 150 | 48 | push @rows, $rowname; | |||||||||||||||||||||||||||||||||
| 151 | 48 | push @matrix, [@row]; | |||||||||||||||||||||||||||||||||
| 152 | } else { | ||||||||||||||||||||||||||||||||||
| 153 | 0 | print; | |||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||
| 156 | 2 | my $matrix = Bio::Matrix::Scoring->new(-values => \@matrix, | |||||||||||||||||||||||||||||||||
| 157 | -rownames => \@rows, | ||||||||||||||||||||||||||||||||||
| 158 | -colnames => \@cols, | ||||||||||||||||||||||||||||||||||
| 159 | %extras); | ||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||
| 162 | =head2 write_matrix | ||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||
| 164 | Title : write_matrix | ||||||||||||||||||||||||||||||||||
| 165 | Usage : $matio->write_matrix($matrix) | ||||||||||||||||||||||||||||||||||
| 166 | Function: Write out a matrix in the BLOSUM/PAM format | ||||||||||||||||||||||||||||||||||
| 167 | Returns : none | ||||||||||||||||||||||||||||||||||
| 168 | Args : L<Bio::Matrix::Scoring> | ||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||
| 171 | =cut | ||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | sub write_matrix{ | ||||||||||||||||||||||||||||||||
|
Subroutine
write_matrix: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 174 | 0 | my ($self,@args) = @_; | |||||||||||||||||||||||||||||||||
| 175 | 0 | $self->warn("cannot actually use this function yet - it isn't finished"); | |||||||||||||||||||||||||||||||||
| 176 | 0 | return; | |||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||
| 180 | 2 | 1; | |||||||||||||||||||||||||||||||||