- while (@current_ids = splice(@gene_ids,0,20)) {
- $url = uri_param_munge($options{pubmed_site}.$options{pubmed_get_url},
- {dopt => uc($options{format}),
- db => $options{database},
- },
- ) .'&' . join('&',map {qq(uid=$_)} @current_ids);
- $request = HTTP::Request->new('GET', $url);
- $response = $ua->request($request);
- $response = $response->content;
+ print {$xml_file} "<opt>\n";
+ while (@current_ids = splice(@gene_ids,0,5)) {
+ $uri = URI->new($options{ncbi_site}.$options{ncbi_get_url});
+ $uri->query_form($uri->query_form(),
+ dopt => uc($options{format}),
+ db => $options{database},
+ map {('uid',$_)} @current_ids,
+ );
+ $url = $uri->as_string;
+ 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';
+ }