Updates:
[bioperl-live.git] / Bio / Tools / EUtilities / Cookie.pm
blob9e219488391a8983e2c88ff8630dc8297aea6df0
1 # $Id$
3 # BioPerl module for Bio::Tools::EUtilities::Cookie
5 # Cared for by Chris Fields
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 # Part of the EUtilities BioPerl package
15 =head1 NAME
17 Bio::Tools::EUtilities::Cookie - lightweight implementation of HistoryI
18 interface (not bound to filehandles, extraneous methods, etc).
20 =head1 SYNOPSIS
22 #should work for any class which is-a HistoryI
24 if ($obj->has_History) {
25 # do something here
28 ($webenv, $querykey) = $obj->history;
30 $obj->history($webenv, $querykey);
32 $webenv = $obj->get_webenv;
34 $query_key = $obj->get_query_key;
36 =head1 DESCRIPTION
38 This class extends methods for any EUtilDataI implementation allow instances to
39 dealwith NCBI history data (WebEnv and query_key). These can be used as
40 parameters for further queries against data sets stored on the NCBI server, much
41 like NCBI's Entrez search history. These are important when one wants to run
42 complex queries using esearch, retrieve related data using elink, and retrieve
43 large datasets using epost/efetch.
45 This class is the simplest implementation and merely holds data for future
46 queries from any HistoryI. See also Bio::Tools::EUtilities::Query (esearch) and
47 Bio::Tools::EUtilities::LinkSet (elink), which also implement HistoryI.
49 =cut
51 =head1 FEEDBACK
53 =head2 Mailing Lists
55 User feedback is an integral part of the evolution of this and other Bioperl
56 modules. Send your comments and suggestions preferably to one of the Bioperl
57 mailing lists. Your participation is much appreciated.
59 bioperl-l@lists.open-bio.org - General discussion
60 http://www.bioperl.org/wiki/Mailing_lists - About the mailing lists
62 =head2 Reporting Bugs
64 Report bugs to the Bioperl bug tracking system to help us keep track the bugs
65 and their resolution. Bug reports can be submitted via the web.
67 http://bugzilla.open-bio.org/
69 =head1 AUTHOR
71 Email cjfields at uiuc dot edu
73 =head1 APPENDIX
75 The rest of the documentation details each of the object methods. Internal
76 methods are usually preceded with a _
78 =cut
80 # Let the code begin...
82 package Bio::Tools::EUtilities::History;
83 use strict;
84 use warnings;
86 use base qw(Bio::Root::Root Bio::Tools::EUtilities::HistoryI);
87 use Data::Dumper;
89 sub new {
90 my ($class, @args) = @_;
91 my $self = $class->SUPER::new(@args);
92 my ($eutil) = $self->_rearrange([qw(eutil)],@args);
93 $eutil || $self->throw('eutil not defined');
94 $self->eutil($eutil);
95 $self->datatype('cookie');
96 return $self;
99 =head2 history
101 Title : history
102 Usage : my ($webenv, $qk) = $hist->history
103 Function : Get/Set two-element list of webenv() and query_key()
104 Returns : array
105 Args : two-element list of webenv, query key
107 =cut
109 =head2 get_webenv
111 Title : get_webenv
112 Usage : my $webenv = $hist->get_webenv
113 Function : returns web environment key needed to retrieve results from
114 NCBI server
115 Returns : string (encoded key)
116 Args : none
118 =cut
120 =head2 get_query_key
122 Title : get_query_key
123 Usage : my $qk = $hist->get_query_key
124 Function : returns query key (integer) for the history number for this session
125 Returns : integer
126 Args : none
128 =cut
130 sub _add_data {
131 my ($self, $simple) = @_;
132 if (!exists $simple->{WebEnv} || !exists $simple->{QueryKey}) {
133 $self->debug("Data:",Dumper($simple));
134 $self->throw("Missing webenv/query key in history output");
136 $self->{_webenv} = $simple->{WebEnv} && delete $simple->{WebEnv};
137 $self->{_querykey} = $simple->{QueryKey} && delete $simple->{QueryKey};
141 __END__