Bio-EUtilities
view release on metacpan or search on metacpan
lib/Bio/DB/EUtilities.pm view on Meta::CPAN
my $ct = $eutil->get_record_count;
while (my $field = $eutil->next_FieldInfo) {
# ...
}
while (my $field = $eutil->next_LinkInfo) {
# ...
}
# History methods (epost data, some data returned from elink)
# data which enables one to retrieve and query against user-stored
# information on the NCBI server
while (my $cookie = $eutil->next_History) {
# ...
}
my @hists = $eutil->get_Histories;
# Bio::Tools::EUtilities::Summary (esummary data)
# information on a specific database record
# retrieve nested docsum data
while (my $docsum = $eutil->next_DocSum) {
print "ID:",$docsum->get_ids,"\n";
while (my $item = $docsum->next_Item) {
# do stuff here...
while (my $listitem = $docsum->next_ListItem) {
# do stuff here...
while (my $listitem = $docsum->next_Structure) {
# do stuff here...
}
}
}
}
# retrieve flattened item list per DocSum
while (my $docsum = $eutil->next_DocSum) {
my @items = $docsum->get_all_DocSum_Items;
}
=head1 DESCRIPTION
This is a general webagent which posts and retrieves data to NCBI's eUtils
service using their CGI interface. A separate project, currently present in
BioPerl-Run, utilizes the SOAP-based interface for eUtils.
A full explanation of the eUtils interfaces are not possible within this short
module; please see the BioPerl wiki HOWTO for more details.
=head1 METHODS
=head2
=head1 TODO
=over 3
=item * Finish documentation
HOWTOs (both standard and Cookbook).
=item * Cookbook tests
Set up dev-only tests for Cookbook examples to make sure they are consistently
updated.
=item * API
Mark Jensen has written up the SOAP-based eUtil modules, maybe we should
coalesce around a consistent API between the two (they are close).
=item * Carryover of parameters
Maybe add a default but configurable list of parameters that can be carried over
between calls.
=item * Make setting certain parameters consistent
Setting history is a bit inconsistent, so maybe use a common alias for this?
=item * Moosify?
Not necessary, but it might make things easier and more maintainable in the long
run.
=back
=head1 Bio::DB::GenericWebAgent methods
=head1 GenericWebDBI methods
=head2 parameter_base
Title : parameter_base
Usage : $dbi->parameter_base($pobj);
Function: Get/Set Bio::ParameterBaseI.
Returns : Bio::ParameterBaseI object
Args : Bio::ParameterBaseI object
=head2 ua
Title : ua
Usage : $dbi->ua;
Function: Get/Set LWP::UserAgent.
Returns : LWP::UserAgent
Args : LWP::UserAgent
=head2 get_Response
Title : get_Response
Usage : $agent->get_Response;
Function: Get the HTTP::Response object by passing it an HTTP::Request (generated from
Bio::ParameterBaseI implementation).
Returns : HTTP::Response object or data if callback is used
Args : (optional)
-cache_response - flag to cache HTTP::Response object;
Default is 1 (TRUE, caching ON)
These are passed on to LWP::UserAgent::request() if stipulated
-cb - use a LWP::UserAgent-compliant callback
-file - dumps the response to a file (handy for large responses)
Note: can't use file and callback at the same time
lib/Bio/DB/EUtilities.pm view on Meta::CPAN
Notes : only applicable for einfo. If -file or -fh are not defined,
prints to STDOUT
=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 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
elink : from parameter_base->dbfrom or undef
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
espell : the queried database
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 (Cookie 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
Usage : $start = $qd->get_retstart();
Function : retstart setting for the query (either set or NCBI default)
Returns : Integer
Args : none
Notes : esearch : retstart
esummary : retstart
all others : from parameter_base->retstart or undef
=head2 get_retmax
Title : get_retmax
( run in 0.817 second using v1.01-cache-2.11-cpan-39bf76dae61 )