Bio/Search/HSP/FastaHSP.pm

filter: Statementstmt 96.1% 50 / 52 Branchbran 66.6% 16 / 24 Conditioncond 33.3% 4 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 100% 6 / 6 Podpod 100% 4 / 4 totaltotal 75.4% 80 / 106 CC 17 SCAR 18.1
CC
17
Cov
80%
get_aln
9.6
sw_score
4.6
evalue2
4.6
CRAP 6.1
« Bio/Tools/Promoterwise.pm ↑ Summary Bio/Location/AvWithinCoordPolicy.pm »
1 #
2 # BioPerl module for Bio::Search::HSP::FastaHSP
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::Search::HSP::FastaHSP - HSP object for FASTA specific data
17  
18 =head1 SYNOPSIS
19  
20 # get a FastaHSP from a SearchIO stream
21 my $in = Bio::SearchIO->new(-format => 'fasta', -file => 'filename.fasta');
22  
23 while( my $r = $in->next_result) {
24 while( my $hit = $r->next_result ) {
25 while( my $hsp = $hit->next_hsp ) {
26 print "smith-waterman score (if available): ",
27 $hsp->sw_score(),"\n";
28 }
29 }
30 }
31  
32 =head1 DESCRIPTION
33  
34 Describe the object here
35  
36 =head1 FEEDBACK
37  
38 =head2 Mailing Lists
39  
40 User feedback is an integral part of the evolution of this and other
41 Bioperl modules. Send your comments and suggestions preferably to
42 the Bioperl mailing list. Your participation is much appreciated.
43  
44 bioperl-l@bioperl.org - General discussion
45 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
46  
47 =head2 Support
48  
49 Please direct usage questions or support issues to the mailing list:
50  
51 I<bioperl-l@bioperl.org>
52  
53 rather than to the module maintainer directly. Many experienced and
54 reponsive experts will be able look at the problem and quickly
55 address it. Please include a thorough description of the problem
56 with code and data examples if at all possible.
57  
58 =head2 Reporting Bugs
59  
60 Report bugs to the Bioperl bug tracking system to help us keep track
61 of the bugs and their resolution. Bug reports can be submitted via the
62 web:
63  
64 https://github.com/bioperl/bioperl-live/issues
65  
66 =head1 AUTHOR - Jason Stajich
67  
68 Email jason-at-bioperl.org
69  
70 =head1 APPENDIX
71  
72 The rest of the documentation details each of the object methods.
73 Internal methods are usually preceded with a _
74  
75 =cut
76  
77  
78 # Let the code begin...
79  
80  
81 package Bio::Search::HSP::FastaHSP;
82 2 $Bio::Search::HSP::FastaHSP::VERSION = '1.7.8';
83 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
84  
85  
86 2 ▶use base qw(Bio::Search::HSP::GenericHSP);
Subroutine BEGIN: called CC=1 SCAR=0.0
87  
88 =head2 new
89  
90 Title : new
91 Usage : my $obj = Bio::Search::HSP::FastaHSP->new();
92 Function: Builds a new Bio::Search::HSP::FastaHSP object
93 Returns : Bio::Search::HSP::FastaHSP
94 Args : -swscore => smith-waterman score
95  
96 =cut
97  
98 7 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
99 7 my($class,@args) = @_;
100  
101 7 my $self = $class->SUPER::new(@args);
102
103 7 my ($swscore, $evalue2) = $self->_rearrange([qw(SWSCORE EVALUE2)], @args);
104  
105 7 ▶ defined $swscore && $self->sw_score($swscore);
Branch: 1 branch
BranchTrueFalseTotal
defined $swscore and $self->sw_score($swscore) 6 1 7
106  
107 7 ▶ defined $evalue2 && $self->evalue2($evalue2);
Branch: 1 branch
BranchTrueFalseTotal
defined $evalue2 and $self->evalue2($evalue2) 7 0 7
108  
109 7 return $self;
110 }
111  
112  
113 =head2 sw_score
114  
115 Title : sw_score
116 Usage : $obj->sw_score($newval)
117 Function: Get/Set Smith-Waterman score
118 Returns : value of sw_score
119 Args : newvalue (optional)
120  
121  
122 =cut
123  
124 6 ▶sub sw_score{
Subroutine sw_score: called CC=4 SCAR=15.2
Pod documented
125 6 my ($self,$value) = @_;
126 6 ▶ if( defined $value || ! defined $self->{'_sw_score'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $self->{"_sw_score"}) 6 0 6
Condition33%1/3
defined $value or not defined $self->{"_sw_score"}
l!l&&r!l&&!r
600
MC/DC0%0/2
defined $value or not defined $self->{"_sw_score"}
defined $value not defined $self->{"_sw_score"}
Truth table33%1/3
A or not(B)
A= defined $valueB= not defined $self->{"_sw_score"}
ABresult
1X1
011
000
127 6 ▶ $value = 0 unless defined $value; # default value
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 6 6
128 6 $self->{'_sw_score'} = $value;
129 }
130 6 return $self->{'_sw_score'};
131 }
132  
133 =head2 evalue2
134  
135 Title : evalue2
136 Usage : $obj->evalue2($newval)
137 Function: Get/Set E2() expectation value
138 Returns : value of evalue2
139 Args : newvalue (optional)
140  
141  
142 =cut
143  
144 7 ▶sub evalue2{
Subroutine evalue2: called CC=4 SCAR=15.2
Pod documented
145 7 my ($self,$value) = @_;
146 7 ▶ if( defined $value || ! defined $self->{'_evalue2'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $self->{"_evalue2"}) 7 0 7
Condition33%1/3
defined $value or not defined $self->{"_evalue2"}
l!l&&r!l&&!r
700
MC/DC0%0/2
defined $value or not defined $self->{"_evalue2"}
defined $value not defined $self->{"_evalue2"}
Truth table33%1/3
A or not(B)
A= defined $valueB= not defined $self->{"_evalue2"}
ABresult
1X1
011
000
147 7 ▶ $value = 0 unless defined $value; # default value
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 7 7
148 7 $self->{'_evalue2'} = $value;
149 }
150 7 return $self->{'_evalue2'};
151 }
152  
153  
154 5 ▶sub get_aln {
Subroutine get_aln: called CC=9 SCAR=22.6
Pod documented
155 5 my ($self) = @_;
156 5 require Bio::LocatableSeq;
157 5 require Bio::SimpleAlign;
158 5 my $aln = Bio::SimpleAlign->new();
159 5 my $hs = $self->hit_string();
160 5 my $qs = $self->query_string();
161  
162 # fasta reports some extra 'regional' sequence information
163 # we need to clear out first
164 # this seemed a bit insane to me at first, but it appears to
165 # work --jason
166
167 # modified to deal with LocatableSeq's end point verification and to deal
168 # with frameshifts (which shift the end points in translated sequences).
169
170 # we infer the end of the regional sequence where the first
171 # non space is in the homology string
172 # then we use the HSP->length to tell us how far to read
173 # to cut off the end of the sequence
174
175 5 my ($start, $rest) = (0, 0);
176 5 ▶ if( $self->homology_string() =~ /^(\s+)?(.*?)\s*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->homology_string =~ /^(\s+)?(.*?)\s*$/) 5 0 5
177 5 ▶ ($start, $rest) = ($1 ? CORE::length($1) : 0, CORE::length($2));
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 3 2 5
178 }
179 5 $self->debug("hs seq is '$hs'\n");
180 5 $self->debug("qs seq is '$qs'\n");
181  
182 5 $hs = substr($hs, $start,$rest);
183 5 $qs = substr($qs, $start,$rest);
184  
185 5 my $seqonly = $qs;
186 5 $seqonly =~ s/\s+//g;
187 5 my ($q_nm,$s_nm) = ($self->query->seq_id(),
188 $self->hit->seq_id());
189 5 ▶ unless( defined $q_nm && CORE::length ($q_nm) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $q_nm and length $q_nm) 0 5 5
Condition33%1/3
defined $q_nm and length $q_nm
!ll&&!rl&&r
005
MC/DC0%0/2
defined $q_nm and length $q_nm
defined $q_nm length $q_nm
Truth table33%1/3
A and B
A= defined $q_nmB= length $q_nm
ABresult
0X0
100
111
190 0 $q_nm = 'query';
191 }
192 5 ▶ unless( defined $s_nm && CORE::length ($s_nm) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $s_nm and length $s_nm) 0 5 5
Condition33%1/3
defined $s_nm and length $s_nm
!ll&&!rl&&r
005
MC/DC0%0/2
defined $s_nm and length $s_nm
defined $s_nm length $s_nm
Truth table33%1/3
A and B
A= defined $s_nmB= length $s_nm
ABresult
0X0
100
111
193 0 $s_nm = 'hit';
194 }
195 5 $self->_calculate_seq_positions;
196 my $query = Bio::LocatableSeq->new('-seq' => $seqonly,
197 '-id' => $q_nm,
198 '-start' => $self->query->start,
199 '-end' => $self->query->end,
200 '-frameshifts' => (exists $self->{seqinds}{_frameshiftRes_query}) ?
201 $self->{seqinds}{_frameshiftRes_query} : undef,
202 5 ▶ '-mapping' => [1, $self->{_query_mapping}],
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'seqinds'}{'_frameshiftRes_query'} ? : 3 2 5
203 -verbose => $self->verbose
204 );
205 5 $seqonly = $hs;
206 5 $seqonly =~ s/\s+//g;
207 my $hit = Bio::LocatableSeq->new('-seq' => $seqonly,
208 '-id' => $s_nm,
209 '-start' => $self->hit->start,
210 '-end' => $self->hit->end,
211 '-frameshifts' => exists $self->{seqinds}{_frameshiftRes_sbjct} ?
212 $self->{seqinds}{_frameshiftRes_sbjct} : undef,
213 5 ▶ '-mapping' => [1, $self->{_hit_mapping}],
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'seqinds'}{'_frameshiftRes_sbjct'} ? : 1 4 5
214 -verbose => $self->verbose
215 );
216 5 $aln->add_seq($query);
217 5 $aln->add_seq($hit);
218 5 return $aln;
219 }
220  
221  
222 2 1;
« Bio/Tools/Promoterwise.pm ↑ Summary Bio/Location/AvWithinCoordPolicy.pm »