Created
November 29, 2012 17:09
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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