#!/usr/local/bin/perl -w
###############################################################################
# #
# MEDSUM PROGRAM 2 : Quick Call - flexible return on query basic data #
# #
###############################################################################
use Getopt::Long;
my ($term, $page);
GetOptions ("query:s" => \$term, "page=i" => \$page);
$term =~ s/~q~q~/\'/g;
if (!($page)) {
$page = 0;
}
###############################################################################
use LWP::Simple;
$base = "http://www.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?".
"db=Pubmed". "&".
"retmax=1". "&".
"term=";
$signature = '&tool=medsum&email=mike_galsworthy@yahoo.co.uk';
$link = $base . $term . $signature;
$esearch = get($base . $term . $signature);
my $errors = 'nothing';
$esearch =~
m|(.+)|s;
$QueryTranslation = $1;
$esearch =~
m|(\d+)|s;
my $Count = $1;
#if ($Count==0) {
# $QueryTranslation = "Sorry, nothing found. (See notes below)";
# }
#if ($QueryTranslation=="0") {
# $QueryTranslation = "Sorry, nothing found. (See notes below)";
# }
################################## Programming part for xml info return ##############################
$esearch =~
m|(.+)|s;
my $literal = $1;
$literal =~ s/\</g;
$literal =~ s/\>/>/g;
$esearch =~
m|(.+)|s;
my $translations = $1;
$translations =~ s/.<\/Explode>//g;
$translations =~ s/.*?<\/OP>//g;
$translations =~ s/.*?<\/Field>//g;
$translations =~ s//Count: /g;
#######################################################################################################
$esearch =~ m|(.+)|s;
$errors = $1;
print "Your query is: $term
";
print "And it found $Count results
";
print "Note that Pubmed translates your query into: $QueryTranslation
";
if ($Count==0) {
print "Notes: NOTHING FOUND.
PubMed returned nothing in association with that query. If it is because those words were not anywhere ";
print "in the database, then I have flagged that below.
";
print "Otherwise, if you have put in a long phrase, that could be the problem. Try just a key word (or two) ";
print "and build up your query from there.
";
}
if ($errors) {
print "Notes: SPECIFIC WORDS NOT FOUND.
The following words from your search are nowhere in the PubMed database: $errors
";
}
if ($page==1) {
print "
<program>QUICKCALL
Commands: full xml page return.
$literal
";
}
if ($page==2) {
print "
<program>QUICKCALL
Commands: translation stack return.
$translations
";
}
open FILE, ">>log.txt" or die $!;
print FILE "QC - $term ($Count) \r\n";
close FILE;