Bio::DB::Query DBQueryResult
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvs
Summary
Bio::DB::Query::DBQueryResult - DESCRIPTION of Object
Package variables
No package variables defined.
Included modules
Bio::DB::Query::QueryResultI
Bio::Root::Root
Inherit
Bio::DB::Query::QueryResultI Bio::Root::Root
Synopsis
Give standard usage here
Description
This modules provides an implementation of Bio::DB::Query::QueryResultI for
database queries through DBI.
Methods
newDescriptionCode
next_objectDescriptionCode
each_ObjectDescriptionCode
finishDescriptionCode
sthDescriptionCode
persistence_adaptorDescriptionCode
object_factoryDescriptionCode
num_fksDescriptionCode
flat_retrievalDescriptionCode
Methods description
newcode    nextTop
 Title   : new
Usage : my $obj = Bio::DB::Query::DBQueryResult->new();
Function: Builds a new Bio::DB::Query::DBQueryResult object
Returns : an instance of Bio::DB::Query::DBQueryResult
Args : named parameters
-sth the statement handle (this object will not execute it) -adaptor the persistence adaptor (basically needs to implement instantiate_from_row($row, $factory) -factory optionally, the object factory to pass to the adaptor -num_fks the number of foreign key object columns in the rows -flat_only whether to retrieve and attach children when building objects (default: false) If none of these are given at instantiation, at least sth() and persistence_adaptor() must be set prior to calling next_object().
next_objectcodeprevnextTop
 Title   : next_object
Usage :
Function: Obtain the next object from the result stream and return it.
Example :
Returns : A Bioperl object (implementing at least Bio::Root::RootI)
Args : none
each_ObjectcodeprevnextTop
 Title   : each_Object
Usage :
Function: This is primarily a convenience method and in most implementations
will just loop over next_object() and return an array of all
objects.
Example :
Returns : A reference to an array of objects.
Args : Optionally, an anonymous function for filtering objects. If given,
the function is passed one argument, the object to evaluate.
The object will be included in the returned array if the function
returns TRUE, and rejected otherwise.
finishcodeprevnextTop
 Title   : finish
Usage :
Function: Indicate being finished with this result so that possibly used
system resources can be released.
Example :
Returns : none
Args : none
sthcodeprevnextTop
 Title   : sth
Usage : $obj->sth($newval)
Function: Get/set statement handle from which to fetch the next row.
This can be changed at any time. If changed, it means the next call to next_object() will fetch from the new handle. Also, the caller needs to finish() the previous handle if necessary (i.e., if not exhausted). Note that this object will not execute the statement handle. The caller needs to ensure that has been happened until next_object() is called. Example : Returns : value of sth (a DBI statement handle) Args : new value (a DBI statement handle, optional)
persistence_adaptorcodeprevnextTop
 Title   : persistence_adaptor
Usage : $obj->persistence_adaptor($newval)
Function: Get/set the instantiation adaptor to which to delegate object
instantiation from an array of row values.
The adaptor can be any object that implements instantiate_from_row() with two arguments, a reference to an array of column values, and optionally an object factory. This can be changed at any time with no adverse side effect other than the kind of object built possibly changing. Example : Returns : value of persistence_adaptor (an object) Args : new value (an object, optional)
object_factorycodeprevnextTop
 Title   : object_factory
Usage : $obj->object_factory($newval)
Function: Get/set the object factory to pass to the instantiation adaptor.
Setting this is optional because providing it to the instantiation adaptor is optional. Example : Returns : value of object_factory (a Bio::Factory::ObjectFactoryI compliant instance) Args : new value (a Bio::Factory::ObjectFactoryI compliant instance, optional)
num_fkscodeprevnextTop
 Title   : num_fks
Usage : $obj->num_fks($newval)
Function: Get/set the number of foreign key columns in a given result row.
Setting this correctly is only important for query results for which the resulting objects must have the foreign key objects attached. Example : Returns : value of num_fks (a scalar) Args : new value (a scalar, optional)
flat_retrievalcodeprevnextTop
 Title   : flat_retrieval
Usage : $obj->flat_retrieval($newval)
Function: Get/set whether objects should be retrieved and built flat
or with all their dependent objects fetched and attached.
The default is to build full objects with all children attached which provides for no bad surprises when inspecting the results. However, building flat objects by disregarding children is potentially a lot faster, so this option is useful if, for instance, for a sequence you don't need any annotation or features. Example : Returns : value of flat_retrieval (a scalar evaluating to true or false) Args : on set, new value (a scalar or undef, optional)
Methods code
newdescriptionprevnextTop
sub new {
    my($class,@args) = @_;

    my $self = $class->SUPER::new(@args);
    
    my ($sth, $adaptor, $fact, $nfks, $flatonly) =
	$self->_rearrange([qw(STH ADAPTOR FACTORY NUM_FKS FLAT_ONLY)], @args);
    
    $self->sth($sth) if $sth;
    $self->persistence_adaptor($adaptor) if $adaptor;
    $self->object_factory($fact) if $fact;
    $self->num_fks($nfks) if defined($nfks);
    $self->flat_retrieval($flatonly);

    return $self;
}
next_objectdescriptionprevnextTop
sub next_object {
    my ($self) = @_;
    my $obj;

    my $row = $self->sth()->fetchrow_arrayref();
    if($row) {
	my $adp = $self->persistence_adaptor();
	# build the object
$obj = $adp->_build_object(-row => $row, -obj_factory => $self->object_factory(), -num_fks => $self->num_fks(), -flat_only => $self->flat_retrieval()); } return $obj;
}
each_ObjectdescriptionprevnextTop
sub each_Object {
    my ($self,$filter) = @_;
    my @objs = ();

    while(my $obj = $self->next_object()) {
	if((! $filter) || &$filter($obj)) {
	    push(@objs, $obj);
	}
    }
    return\@ objs;
}
finishdescriptionprevnextTop
sub finish {
    my $self = shift;
    $self->sth()->finish() if $self->sth();
}
sthdescriptionprevnextTop
sub sth {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'sth'} = $value;
    }
    return $self->{'sth'};
}
persistence_adaptordescriptionprevnextTop
sub persistence_adaptor {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'adp'} = $value;
    }
    return $self->{'adp'};
}
object_factorydescriptionprevnextTop
sub object_factory {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'object_factory'} = $value;
    }
    return $self->{'object_factory'};
}
num_fksdescriptionprevnextTop
sub num_fks {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'num_fks'} = $value;
    }
    return $self->{'num_fks'};
}
flat_retrievaldescriptionprevnextTop
sub flat_retrieval {
    my $self = shift;

    return $self->{'flat_retrieval'} = shift if @_;
    return $self->{'flat_retrieval'};
}

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:
  http://bugzilla.open-bio.org/
AUTHOR - Hilmar LappTop
Email hlapp at gmx.net
Describe contact details here
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 _