Skip to content

Instantly share code, notes, and snippets.

@radaniba
Created November 29, 2012 17:09
Show Gist options
  • Select an option

  • Save radaniba/4170452 to your computer and use it in GitHub Desktop.

Select an option

Save radaniba/4170452 to your computer and use it in GitHub Desktop.
If you want to automate your queries to Ensembl using BioMart perl API you will face the problem of server overloading, thus an alternative is to use webservice, this script solved my problem, hope it helps, Cheers.
# an example script demonstrating the use of BioMart webservice
use strict;
use LWP::UserAgent;
open (FH,$ARGV[0]) || die ("\nUsage: perl getFromEnsembl.pl Query.xml\n\n");
my $xml;
while (<FH>){
$xml .= $_;
}
close(FH);
my $path="http://www.biomart.org/biomart/martservice?";
my $request = HTTP::Request->new("POST",$path,HTTP::Headers->new(),'query='.$xml."\n");
my $ua = LWP::UserAgent->new;
my $response;
$ua->request($request,
sub{
my($data, $response) = @_;
if ($response->is_success) {
print "$data";
}
else {
warn ("Problems with the web server: ".$response->status_line);
}
},1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment