Bio-EUtilities
view release on metacpan or search on metacpan
lib/Bio/Tools/EUtilities.pm view on Meta::CPAN
Args : string
=head1 Methods useful for multiple eutils
=head2 get_ids
Title : get_ids
Usage : my @ids = $parser->get_ids
Function : returns array of requested IDs (see Notes for more specifics)
Returns : array
Args : [conditional] not required except when running elink queries against
multiple databases. In case of the latter, the database name is
optional but recommended when retrieving IDs as the ID list will
be globbed together. In such cases, if a db name isn't provided a
warning is issued as a reminder.
Notes : esearch : returned ID list
elink : returned ID list (see Args above for caveats)
all others : from parameter_base->id or undef
=head2 get_database
Title : get_database
Usage : my $db = $info->get_database;
Function : returns single database name (eutil-compatible). This is the
queried database. For most eutils this is straightforward. For
elinks (which have 'db' and 'dbfrom') this is db/dbto, for egquery,
it is the first db in the list (you probably want get_databases
instead)
Returns : string
Args : none
Notes : egquery : first db in the query (you probably want get_databases)
einfo : the queried database
espell : the queried database
all others : from parameter_base->db or undef
=head2 get_db (alias for get_database)
=head2 get_databases
Title : get_databases
Usage : my @dbs = $parser->get_databases
Function : returns list of databases
Returns : array of strings
Args : none
Notes : This is guaranteed to return a list of databases. For a single
database use the convenience method get_db/get_database
egquery : list of all databases in the query
einfo : the queried database, or the available databases
espell : the queried database
elink : collected from each LinkSet
all others : from parameter_base->db or undef
=head2 get_dbs (alias for get_databases)
=head2 next_History
Title : next_History
Usage : while (my $hist=$parser->next_History) {...}
Function : returns next HistoryI (if present).
Returns : Bio::Tools::EUtilities::HistoryI (Cookie or LinkSet)
Args : none
Note : esearch, epost, and elink are all capable of returning data which
indicates search results (in the form of UIDs) is stored on the
remote server. Access to this data is wrapped up in simple interface
(HistoryI), which is implemented in two classes:
Bio::DB::EUtilities::History (the simplest) and
Bio::DB::EUtilities::LinkSet. In general, calls to epost and esearch
will only return a single HistoryI object (formerly known as a
Cookie), but calls to elink can generate many depending on the
number of IDs, the correspondence, etc. Hence this iterator, which
allows one to retrieve said data one piece at a time.
=head2 next_cookie (alias for next_History)
=head2 get_Histories
Title : get_Histories
Usage : my @hists = $parser->get_Histories
Function : returns list of HistoryI objects.
Returns : list of Bio::Tools::EUtilities::HistoryI (History or LinkSet)
Args : none
=head1 Query-related methods
=head2 get_count
Title : get_count
Usage : my $ct = $parser->get_count
Function : returns the count (hits for a search)
Returns : integer
Args : [CONDITIONAL] string with database name - used to retrieve
count from specific database when using egquery
Notes : egquery : count for specified database (specified above)
esearch : count for last search
all others : undef
=head2 get_term
Title : get_term
Usage : $st = $qd->get_term;
Function : retrieve the term for the global search
Returns : string
Args : none
Notes : egquery : search term
espell : search term
esearch : from parameter_base->term or undef
all others : undef
=head2 get_translation_from
Title : get_translation_from
Usage : $string = $qd->get_translation_from();
Function: portion of the original query replaced with translated_to()
Returns : string
Args : none
Note : only applicable for esearch
=head2 get_translation_to
Title : get_translation_to
Usage : $string = $qd->get_translation_to();
Function: replaced string used in place of the original query term in translation_from()
Returns : string
Args : none
Note : only applicable for esearch
=head2 get_retstart
Title : get_retstart
lib/Bio/Tools/EUtilities.pm view on Meta::CPAN
Returns : LinkSet object
Args : none
Notes : only applicable for elink. Uses callback() for filtering if defined
for 'linksets'
=head2 get_LinkSets
Title : get_LinkSets
Usage : my @links = $info->get_LinkSets;
Function : returns list of LinkSets objects
Returns : array (LinkSet objects)
Args : none
Notes : only applicable for elink.
=head2 print_LinkSets
Title : print_LinkSets
Usage : $info->print_LinkSets();
$info->print_LinkSets(-fh => $fh, -cb => $coderef);
Function : prints link data for each LinkSet object. The default is generated
via LinkSet::to_string
Returns : none
Args : [optional]
-file : file to print to
-fh : filehandle to print to (cannot be used concurrently with file)
-cb : coderef to use in place of default print method. This is passed
in a LinkSet object
-wrap : number of columns to wrap default text output to (def = 80)
Notes : only applicable for einfo. If -file or -fh are not defined,
prints to STDOUT
=head2 get_linked_databases
Title : get_linked_databases
Usage : my @dbs = $eutil->get_linked_databases
Function : returns list of databases linked to in linksets
Returns : array of databases
Args : none
Notes : only applicable for elink. Now defers to get_databases.
=head1 Iterator- and callback-related methods
=head2 rewind
Title : rewind
Usage : $esum->rewind()
$esum->rewind('recursive')
Function : retrieve a list of DocSum instances
Returns : array of Bio::Tools::EUtilities::Summary::DocSum
Args : [optional] Scalar; string ('all') to reset all iterators, or string
describing the specific main object iterator to reset. The following
are recognized (case-insensitive):
'all' - rewind all objects and also recursively resets nested object
iterators (such as LinkSets and DocSums).
'globalqueries' - GlobalQuery objects
'fieldinfo' or 'fieldinfos' - FieldInfo objects
'linkinfo' or 'linkinfos' - LinkInfo objects in this layer
'linksets' - LinkSet objects
'docsums' - DocSum objects
'histories' - HistoryI objects (Cookies, LinkSets)
=head2 generate_iterator
Title : generate_iterator
Usage : my $coderef = $esum->generate_iterator('linkinfo')
Function : generates an iterator (code reference) which iterates through
the relevant object indicated by the args
Returns : code reference
Args : [REQUIRED] Scalar; string describing the specific object to iterate.
The following are currently recognized (case-insensitive):
'globalqueries'
'fieldinfo' or 'fieldinfos' (the latter sounds clumsy, but I alias it JIC)
'linkinfo' or 'linkinfos' (the latter sounds clumsy, but I alias it JIC)
'linksets'
'docsums'
'histories'
Note : This function generates a simple coderef that one can use
independently of the various next_* functions (in fact, the next_*
functions use lazily created iterators generated via this method,
while rewind() merely deletes them so they can be regenerated on the
next call).
A callback specified using callback() will be used to filter objects
for any generated iterator. This behaviour is implemented for both
normal and lazy iterator types and is the default. If you don't want
this, make sure to reset any previously set callbacks via
reset_callback() (which just deletes the code ref). Note that setting
callback() also changes the behavior of the next_* functions as the
iterators are generated here (as described above); this is a feature
and not a bug.
'Lazy' iterators are considered an experimental feature and may be
modified in the future. A 'lazy' iterator, which loops through and
returns objects as they are created (instead of creating all data
instances up front, then iterating through) is returned if the
parser is set to 'lazy' mode. This mode is only present for elink
and esummary output as they are the two formats parsed which can
generate potentially thousands of individual objects (note efetch
isn't parsed, so isn't counted). Use of rewind() with these
iterators is not supported for the time being as we can't guarantee
you can rewind(), as this depends on whether the data source is
seek()able and thus 'rewindable'. We will add rewind() support at a
later time which will work for 'seekable' data or possibly cached
objects via Storable or BDB.
=head2 callback
Title : callback
Usage : $parser->callback(sub {$_[0]->get_database eq 'protein'});
Function : Get/set callback code ref used to filter returned data objects
Returns : code ref if previously set
Args : single argument:
code ref - evaluates a passed object and returns true or false value
(used in iterators)
'reset' - string, resets the iterator.
returns upon any other args
=head1 FEEDBACK
( run in 1.195 second using v1.01-cache-2.11-cpan-39bf76dae61 )