Bio::Search::Result GenericResult
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
Bio::Search::Result::GenericResult - Generic Implementation of Bio::Search::Result::ResultI interface applicable to most search results.
Package variables
No package variables defined.
Included modules
Bio::Root::Root
Bio::Search::Result::ResultI
Inherit
Bio::Root::Root Bio::Search::Result::ResultI
Synopsis
    # typically one gets Results from a SearchIO stream
use Bio::SearchIO;
my $io = new Bio::SearchIO(-format => 'blast',
-file => 't/data/HUMBETGLOA.tblastx');
while( my $result = $io->next_result) {
# process all search results within the input stream
while( my $hit = $result->next_hits()) {
# insert code here for hit processing
}
}
use Bio::Search::Result::GenericResult; my @hits = (); # would be a list of Bio::Search::Hit::HitI objects # typically these are created from a Bio::SearchIO stream my $result = new Bio::Search::Result::GenericResult ( -query_name => 'HUMBETGLOA', -query_accession => '' -query_description => 'Human haplotype C4 beta-globin gene, complete cds.' -query_length => 3002 -database_name => 'ecoli.aa' -database_letters => 4662239, -database_entries => 400, -parameters => { 'e' => '0.001' }, -statistics => { 'kappa' => 0.731 }, -algorithm => 'blastp', -algorithm_version => '2.1.2', ); my $id = $result->query_name(); my $desc = $result->query_description(); my $name = $result->database_name(); my $size = $result->database_letters(); my $num_entries = $result->database_entries(); my $gap_ext = $result->get_parameter('e'); my @params = $result->available_parameters; my $kappa = $result->get_statistic('kappa'); my @statnames = $result->available_statistics;
Description
This object is an implementation of the Bio::Search::Result::ResultI
interface and provides a generic place to store results from a
sequence database search.
Methods
_nexthitindexDescriptionCode
add_hitDescriptionCode
add_parameterDescriptionCode
add_statisticDescriptionCode
algorithmDescriptionCode
algorithm_referenceDescriptionCode
algorithm_versionDescriptionCode
available_parametersDescriptionCode
available_statisticsDescriptionCode
database_entriesDescriptionCode
database_lettersDescriptionCode
database_nameDescriptionCode
get_parameterDescriptionCode
get_statisticDescriptionCode
hitsDescriptionCode
iterationsDescriptionCode
newDescriptionCode
next_hitDescriptionCode
no_hits_foundDescriptionCode
num_hitsDescriptionCode
psiblastDescriptionCode
query_accessionDescriptionCode
query_descriptionDescriptionCode
query_lengthDescriptionCode
query_nameDescriptionCode
rewindDescriptionCode
set_no_hits_foundDescriptionCode
to_stringDescriptionCode
Methods description
_nexthitindexcode    nextTop
 Title   : _nexthitindex
Usage : private
add_hitcodeprevnextTop
 Title   : add_hit
Usage : $report->add_hit($hit)
Function: Adds a HitI to the stored list of hits
Returns : Number of HitI currently stored
Args : Bio::Search::Hit::HitI
add_parametercodeprevnextTop
 Title   : add_parameter
Usage : $report->add_parameter('gapext', 11);
Function: Adds a parameter
Returns : none
Args : key - key value name for this parama
value - value for this parameter
add_statisticcodeprevnextTop
 Title   : add_statistic
Usage : $report->add_statistic('lambda', 2.3);
Function: Adds a parameter
Returns : none
Args : key - key value name for this parama
value - value for this parameter
algorithmcodeprevnextTop
 Title   : algorithm
Usage : my $r_type = $hsp->algorithm
Function: Obtain the name of the algorithm used to obtain the Result
Returns : string (e.g., BLASTP)
Args : [optional] scalar string to set value
algorithm_referencecodeprevnextTop
 Title   : algorithm_reference
Usage : $obj->algorithm_reference($newval)
Function:
Returns : string containing literature reference for the algorithm
Args : newvalue string (optional)
Comments: Formerly named program_reference(), which is still supported
for backwards compatibility.
algorithm_versioncodeprevnextTop
 Title   : algorithm_version
Usage : my $r_version = $hsp->algorithm_version
Function: Obtain the version of the algorithm used to obtain the Result
Returns : string (e.g., 2.1.2)
Args : [optional] scalar string to set algorithm version value
available_parameterscodeprevnextTop
 Title   : available_parameters
Usage : my @params = $report->available_paramters
Function: Returns the names of the available parameters
Returns : Return list of available parameters used for this report
Args : none
available_statisticscodeprevnextTop
 Title   : available_statistics
Usage : my @statnames = $report->available_statistics
Function: Returns the names of the available statistics
Returns : Return list of available statistics used for this report
Args : none
database_entriescodeprevnextTop
 Title   : database_entries
Usage : $num_entries = $result->database_entries()
Function: Used to obtain the number of entries contained in the database.
Returns : a scalar integer representing the number of entities in the database
or undef if the information was not available.
Args : [optional] new integer for the number of sequence entries in the db
database_letterscodeprevnextTop
 Title   : database_letters
Usage : $size = $result->database_letters()
Function: Used to obtain the size of database that was searched against.
Returns : a scalar integer (units specific to algorithm, but probably the
total number of residues in the database, if available) or undef if
the information was not available to the Processor object.
Args : [optional] new scalar integer for number of letters in db
database_namecodeprevnextTop
 Title   : database_name
Usage : $name = $result->database_name()
Function: Used to obtain the name of the database that the query was searched
against by the algorithm.
Returns : a scalar string
Args : [optional] new string for the db name
get_parametercodeprevnextTop
 Title   : get_parameter
Usage : my $gap_ext = $report->get_parameter('gapext')
Function: Returns the value for a specific parameter used
when running this report
Returns : string
Args : name of parameter (string)
get_statisticcodeprevnextTop
 Title   : get_statistic
Usage : my $gap_ext = $report->get_statistic('kappa')
Function: Returns the value for a specific statistic available
from this report
Returns : string
Args : name of statistic (string)
hitscodeprevnextTop
 Title   : hits
Usage : my @hits = $result->hits
Function: Returns the available hits for this Result
Returns : Array of Bio::Search::Hit::HitI objects
Args : none
iterationscodeprevnextTop
See documentation in Bio::Search::Result::ResultI::iterations()
newcodeprevnextTop
 Title   : new
Usage : my $obj = new Bio::Search::Result::GenericResult();
Function: Builds a new Bio::Search::Result::GenericResult object
Returns : Bio::Search::Result::GenericResult
Args : -query_name => Name of query Sequence
-query_accession => Query accession number (if available)
-query_description => Description of query sequence
-query_length => Length of query sequence
-database_name => Name of database
-database_letters => Number of residues in database
-database_entries => Number of entries in database
-parameters => hash ref of search parameters (key => value)
-statistics => hash ref of search statistics (key => value)
-algorithm => program name (blastx)
-algorithm_version => version of the algorithm (2.1.2)
-algorithm_reference => literature reference string for this algorithm
next_hitcodeprevnextTop
 Title   : next_hit
Usage : while( $hit = $result->next_hit()) { ... }
Function: Returns the next available Hit object, representing potential
matches between the query and various entities from the database.
Returns : a Bio::Search::Hit::HitI object or undef if there are no more.
Args : none
no_hits_foundcodeprevnextTop
See documentation in Bio::Search::Result::ResultI::no_hits_found()
num_hitscodeprevnextTop
 Title   : num_hits
Usage : my $hitcount= $result->num_hits
Function: returns the number of hits for this query result
Returns : integer
Args : none
psiblastcodeprevnextTop
See documentation in Bio::Search::Result::ResultI::psiblast()
query_accessioncodeprevnextTop
 Title   : query_accession
Usage : $id = $result->query_accession();
Function: Get the accession (if available) for the query sequence
Returns : a string
Args : [optional] new string value for accession
query_descriptioncodeprevnextTop
 Title   : query_description
Usage : $id = $result->query_description();
Function: Get the description of the query sequence
used in the search.
Returns : a string
Args : [optional] new string for the query description
query_lengthcodeprevnextTop
 Title   : query_length
Usage : $id = $result->query_length();
Function: Get the length of the query sequence
used in the search.
Returns : a number
Args : [optional] new integer value for query length
query_namecodeprevnextTop
 Title   : query_name
Usage : $id = $result->query_name();
Function: Get the string identifier of the query used by the
algorithm that performed the search.
Returns : a string.
Args : [optional] new string value for query name
rewindcodeprevnextTop
 Title   : rewind
Usage : $result->rewind;
Function: Allow one to reset the Hit iteration to the beginning
Since this is an in-memory implementation
Returns : none
Args : none
set_no_hits_foundcodeprevnextTop
See documentation in Bio::Search::Result::ResultI::set_no_hits_found()
to_stringcodeprevnextTop
 Title   : to_string
Usage : print $blast->to_string;
Function: Returns a string representation for the Blast result.
Primarily intended for debugging purposes.
Example : see usage
Returns : A string of the form:
[GenericResult] <analysis_method> query=<name> <description> db=<database
e.g.:
[GenericResult] BLASTP query=YEL060C vacuolar protease B, db=PDBUNIQ
Args : None
Methods code
_nexthitindexdescriptionprevnextTop
sub _nexthitindex {
   my ($self,@args) = @_;
   return $self->{'_hitindex'}++;
}
add_hitdescriptionprevnextTop
sub add_hit {
    my ($self,$s) = @_;
    if( $s->isa('Bio::Search::Hit::HitI') ) { 
	push @{$self->{'_hits'}}, $s;
    } else { 
	$self->warn("Passed in " .ref($s). 
		    " as a Hit which is not a Bio::Search::HitI... skipping");
    }
    return scalar @{$self->{'_hits'}};
}
add_parameterdescriptionprevnextTop
sub add_parameter {
   my ($self,$key,$value) = @_;
   $self->{'_parameters'}->{$key} = $value;
}
add_statisticdescriptionprevnextTop
sub add_statistic {
   my ($self,$key,$value) = @_;
   $self->{'_statistics'}->{$key} = $value;
   return;
}
algorithmdescriptionprevnextTop
sub algorithm {
    my ($self,$value) = @_;
    my $previous = $self->{'_algorithm'};
    if( defined $value || ! defined $previous ) { 
	$value = $previous = '' unless defined $value;
	$self->{'_algorithm'} = $value;
    } 
    return $previous;
}
algorithm_referencedescriptionprevnextTop
sub algorithm_reference {
   my ($self,$value) = @_;
   if( defined $value) {
      $self->{'algorithm_reference'} = $value;
    }
    return $self->{'algorithm_reference'};
}
algorithm_versiondescriptionprevnextTop
sub algorithm_version {
    my ($self,$value) = @_;
    my $previous = $self->{'_algorithm_version'};
    if( defined $value || ! defined $previous ) { 
	$value = $previous = '' unless defined $value;
	$self->{'_algorithm_version'} = $value;
    } 

    return $previous;
}
available_parametersdescriptionprevnextTop
sub available_parameters {
   my ($self) = @_;
   return keys %{$self->{'_parameters'}};
}
available_statisticsdescriptionprevnextTop
sub available_statistics {
   my ($self) = @_;
   return keys %{$self->{'_statistics'}};
}
database_entriesdescriptionprevnextTop
sub database_entries {
    my ($self,$value) = @_;
    my $previous = $self->{'_dbentries'};
    if( defined $value || ! defined $previous ) {
	$value = $previous = '' unless defined $value;
	$self->{'_dbentries'} = $value;
    } 
    return $previous;
}
database_lettersdescriptionprevnextTop
sub database_letters {
    my ($self,$value) = @_;
    my $previous = $self->{'_dbletters'};
    if( defined $value || ! defined $previous ) {
	$value = $previous = '' unless defined $value;
	$self->{'_dbletters'} = $value;
    } 
    return $previous;
}
database_namedescriptionprevnextTop
sub database_name {
    my ($self,$value) = @_;
    my $previous = $self->{'_dbname'};
    if( defined $value || ! defined $previous ) {
	$value = $previous = '' unless defined $value;
	$self->{'_dbname'} = $value;
    } 
    return $previous;
}
get_parameterdescriptionprevnextTop
sub get_parameter {
   my ($self,$name) = @_;
   return $self->{'_parameters'}->{$name};
}
get_statisticdescriptionprevnextTop
sub get_statistic {
   my ($self,$key) = @_;
   return $self->{'_statistics'}->{$key};
}
hitsdescriptionprevnextTop
sub hits {
   my ($self) = shift;
   my @hits = ();
   if( ref $self->{'_hits'}) {
       @hits = @{$self->{'_hits'}};
   }
    return @hits;
}
iterationsdescriptionprevnextTop
sub iterations {
#----------------
my ($self, $num ) = @_; if( defined $num ) { $self->{'_iterations'} = $num; } return $self->{'_iterations'};
}
newdescriptionprevnextTop
sub new {
  my($class,@args) = @_;

  my $self = $class->SUPER::new(@args);

  $self->{'_hits'} = [];
  $self->{'_hitindex'} = 0;
  $self->{'_statistics'} = {};
  $self->{'_parameters'} = {};

  my ($qname,$qacc,$qdesc,$qlen,
      $dbname,$dblet,$dbent,$params,   
      $stats, $hits, $algo, $algo_v,
      $prog_ref, $algo_r) = $self->_rearrange([qw(QUERY_NAME
                                                  QUERY_ACCESSION
                                                  QUERY_DESCRIPTION
                                                  QUERY_LENGTH
                                                  DATABASE_NAME
                                                  DATABASE_LETTERS
                                                  DATABASE_ENTRIES
                                                  PARAMETERS
                                                  STATISTICS
                                                  HITS
                                                  ALGORITHM
                                                  ALGORITHM_VERSION
                                                  PROGRAM_REFERENCE
                                                  ALGORITHM_REFERENCE
                                                 )],@args);

  $algo_r ||= $prog_ref;         
  defined $algo   && $self->algorithm($algo);
  defined $algo_v && $self->algorithm_version($algo_v);
  defined $algo_r && $self->algorithm_reference($algo_r);

  defined $qname && $self->query_name($qname);
  defined $qacc  && $self->query_accession($qacc);
  defined $qdesc && $self->query_description($qdesc);
  defined $qlen  && $self->query_length($qlen);
  defined $dbname && $self->database_name($dbname);
  defined $dblet  && $self->database_letters($dblet);
  defined $dbent  && $self->database_entries($dbent);

  if( defined $params ) {
      if( ref($params) !~ /hash/i ) {
	  $self->throw("Must specify a hash reference with the the parameter '-parameters");
      }
      while( my ($key,$value) = each %{$params} ) {
	  $self->add_parameter($key,$value);
      }
  }
  if( defined $stats ) {
      if( ref($stats) !~ /hash/i ) {
	  $self->throw("Must specify a hash reference with the the parameter '-statistics");
      }
      while( my ($key,$value) = each %{$stats} ) {
	  $self->add_statistic($key,$value);
      }
  }

  if( defined $hits  ) { 
      $self->throw("Must define arrayref of Hits when initializing a $class\n") unless ref($hits) =~ /array/i;

      foreach my $s ( @$hits ) {
	  $self->add_hit($s);
      }
  }
  return $self;
}
next_hitdescriptionprevnextTop
sub next_hit {
    my ($self,@args) = @_;
    my $index = $self->_nexthitindex;
    return undef if $index > scalar @{$self->{'_hits'}};
    return $self->{'_hits'}->[$index];
}
no_hits_founddescriptionprevnextTop
sub no_hits_found {
#-----------
my ($self, $round) = @_; my $result = 0; # final return value of this method.
# Watch the double negative!
# result = 0 means "yes hits were found"
# result = 1 means "no hits were found" (for the indicated iteration or all iterations)
# If a iteration was not specified and there were multiple iterations,
# this method should return true only if all iterations had no hits found.
if( not defined $round ) { if( $self->{'_iterations'} > 1) { $result = 1; foreach my $i( 1..$self->{'_iterations'} ) { if( not defined $self->{"_iteration_$i"}->{'_no_hits_found'} ) { $result = 0; last; } } } else { $result = $self->{"_iteration_1"}->{'_no_hits_found'}; } } else { $result = $self->{"_iteration_$round"}->{'_no_hits_found'}; } return $result;
}
num_hitsdescriptionprevnextTop
sub num_hits {
   my ($self) = shift;
   if (not defined $self->{'_hits'}) {
       $self->throw("Can't get Hits: data not collected.");
    }
    return scalar(@{$self->{'_hits'}});
}
psiblastdescriptionprevnextTop
sub psiblast {
#----------------
my ($self, $val ) = @_; if( $val ) { $self->{'_psiblast'} = 1; } return $self->{'_psiblast'};
}
query_accessiondescriptionprevnextTop
sub query_accession {
    my ($self,$value) = @_;
    my $previous = $self->{'_queryacc'};
    if( defined $value || ! defined $previous ) {
	$value = $previous = '' unless defined $value;
	$self->{'_queryacc'} = $value;
    } 
    return $previous;
}
query_descriptiondescriptionprevnextTop
sub query_description {
    my ($self,$value) = @_;
    my $previous = $self->{'_querydesc'};
    if( defined $value || ! defined $previous ) {
	$value = $previous = '' unless defined $value;
	$self->{'_querydesc'} = $value;
    } 
    return $previous;
}
query_lengthdescriptionprevnextTop
sub query_length {
    my ($self,$value) = @_;
    my $previous = $self->{'_querylength'};
    if( defined $value || ! defined $previous ) {
	$value = $previous = 0 unless defined $value;
	$self->{'_querylength'} = $value;
    } 
    return $previous;
}
query_namedescriptionprevnextTop
sub query_name {
    my ($self,$value) = @_;
    my $previous = $self->{'_queryname'};
    if( defined $value || ! defined $previous ) {
	$value = $previous = '' unless defined $value;
	$self->{'_queryname'} = $value;
    } 
    return $previous;
}
rewinddescriptionprevnextTop
sub rewind {
   my ($self) = @_;
   $self->{'_hitindex'} = 0;
}
set_no_hits_founddescriptionprevnextTop
sub set_no_hits_found {
#-----------
my ($self, $round) = @_; $round ||= 1; $self->{"_iteration_$round"}->{'_no_hits_found'} = 1;
}
to_stringdescriptionprevnextTop
sub to_string {
#---------------
my $self = shift; my $str = "[GenericResult] " . $self->algorithm . " query=" . $self->query_name . " " . $self->query_description .", db=" . $self->database_name; return $str; } 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/MailList.shtml - About the mailing lists
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
email or the web:
  bioperl-bugs@bioperl.org
http://bugzilla.bioperl.org/
AUTHOR - Jason Stajich and Steve ChervitzTop
Email jason@bioperl.org
Email sac@bioperl.org
CONTRIBUTORSTop
Additional contributors names and emails here
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
Bio::Search::Result::ResultI interface methodsTop
Bio::Search::Result::ResultI implementation
Bio::Search::Report Top
Bio::Search::Result::GenericResult specific methods