Clair::Bio::EUtils

ESearch


SummaryPackage variablesSynopsisDescriptionGeneral documentationMethods

SummaryTop
Clair::Bio::EUtils::ESearch - a Perl interface to the ESearch utility

Package variablesTop
No package variables defined.

Included modulesTop
Carp
Clair::Bio::EUtils qw ( $ESEARCH_URL $TOOL $EMAIL build_url )
Clair::Bio::EUtils::ESearchHandler
LWP::Simple
XML::Parser::PerlSAX

SynopsisTop
    
my $esearch = new Clair::Bio::EUtils::ESearch(
term => "asthma[mh] OR hay fever[mh]",
retmax => "100"
);
my $idlistref = $esearch->{IdList}; foreach my $id (@$idlistref) { print "$id\n"; }

DescriptionTop
The ESearch utility is used to query a database and return a list of
ids. For example, search PubMed for articles and return a list of PMIDs.
For a complete description, see the ESearch specification on the Entrez
website.

MethodsTop
get_esearch_argsDescriptionCode
newDescriptionCode

Methods description


get_esearch_argscode    nextTop
Returns a hash of the arguments passed to ESearch.

newcodeprevnextTop
    my $esearch = new Clair::Bio::EUtils::ESearch(
[key => value]
);
Performs a search given a hash of the key value pairs described on the 
ESearch website. The tool, email, and retmode parameters are set by the
module and cannot be overridden.
Once a successful search has been completed, the results are available as
key/value pairs in the Clair::Bio::EUtils::ESearch object. These are

    IdList

    A list of the IDs returned by ESearch.

    Count

    The total number of items returned.

    RetMax

    The maximum number specified in the query.

    RetStart

    The starting index specified in the query.

    QueryKey, WebEnv

    See the EUtils documentation on how to use these variables.

Methods code


get_esearch_argsdescriptionprevnextTop
sub get_esearch_args {
    my $self = shift;
    if (defined $self->{_esearch_args}) {
        return %{ $self->{_esearch_args} };
    } else {
        return undef;
    }
}

newdescriptionprevnextTop
sub new {
    my $class =shift;
    my $self = {};
    my %params = @_;
    my %esearch_args = (
        db => "PubMed",
        usehistory => "y",
    );

    # Merge with the defaults
foreach my $key (keys %params) { $esearch_args{$key} = $params{$key}; } # Set the required parameters
$esearch_args{tool} = $TOOL; $esearch_args{email} = $EMAIL; $esearch_args{retmode} = "xml"; $self->{_esearch_args} =\% esearch_args; my $url = build_url( base => $ESEARCH_URL, args =>\% esearch_args ); my $handler = new Clair::Bio::EUtils::ESearchHandler; my $parser = new XML::Parser::PerlSAX( Handler => $handler ); eval { $parser->parse(get($url)); }; croak "Couldn't parse ESearch results: $@" if $@; # Copy the results from the handler
foreach my $key (keys %$handler) { $self->{$key} = $handler->{$key}; } return bless($self, $class);
}

General documentation


REQUIRESTop
Clair::Bio::EUtils
Clair::Bio::EUtils::ESearchHandler
LWP::Simple
XML::Parser::PerlSAX

AUTHORTop
Tony Fader, afader@umich.edu

SEE ALSOTop
The ESearch specification on the Entrez site:
http://www.ncbi.nlm.nih.gov/entrez/query/static/esearch_help.html.