[Bioperl-guts-l] bioperl-live/Bio/Tools/EUtilities History.pm, 1.1, 1.2 Info.pm, 1.1, 1.2 Link.pm, 1.1, 1.2 Query.pm, 1.1, 1.2 Summary.pm, 1.1, 1.2

Christopher John Fields cjfields at dev.open-bio.org
Sun Jun 24 23:43:32 EDT 2007


Update of /home/repository/bioperl/bioperl-live/Bio/Tools/EUtilities
In directory dev.open-bio.org:/tmp/cvs-serv11600/EUtilities

Modified Files:
	History.pm Info.pm Link.pm Query.pm Summary.pm 
Log Message:
Cleaning up API, need to clean up POD and make callbacks more consistent

Index: History.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/Tools/EUtilities/History.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** History.pm	23 Jun 2007 04:43:04 -0000	1.1
--- History.pm	25 Jun 2007 03:43:29 -0000	1.2
***************
*** 82,86 ****
  #use URI::Escape qw(uri_unescape); 
  
! use base qw(Bio::Tools::EUtilities Bio::Tools::EUtilities::HistoryI);
  
  =head2 history
--- 82,91 ----
  #use URI::Escape qw(uri_unescape); 
  
! use base qw(Bio::Tools::EUtilities);
! 
! =head1 Bio::Tools::EUtilities::History relevant methods
! 
! These are inherited through the Bio::Tools::EUtilities interface
! Bio::Tools::EUtilities::HistoryI
  
  =head2 history

Index: Info.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/Tools/EUtilities/Info.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Info.pm	23 Jun 2007 04:43:04 -0000	1.1
--- Info.pm	25 Jun 2007 03:43:29 -0000	1.2
***************
*** 131,155 ****
  use Bio::Tools::EUtilities::Info::FieldInfo;
  
! =head2 new
! 
!  Title    : new
!  Usage    : ***Should not be used directly; instance generated as follows***
!             my $info = Bio::Tools::EUtilities->new(-eutil => 'einfo',
!                                                 -datatype => 'base');
!  Function : create new Bio::Tools::EUtilities::Info data instance
!  Returns  : new Bio::Tools::EUtilities::Info object based on type
!  Args     : [REQUIRED] -datatype : string, 'info', 'field', 'link'
! 
! =cut
! 
! =head1 Bio::Tools::EUtilities::EUtilDataI methods
  
! See Bio::Tools::EUtilities::EUtilDataI for details
  
  =cut
  
- =head2 add_data
  
! =cut
  
  sub _add_data {
--- 131,150 ----
  use Bio::Tools::EUtilities::Info::FieldInfo;
  
! =head2 rewind
  
!  Title    : rewind
!  Usage    : $info->rewind() # rewinds all (default)
!             $info->rewind('links') # rewinds only links
!  Function : 'rewinds' (resets) specified interators (all if no arg)
!  Returns  : none
!  Args     : [OPTIONAL] String: 
!             'all'    - all iterators (default)
!             'linkinfo'  - LinkInfo objects only
!             'fieldinfo' - FieldInfo objects only
  
  =cut
  
  
! # private EUtilDataI method
  
  sub _add_data {
***************
*** 189,453 ****
  }
  
- =head2 eutil
- 
-  Title    : eutil
-  Usage    : $eutil->$foo->eutil
-  Function : Get/Set eutil
-  Returns  : string
-  Args     : string (eutil)
-  Throws   : on invalid eutil
-  
- =cut
- 
- =head2 datatype
- 
-  Title    : datatype
-  Usage    : $type = $foo->datatype;
-  Function : Get/Set data object type
-  Returns  : string
-  Args     : string
- 
- =cut
- 
- =head1 Bio::Tools::EUtilities::Info methods
- 
- =head2 get_available_databases
- 
-  Title    : get_available_databases
-  Usage    : my @dbs = $info->get_available_databases
-  Function : returns list of available eutil-compatible database names
-  Returns  : Array of strings 
-  Args     : none
- 
- =cut
- 
- sub get_available_databases {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;
-     ($self->{'_available_databases'}) ?
-         return @{($self->{'_available_databases'})} :
-         return ();
- }
- 
- =head2 get_record_count
- 
-  Title    : get_record_count
-  Usage    : my $ct = $eutil->get_record_count;
-  Function : returns database record count
-  Returns  : integer
-  Args     : none
- 
- =cut
- 
- sub get_record_count {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;
-     return $self->{'_count'}
- }
- 
- =head2 get_last_update
- 
-  Title    : get_last_update
-  Usage    : my $time = $info->get_last_update;
-  Function : returns string containing time/date stamp for last database update
-  Returns  : integer
-  Args     : none
- 
- =cut
- 
- sub get_last_update {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;
-     return $self->{'_lastupdate'}
- }
- 
- =head2 get_menu_name
- 
-  Title    : get_menu_name
-  Usage    : my $nm = $info->get_menu_name;
-  Function : returns string of database menu name
-  Returns  : string
-  Args     : none
-  
- =cut
- 
- sub get_menu_name {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;    
-     exists $self->{'_menuname'} ? return $self->{'_menuname'} :
-     exists $self->{'_menu'} ? return $self->{'_menu'} :
-     return;
- }
- 
- =head2 get_description
- 
-  Title    : get_description
-  Usage    : my $desc = $info->get_description;
-  Function : returns database description
-  Returns  : string
-  Args     : none
- 
- =cut
- 
- sub get_description {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;        
-     return $self->{'_description'};
- }
- 
- =head2 get_db
- 
-  Title    : get_db
-  Usage    : my $db = $info->get_db;
-  Function : returns database name (eutil-compatible)
-  Returns  : string
-  Args     : none
-  
- =cut
- 
- sub get_db {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;
-     return $self->{'_dbname'};
- }
- 
- =head2 get_database
- 
-  Title    : get_database
-  Usage    : my $db = $eutil->get_database;
-  Note     : alias for get_db()
- 
- =cut
- 
- *get_database = \&get_db;
- 
- =head2 next_FieldInfo
- 
-  Title    : next_FieldInfo
-  Usage    : while (my $field = $info->next_FieldInfo) {...}
-  Function : iterate through FieldInfo objects
-  Returns  : Field object
-  Args     : none
-  Note     : uses callback() for filtering if defined for 'fields'
-  
- =cut
- 
- sub next_FieldInfo {
-     my ($self, $cb) = @_;
-     unless ($self->{'_fieldinfo_it'}) {
-         $self->throw("Callback must be a code reference")
-             if $cb && ref $cb ne 'CODE';
-         my $fieldcount = $self->get_FieldInfo;
-         my $current = 0;
-         $self->{"_fieldinfo_it"} = sub {
-             while ($current < $fieldcount) {
-                 if ($cb) {
-                     $cb->($self->{'_fieldinfo'}->[$current++]) ?
-                     return $self->{'_fieldinfo'}->[$current] :
-                     next;
-                 } else {
-                     return $self->{'_fieldinfo'}->[$current++]
-                 }
-             }
-         }
-     }    
-     $self->{'_fieldinfo_it'}->(); 
- }
- 
- =head2 get_FieldInfo
- 
-  Title    : get_FieldInfo
-  Usage    : my @fields = $info->get_FieldInfo;
-  Function : returns list of FieldInfo objects
-  Returns  : array (FieldInfo objects)
-  Args     : none
- 
- =cut
- 
- sub get_FieldInfo {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;        
-     return ref $self->{'_fieldinfo'} ? @{ $self->{'_fieldinfo'} } : return 0;
- }
- 
- =head2 next_LinkInfo
- 
-  Title    : next_LinkInfo
-  Usage    : while (my $link = $info->next_LinkInfo) {...}
-  Function : iterate through LinkInfo objects
-  Returns  : LinkInfo object
-  Args     : [OPTIONAL] callback; checks object and returns TRUE if wanted
-  Note     : uses callback() for filtering if defined for 'links'
-  
- =cut
- 
- sub next_LinkInfo {
-     my $self = shift;
-     unless ($self->{'_linkinfo_it'}) {
-         my $cb;
-         $self->throw("Callback must be a code reference")
-             if $cb && ref $cb ne 'CODE';
-         my $linkcount = $self->get_LinkInfo;
-         my $current = 0;
-         $self->{"_linkinfo_it"} = sub {
-             while ($current < $linkcount) {
-                 if ($cb) {
-                     $cb->($self->{'_linkinfo'}->[$current++]) ?
-                     return $self->{'_linkinfo'}->[$current] :
-                     next;
-                 } else {
-                     return $self->{'_linkinfo'}->[$current++]
-                 }
-             }
-         }
-     }    
-     $self->{'_linkinfo_it'}->();    
- }
- 
- =head2 get_LinkInfo
- 
-  Title    : get_LinkInfo
-  Usage    : my @links = $info->get_LinkInfo;
-  Function : returns list of LinkInfo objects
-  Returns  : array (LinkInfo objects)
-  Args     : none
- 
- =cut
- 
- sub get_LinkInfo {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;        
-     return ref $self->{'_linkinfo'} ? @{ $self->{'_linkinfo'} } : return 0;
- }
- 
- =head2 rewind
- 
-  Title    : rewind
-  Usage    : $info->rewind() # rewinds all (default)
-             $info->rewind('links') # rewinds only links
-  Function : 'rewinds' (resets) specified interators (all if no arg)
-  Returns  : none
-  Args     : [OPTIONAL] String: 
-             'all'    - all iterators (default)
-             'links'  - link objects only
-             'fields' - field objects only
- 
- =cut
- 
- {
-     my %VALID_DATA = ('links' => 'linkinfo',
-                       'fields' => 'fieldinfo');
-     
-     sub rewind {
-         my ($self, $arg) = @_;
-         $arg ||= 'all';
-         if (exists $VALID_DATA{$arg}) {
-             delete $self->{"_$VALID_DATA{$arg}_it"};
-         } elsif ($arg eq 'all') {
-             delete $self->{'_'.$_.'_it'} for values %VALID_DATA;
-         }
-     }
- }
- 
  1;
  
--- 184,187 ----

Index: Summary.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/Tools/EUtilities/Summary.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Summary.pm	23 Jun 2007 04:43:04 -0000	1.1
--- Summary.pm	25 Jun 2007 03:43:29 -0000	1.2
***************
*** 86,170 ****
  use Bio::Tools::EUtilities::Summary::DocSum;
  
- =head2 get_ids
- 
-  Title    : get_ids
-  Usage    : @ids = $esum->get_ids
-  Function : returns array or array ref of IDs
-  Returns  : array or array ref of IDs (depending on wantarray)
-  Args     : none
- 
- =cut
- 
- sub get_ids {
-     my $self = shift;
-     unless (exists $self->{'_id'}) {
-         push @{$self->{'_id'}}, map {$_->get_id } $self->get_DocSums;
-     }
-     return wantarray ? @{$self->{'_id'}} : $self->{'_id'};
- }
- 
- =head2 next_DocSum
- 
-  Title    : next_DocSum
-  Usage    : while (my $ds = $esum->next_DocSum) {...}
-  Function : iterate through DocSum instances
-  Returns  : single Bio::Tools::EUtilities::Summary::DocSum
-  Args     : none yet
- 
- =cut
- 
- # add an option (?) for lazy parsing via fh (which allows tempfile or piping)
- # add data to Simple object in chunks, create DocSum, return
- 
- # maybe allow callback to only return interesting DocSums?
- 
- sub next_DocSum {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;
-     unless ($self->{"_docsums_it"}) {
-         my @docsums = $self->get_DocSums;
-         $self->{"_docsums_it"} = sub {return shift @docsums}
-     }
-     $self->{'_docsums_it'}->();
- }
- 
- =head2 get_DocSums
- 
-  Title    : get_DocSums
-  Usage    : my @docsums = $esum->get_DocSums
-  Function : retrieve a list of DocSum instances
-  Returns  : array of Bio::Tools::EUtilities::Summary::DocSum
-  Args     : none
- 
- =cut
- 
- sub get_DocSums {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;
-     # always return a list for consistency...
-     return ref $self->{'_docsums'} ? @{ $self->{'_docsums'} } : return ();
- }
- 
- =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]
-            'recursive' - rewind all DocSum object layers
-                          (Items, ListItems, StructureItems)
- 
- =cut
- 
- sub rewind {
-     my ($self, $request) = @_;
-     if ($request && $request eq 'recursive') {
-         map {$_->rewind('recursive') } $self->get_DocSums;
-     }
-     delete $self->{"_docsums_it"};
- }
- 
  # private EUtilDataI method
  
--- 86,89 ----

Index: Link.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/Tools/EUtilities/Link.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Link.pm	23 Jun 2007 04:43:04 -0000	1.1
--- Link.pm	25 Jun 2007 03:43:29 -0000	1.2
***************
*** 69,184 ****
  use Bio::Tools::EUtilities::Link::LinkSet;
  
! =head2 get_ids
! 
!  Title    : get_ids
!  Usage    : my @ids = $eutil->get_ids
!  Function : returns list of retrieved IDs
!  Returns  : array or array ref of IDs
!  Args     : [optional] a single string (database name) or a callback (code ref)
!             which is passed the LinkSet.
!             
!             In most cases no arg is needed. However when multiple databases are
!             queried each search returns a LinkSet with it's own database, IDs,
!             linkname, etc., with some databases reporting back more than one
!             group of IDs (eg more than one linkset).
! 
! =cut
! 
! sub get_ids {
!     my ($self, $request) = @_;
!     $self->parse_data unless $self->data_parsed;
!     my @ids;
!     if ($request) {
!         if (ref $request eq 'CODE') {
!             push @ids, map {$_->get_ids }
!                 grep { $request->($_) } $self->get_LinkSets;
!         } else {
!             push @ids, map {$_->get_ids }
!                 grep {$_->get_dbto eq $request} $self->get_LinkSets;
!         }
!     } else {
!         $self->warn('Multiple database present, IDs will be globbed together')
!             if $self->get_dbs > 1;
!         push @ids, map {$_->get_ids } $self->get_LinkSets;
!     }
!     return wantarray ? @ids : \@ids;
! }
! 
! =head2 get_dbs
! 
!  Title    : get_dbs
!  Usage    : my @dbs = $eutil->get_dbs
!  Function : returns list of databases linked to in linksets
!  Returns  : array of databases
!  Args     : none
! 
! =cut
! 
! sub get_dbs {
!     my $self = shift;
!     $self->parse_data unless $self->data_parsed;
!     unless (exists $self->{'_db'}) {
!         my %temp;
!         # make sure unique db is returned
!         # do the linksets have a db? (URLs, db checks do not)
!         
!         push @{$self->{'_db'}}, map {$_->get_dbto}
!             grep { $_->get_dbto ? !$temp{$_->get_dbto}++: 0 } $self->get_LinkSets;
!     }
!     return @{$self->{'_db'}};
! }
! 
! =head2 next_LinkSet
! 
!  Title    : next_LinkSet
!  Usage    : 
!  Function : 
!  Returns  : 
!  Args     : 
! 
! =cut
! 
! sub next_LinkSet {
!     my $self = shift;
!     $self->parse_data unless $self->data_parsed;
!     unless ($self->{"_linksets_it"}) {
!         my @ls = $self->get_LinkSets;
!         $self->{"_linksets_it"} = sub {return shift @ls}
!     }
!     $self->{'_linksets_it'}->();
! }
! 
! =head2 get_LinkSets
! 
!  Title    : get_LinkSets
!  Usage    : 
!  Function : 
!  Returns  : 
!  Args     : 
! 
! =cut
! 
! # add support for retrieval of data if lazy parsing is enacted
! 
! sub get_LinkSets {
!     my $self = shift;
!     $self->parse_data unless $self->data_parsed;
!     return ref $self->{'_linksets'} ? @{ $self->{'_linksets'} } : return;
! }
! 
! =head2 rewind
! 
!  Title    : rewind
!  Usage    : 
!  Function : 
!  Returns  : 
!  Args     : 
! 
! =cut
! 
! sub rewind {
!     my $self = shift;
!     delete $self->{'_linksets_it'}
! }
  
  {
--- 69,73 ----
  use Bio::Tools::EUtilities::Link::LinkSet;
  
! # private EUtilDataI method
  
  {
***************
*** 197,201 ****
          for my $ls (@{ $data->{LinkSet} }) {
              my $subclass;
!             # caching for efficiency
              if (!exists $self->{'_subclass_type'}) {
                  ($subclass) = grep { exists $ls->{$_} } qw(LinkSetDb LinkSetDbHistory IdUrlList IdCheckList);
--- 86,90 ----
          for my $ls (@{ $data->{LinkSet} }) {
              my $subclass;
!             # caching for efficiency; no need to recheck
              if (!exists $self->{'_subclass_type'}) {
                  ($subclass) = grep { exists $ls->{$_} } qw(LinkSetDb LinkSetDbHistory IdUrlList IdCheckList);

Index: Query.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/Tools/EUtilities/Query.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Query.pm	23 Jun 2007 04:43:04 -0000	1.1
--- Query.pm	25 Jun 2007 03:43:29 -0000	1.2
***************
*** 76,94 ****
  use warnings;
  
! use base qw(Bio::Tools::EUtilities Bio::Tools::EUtilities::HistoryI);
  
  use Bio::Tools::EUtilities::Query::GlobalQuery;
  
! =head1 Bio::Tools::EUtilities::EUtilDataI methods
! 
! See Bio::Tools::EUtilities::EUtilDataI for more details
  
  =cut
  
  {
  my %TYPE = (
      'espell'    => 'spelling',
!     'esearch'   => 'simple',
!     'egquery'   => 'base',
      );
  
--- 76,94 ----
  use warnings;
  
! use base qw(Bio::Tools::EUtilities);
  
  use Bio::Tools::EUtilities::Query::GlobalQuery;
  
! =head1 Bio::Tools::EUtilities::Query methods
  
  =cut
  
+ # private EUtilDataI method
+ 
  {
  my %TYPE = (
      'espell'    => 'spelling',
!     'esearch'   => 'singledbquery',
!     'egquery'   => 'multidbquery',
      );
  
***************
*** 130,433 ****
  }
  
- =head1 Bio::Tools::EUtilities::HistoryI methods
- 
- =head2 history
- 
-  Title    : history
-  Usage    : my ($webenv, $qk) = $hist->history
-  Function : returns two-element list of webenv() and query_key()
-  Returns  : array
-  Args     : none
- 
- =cut
- 
- =head2 get_webenv
- 
-  Title    : get_webenv
-  Usage    : my $webenv = $hist->get_webenv
-  Function : returns web environment key needed to retrieve results from
-             NCBI server
-  Returns  : string (encoded key)
-  Args     : none
- 
- =cut
- 
- =head2 get_query_key
- 
-  Title    : get_query_key
-  Usage    : my $qk = $hist->get_query_key
-  Function : returns query key (integer) for the history number for this session
-  Returns  : integer
-  Args     : none
- 
- =cut
- 
- =head2 has_history
- 
-  Title    : has_history
-  Usage    : if ($hist->has_history) {...}
-  Function : returns TRUE if full history (webenv, query_key) is present 
-  Returns  : BOOLEAN, value eval'ing to TRUE or FALUE
-  Args     : none
- 
- =cut
- 
- =head1 Bio::Tools::EUtilities::Query methods
- 
- =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] not needed in most cases; required when using egquery
-             to retrieve the count for a particular database
- 
- =cut
- 
- # egquery and espell
- 
- sub get_count {
-     my ($self, @args) = @_;
-     $self->parse_data unless $self->data_parsed;
-     return $self->{'_count'};
- }
- 
- =head2 get_ids
- 
-  Title    : get_ids
-  Usage    : my @ids = $parser->get_ids
-  Function : returns array or array ref of IDs
-  Returns  : array or array ref (based on wantarray)
-  Args     : none
- 
- =cut
- 
- # egquery and espell
- 
- sub get_ids {
-     my ($self, @args) = @_;
-     $self->parse_data unless $self->data_parsed;
-     return wantarray && $self->{'_id'} ? @{ $self->{'_id'} } : $self->{'_id'} ;
- }
- 
- =head2 get_term
- 
-  Title   : get_term
-  Usage   : $st = $qd->get_term;
-  Function: retrieve the term for the global search
-  Returns : string
-  Args    : none
- 
- =cut
- 
- sub get_term {
-     my ($self, @args) = @_;
-     $self->parse_data unless $self->data_parsed;
-     return $self->{'_term'};
- }
- 
- =head2 get_database
- 
-  Title   : get_database
-  Usage   : $ct = $qd->get_database;
-  Function: retrieve the database
-  Returns : string
-  Args    : none
- 
- =cut
- 
- sub get_database {
-     my ($self) = @_;
-     $self->parse_data unless $self->data_parsed;
-     $self->{'_database'};
- }
- 
- =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
- 
- =cut
- 
- # esearch
- 
- sub get_translation_from {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;
-     return $self->{'_translation'}->{From};
- }
- 
- =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
- 
- =cut
- 
- sub get_translation_to {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;
-     return $self->{'_translation'}->{To};
- }
- 
- =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
- 
- =cut
- 
- sub get_retstart {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;    
-     return $self->{'_retstart'};
- }
- 
- =head2 get_retmax
- 
-  Title   : get_retmax
-  Usage   : $max = $qd->get_retmax();
-  Function: retmax setting for the query (either set or NCBI default)
-  Returns : Integer
-  Args    : none
- 
- =cut
- 
- sub get_retmax {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;    
-     return $self->{'_retmax'};
- }
- 
- =head2 get_query_translation
- 
-  Title   : get_query_translation
-  Usage   : $string = $qd->get_query_translation();
-  Function: returns the translated query used for the search (if any)
-  Returns : string
-  Args    : none
-  Note    : this differs from the original term.
- 
- =cut
- 
- sub get_query_translation {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;
-     return $self->{'_querytranslation'};
- }
- 
- =head2 get_corrected_query
- 
-  Title    : get_corrected_query
-  Usage    : my $cor = $eutil->get_corrected_query;
-  Function : retrieves the corrected query when using espell
-  Returns  : string 
-  Args     : none
- 
- =cut
- 
- sub get_corrected_query {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;
-     return $self->{'_correctedquery'};
- }
- 
- =head2 get_replaced_terms
- 
-  Title    : get_replaced_terms
-  Usage    : my $term = $eutil->get_replaced_term
-  Function : returns array of strings replaced in the query
-  Returns  : string 
-  Args     : none
- 
- =cut
- 
- sub get_replaced_terms {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;
-     if ($self->{'_spelledquery'} && $self->{'_spelledquery'}->{Replaced}) {
-         ref $self->{'_spelledquery'}->{Replaced} ?
-         return @{ $self->{'_spelledquery'}->{Replaced} } : return;
-     }
- }
- 
- =head2 next_GlobalQuery
- 
-  Title    : next_GlobalQuery
-  Usage    : while (my $query = $eutil->next_GlobalQuery) {...}
-  Function : iterates through the queries returned from an egquery search
-  Returns  : GlobalQuery object
-  Args     : none
- 
- =cut
- 
- sub next_GlobalQuery {
-     my $self = shift;
-     unless ($self->{'_globalqueries_it'}) {
-         my $cb = $self->{"_globalqueries_cb"};
-         $self->throw("Callback must be a code reference")
-             if $cb && ref $cb ne 'CODE';
-         my $qcount = $self->get_GlobalQueries;
-         my $current = 0;
-         $self->{"_globalqueries_it"} = sub {
-             while ($current < $qcount) {
-                 if ($cb) {
-                     $cb->($self->{'_globalqueries'}->[$current++]) ?
-                     return $self->{'_globalqueries'}->[$current] :
-                     next;
-                 } else {
-                     return $self->{'_globalqueries'}->[$current++]
-                 }
-             }
-         }
-     }    
-     $self->{'_globalqueries_it'}->();
- }
- 
- =head2 get_GlobalQueries
- 
-  Title    : get_GlobalQueries
-  Usage    : @queries = $eutil->get_GlobalQueries
-  Function : returns list of GlobalQuery objects
-  Returns  : array of GlobalQuery objects
-  Args     : none
- 
- =cut
- 
- sub get_GlobalQueries {
-     my $self = shift;
-     $self->parse_data unless $self->data_parsed;
-     ref $self->{'_globalqueries'} ? return @{ $self->{'_globalqueries'} } : return ();
- }
- 
- =head2 rewind
- 
-  Title    : rewind
-  Usage    : $eutil->rewind;
-  Function : rewinds the globalquery iterator if present
-  Returns  : none
-  Args     : none
- 
- =cut
- 
- sub rewind {
-     my $self = shift;
-     delete $self->{'_globalqueries_it'};
- }
- 
- 
- 
  1;
  
--- 130,133 ----



More information about the Bioperl-guts-l mailing list