1
# $Id: esearch.pm,v 1.11.4.2 2006/10/02 23:10:16 sendu Exp $
3
# BioPerl module for Bio::DB::EUtilities::esearch
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
17
Bio::DB::EUtilities::esearch - Base interface class for handling web
18
queries and data retrieval from Entrez Utilities from NCBI.
19
You shouldn't use this class directly.
23
*** Give standard usage here
27
*** Describe the object here
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@bioperl.org - General discussion
40
http://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::esearch;
67
use Bio::DB::EUtilities::Cookie;
73
use base qw(Bio::DB::EUtilities);
75
our $EUTIL = 'esearch';
78
my ($self, @args ) = @_;
79
$self->SUPER::_initialize(@args);
80
my ($term, $field, $reldate, $mindate, $maxdate, $datetype, $rettype, $retstart,
81
$retmax, $sort, $usehistory) =
82
$self->_rearrange([qw(TERM FIELD RELDATE MINDATE MAXDATE DATETYPE RETTYPE
83
RETSTART RETMAX SORT USEHISTORY)],
86
$self->_eutil($EUTIL);
88
$self->datetype($datetype) if $datetype;
89
$term && $self->term($term);
90
$field && $self->field($field);
91
$reldate && $self->reldate($reldate);
92
$mindate && $self->mindate($mindate);
93
$maxdate && $self->maxdate($maxdate);
94
$retstart && $self->retstart($retstart);
95
$retmax && $self->retmax($retmax);
96
$rettype && $self->rettype($rettype);
97
$sort && $self->sort_results($sort);
98
$usehistory && $self->usehistory($usehistory);
101
=head2 parse_response
103
Title : parse_response
104
Usage : $db->_parse_response($content)
105
Function: parse out response for cookie
108
Throws : 'unparseable output exception'
114
my $response = shift if @_;
115
if (!$response || !$response->isa("HTTP::Response")) {
116
$self->throw("Need HTTP::Response object");
118
my $history = $self->usehistory;
120
my $xs = XML::Simple->new();
121
my $simple = $xs->XMLin($response->content);
122
#$self->debug("Response dumper:\n".Dumper($simple));
123
# check for major and minor errors and warnings
124
if ($simple->{ERROR}) {
125
$self->throw("NCBI esearch nonrecoverable error: ".$simple->{ERROR});
127
if ($simple->{ErrorList} || $simple->{WarningList}) {
128
my %errorlist = %{ $simple->{ErrorList} };
129
my %warninglist = %{ $simple->{WarningList} };
131
for my $key (sort keys %errorlist) {
132
$err_warn .= "Error : $key = $errorlist{$key}\n";
134
for my $key (sort keys %warninglist) {
135
$err_warn .= "Warning : $key = $warninglist{$key}\n";
138
$self->warn("NCBI esearch Errors/Warnings:\n".$err_warn)
140
my $count = $simple->{Count};
141
$self->esearch_count($count);
142
my $id_ref = $simple->{IdList}->{Id};
143
$self->_add_db_ids($id_ref) if ($id_ref);
144
if ($history && $history eq 'y') {
145
my $webenv = $simple->{WebEnv};
146
my $querykey = $simple->{QueryKey};
147
my $cookie = Bio::DB::EUtilities::Cookie->new(
148
-term => $self->term,
150
-querykey => $querykey,
155
$self->add_cookie($cookie);
161
Title : esearch_count
162
Usage : $count = $db->esearch_count;
163
Function: return count of number of entries retrieved by query
171
return $self->{'_esearch_count'} = shift if @_;
172
return $self->{'_esearch_count'};
b'\\ No newline at end of file'