Skip to content

Instantly share code, notes, and snippets.

@cory-ko-g
Created August 23, 2011 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cory-ko-g/1164139 to your computer and use it in GitHub Desktop.
Save cory-ko-g/1164139 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use LWP::UserAgent;
use HTTP::Request::Common qw/POST/;
use strict;
use warnings;
my $xml = _query_xml();
my %form_data = (
"query" => $xml,
);
my $serv_url = "http://www.biomart.org/biomart/martservice";
my $ua = LWP::UserAgent->new();
my $request = POST($serv_url, [%form_data]);
$ua->request($request,
sub{
my($data, $response) = @_;
if ( $response->is_error() ) {
die ("Problems with the web server: ".$response->status_line);
} else { # $response->is_success()
print "$data";
}
},1000);
sub _query_xml {
return<<XML;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Query>
<Query virtualSchemaName = "default" formatter = "TSV" header = "0" uniqueRows = "0" count = "" datasetConfigVersion = "0.6" >
<Dataset name = "mmusculus_gene_ensembl" interface = "default" >
<Filter name = "with_affy_mouse430_2" excluded = "0"/>
<Attribute name = "uniprot_swissprot_accession" />
<Attribute name = "affy_mouse430_2" />
</Dataset>
</Query>
XML
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment