Bio/Matrix/IO/scoring.pm

filter: Statementstmt 73.4% 36 / 49 Branchbran 76.6% 23 / 30 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 100% 2 / 2 totaltotal 75.5% 65 / 86 CC 16 SCAR 28.2
CC
16
Cov
75%
next_matrix
20.6
write_matrix
2.0
BEGIN
1.0
CRAP 16.7
« Bio/SeqIO/table.pm ↑ Summary Bio/SearchIO/erpin.pm »
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
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 65 2 67
108 65 ▶ next if ( /^\s*$/);
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*$/ 0 65 65
109 65 ▶ if( /^\#/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if (/^\#/) { } 15 50 65
elsif (s/^\s+(\S+)/$1/) { } 2 48 50
elsif ($inmatrix) { } 48 0 48
110 15 ▶ if( $inmatrix ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inmatrix) 0 15 15
111 0 $self->_pushback($_);
112 0 last;
113 }
114 15 ▶ if( m/Entropy\s+\=\s+(\S+)\,\s+
Branch: 7 branches
BranchTrueFalseTotal
if (/Entropy\s+\=\s+(\S+)\,\s+ Expected\s+\=\s+(\S+)/ox) { } 1 14 15
elsif (/Expected\s+score\s+\=\s+(\S+)\, \s+Entropy\s+\=\s+(\S+)/ox) { } 1 13 14
elsif (/(PAM\s+\d+)\s+substitution.+ scale\s+\=\s+(\S+)\s+\=\s+(\S+)/ox) { } 1 12 13
elsif (/Blocks Database\s+\=\s+(\S+)/o) { } 1 11 12
elsif (/(\S+)\s+Bit\s+Units/ox) { } 1 10 11
elsif (/Lowest score\s+\=\s+(\S+)\,\s+ Highest score\s+\=\s+(\S+)/ox) { } 0 10 10
elsif (/(Lambda)\s+\=\s+(\S+)\s+bits\, \s+(H)\s+\=\s+(\S+)/ox) { } 0 10 10
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
BranchTrueFalseTotal
if ($cols[0] ne "A") 0 2 2
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
BranchTrueFalseTotal
unless (/^(\S+)/) 0 48 48
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;
« Bio/SeqIO/table.pm ↑ Summary Bio/SearchIO/erpin.pm »