Bio/AlignIO/psi.pm

filter: Statementstmt 94.7% 54 / 57 Branchbran 83.3% 15 / 18 Conditioncond 33.3% 4 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 79.6% 82 / 103 CC 16 SCAR 20.1
CC
16
Cov
84%
write_aln
10.4
next_aln
8.2
BEGIN
1.0
CRAP 7.4
« Bio/Annotation/StructuredValue.pm ↑ Summary Bio/AlignIO/mase.pm »
1 #
2 # BioPerl module for Bio::AlignIO::psi
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Jason Stajich <jason@bioperl.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::AlignIO::psi - Read/Write PSI-BLAST profile alignment files
17  
18 =head1 SYNOPSIS
19  
20 This module will parse PSI-BLAST output of the format seqid XXXX
21  
22 =head1 DESCRIPTION
23  
24 This is a parser for psi-blast blocks.
25  
26 =head1 FEEDBACK
27  
28 =head2 Mailing Lists
29  
30 User feedback is an integral part of the evolution of this and other
31 Bioperl modules. Send your comments and suggestions preferably to
32 the Bioperl mailing list. Your participation is much appreciated.
33  
34 bioperl-l@bioperl.org - General discussion
35 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
36  
37 =head2 Support
38  
39 Please direct usage questions or support issues to the mailing list:
40  
41 I<bioperl-l@bioperl.org>
42  
43 rather than to the module maintainer directly. Many experienced and
44 reponsive experts will be able look at the problem and quickly
45 address it. Please include a thorough description of the problem
46 with code and data examples if at all possible.
47  
48 =head2 Reporting Bugs
49  
50 Report bugs to the Bioperl bug tracking system to help us keep track
51 of the bugs and their resolution. Bug reports can be submitted via
52 the web:
53  
54 https://github.com/bioperl/bioperl-live/issues
55  
56 =head1 AUTHOR - Jason Stajich
57  
58 Email jason@bioperl.org
59  
60 =head1 APPENDIX
61  
62 The rest of the documentation details each of the object methods.
63 Internal methods are usually preceded with a _
64  
65 =cut
66  
67  
68 # Let the code begin...
69  
70  
71 package Bio::AlignIO::psi;
72 3 $Bio::AlignIO::psi::VERSION = '1.7.7';
73 3 ▶use vars qw($BlockLen $IdLength);
Subroutine BEGIN: called CC=1 SCAR=0.0
74 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
75  
76 3 $BlockLen = 100;
77 3 $IdLength = 13;
78  
79 # Object preamble - inherits from Bio::Root::Root
80  
81 3 ▶use Bio::SimpleAlign;
Subroutine BEGIN: called CC=1 SCAR=0.0
82 3 ▶use Bio::LocatableSeq;
Subroutine BEGIN: called CC=1 SCAR=0.0
83  
84 3 ▶use base qw(Bio::AlignIO);
Subroutine BEGIN: called CC=1 SCAR=0.0
85  
86 =head2 new
87  
88 Title : new
89 Usage : my $obj = Bio::AlignIO::psi->new();
90 Function: Builds a new Bio::AlignIO::psi object
91 Returns : Bio::AlignIO::psi
92 Args :
93  
94 =cut
95  
96 =head2 next_aln
97  
98 Title : next_aln
99 Usage : $aln = $stream->next_aln()
100 Function: returns the next alignment in the stream
101 Returns : Bio::Align::AlignI object
102 Args : NONE
103  
104 See L<Bio::Align::AlignI>
105  
106 =cut
107  
108 sub next_aln {
109 15 ▶ my ($self) = @_;
Subroutine next_aln: called CC=8 SCAR=21.0
Pod documented
110 15 my $aln;
111 my %seqs;
112 15 my @order;
113 15 ▶ while( defined ($_ = $self->_readline ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 13665 15 13680
114 13665 ▶ next if( /^\s+$/);
Branch: 1 branch
BranchTrueFalseTotal
if /^\s+$/ 225 13440 13665
115 13440 ▶ if( !defined $aln ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $aln) 15 13425 13440
116 15 $aln = Bio::SimpleAlign->new();
117 }
118 13440 my ($id,$s) = split;
119 13440 ▶ push @order, $id if( ! defined $seqs{$id});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $seqs{$id} 840 12600 13440
120 13440 $seqs{$id} .= $s;
121 }
122 15 foreach my $id ( @order) {
123 840 my $gaps = $seqs{$id} =~ tr/-/-/;
124 my $seq = Bio::LocatableSeq->new(-seq => $seqs{$id},
125 -id => $id,
126 -start => 1,
127 840 -end => length($seqs{$id}) - $gaps,
128 -alphabet => $self->alphabet,
129 );
130 840 $aln->add_seq($seq);
131 }
132 15 ▶ return $aln if defined $aln && $aln->num_sequences;
Branch: 1 branch
BranchTrueFalseTotal
if defined $aln and $aln->num_sequences 15 0 15
Condition33%1/3
defined $aln and $aln->num_sequences
!ll&&!rl&&r
0015
MC/DC0%0/2
defined $aln and $aln->num_sequences
defined $aln $aln->num_sequences
Truth table33%1/3
A and B
A= defined $alnB= $aln->num_sequences
ABresult
0X0
100
111
133 0 return;
134 }
135  
136 =head2 write_aln
137  
138 Title : write_aln
139 Usage : $stream->write_aln(@aln)
140 Function: writes the NCBI psi-format object (.aln) into the stream
141 Returns : 1 for success and 0 for error
142 Args : Bio::Align::AlignI object
143  
144 L<Bio::Align::AlignI>
145  
146 =cut
147  
148 sub write_aln {
149 1 ▶ my ($self,$aln) = @_;
Subroutine write_aln: called CC=9 SCAR=23.4
Pod documented
150 1 ▶ unless( defined $aln && ref($aln) &&
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $aln and ref $aln and $aln->isa("Bio::Align::AlignI")) 0 1 1
Condition33%2/6
defined $aln and ref $aln and $aln->isa("Bio::Align::AlignI")
!ll&&!rl&&r
001
defined $aln and ref $aln
!ll&&!rl&&r
001
MC/DC0%0/3
defined $aln and ref $aln and $aln->isa("Bio::Align::AlignI")
defined $aln ref $aln $aln->isa("Bio::Align::AlignI")
Truth table25%1/4
A and B and C
A= defined $alnB= ref $alnC= $aln->isa("Bio::Align::AlignI")
ABCresult
0XX0
10X0
1100
1111
151 $aln->isa('Bio::Align::AlignI') ) {
152 0 $self->warn("Must provide a valid Bio::Align::AlignI to write_aln");
153 0 return 0;
154 }
155 1 my $ct = 0;
156 1 my @seqs = $aln->each_seq;
157 1 my $len = 1;
158 1 my $alnlen = $aln->length;
159 1 my $idlen = $IdLength;
160 1 my @ids = map { substr($_->display_id,0,$idlen) } @seqs;
161 1 ▶ while( $len < ($alnlen + 1) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len < $alnlen + 1) 5 1 6
162 5 my $start = $len;
163 5 my $end = $len + $BlockLen;
164 5 ▶ $end = $alnlen if ( $end > $alnlen );
Branch: 1 branch
BranchTrueFalseTotal
if $end > $alnlen 1 4 5
165 5 my $c = 0;
166 5 foreach my $seq ( @seqs ) {
167 30 $self->_print(sprintf("%-".$idlen."s %s\n",
168 $ids[$c++],
169 $seq->subseq($start,$end)));
170 }
171 5 $self->_print("\n");
172 5 $len += $BlockLen+1;
173 }
174 1 ▶ $self->flush if $self->_flush_on_write && defined $self->_fh;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_flush_on_write and defined $self->_fh 1 0 1
Condition33%1/3
$self->_flush_on_write and defined $self->_fh
!ll&&!rl&&r
001
MC/DC0%0/2
$self->_flush_on_write and defined $self->_fh
$self->_flush_on_write defined $self->_fh
Truth table33%1/3
A and B
A= $self->_flush_on_writeB= defined $self->_fh
ABresult
0X0
100
111
175 1 return 1;
176 }
177  
178 3 1;
« Bio/Annotation/StructuredValue.pm ↑ Summary Bio/AlignIO/mase.pm »