Bio::Search::Hit
HmmpfamHit
Summary
Bio::Search::Hit::HmmpfamHit - A parser and hit object for hmmpfam hits
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
# generally we use Bio::SearchIO to build these objects
use Bio::SearchIO;
my $in = new Bio::SearchIO(-format => 'hmmer_pull',
-file => 'result.hmmer');
while (my $result = $in->next_result) {
while (my $hit = $result->next_hit) {
print $hit->name, "\n";
print $hit->score, "\n";
print $hit->significance, "\n";
while (my $hsp = $hit->next_hsp) {
# process HSPI objects
}
}
}
Description
This object implements a parser for hmmpfam hit output, a program in the HMMER
package.
Methods
Methods description
Title : new Usage : my $obj = new Bio::Search::Hit::HmmpfamHit(); Function: Builds a new Bio::Search::Hit::HmmpfamHit object. Returns : Bio::Search::Hit::HmmpfamHit Args : -chunk => [Bio::Root::IO, $start, $end] (required if no -parent) -parent => Bio::PullParserI object (required if no -chunk) -hit_data => array ref with [name description score significance num_hsps rank]
where the array ref provided to -chunk contains an IO object
for a filehandle to something representing the raw data of the
hit, and $start and $end define the tell() position within the
filehandle that the hit data starts and ends (optional; defaults
to start and end of the entire thing described by the filehandle) |
Title : next_hsp Usage : while( $hsp = $obj->next_hsp()) { ... } Function : Returns the next available High Scoring Pair Example : Returns : Bio::Search::HSP::HSPI object or null if finished Args : none |
Usage : $hit_object->hsps(); Purpose : Get a list containing all HSP objects. Example : @hsps = $hit_object->hsps(); Returns : list of Bio::Search::HSP::BlastHSP objects. Argument : none |
Usage : $hit_object->hsp( [string] ); Purpose : Get a single HSPI object for the present HitI object. Example : $hspObj = $hit_object->hsp; # same as 'best' : $hspObj = $hit_object->hsp('best'); : $hspObj = $hit_object->hsp('worst'); Returns : Object reference for a Bio::Search::HSP::HSPI object. Argument : String (or no argument). : No argument (default) = highest scoring HSP (same as 'best'). : 'best' = highest scoring HSP. : 'worst' = lowest scoring HSP. Throws : Exception if an unrecognized argument is used.
See Also : hsps(), num_hsps() |
Title : rewind Usage : $result->rewind; Function: Allow one to reset the Hit iterator to the beginning, so that next_hit() will subsequently return the first hit and so on. Returns : n/a Args : none |
Usage : $sbjct->strand( [seq_type] ); Purpose : Gets the strand(s) for the query, sbjct, or both sequences. : For hmmpfam, the answers are always 1 (forward strand). Example : $qstrand = $sbjct->strand('query'); : $sstrand = $sbjct->strand('hit'); : ($qstrand, $sstrand) = $sbjct->strand(); Returns : scalar context: integer '1' : array context without args: list of two strings (1, 1) : Array context can be "induced" by providing an argument of 'list' : or 'array'. Argument : In scalar context: seq_type = 'query' or 'hit' or 'sbjct' (default : = 'query') ('sbjct' is synonymous with 'hit') |
Usage : $hit_object->frac_aligned_query(); Purpose : Get the fraction of the query sequence which has been aligned : across all HSPs (not including intervals between non-overlapping : HSPs). Example : $frac_alnq = $hit_object->frac_aligned_query(); Returns : undef (the length of query sequences is unknown in Hmmpfam reports) Argument : none |
Methods code
sub new
{ my ($class, @args) = @_;
my $self = $class->SUPER::new(@args);
$self->_setup(@args);
my $fields = $self->_fields;
foreach my $field (qw( next_domain domains hsp_data )) {
$fields->{$field} = undef;
}
my $hit_data = $self->_raw_hit_data;
if ($hit_data && ref($hit_data) eq 'ARRAY') {
foreach my $field (qw(name description score significance num_hsps rank)) {
$fields->{$field} = shift(@{$hit_data});
}
}
$fields->{hit_start} = 1;
delete $self->_fields->{accession};
$self->_dependencies( { ( length => 'hsp_data' ) } );
return $self;} |
sub _discover_description
{ return; } |
sub _discover_hsp_data
{ my $self = shift;
my $hsp_table = $self->get_field('hsp_table');
my $hsp_data = $hsp_table->{$self->get_field('name')} || undef;
if ($hsp_data) {
if (defined $hsp_data->{hit_length}) {
$self->_fields->{length} = $hsp_data->{hit_length};
}
$self->_fields->{hsp_data} = $hsp_data->{hsp_data};
}} |
sub _discover_query_start
{ my $self = shift;
my $hsp_data = $self->get_field('hsp_data') || return;
my ($this_hsp) = sort { $a->[1] <=> $b->[1] } @{$hsp_data};
$self->_fields->{query_start} = $this_hsp->[1];} |
sub _discover_query_end
{ my $self = shift;
my $hsp_data = $self->get_field('hsp_data') || return;
my ($this_hsp) = sort { $b->[2] <=> $a->[2] } @{$hsp_data};
$self->_fields->{query_end} = $this_hsp->[2];} |
sub _discover_hit_start
{ my $self = shift;
my $hsp_data = $self->get_field('hsp_data') || return;
my ($this_hsp) = sort { $a->[3] <=> $b->[3] } @{$hsp_data};
$self->_fields->{hit_start} = $this_hsp->[3];} |
sub _discover_hit_end
{ my $self = shift;
my $hsp_data = $self->get_field('hsp_data') || return;
my ($this_hsp) = sort { $b->[4] <=> $a->[4] } @{$hsp_data};
$self->_fields->{hit_end} = $this_hsp->[4];} |
sub _discover_next_hsp
{ my $self = shift;
my $hsp_data = $self->get_field('hsp_data') || return;
unless (defined $self->{_next_hsp_index}) {
$self->{_next_hsp_index} = 0;
}
return if $self->{_next_hsp_index} == -1;
$self->_fields->{next_hsp} = new Bio::Search::HSP::HmmpfamHSP(-parent => $self,
-hsp_data => $hsp_data->[$self->{_next_hsp_index}++]);
if ($self->{_next_hsp_index} > $#{$hsp_data}) {
$self->{_next_hsp_index} = -1;
}} |
sub next_hsp
{ my $self = shift;
my $hsp = $self->get_field('next_hsp');
undef $self->_fields->{next_hsp};
return $hsp;} |
sub hsps
{ my $self = shift;
my $old = $self->{_next_hsp_index} || 0;
$self->rewind;
my @hsps;
while (defined(my $hsp = $self->next_hsp)) {
push(@hsps, $hsp);
}
$self->{_next_hsp_index} = @hsps > 0 ? $old : -1;
return @hsps;} |
sub hsp
{ my ($self, $type) = @_;
$type ||= 'best';
my $hsp_data = $self->get_field('hsp_data') || return;
my $sort;
if ($type eq 'best') {
$sort = sub { $a->[6] <=> $b->[6] };
}
elsif ($type eq 'worst') {
$sort = sub { $b->[6] <=> $a->[6] };
}
else {
$self->throw("Unknown arg '$type' given to hsp()");
}
my ($this_hsp) = sort $sort @{$hsp_data};
return new Bio::Search::HSP::HmmpfamHSP(-parent => $self, -hsp_data => $this_hsp);} |
sub rewind
{ my $self = shift;
my $hsp_data = $self->get_field('hsp_data') || return;
$self->{_next_hsp_index} = @{$hsp_data} > 0 ? 0 : -1;} |
sub p
{ return shift->significance; } |
sub strand
{ my ($self, $type) = @_;
$type ||= (wantarray ? 'list' : 'query');
$type = lc($type);
if ($type eq 'list' || $type eq 'array') {
return (1, 1);
}
return 1;} |
sub frac_aligned_query
{ return undef; } |
General documentation
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
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:
http://bugzilla.open-bio.org/
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
Title : next_domain
Usage : my $domain = $hit->next_domain();
Function: An alias for next_hsp(), this will return the next HSP
Returns : Bio::Search::HSP::HSPI object
Args : none
Title : domains
Usage : my @domains = $hit->domains();
Function: An alias for hsps(), this will return the full list of hsps
Returns : array of Bio::Search::HSP::HSPI objects
Args : none