ESearch with a Perl script

Condition


  • We might look for some issues in fuzzy and how we use NCBI database to search the information we need? We could use ESearch to retrieve items with higher similarity and further take these result into EFetch program to get specific results.

  • Perl Coding

#!/usr/bin/perl

use strict;
use LWP::Simple;

# global variables
my $db = "nucleotide";
my $query = "h1n1 \"segment 6\" influenza a virus";
my $format = "fasta";
my $retMax = "100";        # for much more entries
my $baseURL = "http://www.ncbi.nlm.nih.gov/entrez/eutils";

# for ESearch
my $ESearch = "$baseURL/esearch.fcgi?";
$ESearch .= "db=$db&retmax=1&usehistory=y&term=$query";

my $esearch_res = get($ESearch);
#print $esearch_res;

# get the result from ESearch and then take these for further operation, EFetch
# the regular expression, '|' is used for search in the document 
# for all content not specific to the first position
$esearch_res =~ m|(\d+)(.*)|;
my $queryKey = $1;
my $webEnv = $2;

my $efetch = "$baseURL/efetch.fcgi?";
$efetch .= "db=$db&rettype=$format&retmax=$retMax&query_key=$queryKey&WebEnv=$webEnv";

my $efetch_res = get($efetch);
print $efetch_res."\n";

results matching ""

    No results matching ""