Bio::Search::Hit HmmpfamHit
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvs
Summary
Bio::Search::Hit::HmmpfamHit - A parser and hit object for hmmpfam hits
Package variables
No package variables defined.
Included modules
Bio::Search::HSP::HmmpfamHSP
Inherit
Bio::Root::Root Bio::Search::Hit::PullHitI
Synopsis
    # generally we use Bio::SearchIO to build these objects
use Bio::SearchIO;
my $in = Bio::SearchIO->new(-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
newDescriptionCode
_discover_description
No description
Code
_discover_hsp_data
No description
Code
_discover_query_start
No description
Code
_discover_query_end
No description
Code
_discover_hit_start
No description
Code
_discover_hit_end
No description
Code
_discover_next_hsp
No description
Code
next_hspDescriptionCode
hspsDescriptionCode
hspDescriptionCode
rewindDescriptionCode
p
No description
Code
strandDescriptionCode
frac_aligned_queryDescriptionCode
Methods description
newcode    nextTop
 Title   : new
Usage : my $obj = Bio::Search::Hit::HmmpfamHit->new();
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)
next_hspcodeprevnextTop
 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
hspscodeprevnextTop
 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
hspcodeprevnextTop
 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()
rewindcodeprevnextTop
 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
strandcodeprevnextTop
 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')
frac_aligned_querycodeprevnextTop
 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
newdescriptionprevnextTop
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;
}

#
# PullParserI discovery methods so we can answer all HitI questions
#
}
_discover_descriptiondescriptionprevnextTop
sub _discover_description {
	# this should be set when this object is created, but if it was undef as is
# possible, this _discover method will be called: just return and keep the
# return value undef
return;
}
_discover_hsp_datadescriptionprevnextTop
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};
		}
		
		# rank query_start query_end hit_start hit_end score evalue
$self->_fields->{hsp_data} = $hsp_data->{hsp_data}; }
}
_discover_query_startdescriptionprevnextTop
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];
}
_discover_query_enddescriptionprevnextTop
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];
}
_discover_hit_startdescriptionprevnextTop
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];
}
_discover_hit_enddescriptionprevnextTop
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];
}
_discover_next_hspdescriptionprevnextTop
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} = Bio::Search::HSP::HmmpfamHSP->new(-parent => $self,
																  -hsp_data => $hsp_data->[$self->{_next_hsp_index}++]);
	
	if ($self->{_next_hsp_index} > $#{$hsp_data}) {
		$self->{_next_hsp_index} = -1;
	}
}
next_hspdescriptionprevnextTop
sub next_hsp {
    my $self = shift;
    my $hsp = $self->get_field('next_hsp');
	undef $self->_fields->{next_hsp};
	return $hsp;
}
hspsdescriptionprevnextTop
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;
}
hspdescriptionprevnextTop
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 Bio::Search::HSP::HmmpfamHSP->new(-parent => $self, -hsp_data => $this_hsp);
}
rewinddescriptionprevnextTop
sub rewind {
	my $self = shift;
	my $hsp_data = $self->get_field('hsp_data') || return;
	$self->{_next_hsp_index} = @{$hsp_data} > 0 ? 0 : -1;
}

# have p() a synonym of significance()
}
pdescriptionprevnextTop
sub p {
	return shift->significance;
}
stranddescriptionprevnextTop
sub strand {
    my ($self, $type) = @_;
	$type ||= (wantarray ? 'list' : 'query');
    $type = lc($type);
	if ($type eq 'list' || $type eq 'array') {
		return (1, 1);
	}
	return 1;
}
frac_aligned_querydescriptionprevnextTop
sub frac_aligned_query {
}
General documentation
FEEDBACKTop
Mailing ListsTop
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
Support Top
Please direct usage questions or support issues to the mailing list:
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.
Reporting BugsTop
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://redmine.open-bio.org/projects/bioperl/
AUTHOR - Sendu BalaTop
Email bix@sendu.me.uk
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
next_domainTop
 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
domainsTop
 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