X-Git-Url: https://git.donarmstrong.com/?p=function2gene.git;a=blobdiff_plain;f=bin%2Fget_ncbi_results;h=e126d5f687fc984107aafcb1263986158ddd2086;hp=3e1a6259ce1d2e717727ad7a9ed4a1d1a3bef118;hb=67d86ccaa9e63139266e501f33c69cd30803f6eb;hpb=0486e6434cd182e8b30ba008d98ad3d3f008d2ab diff --git a/bin/get_ncbi_results b/bin/get_ncbi_results index 3e1a625..e126d5f 100755 --- a/bin/get_ncbi_results +++ b/bin/get_ncbi_results @@ -87,9 +87,9 @@ my %options = (debug => 0, name => 'ncbi_${search}_results.$format', terms => '-', orgn => 'homo', - pubmed_site => 'http://www.ncbi.nlm.nih.gov', - pubmed_search_url => '/entrez/query.fcgi?cmd=search&doptcmdl=Brief&dispmax=1000', - pubmed_get_url => '/entrez/query.fcgi?cmd=Text', + ncbi_site => 'http://www.ncbi.nlm.nih.gov', + ncbi_search_url => '/entrez/query.fcgi?cmd=search&doptcmdl=Brief&dispmax=1000', + ncbi_get_url => '/entrez/query.fcgi?cmd=Text', ); GetOptions(\%options,'format|f=s','database|b=s','name|n=s', @@ -121,7 +121,7 @@ while (<$terms>) { chomp; my $search = $_; my $format = $options{format}; - my $uri = URI->new($options{pubmed_site}.$options{pubmed_search_url}); + my $uri = URI->new($options{ncbi_site}.$options{ncbi_search_url}); $uri->query_form($uri->query_form(), term => $search.' AND '.$options{orgn}.'[Orgn]', db => $options{database}, @@ -145,7 +145,7 @@ while (<$terms>) { my @current_ids; print {$xml_file} "\n"; while (@current_ids = splice(@gene_ids,0,5)) { - $uri = URI->new($options{pubmed_site}.$options{pubmed_get_url}); + $uri = URI->new($options{ncbi_site}.$options{ncbi_get_url}); $uri->query_form($uri->query_form(), dopt => uc($options{format}), db => $options{database}, @@ -155,6 +155,15 @@ while (<$terms>) { print STDERR "url: $url\n"; $mech->get($url); my $response = $mech->content; + my $retry_count=5; + while ($response =~ /Error reading from remote server/ and $retry_count > 0) { + $mech->get($url); + $response = $mech->content; + $retry_count--; + } + if ($retry_count <= 0) { + die 'Unable to retreive ids ['.join(',',@current_ids).'] because of a remote server error'; + } # For some dumb reason, they send us xml with html # entities. Ditch them. #$response = decode_entities($response);