]> git.donarmstrong.com Git - bin.git/commitdiff
use EUtilities instead of SOAP
authorDon Armstrong <don@donarmstrong.com>
Sun, 6 Dec 2015 00:23:38 +0000 (18:23 -0600)
committerDon Armstrong <don@donarmstrong.com>
Sun, 6 Dec 2015 00:23:38 +0000 (18:23 -0600)
pubmed_search

index 23333ea3004257c94b48930759ecc996087c84ab..c0d15ce50afb745f3fb2a6f3b781a21e131dacaf 100755 (executable)
@@ -12,7 +12,7 @@ use strict;
 use Getopt::Long;
 use Pod::Usage;
 
-use Bio::DB::SoapEUtilities;
+use Bio::DB::EUtilities;
 
 use Encode qw(encode_utf8);
 use Term::ANSIColor qw(:constants);
@@ -86,18 +86,23 @@ if (not @ARGV) {
 pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
 
 
-my $fac = Bio::DB::SoapEUtilities->new();
-
-my $result = $fac->esearch(-email => 'don@donarmstrong.com',
-                           -db    => 'pubmed',
-                           -term => join(' ',@ARGV),
-                           -retmax => 1000,
-                          )->run();
-if ($result eq '0') {
+my $result =
+    Bio::DB::EUtilities->new(-email => 'don@donarmstrong.com',
+                             -db    => 'pubmed',
+                             -term => join(' ',@ARGV),
+                             -retmax => 1000,
+                             -eutil  => 'esearch',
+                            );
+my @ids;
+eval {
+    # this warns for everything, so hide the warning.
+    local $SIG{__WARN__} = sub {};
+    @ids = $result->get_ids('pubmed')
+};
+if (not @ids) {
     print "No results\n";
     exit;
 }
-my @ids = $result->ids;
 if (@ids > 0 and ref($ids[0])) {
     @ids = @{$ids[0]};
 }
@@ -110,12 +115,13 @@ if ($options{org_mode}) {
 }
 print scalar(@ids)." results:\n";
 exit 0 unless @ids;
-my $raw_xml = $fac->efetch(-email => 'don@donarmstrong.com',
-                           -db    => 'pubmed',
-                           -id  => \@ids
-                          )->run(-raw_xml => 1);
+my $raw_xml = Bio::DB::EUtilities->new(-email => 'don@donarmstrong.com',
+                                       -db    => 'pubmed',
+                                       -id  => \@ids,
+                                       -eutil => 'efetch',
+                                      );
 use XML::LibXML;
-my $xml = XML::LibXML->load_xml(string => $raw_xml);
+my $xml = XML::LibXML->load_xml(string => $raw_xml->get_Response->content);
 print STDERR $xml->toString if $DEBUG;
 for my $article ($xml->findnodes(q{//*[local-name()='MedlineCitation']})) {
     print STDERR $article->toString if $DEBUG;