File Coverage

Bio/Search/HSP/WABAHSP.pm
Criterion Covered Total %
statement 31 35 88.5
branch 8 10 80.0
condition 3 3 100.0
subroutine 5 6 83.3
pod 3 3 100.0
total 50 57 87.7


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::Search::HSP::WABAHSP
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Jason Stajich
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::WABAHSP - HSP object suitable for describing WABA alignments
17              
18             =head1 SYNOPSIS
19              
20             # use this object as you would a GenericHSP
21             # a few other methods have been added including state
22              
23             =head1 DESCRIPTION
24              
25             This object implements a few of the extra methods such as
26             hmmstate_string which returns the HMM state representation for the
27             WABA alignment. We also must implement a method to calculate
28             homology_string since it is not returned by the algorithm in the
29             machine readable format.
30              
31             =head1 FEEDBACK
32              
33             =head2 Mailing Lists
34              
35             User feedback is an integral part of the evolution of this and other
36             Bioperl modules. Send your comments and suggestions preferably to
37             the Bioperl mailing list. Your participation is much appreciated.
38              
39             bioperl-l@bioperl.org - General discussion
40             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
41              
42             =head2 Support
43              
44             Please direct usage questions or support issues to the mailing list:
45              
46             I
47              
48             rather than to the module maintainer directly. Many experienced and
49             reponsive experts will be able look at the problem and quickly
50             address it. Please include a thorough description of the problem
51             with code and data examples if at all possible.
52              
53             =head2 Reporting Bugs
54              
55             Report bugs to the Bioperl bug tracking system to help us keep track
56             of the bugs and their resolution. Bug reports can be submitted via the
57             web:
58              
59             https://github.com/bioperl/bioperl-live/issues
60              
61             =head1 AUTHOR - Jason Stajich
62              
63             Email jason@bioperl.org
64              
65             =head1 APPENDIX
66              
67             The rest of the documentation details each of the object methods.
68             Internal methods are usually preceded with a _
69              
70             =cut
71              
72             # Let the code begin...
73              
74              
75             package Bio::Search::HSP::WABAHSP;
76 1     1   4 use strict;
  1         1  
  1         21  
77 1     1   4 use Bio::Root::RootI;
  1         0  
  1         17  
78              
79 1     1   3 use base qw(Bio::Search::HSP::GenericHSP);
  1         0  
  1         289  
80              
81             =head2 new
82              
83             Title : new
84             Usage : my $obj = Bio::Search::HSP::WABAHSP->new();
85             Function: Builds a new Bio::Search::HSP::WABAHSP object
86             Returns : Bio::Search::HSP::WABAHSP
87             Args : -hmmstate_seq => the string representing the state output from WABA
88              
89             =cut
90              
91             sub new {
92 4     4 1 17 my($class,@args) = @_;
93              
94             # gotta do some preprocessing before we send the arguments to the superclass
95 4         11 my ($len,$qs,$hs) = Bio::Root::RootI->_rearrange([qw(HSP_LENGTH
96             QUERY_SEQ
97             HIT_SEQ)],@args);
98 4 50       14 if( $len != length($qs) ) {
99 0         0 Bio::Root::RootI->warn("HSP_LENGTH must equal length of query_seq string, using value from QUERY_SEQ\n");
100 0         0 $len = length($qs);
101             }
102 4         6 my( $homol_seq,$gapct,$identical) = ('',0,0);
103            
104 4         6 for(my $i=0;$i<$len;$i++) {
105 17834         11763 my $q = substr($qs,$i,1);
106 17834         11108 my $h = substr($hs,$i,1);
107 17834 100 100     37227 if( $q eq '-' || $h eq '-' ) {
    100          
108 5686         3264 $homol_seq .= ' ';
109 5686         6519 $gapct ++;
110             } elsif( $q eq $h ) {
111 8072         4862 $homol_seq .= '|';
112 8072         9279 $identical++;
113             } else {
114 4076         4933 $homol_seq .= ' ';
115             }
116             }
117 4         28 my $self = $class->SUPER::new('-conserved' => $identical,
118             '-identical' => $identical,
119             '-gaps' => $gapct,
120             '-homology_seq' => $homol_seq,
121             @args);
122            
123 4         12 my ($hmmst) = $self->_rearrange([qw(HMMSTATE_SEQ)],@args);
124 4 50       12 defined $hmmst && $self->hmmstate_string($hmmst);
125            
126 4         9 $self->add_tag_value('Target' , join(" ","Sequence:".$self->hit->seq_id,
127             $self->hit->start, $self->hit->end));
128              
129 4         36 return $self;
130             }
131              
132             =head2 hmmstate_string
133              
134             Title : hmmstate_string
135             Usage : my $hmmseq = $wabahsp->hmmstate_string();
136             Function: Get/Set the WABA HMM stateseq
137             Returns : string
138             Args : [optional] string
139              
140              
141             =cut
142              
143             sub hmmstate_string{
144 8     8 1 11 my ($self,$val) = @_;
145 8 100       15 if( defined $val ) {
146 4         9 $self->{'_hmmstate_string'} = $val;
147             }
148 8         17 return $self->{'_hmmstate_string'};
149             }
150              
151             =head2 homology_string
152              
153             Title : homolgy_string
154             Usage : my $homology_str = $hsp->homology_string();
155             Function: Homology string must be calculated for a WABA HSP so we can do
156             so here and cache the result so it is only done once
157             Returns : string
158             Args : none
159              
160              
161             =cut
162              
163             sub homology_string{
164 0     0 1   my ($self) = @_;
165 0           return '';
166             }
167              
168              
169             1;