maint: restructure to use Dist::Zilla
[bioperl-live.git] / lib / Bio / Search / HSP / WABAHSP.pm
blobca0b787188df7dbf67c7064c7fef00e11e9245b7
2 # BioPerl module for Bio::Search::HSP::WABAHSP
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Jason Stajich <jason@bioperl.org>
8 # Copyright Jason Stajich
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::Search::HSP::WABAHSP - HSP object suitable for describing WABA alignments
18 =head1 SYNOPSIS
20 # use this object as you would a GenericHSP
21 # a few other methods have been added including state
23 =head1 DESCRIPTION
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.
31 =head1 FEEDBACK
33 =head2 Mailing Lists
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.
39 bioperl-l@bioperl.org - General discussion
40 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
42 =head2 Support
44 Please direct usage questions or support issues to the mailing list:
46 I<bioperl-l@bioperl.org>
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.
53 =head2 Reporting Bugs
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:
59 https://github.com/bioperl/bioperl-live/issues
61 =head1 AUTHOR - Jason Stajich
63 Email jason@bioperl.org
65 =head1 APPENDIX
67 The rest of the documentation details each of the object methods.
68 Internal methods are usually preceded with a _
70 =cut
72 # Let the code begin...
75 package Bio::Search::HSP::WABAHSP;
76 use strict;
77 use Bio::Root::RootI;
79 use base qw(Bio::Search::HSP::GenericHSP);
81 =head2 new
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
89 =cut
91 sub new {
92 my($class,@args) = @_;
94 # gotta do some preprocessing before we send the arguments to the superclass
95 my ($len,$qs,$hs) = Bio::Root::RootI->_rearrange([qw(HSP_LENGTH
96 QUERY_SEQ
97 HIT_SEQ)],@args);
98 if( $len != length($qs) ) {
99 Bio::Root::RootI->warn("HSP_LENGTH must equal length of query_seq string, using value from QUERY_SEQ\n");
100 $len = length($qs);
102 my( $homol_seq,$gapct,$identical) = ('',0,0);
104 for(my $i=0;$i<$len;$i++) {
105 my $q = substr($qs,$i,1);
106 my $h = substr($hs,$i,1);
107 if( $q eq '-' || $h eq '-' ) {
108 $homol_seq .= ' ';
109 $gapct ++;
110 } elsif( $q eq $h ) {
111 $homol_seq .= '|';
112 $identical++;
113 } else {
114 $homol_seq .= ' ';
117 my $self = $class->SUPER::new('-conserved' => $identical,
118 '-identical' => $identical,
119 '-gaps' => $gapct,
120 '-homology_seq' => $homol_seq,
121 @args);
123 my ($hmmst) = $self->_rearrange([qw(HMMSTATE_SEQ)],@args);
124 defined $hmmst && $self->hmmstate_string($hmmst);
126 $self->add_tag_value('Target' , join(" ","Sequence:".$self->hit->seq_id,
127 $self->hit->start, $self->hit->end));
129 return $self;
132 =head2 hmmstate_string
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
141 =cut
143 sub hmmstate_string{
144 my ($self,$val) = @_;
145 if( defined $val ) {
146 $self->{'_hmmstate_string'} = $val;
148 return $self->{'_hmmstate_string'};
151 =head2 homology_string
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
161 =cut
163 sub homology_string{
164 my ($self) = @_;
165 return '';