Approaches to Web Development for Bioinformatics
Web Services
NCBI also provides programmatic access to its databases via web
services. The Entrez EUtilities service2 is included
within in this. Here is an example of a Perl program that
performs a query from the NCBI PubMed database for terms matching
'Huntington'.
#!/usr/bin/perl
# CGI Program to test searching PubMed with
NCBI Entrez EUtilities
use LWP::Simple;
# Print header
print "Content-type: text/plain\n\n";
# Perform query
my $url =
"http://www.ncbi.nlm.nih.gov/entrez/eutils/$utils/esearch.fcgi?db=Pubmed&retmax=1&usehistory=y&term=Huntington";
my
$esearch_result = get($url);
# Print result
print "\nESEARCH RESULT: $esearch_result\n";
The program makes use of the LWP::simple module, which
makes HTTP requests in the same way a browser does. The program
uses the get() function to query PubMed for the term 'Huntingon' and
prints out the results. The output of the program is
ESEARCH RESULT:
<?xml version="1.0"?>
<!DOCTYPE eSearchResult PUBLIC "-//NLM//DTD eSearchResult, 11 May 2002//EN"
"http://www.ncbi.nlm.nih.gov/entrez/query/DTD/eSearch_020511.dtd">
<eSearchResult>
<
Count>9201</
Count>
<
RetMax>1</
RetMax>
<
RetStart>0</
RetStart>
<
QueryKey>1</
QueryKey>
<
WebEnv>0Va6QU_UfRhO7-lRqJepWjj701QentQrMpyEGfWUCE2C-Uf_xmzOAQ@vJV1gIIOFpQAAFj-QskAAAAI</
WebEnv>
<
IdList>
<Id>16730765</Id>
</
IdList>
<
TranslationSet>
</
TranslationSet>
<
TranslationStack>
<
TermSet>
<Term>Huntington[All Fields]</Term>
<Field>All Fields</Field>
<Count>9212</Count>
<Explode>Y</Explode>
</
TermSet>
<
OP>GROUP</
OP>
</
TranslationStack>
</eSearchResult>
This XML response can be parsed with an XML parser. See CPAN for
details on Perl XML parsing or Introduction
to Extensible Markup Language for Chemistry and Biosciences for
details on working with XML in Java.
There are no user comments.
Please send ideas and opinions by email at alexamies@gmail.com.
© 2006-2007 Alex Amies