Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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