BioPerl
view release on metacpan or search on metacpan
Bio/Search/HSP/PullHSPI.pm view on Meta::CPAN
I<bioperl-l@bioperl.org>
rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
=head2 Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via the
web:
https://github.com/bioperl/bioperl-live/issues
=head1 AUTHOR - Sendu Bala
Email bix@sendu.me.uk
=head1 COPYRIGHT
Copyright (c) 2006 Sendu Bala. All Rights Reserved.
=head1 DISCLAIMER
This software is provided "as is" without warranty of any kind.
=head1 APPENDIX
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
=cut
# Let the code begin...
package Bio::Search::HSP::PullHSPI;
use strict;
use base qw(Bio::Search::HSP::HSPI Bio::PullParserI);
=head2 _setup
Title : _setup
Usage : $self->_setup(@args)
Function: Implementers should call this to setup common fields and deal with
common arguments to new().
Returns : n/a
Args : @args received in new().
=cut
sub _setup {
my ($self, @args) = @_;
# fields most subclasses probably will want
$self->_fields( { ( hsp_length => undef,
identical => undef,
percent_identity => undef,
conserved => undef,
hsp_gaps => undef,
query_gaps => undef,
hit_gaps => undef,
evalue => undef,
pvalue => undef,
score => undef,
query_start => undef,
query_end => undef,
query_string => undef,
hit_start => undef,
hit_end => undef,
hit_string => undef,
homology_string => undef,
rank => undef,
seq_inds => undef,
hit_identical_inds => undef,
hit_conserved_inds => undef,
hit_nomatch_inds => undef,
hit_gap_inds => undef,
query_identical_inds => undef,
query_conserved_inds => undef,
query_nomatch_inds => undef,
query_gap_inds => undef ) } );
my ($parent, $chunk, $hsp_data) = $self->_rearrange([qw(PARENT
CHUNK
HSP_DATA)], @args);
$self->throw("Need -parent or -chunk to be defined") unless defined $parent || $chunk;
$self->parent($parent) if $parent;
if ($chunk) {
my ($io, $start, $end) = (undef, 0, undef);
if (ref($chunk) eq 'ARRAY') {
($io, $start, $end) = @{$chunk};
}
else {
$io = $chunk;
}
$self->chunk($io, -start => $start, -end => $end);
}
$self->_raw_hsp_data($hsp_data) if $hsp_data;
return $self;
}
sub _raw_hsp_data {
my $self = shift;
if (@_) {
$self->{_raw_hsp_data} = shift;
}
return $self->{_raw_hsp_data};
}
#
# Some of these methods are written explitely to avoid HSPI throwing not
# implemented or the wrong ancestor class being used to answer the method;
Bio/Search/HSP/PullHSPI.pm view on Meta::CPAN
Usage : my $homo_string = $hsp->homology_string;
Function: Retrieves the homology sequence for this HSP as a string.
: The homology sequence is the string of symbols in between the
: query and hit sequences in the alignment indicating the degree
: of conservation (e.g., identical, similar, not similar).
Returns : string
Args : none
=cut
sub homology_string {
return shift->get_field('homology_string');
}
=head2 length
Title : length
Usage : my $len = $hsp->length( ['query'|'hit'|'total'] );
Function : Returns the length of the query or hit in the alignment (without gaps)
or the aggregate length of the HSP (including gaps;
this may be greater than either hit or query )
Returns : integer
Args : 'query' = length of query seq (without gaps)
'hit' = length of hit seq (without gaps)
'total' = length of alignment (with gaps)
default = 'total'
Args : none
=cut
sub length {
my ($self, $type) = @_;
$type = 'total' unless defined $type;
$type = lc $type;
if ($type =~ /^q/i) {
return $self->query->length;
}
elsif ($type =~ /^(hit|subject|sbjct)/) {
return $self->hit->length;
}
else {
return $self->hit->length + $self->gaps('hit');
}
}
=head2 hsp_length
Title : hsp_length
Usage : my $len = $hsp->hsp_length()
Function: shortcut length('hsp')
Returns : floating point between 0 and 100
Args : none
=cut
sub hsp_length {
return shift->length('total');
}
=head2 percent_identity
Title : percent_identity
Usage : my $percentid = $hsp->percent_identity()
Function: Returns the calculated percent identity for an HSP
Returns : floating point between 0 and 100
Args : none
=cut
sub percent_identity{
my ($self) = @_;
return $self->frac_identical('hsp') * 100;
}
=head2 get_aln
Title : get_aln
Usage : my $aln = $hsp->get_aln
Function: Returns a Bio::SimpleAlign representing the HSP alignment
Returns : Bio::SimpleAlign
Args : none
=cut
sub get_aln {
my $self = shift;
require Bio::LocatableSeq;
require Bio::SimpleAlign;
my $aln = Bio::SimpleAlign->new();
my $hs = $self->seq('hit');
my $qs = $self->seq('query');
if ($hs && $qs) {
$aln->add_seq($hs);
$aln->add_seq($qs);
return $aln;
}
return;
}
=head2 seq_inds
Title : seq_inds
Purpose : Get a list of residue positions (indices) for all identical
: or conserved residues in the query or sbjct sequence.
Example : @s_ind = $hsp->seq_inds('query', 'identical');
: @h_ind = $hsp->seq_inds('hit', 'conserved');
: @h_ind = $hsp->seq_inds('hit', 'conserved', 1);
Returns : List of integers
: May include ranges if collapse is true.
Argument : seq_type = 'query' or 'hit' or 'sbjct' (default = query)
('sbjct' is synonymous with 'hit')
class = 'identical' or 'conserved' or 'nomatch' or 'gap'
(default = identical)
(can be shortened to 'id' or 'cons')
Note that 'conserved' includes identical unless you
use 'conserved-not-identical'
collapse = boolean, if true, consecutive positions are merged
using a range notation, e.g., "1 2 3 4 5 7 9 10 11"
collapses to "1-5 7 9-11". This is useful for
consolidating long lists. Default = no collapse.
Throws : n/a.
Comments :
See Also : L<Bio::Search::BlastUtils::collapse_nums()|Bio::Search::BlastUtils>, L<Bio::Search::Hit::HitI::seq_inds()|Bio::Search::Hit::HitI>
=cut
sub seq_inds {
( run in 0.992 second using v1.01-cache-2.11-cpan-39bf76dae61 )