Skip to content

Instantly share code, notes, and snippets.

@mjg17
Last active December 17, 2015 22:49
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 mjg17/5684406 to your computer and use it in GitHub Desktop.
Save mjg17/5684406 to your computer and use it in GitHub Desktop.
EnsEMBL REST API from perl: Trawl variations in gene FTO
use strict;
use warnings;
use HTTP::Tiny;
use JSON;
use Data::Dumper;
my $http = HTTP::Tiny->new();
my $server = 'http://beta.rest.ensembl.org';
my $request = '/feature/id/ENSG00000140718?feature=variation';
my $response = $http->get($server.$request, {
headers => { 'Content-type' => 'application/json' }
});
die "Failed!" unless $response->{success};
if (length $response->{content}) {
my $results = decode_json($response->{content});
my @matches = grep { $_->{ID} eq 'rs16953002' } @$results;
local $Data::Dumper::Terse = 1;
local $Data::Dumper::Indent = 1;
print Dumper \@matches;
print "\n";
}
[
{
'ID' => 'rs16953002',
'alt_alleles' => [
'G',
'A'
],
'feature_type' => 'variation',
'end' => 54114824,
'seq_region_name' => '16',
'consequence_type' => 'intron_variant',
'strand' => 1,
'start' => 54114824
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment