Bio::SearchIO hmmer_pull
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvs
Summary
Bio::SearchIO::hmmer_pull - A parser for HMMER output
Package variables
No package variables defined.
Inherit
Bio::PullParserI Bio::SearchIO
Synopsis
    # do not use this class directly it is available through Bio::SearchIO
use Bio::SearchIO;
my $in = Bio::SearchIO->new(-format => 'hmmer_pull',
-file => 't/data/hmmpfam.bigout');
while (my $result = $in->next_result) {
# this is a Bio::Search::Result::HmmpfamResult object
print $result->query_name(), " for HMM ", $result->hmm_name(), "\n";
while (my $hit = $result->next_hit) {
print $hit->name(), "\n";
while (my $hsp = $hit->next_hsp) {
print "length is ", $hsp->length(), "\n";
}
}
}
Description
This object implements a pull-parser for HMMER output. It is fast since it
only does work on request (hence 'pull').
Methods
_initialize
No description
Code
_discover_header
No description
Code
_discover_database_name
No description
Code
_discover_next_result
No description
Code
next_resultDescriptionCode
result_countDescriptionCode
rewindDescriptionCode
Methods description
next_resultcode    nextTop
 Title   : next_result
Usage : my $hit = $searchio->next_result;
Function: Returns the next Result from a search
Returns : Bio::Search::Result::ResultI object
Args : none
result_countcodeprevnextTop
 Title   : result_count
Usage : my $count = $searchio->result_count
Function: Returns the number of results we have processed.
Returns : integer
Args : none
rewindcodeprevnextTop
 Title   : rewind
Usage : $searchio->rewind;
Function: Allow one to reset the Result iterator to the beginning, so that
next_result() will subsequently return the first result and so on.
NB: result objects are not cached, so you will get new result objects each time you rewind. Also, note that result_count() counts the number of times you have called next_result(), so will not be able tell you how many results there were in the file if you use rewind(). Returns : n/a Args : none
Methods code
_initializedescriptionprevnextTop
sub _initialize {
    my ($self, @args) = @_;
    
    # don't do normal SearchIO initialization
my ($writer, $file, $fh, $piped_behaviour, $evalue, $score, $hsps) = $self->_rearrange([qw(WRITER FILE FH PIPED_BEHAVIOUR EVALUE SCORE HSPS)], @args); $self->writer($writer) if $writer; $self->_fields( { ( header => undef, algorithm => undef, algorithm_version => undef, algorithm_reference => '', hmm_file => undef, hmm_name => undef, sequence_file => undef, sequence_database => undef, database_name => undef, database_letters => undef, database_entries => undef, next_result => undef, evalue_cutoff => '[unset]', score_cutoff => '[unset]', hsps_cutoff => '[unset]' ) } ); $self->_fields->{evalue_cutoff} = $evalue if $evalue; $self->_fields->{score_cutoff} = $score if $score; $self->_fields->{hsps_cutoff} = $hsps if $hsps; $self->_dependencies( { ( algorithm => 'header', algorithm_version => 'header', hmm_file => 'header', hmm_name => 'header', sequence_file => 'header', sequence_database => 'header' ) } ); $self->chunk($file || $fh || $self->throw("-file or -fh must be supplied"), -piped_behaviour => $piped_behaviour || 'sequential_read');
}
_discover_headerdescriptionprevnextTop
sub _discover_header {
    my $self = shift;
    $self->_chunk_seek(0);
    my $header = $self->_get_chunk_by_nol(8);
    $self->{_after_header} = $self->_chunk_tell;
    
    my ($algo) = $header =~ /^(hmm\S+) - search/m;
    $self->_fields->{algorithm} = uc $algo;
    
    ($self->_fields->{algorithm_version}) = $header =~ /^HMMER\s+?(\S+)/m;
    
    ($self->_fields->{hmm_file}) = $header =~ /^HMM file:\s.+?(\S+)$/m;
    $self->_fields->{hmm_name} = $self->_fields->{hmm_file};
    
    ($self->_fields->{sequence_file}) = $header =~ /^Sequence (?:file|database):\s.+?(\S+)$/m;
    $self->_fields->{sequence_database} = $self->_fields->{sequence_file};
    
    $self->_fields->{header} = 1;
}
_discover_database_namedescriptionprevnextTop
sub _discover_database_name {
    my $self = shift;
    my $type = $self->get_field('algorithm');
    
    if ($type eq 'HMMPFAM') {
        $self->_fields->{database_name} = $self->get_field('hmm_file');
    }
    elsif ($type eq 'HMMSEARCH') {
        $self->_fields->{database_name} = $self->get_field('sequence_file');
    }
}
_discover_next_resultdescriptionprevnextTop
sub _discover_next_result {
    my $self = shift;
    my $type = $self->get_field('algorithm'); # also sets _after_header if not set
if ($type eq 'HMMPFAM') { use Bio::Search::Result::HmmpfamResult; unless ($self->_sequential) { $self->_chunk_seek($self->{_end_of_previous_result} || $self->{_after_header}); my ($start, $end) = $self->_find_chunk_by_end("//\n"); return if $start == $end; $self->_fields->{next_result} = Bio::Search::Result::HmmpfamResult->new(-chunk => [($self->chunk, $start, $end)], -parent => $self); $self->{_end_of_previous_result} = $end; } else { # deliberatly don't cache these, which means rewind won't work;
# if we cached we may as well have used 'memory' option to
# -piped_behaviour
my $chunk = $self->_get_chunk_by_end("//\n"); $chunk || return; $self->_fields->{next_result} = Bio::Search::Result::HmmpfamResult->new(-chunk => [$chunk], -parent => $self); } } elsif ($type eq 'HMMSEARCH') { $self->throw("Can't handle hmmsearch yet\n"); } else { $self->throw("Unknown report type"); }
}
next_resultdescriptionprevnextTop
sub next_result {
    my $self = shift;
    my $result = $self->get_field('next_result') || return;
    
    undef $self->_fields->{next_result};
    
    $self->{'_result_count'}++;
    return $result;
}
result_countdescriptionprevnextTop
sub result_count {
    my $self = shift;
    return $self->{'_result_count'};
}
rewinddescriptionprevnextTop
sub rewind {
	my $self = shift;
    if ($self->_sequential) {
        $self->warn("rewind has no effect on piped input when you have chosen 'sequential_read' mode");
    }
	delete $self->{_end_of_previous_result};
}

1;
}
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 _
newTop
 Title   : new
Usage : my $obj = Bio::SearchIO::hmmer_pull->new();
Function: Builds a new Bio::SearchIO::hmmer_pull object
Returns : Bio::SearchIO::hmmer_pull
Args : -fh/-file => HMMER output filename
-format => 'hmmer_pull'
-evalue => float or scientific notation number to be used
as an evalue cutoff for hits
-score => integer or scientific notation number to be used
as a score value cutoff for hits
-hsps => integer minimum number of hsps (domains) a hit must have
-piped_behaviour => 'temp_file'|'memory'|'sequential_read'
-piped_behaviour defines what the parser should do if the input is an unseekable filehandle (eg. piped input), see Bio::PullParserI::chunk for details. Default is 'sequential_read'.