]> git.donarmstrong.com Git - bin.git/commitdiff
switch pubmed search to use soap
authorDon Armstrong <don@donarmstrong.com>
Sat, 4 Jan 2014 00:06:14 +0000 (16:06 -0800)
committerDon Armstrong <don@donarmstrong.com>
Sat, 4 Jan 2014 00:06:14 +0000 (16:06 -0800)
pubmed_search

index 7b3041ed43b4f552bebb1082e9b2c185e8a6910b..cc90661e363918f5a1e6cb3a5e8dffd78da9323e 100755 (executable)
@@ -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');