From e68445999cdb36227671a287439cc4c64f62e7e7 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Fri, 3 Jan 2014 16:06:14 -0800 Subject: [PATCH] switch pubmed search to use soap --- pubmed_search | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pubmed_search b/pubmed_search index 7b3041e..cc90661 100755 --- a/pubmed_search +++ b/pubmed_search @@ -12,7 +12,7 @@ use strict; use Getopt::Long; use Pod::Usage; -use Bio::DB::EUtilities; +use Bio::DB::SoapEUtilities; use Encode qw(encode_utf8); use Term::ANSIColor qw(:constants); @@ -84,13 +84,14 @@ if (not @ARGV) { pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS; -my $search = Bio::DB::EUtilities->new(-eutil => 'esearch', - -email => 'don@donarmstrong.com', - -db => 'pubmed', - -term => join(' ',@ARGV), - -retmax => 1000, - ); -my @ids = $search->get_ids(); +my $fac = Bio::DB::SoapEUtilities->new(); + +my $result = $fac->esearch(-email => 'don@donarmstrong.com', + -db => 'pubmed', + -term => join(' ',@ARGV), + -retmax => 1000, + )->run(); +my @ids = $result->ids; if ($options{org_mode}) { print "* Pubmed search results for ".join(' ',@ARGV)." (".scalar(@ids).")\n"; print " + "; @@ -100,13 +101,12 @@ if ($options{org_mode}) { } print scalar(@ids)." results:\n"; exit 0 unless @ids; -my $esummary = Bio::DB::EUtilities->new(-eutil => 'efetch', - -email => 'don@donarmstrong.com', - -db => 'pubmed', - -id => \@ids - ); +my $raw_xml = $fac->efetch(-email => 'don@donarmstrong.com', + -db => 'pubmed', + -id => \@ids + )->run(-raw_xml => 1); use XML::LibXML; -my $xml = XML::LibXML->load_xml(string => $esummary->get_Response()->content()); +my $xml = XML::LibXML->load_xml(string => $raw_xml); for my $article ($xml->findnodes('PubmedArticleSet/PubmedArticle/MedlineCitation')) { # print $article->toString; my ($pmid) = $article->findnodes('./PMID'); -- 2.39.5