3 # BioPerl module for Bio::DB::EUtilities
5 # Cared for by Chris Fields <cjfields at uiuc dot edu>
7 # Copyright Chris Fields
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
13 # EUtil-based extension of GenericWebDBI interface
17 Bio::DB::EUtilities - webagent which interacts with and retrieves data from
26 This is a general webagent which posts and retrieves data to NCBI's eUtilities
27 service using their CGI interface.
33 User feedback is an integral part of the
34 evolution of this and other Bioperl modules. Send
35 your comments and suggestions preferably to one
36 of the Bioperl mailing lists. Your participation
39 bioperl-l@lists.open-bio.org - General discussion
40 http://www.bioperl.org/wiki/Mailing_lists - About the mailing lists
44 Report bugs to the Bioperl bug tracking system to
45 help us keep track the bugs and their resolution.
46 Bug reports can be submitted via the web.
48 http://bugzilla.open-bio.org/
52 Email cjfields at uiuc dot edu
56 The rest of the documentation details each of the
57 object methods. Internal methods are usually
62 # Let the code begin...
64 package Bio
::DB
::EUtilities
;
66 use Bio
::Tools
::EUtilities
::EUtilParameters
;
67 use Bio
::Tools
::EUtilities
;
69 use base
qw(Bio::DB::GenericWebAgent);
72 my($class,@args) = @_;
73 my $self = $class->SUPER::new
(@args);
74 my $params = Bio
::Tools
::EUtilities
::EUtilParameters
->new(-verbose
=> $self->verbose,
77 $self->parameter_base($params);
81 =head1 Bio::DB::GenericWebAgent methods
85 =head1 GenericWebDBI methods
89 Title : parameter_base
90 Usage : $dbi->parameter_base($pobj);
91 Function: Get/Set Bio::ParameterBaseI.
92 Returns : Bio::ParameterBaseI object
93 Args : Bio::ParameterBaseI object
101 Function: Get/Set LWP::UserAgent.
102 Returns : LWP::UserAgent
103 Args : LWP::UserAgent
110 Usage : $agent->get_Response;
111 Function: Get the HTTP::Response object by passing it an HTTP::Request (generated from
112 Bio::ParameterBaseI implementation).
113 Returns : HTTP::Response object or data if callback is used
116 -cache_response - flag to cache HTTP::Response object;
117 Default is 1 (TRUE, caching ON)
119 These are passed on to LWP::UserAgent::request() if stipulated
121 -file - use a LWP::UserAgent-compliant callback
122 -cb - dumps the response to a file (handy for large responses)
123 Note: can't use file and callback at the same time
124 -read_size_hint - bytes of content to read in at a time to pass to callback
125 Note : Caching and parameter checking are set
132 Usage : $secs = $self->delay([$secs])
133 Function: get/set number of seconds to delay between fetches
134 Returns : number of seconds to delay
137 NOTE: the default is to use the value specified by delay_policy().
138 This can be overridden by calling this method.
142 =head1 LWP::UserAgent related methods
147 Usage : $httpproxy = $db->proxy('http') or
148 $db->proxy(['http','ftp'], 'http://myproxy' )
149 Function: Get/Set a proxy for use of proxy
150 Returns : a string indicating the proxy
151 Args : $protocol : an array ref of the protocol(s) to set/get
152 $proxyurl : url of the proxy to use for the specified protocol
153 $username : username (if proxy requires authentication)
154 $password : password (if proxy requires authentication)
158 =head2 authentication
160 Title : authentication
161 Usage : $db->authentication($user,$pass)
162 Function: Get/Set authentication credentials
163 Returns : Array of user/pass
164 Args : Array or user/pass
171 Usage : $secs = $self->delay_policy
172 Function: return number of seconds to delay between calls to remote db
173 Returns : number of seconds to delay
176 NOTE: NCBI requests a delay of 3 seconds between requests. This method
177 implements that policy. This may change to check time of day for lengthening delays if needed
189 Usage : $agent->get_Parser;
190 Function: Retrieve the parser used for last agent request
191 Returns : The Bio::Tools::EUtilities parser used to parse the HTTP::Response
194 Note : Abstract method; defined by implementation
200 my $pobj = $self->parameter_base;
201 if ($pobj->parameters_changed || !$self->{'_parser'}) {
202 my $eutil = $pobj->eutil ;
203 if ($eutil eq 'efetch') {
204 $self->throw("No parser defined for efetch; use get_Response() directly");
206 # if we are to add pipe/tempfile support this would probably be the
207 # place to add it....
208 my $parser = Bio
::Tools
::EUtilities
->new(
210 -response
=> $self->get_Response,
211 -parameters
=> $pobj,
212 -verbose
=> $self->verbose);
213 return $self->{'_parser'} = $parser;
215 return $self->{'_parser'};
218 =head1 Bio::Tools::EUtilities::EUtilParameters-delegating methods
220 This is only a subset of parameters available from Bio::Tools::EUtilities::EUtilParameters (the
221 ones deemed absolutely necessary). All others are available by calling
222 'parameter_base-E<gt>method' when needed.
226 =head2 set_parameters
228 Title : set_parameters
229 Usage : $pobj->set_parameters(@params);
230 Function: sets the NCBI parameters listed in the hash or array
232 Args : [optional] hash or array of parameter/values.
233 Note : This sets any parameter (i.e. doesn't screen them). In addition to
234 regular eutil-specific parameters, you can set the following:
236 -eutil - the eUtil to be used (default 'efetch')
237 -history - pass a HistoryI-implementing object, which
238 sets the WebEnv, query_key, and possibly db and linkname
239 (the latter two only for LinkSets)
240 -correspondence - Boolean flag, set to TRUE or FALSE; indicates how
241 IDs are to be added together for elink request where
242 ID correspondence might be needed
248 my ($self, @args) = @_;
249 # just ensures that parser instance isn't reused
250 delete $self->{'_parser'};
251 $self->parameter_base->set_parameters(@args);
254 =head2 reset_parameters
256 Title : reset_parameters
257 Usage : resets values
258 Function: resets parameters to either undef or value in passed hash
260 Args : [optional] hash of parameter-value pairs
261 Note : this also resets eutil(), correspondence(), and the history and request
266 sub reset_parameters
{
267 my ($self, @args) = @_;
268 # just ensures that parser instance isn't reused
269 delete $self->{'_parser'};
270 $self->parameter_base->reset_parameters(@args);
273 =head2 available_parameters
275 Title : available_parameters
276 Usage : @params = $pobj->available_parameters()
277 Function: Returns a list of the available parameters
278 Returns : Array of available parameters (no values)
279 Args : [optional] A string; either eutil name (for returning eutil-specific
280 parameters) or 'history' (for those parameters allowed when retrieving
281 data stored on the remote server using a 'History' object).
285 sub available_parameters
{
286 my ($self, @args) = @_;
287 return $self->parameter_base->available_parameters(@args);
290 =head2 get_parameters
292 Title : get_parameters
293 Usage : @params = $pobj->get_parameters;
294 %params = $pobj->get_parameters;
295 Function: Returns list of key/value pairs, parameter => value
296 Returns : Flattened list of key-value pairs. All key-value pairs returned,
297 though subsets can be returned based on the '-type' parameter.
298 Data passed as an array ref are returned based on whether the
299 '-join_id' flag is set (default is the same array ref).
300 Args : -type : the eutil name or 'history', for returning a subset of
301 parameters (Default: returns all)
302 -join_ids : Boolean; join IDs based on correspondence (Default: no join)
307 my ($self, @args) = @_;
308 return $self->parameter_base->get_parameters(@args);
311 =head2 get_parameter_values
313 Title : get_parameter_values
314 Usage : @vals = $factory->get_parameter_value('id'); # always get array
315 Function: Returns the specific parameter values.
316 Returns : For consistency returns a list of values for this parameter. If only
317 one is expected, use:
319 ($val) = $factory->get_parameter_value('id');
321 Args : parameter expected
325 sub get_parameter_values
{
327 my %params = $self->parameter_base->get_parameters(-list
=> [$p]);
328 if (exists $params{$p}) {
329 return ref $params{$p} eq 'ARRAY' ? @
{$params{$p}} : $params{$p};
334 =head1 Bio::Tools::EUtilities-delegating methods
338 =head1 Bio::Tools::EUtilities::EUtilDataI methods
343 Usage : $eutil->$foo->eutil
344 Function : Get/Set eutil
346 Args : string (eutil)
347 Throws : on invalid eutil
352 my ($self, @args) = @_;
353 return $self->get_Parser->eutil(@args);
359 Usage : $type = $foo->datatype;
360 Function : Get/Set data object type
367 my ($self, @args) = @_;
368 return $self->get_Parser->datatype(@args);
374 Usage : $foo->to_string()
375 Function : converts current object to string
377 Args : (optional) simple data for text formatting
378 Note : Implemented in plugins
383 my ($self, @args) = @_;
384 return $self->get_Parser->to_string(@args);
390 Usage : $info->print_all();
391 $info->print_all(-fh => $fh, -cb => $coderef);
392 Function : prints (dumps) all data in parser. Unless a coderef is supplied,
393 this just dumps the parser-specific to_string method to either a
397 -file : file to print to
398 -fh : filehandle to print to (cannot be used concurrently with file)
399 -cb : coderef to use in place of default print method. This is passed
401 -wrap : number of columns to wrap default text output to (def = 80)
402 Notes : only applicable for einfo. If -file or -fh are not defined,
408 my ($self, @args) = @_;
409 return $self->get_Parser->print_all(@args);
412 =head1 Methods useful for multiple eutils
417 Usage : my @ids = $parser->get_ids
418 Function : returns array of requested IDs (see Notes for more specifics)
420 Args : [conditional] not required except when running elink queries against
421 multiple databases. In case of the latter, the database name is
422 optional but recommended when retrieving IDs as the ID list will
423 be globbed together. In such cases, if a db name isn't provided a
424 warning is issued as a reminder.
425 Notes : esearch : returned ID list
426 elink : returned ID list (see Args above for caveats)
427 all others : from parameter_base->id or undef
432 my ($self, @args) = @_;
433 return $self->get_Parser->get_ids(@args);
439 Usage : my $db = $info->get_database;
440 Function : returns single database name (eutil-compatible). This is the queried
441 database. For most eutils this is straightforward. For elinks
442 (which have 'db' and 'dbfrom') this is dbto, for egquery, it is the first
443 db in the list (you probably want get_databases instead)
446 Notes : egquery : first db in the query (you probably want get_databases)
447 einfo : the queried database
448 espell : the queried database
449 elink : from parameter_base->dbfrom or undef
450 all others : from parameter_base->db or undef
455 my ($self, @args) = @_;
456 return $self->get_Parser->get_database(@args);
459 =head2 get_db (alias for get_database)
464 my ($self, @args) = @_;
465 return $self->get_Parser->get_db(@args);
470 Title : get_databases
471 Usage : my @dbs = $parser->get_databases
472 Function : returns list of databases
473 Returns : array of strings
475 Notes : This is guaranteed to return a list of databases. For a single
476 database use the convenience method get_db/get_database
478 egquery : list of all databases in the query
479 einfo : the queried database
480 espell : the queried database
481 all others : from parameter_base->db or undef
486 my ($self, @args) = @_;
487 return $self->get_Parser->get_databases(@args);
490 =head2 get_dbs (alias for get_databases)
495 my ($self, @args) = @_;
496 return $self->get_Parser->get_databases(@args);
502 Usage : while (my $hist=$parser->next_History) {...}
503 Function : returns next HistoryI (if present).
504 Returns : Bio::Tools::EUtilities::HistoryI (Cookie or LinkSet)
506 Note : esearch, epost, and elink are all capable of returning data which
507 indicates search results (in the form of UIDs) is stored on the
508 remote server. Access to this data is wrapped up in simple interface
509 (HistoryI), which is implemented in two classes:
510 Bio::DB::EUtilities::History (the simplest) and
511 Bio::DB::EUtilities::LinkSet. In general, calls to epost and esearch
512 will only return a single HistoryI object (formerly known as a
513 Cookie), but calls to elink can generate many depending on the
514 number of IDs, the correspondence, etc. Hence this iterator, which
515 allows one to retrieve said data one piece at a time.
520 my ($self, @args) = @_;
521 return $self->get_Parser->next_History(@args);
524 =head2 next_cookie (alias for next_History)
529 my ($self, @args) = @_;
530 return $self->get_Parser->next_History(@args);
535 Title : get_Histories
536 Usage : my @hists = $parser->get_Histories
537 Function : returns list of HistoryI objects.
538 Returns : list of Bio::Tools::EUtilities::HistoryI (Cookie or LinkSet)
544 my ($self, @args) = @_;
545 return $self->get_Parser->get_Histories(@args);
548 =head1 Query-related methods
553 Usage : my $ct = $parser->get_count
554 Function : returns the count (hits for a search)
556 Args : [CONDITIONAL] string with database name - used to retrieve
557 count from specific database when using egquery
558 Notes : egquery : count for specified database (specified above)
559 esearch : count for last search
565 my ($self, @args) = @_;
566 return $self->get_Parser->get_count(@args);
572 Usage : $st = $qd->get_term;
573 Function : retrieve the term for the global search
576 Notes : egquery : search term
578 esearch : from parameter_base->term or undef
584 my ($self, @args) = @_;
585 return $self->get_Parser->get_term(@args);
588 =head2 get_translation_from
590 Title : get_translation_from
591 Usage : $string = $qd->get_translation_from();
592 Function: portion of the original query replaced with translated_to()
595 Note : only applicable for esearch
599 sub get_translation_from
{
600 my ($self, @args) = @_;
601 return $self->get_Parser->get_translation_from(@args);
604 =head2 get_translation_to
606 Title : get_translation_to
607 Usage : $string = $qd->get_translation_to();
608 Function: replaced string used in place of the original query term in translation_from()
611 Note : only applicable for esearch
615 sub get_translation_to
{
616 my ($self, @args) = @_;
617 return $self->get_Parser->get_translation_to(@args);
623 Usage : $start = $qd->get_retstart();
624 Function : retstart setting for the query (either set or NCBI default)
627 Notes : esearch : retstart
629 all others : from parameter_base->retstart or undef
634 my ($self, @args) = @_;
635 return $self->get_Parser->get_retstart(@args);
641 Usage : $max = $qd->get_retmax();
642 Function : retmax setting for the query (either set or NCBI default)
645 Notes : esearch : retmax
647 all others : from parameter_base->retmax or undef
652 my ($self, @args) = @_;
653 return $self->get_Parser->get_retmax(@args);
656 =head2 get_query_translation
658 Title : get_query_translation
659 Usage : $string = $qd->get_query_translation();
660 Function: returns the translated query used for the search (if any)
663 Notes : only applicable for esearch. This is the actual term used for
668 sub get_query_translation
{
669 my ($self, @args) = @_;
670 return $self->get_Parser->get_query_translation(@args);
673 =head2 get_corrected_query
675 Title : get_corrected_query
676 Usage : my $cor = $eutil->get_corrected_query;
677 Function : retrieves the corrected query when using espell
680 Notes : only applicable for espell.
684 sub get_corrected_query
{
685 my ($self, @args) = @_;
686 return $self->get_Parser->get_corrected_query(@args);
689 =head2 get_replaced_terms
691 Title : get_replaced_terms
692 Usage : my $term = $eutil->get_replaced_term
693 Function : returns array of strings replaced in the query
696 Notes : only applicable for espell
700 sub get_replaced_terms
{
701 my ($self, @args) = @_;
702 return $self->get_Parser->get_replaced_terms(@args);
705 =head2 next_GlobalQuery
707 Title : next_GlobalQuery
708 Usage : while (my $query = $eutil->next_GlobalQuery) {...}
709 Function : iterates through the queries returned from an egquery search
710 Returns : GlobalQuery object
712 Notes : only applicable for egquery
716 sub next_GlobalQuery
{
717 my ($self, @args) = @_;
718 return $self->get_Parser->next_GlobalQuery(@args);
721 =head2 get_GlobalQueries
723 Title : get_GlobalQueries
724 Usage : @queries = $eutil->get_GlobalQueries
725 Function : returns list of GlobalQuery objects
726 Returns : array of GlobalQuery objects
728 Notes : only applicable for egquery
732 sub get_GlobalQueries
{
733 my ($self, @args) = @_;
734 return $self->get_Parser->get_GlobalQueries(@args);
737 =head2 print_GlobalQueries
739 Title : print_GlobalQueries
740 Usage : $docsum->print_GlobalQueries();
741 $docsum->print_GlobalQueries(-fh => $fh, -cb => $coderef);
742 Function : prints item data for all global queries. The default printing
743 method is each item per DocSum is printed with relevant values if
744 present in a simple table using Text::Wrap.
747 -file : file to print to
748 -fh : filehandle to print to (cannot be used concurrently with file)
749 -cb : coderef to use in place of default print method. This is passed
750 in a GlobalQuery object;
751 -wrap : number of columns to wrap default text output to (def = 80)
752 Notes : only applicable for esummary. If -file or -fh are not defined,
757 sub print_GlobalQueries
{
758 my ($self, @args) = @_;
759 return $self->get_Parser->print_GlobalQueries(@args);
762 =head1 Summary-related methods
767 Usage : while (my $ds = $esum->next_DocSum) {...}
768 Function : iterate through DocSum instances
769 Returns : single Bio::Tools::EUtilities::Summary::DocSum
771 Notes : only applicable for esummary
776 my ($self, @args) = @_;
777 return $self->get_Parser->next_DocSum(@args);
783 Usage : my @docsums = $esum->get_DocSums
784 Function : retrieve a list of DocSum instances
785 Returns : array of Bio::Tools::EUtilities::Summary::DocSum
787 Notes : only applicable for esummary
792 my ($self, @args) = @_;
793 return $self->get_Parser->get_DocSums(@args);
798 Title : print_DocSums
799 Usage : $docsum->print_DocSums();
800 $docsum->print_DocSums(-fh => $fh, -cb => $coderef);
801 Function : prints item data for all docsums. The default printing method is
802 each item per DocSum is printed with relevant values if present
803 in a simple table using Text::Wrap.
806 -file : file to print to
807 -fh : filehandle to print to (cannot be used concurrently with file)
808 -cb : coderef to use in place of default print method. This is passed
810 -wrap : number of columns to wrap default text output to (def = 80)
811 Notes : only applicable for esummary. If -file or -fh are not defined,
817 my ($self, @args) = @_;
818 return $self->get_Parser->print_DocSums(@args);
821 =head1 Info-related methods
823 =head2 get_available_databases
825 Title : get_available_databases
826 Usage : my @dbs = $info->get_available_databases
827 Function : returns list of available eutil-compatible database names
828 Returns : Array of strings
830 Notes : only applicable for einfo.
834 sub get_available_databases
{
835 my ($self, @args) = @_;
836 return $self->get_Parser->get_available_databases(@args);
839 =head2 get_record_count
841 Title : get_record_count
842 Usage : my $ct = $eutil->get_record_count;
843 Function : returns database record count
846 Notes : only applicable for einfo.
850 sub get_record_count
{
851 my ($self, @args) = @_;
852 return $self->get_Parser->get_record_count(@args);
855 =head2 get_last_update
857 Title : get_last_update
858 Usage : my $time = $info->get_last_update;
859 Function : returns string containing time/date stamp for last database update
862 Notes : only applicable for einfo.
866 sub get_last_update
{
867 my ($self, @args) = @_;
868 return $self->get_Parser->get_last_update(@args);
873 Title : get_menu_name
874 Usage : my $nm = $info->get_menu_name;
875 Function : returns string of database menu name
878 Notes : only applicable for einfo.
883 my ($self, @args) = @_;
884 return $self->get_Parser->get_menu_name(@args);
887 =head2 get_description
889 Title : get_description
890 Usage : my $desc = $info->get_description;
891 Function : returns database description
894 Notes : only applicable for einfo.
898 sub get_description
{
899 my ($self, @args) = @_;
900 return $self->get_Parser->get_description(@args);
903 =head2 next_FieldInfo
905 Title : next_FieldInfo
906 Usage : while (my $field = $info->next_FieldInfo) {...}
907 Function : iterate through FieldInfo objects
908 Returns : Field object
910 Notes : only applicable for einfo. Uses callback() for filtering if defined
916 my ($self, @args) = @_;
917 return $self->get_Parser->next_FieldInfo(@args);
922 Title : get_FieldInfo
923 Usage : my @fields = $info->get_FieldInfo;
924 Function : returns list of FieldInfo objects
925 Returns : array (FieldInfo objects)
927 Notes : only applicable for einfo.
932 my ($self, @args) = @_;
933 return $self->get_Parser->get_FieldInfo(@args);
936 *get_FieldInfos
= \
&get_FieldInfo
;
940 Title : next_LinkInfo
941 Usage : while (my $link = $info->next_LinkInfo) {...}
942 Function : iterate through LinkInfo objects
943 Returns : LinkInfo object
945 Notes : only applicable for einfo. Uses callback() for filtering if defined
951 my ($self, @args) = @_;
952 return $self->get_Parser->next_LinkInfo(@args);
958 Usage : my @links = $info->get_LinkInfo;
959 Function : returns list of LinkInfo objects
960 Returns : array (LinkInfo objects)
962 Notes : only applicable for einfo.
967 my ($self, @args) = @_;
968 return $self->get_Parser->get_LinkInfo(@args);
971 *get_LinkInfos
= \
&get_LinkInfo
;
973 =head2 print_FieldInfo
975 Title : print_FieldInfo
976 Usage : $info->print_FieldInfo();
977 $info->print_FieldInfo(-fh => $fh, -cb => $coderef);
978 Function : prints field data for each FieldInfo object. The default method
979 prints data from each FieldInfo in a simple table using Text::Wrap.
982 -file : file to print to
983 -fh : filehandle to print to (cannot be used concurrently with file)
984 -cb : coderef to use in place of default print method.
985 -wrap : number of columns to wrap default text output to (def = 80)
986 Note : if -file or -fh are not defined, prints to STDOUT
990 sub print_FieldInfo
{
991 my ($self, @args) = @_;
992 return $self->get_Parser->print_FieldInfo(@args);
995 =head2 print_LinkInfo
997 Title : print_LinkInfo
998 Usage : $info->print_LinkInfo();
999 $info->print_LinkInfo(-fh => $fh, -cb => $coderef);
1000 Function : prints link data for each LinkInfo object. The default is generated
1001 via LinkInfo::to_string
1004 -file : file to print to
1005 -fh : filehandle to print to (cannot be used concurrently with file)
1006 -cb : coderef to use in place of default print method. This is passed
1007 in a LinkInfo object;
1008 -wrap : number of columns to wrap default text output to (def = 80)
1009 Notes : only applicable for einfo. If -file or -fh are not defined,
1014 sub print_LinkInfo
{
1015 my ($self, @args) = @_;
1016 return $self->get_Parser->print_LinkInfo(@args);
1019 =head1 Bio::Tools::EUtilities::Link-related methods
1023 Title : next_LinkSet
1024 Usage : while (my $ls = $eutil->next_LinkSet {...}
1025 Function : iterate through LinkSet objects
1026 Returns : LinkSet object
1028 Notes : only applicable for elink. Uses callback() for filtering if defined
1034 my ($self, @args) = @_;
1035 return $self->get_Parser->next_LinkSet(@args);
1040 Title : get_LinkSets
1041 Usage : my @links = $info->get_LinkSets;
1042 Function : returns list of LinkSets objects
1043 Returns : array (LinkSet objects)
1045 Notes : only applicable for elink.
1049 # add support for retrieval of data if lazy parsing is enacted
1052 my ($self, @args) = @_;
1053 return $self->get_Parser->get_LinkSets(@args);
1056 =head2 print_LinkSets
1058 Title : print_LinkSets
1059 Usage : $info->print_LinkSets();
1060 $info->print_LinkSets(-fh => $fh, -cb => $coderef);
1061 Function : prints link data for each LinkSet object. The default is generated
1062 via LinkSet::to_string
1065 -file : file to print to
1066 -fh : filehandle to print to (cannot be used concurrently with file)
1067 -cb : coderef to use in place of default print method. This is passed
1069 -wrap : number of columns to wrap default text output to (def = 80)
1070 Notes : only applicable for einfo. If -file or -fh are not defined,
1075 sub print_LinkSets
{
1076 my ($self, @args) = @_;
1077 return $self->get_Parser->print_LinkSets(@args);
1080 =head2 get_linked_databases
1082 Title : get_linked_databases
1083 Usage : my @dbs = $eutil->get_linked_databases
1084 Function : returns list of databases linked to in linksets
1085 Returns : array of databases
1087 Notes : only applicable for elink.
1091 sub get_linked_databases
{
1092 my ($self, @args) = @_;
1093 return $self->get_Parser->get_linked_databases(@args);
1096 =head1 Iterator- and callback-related methods
1103 Usage : $esum->rewind()
1104 $esum->rewind('recursive')
1105 Function : retrieve a list of DocSum instances
1106 Returns : array of Bio::Tools::EUtilities::Summary::DocSum
1107 Args : [optional] Scalar; string ('all') to reset all iterators, or string
1108 describing the specific main object iterator to reset. The following
1109 are recognized (case-insensitive):
1111 'all' - rewind all objects and also recursively resets nested object
1112 interators (such as LinkSets and DocSums).
1114 'fieldinfo' or 'fieldinfos'
1115 'linkinfo' or 'linkinfos'
1122 my ($self, $string) = @_;
1123 return $self->get_Parser->rewind($string);
1126 =head2 generate_iterator
1128 Title : generate_iterator
1129 Usage : my $coderef = $esum->generate_iterator('linkinfo')
1130 Function : generates an iterator (code reference) which iterates through
1131 the relevant object indicated by the args
1132 Returns : code reference
1133 Args : [REQUIRED] Scalar; string describing the specific object to iterate.
1134 The following are currently recognized (case-insensitive):
1137 'fieldinfo' or 'fieldinfos'
1138 'linkinfo' or 'linkinfos'
1142 A second argument can also be passed to generate a 'lazy' iterator,
1143 which loops through and returns objects as they are created (instead
1144 of creating all data instances up front, then iterating through,
1145 which is the default). Use of these iterators precludes use of
1146 rewind() for the time being as we can't guarantee you can rewind(),
1147 as this depends on whether the data source is seek()able and thus
1148 'rewindable'. We will add rewind() support at a later time which
1149 will work for 'seekable' data.
1151 A callback specified using callback() will be used to filter objects
1152 for any generated iterator. This behaviour is implemented for both
1153 normal and lazy iterator types and is the default. If you don't want
1154 this, make sure to reset any previously set callbacks via
1155 reset_callback() (which just deletes the code ref).
1156 TODO : generate seekable iterators ala HOP for seekable fh data
1160 sub generate_iterator
{
1161 my ($self, @args) = @_;
1162 return $self->get_Parser->generate_iterator(@args);
1168 Usage : $parser->callback(sub {$_[0]->get_database eq 'protein'});
1169 Function : Get/set callback code ref used to filter returned data objects
1170 Returns : code ref if previously set
1171 Args : single argument:
1172 code ref - evaluates a passed object and returns true or false value
1174 'reset' - string, resets the iterator.
1175 returns upon any other args
1180 my ($self, @args) = @_;
1181 return $self->get_Parser->callback(@args);