GET sequence/id/:id

Request multiple types of sequence by stable identifier. Supports feature masking and expand options.

Parameters

Required

NameTypeDescriptionDefaultExample Values
id String An Ensembl stable ID - ENSG00000157764
ENSG00000157764.fasta (supported on some deployments)

Optional

NameTypeDescriptionDefaultExample Values
callback String Name of the callback subroutine to be returned by the requested JSONP response. Required ONLY when using JSONP as the serialisation method. Please see the user guide. - randomlygeneratedname
db_type String Restrict the search to a database other than the default. Useful if you need to use a DB other than core - core
end Int Trim the end of the sequence by this many basepairs. Trimming is relative to reading direction and in the coordinate system of the stable identifier. Parameter can not be used in conjunction with expand_5prime or expand_3prime. - 1000
expand_3prime Int Expand the sequence downstream of the sequence by this many basepairs. Only available when using genomic sequence type. - 1000
expand_5prime Int Expand the sequence upstream of the sequence by this many basepairs. Only available when using genomic sequence type. - 1000
format Enum(fasta) Format of the data - fasta
mask Enum(hard,soft) Request the sequence masked for repeat sequences. Hard will mask all repeats as N's and soft will mask repeats as lowercased characters. Only available when using genomic sequence type. - hard
mask_feature Boolean Mask features on the sequence. If sequence is genomic, mask introns. If sequence is cDNA, mask UTRs. Incompatible with the 'mask' option 0 -
multiple_sequences Boolean Allow the service to return more than 1 sequence per identifier. This is useful when querying for a gene but using a type such as protein. 0 -
object_type String Filter by feature type - gene
species String Species name/alias - homo_sapiens
start Int Trim the start of the sequence by this many basepairs. Trimming is relative to reading direction and in the coordinate system of the stable identifier. Parameter can not be used in conjunction with expand_5prime or expand_3prime. - 1000
type Enum(genomic,cds,cdna,protein) Type of sequence. Defaults to genomic where applicable, i.e. not translations. cdna refers to the spliced transcript sequence with UTR; cds refers to the spliced transcript sequence without UTR. genomic cds

Example Requests

/sequence/id/ENSG00000157764?content-type=text/plain


  1. use strict;
  2. use warnings;
  3.  
  4. use HTTP::Tiny;
  5.  
  6. my $http = HTTP::Tiny->new();
  7.  
  8. my $server = 'http://rest.ensembl.org';
  9. my $ext = '/sequence/id/ENSG00000157764?';
  10. my $response = $http->get($server.$ext, {
  11. headers => { 'Content-type' => 'text/plain' }
  12. });
  13.  
  14. die "Failed!\n" unless $response->{success};
  15.  
  16.  
  17. print "$response->{content}\n";
  18.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENSG00000157764?"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/plain"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print r.text
  14.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENSG00000157764?"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/plain"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print(r.text)
  14.  
  1. require 'net/http'
  2. require 'uri'
  3.  
  4. server='http://rest.ensembl.org'
  5. path = '/sequence/id/ENSG00000157764?'
  6.  
  7. url = URI.parse(server)
  8. http = Net::HTTP.new(url.host, url.port)
  9.  
  10. request = Net::HTTP::Get.new(path, {'Content-Type' => 'text/plain'})
  11.  
  12. response = http.request(request)
  13.  
  14. if response.code != "200"
  15. puts "Invalid response: #{response.code}"
  16. puts response.body
  17. exit
  18. end
  19.  
  20.  
  21. puts response.body
  22.  
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import java.net.HttpURLConnection;
  4. import java.io.BufferedReader;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.IOException;
  8. import java.io.Reader;
  9.  
  10.  
  11. public class EnsemblRest {
  12.  
  13. public static void main(String[] args) throws Exception {
  14. String server = "http://rest.ensembl.org";
  15. String ext = "/sequence/id/ENSG00000157764?";
  16. URL url = new URL(server + ext);
  17.  
  18. URLConnection connection = url.openConnection();
  19. HttpURLConnection httpConnection = (HttpURLConnection)connection;
  20. httpConnection.setRequestProperty("Content-Type", "text/plain");
  21.  
  22. InputStream response = connection.getInputStream();
  23. int responseCode = httpConnection.getResponseCode();
  24.  
  25. if(responseCode != 200) {
  26. throw new RuntimeException("Response code was not 200. Detected response was "+responseCode);
  27. }
  28.  
  29. String output;
  30. Reader reader = null;
  31. try {
  32. reader = new BufferedReader(new InputStreamReader(response, "UTF-8"));
  33. StringBuilder builder = new StringBuilder();
  34. char[] buffer = new char[8192];
  35. int read;
  36. while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
  37. builder.append(buffer, 0, read);
  38. }
  39. output = builder.toString();
  40. }
  41. finally {
  42. if (reader != null) try {
  43. reader.close();
  44. } catch (IOException logOrIgnore) {
  45. logOrIgnore.printStackTrace();
  46. }
  47. }
  48.  
  49. System.out.println(output);
  50. }
  51. }
  52.  
  1. library(httr)
  2. library(jsonlite)
  3. library(xml2)
  4.  
  5. server <- "http://rest.ensembl.org"
  6. ext <- "/sequence/id/ENSG00000157764?"
  7.  
  8. r <- GET(paste(server, ext, sep = ""), content_type("text/plain"))
  9.  
  10. stop_for_status(r)
  11.  
  12.  
  13. print(content(r))
  14.  
  1.  
  2. curl 'http://rest.ensembl.org/sequence/id/ENSG00000157764?' -H 'Content-type:text/plain'
  3.  
  1. wget -q --header='Content-type:text/plain' 'http://rest.ensembl.org/sequence/id/ENSG00000157764?' -O -
  2.  

/sequence/id/CCDS5863.1?content-type=text/x-fasta;object_type=transcript;db_type=otherfeatures;type=cds;species=human


 >CCDS5863.1.1
ATGGCGGCGCTGAGCGGTGGCGGTGGTGGCGGCGCGGAGCCGGGCCAGGCTCTGTTCAAC
GGGGACATGGAGCCCGAGGCCGGCGCCGGCGCCGGCGCCGCGGCCTCTTCGGCTGCGGAC
CCTGCCATTCCGGAGGAGGTGTGGAATATCAAACAAATGATTAAGTTGACACAGGAACAT
ATAGAGGCCCTATTGGACAAATTTGGTGGGGAGCATAATCCACCATCAATATATCTGGAG
GCCTATGAAGAATACACCAGCAAGCTAGATGCACTCCAACAAAGAGAACAACAGTTATTG
GAATCTCTGGGGAACGGAACTGATTTTTCTGTTTCTAGCTCTGCATCAATGGATACCGTT
ACATCTTCTTCCTCTTCTAGCCTTTCAGTGCTACCTTCATCTCTTTCAGTTTTTCAAAAT
CCCACAGATGTGGCACGGAGCAACCCCAAGTCACCACAAAAACCTATCGTTAGAGTCTTC
CTGCCCAACAAACAGAGGACAGTGGTACCTGCAAGGTGTGGAGTTACAGTCCGAGACAGT
CTAAAGAAAGCACTGATGATGAGAGGTCTAATCCCAGAGTGCTGTGCTGTTTACAGAATT
CAGGATGGAGAGAAGAAACCAATTGGTTGGGACACTGATATTTCCTGGCTTACTGGAGAA
GAATTGCATGTGGAAGTGTTGGAGAATGTTCCACTTACAACACACAACTTTGTACGAAAA
ACGTTTTTCACCTTAGCATTTTGTGACTTTTGTCGAAAGCTGCTTTTCCAGGGTTTCCGC
TGTCAAACATGTGGTTATAAATTTCACCAGCGTTGTAGTACAGAAGTTCCACTGATGTGT
GTTAATTATGACCAACTTGATTTGCTGTTTGTCTCCAAGTTCTTTGAACACCACCCAATA
CCACAGGAAGAGGCGTCCTTAGCAGAGACTGCCCTAACATCTGGATCATCCCCTTCCGCA
CCCGCCTCGGACTCTATTGGGCCCCAAATTCTCACCAGTCCGTCTCCTTCAAAATCCATT
CCAATTCCACAGCCCTTCCGACCAGCAGATGAAGATCATCGAAATCAATTTGGGCAACGA
GACCGATCCTCATCAGCTCCCAATGTGCATATAAACACAATAGAACCTGTCAATATTGAT
GACTTGATTAGAGACCAAGGATTTCGTGGTGATGGAGGATCAACCACAGGTTTGTCTGCT
ACCCCCCCTGCCTCATTACCTGGCTCACTAACTAACGTGAAAGCCTTACAGAAATCTCCA
GGACCTCAGCGAGAAAGGAAGTCATCTTCATCCTCAGAAGACAGGAATCGAATGAAAACA
CTTGGTAGACGGGACTCGAGTGATGATTGGGAGATTCCTGATGGGCAGATTACAGTGGGA
CAAAGAATTGGATCTGGATCATTTGGAACAGTCTACAAGGGAAAGTGGCATGGTGATGTG
GCAGTGAAAATGTTGAATGTGACAGCACCTACACCTCAGCAGTTACAAGCCTTCAAAAAT
GAAGTAGGAGTACTCAGGAAAACACGACATGTGAATATCCTACTCTTCATGGGCTATTCC
ACAAAGCCACAACTGGCTATTGTTACCCAGTGGTGTGAGGGCTCCAGCTTGTATCACCAT
CTCCATATCATTGAGACCAAATTTGAGATGATCAAACTTATAGATATTGCACGACAGACT
GCACAGGGCATGGATTACTTACACGCCAAGTCAATCATCCACAGAGACCTCAAGAGTAAT
AATATATTTCTTCATGAAGACCTCACAGTAAAAATAGGTGATTTTGGTCTAGCTACAGTG
AAATCTCGATGGAGTGGGTCCCATCAGTTTGAACAGTTGTCTGGATCCATTTTGTGGATG
GCACCAGAAGTCATCAGAATGCAAGATAAAAATCCATACAGCTTTCAGTCAGATGTATAT
GCATTTGGAATTGTTCTGTATGAATTGATGACTGGACAGTTACCTTATTCAAACATCAAC
AACAGGGACCAGATAATTTTTATGGTGGGACGAGGATACCTGTCTCCAGATCTCAGTAAG
GTACGGAGTAACTGTCCAAAAGCCATGAAGAGATTAATGGCAGAGTGCCTCAAAAAGAAA
AGAGATGAGAGACCACTCTTTCCCCAAATTCTCGCCTCTATTGAGCTGCTGGCCCGCTCA
TTGCCAAAAATTCACCGCAGTGCATCAGAACCCTCCTTGAATCGGGCTGGTTTCCAAACA
GAGGATTTTAGTCTATATGCTTGTGCTTCTCCAAAAACACCCATCCAGGCAGGGGGATAT
GGTGCGTTTCCTGTCCACTGA
  1. use strict;
  2. use warnings;
  3.  
  4. use HTTP::Tiny;
  5.  
  6. my $http = HTTP::Tiny->new();
  7.  
  8. my $server = 'http://rest.ensembl.org';
  9. my $ext = '/sequence/id/CCDS5863.1?object_type=transcript;db_type=otherfeatures;type=cds;species=human';
  10. my $response = $http->get($server.$ext, {
  11. headers => { 'Content-type' => 'text/x-fasta' }
  12. });
  13.  
  14. die "Failed!\n" unless $response->{success};
  15.  
  16.  
  17. print "$response->{content}\n";
  18.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/CCDS5863.1?object_type=transcript;db_type=otherfeatures;type=cds;species=human"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/x-fasta"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print r.text
  14.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/CCDS5863.1?object_type=transcript;db_type=otherfeatures;type=cds;species=human"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/x-fasta"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print(r.text)
  14.  
  1. require 'net/http'
  2. require 'uri'
  3.  
  4. server='http://rest.ensembl.org'
  5. path = '/sequence/id/CCDS5863.1?object_type=transcript;db_type=otherfeatures;type=cds;species=human'
  6.  
  7. url = URI.parse(server)
  8. http = Net::HTTP.new(url.host, url.port)
  9.  
  10. request = Net::HTTP::Get.new(path, {'Content-Type' => 'text/x-fasta'})
  11.  
  12. response = http.request(request)
  13.  
  14. if response.code != "200"
  15. puts "Invalid response: #{response.code}"
  16. puts response.body
  17. exit
  18. end
  19.  
  20.  
  21. puts response.body
  22.  
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import java.net.HttpURLConnection;
  4. import java.io.BufferedReader;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.IOException;
  8. import java.io.Reader;
  9.  
  10.  
  11. public class EnsemblRest {
  12.  
  13. public static void main(String[] args) throws Exception {
  14. String server = "http://rest.ensembl.org";
  15. String ext = "/sequence/id/CCDS5863.1?object_type=transcript;db_type=otherfeatures;type=cds;species=human";
  16. URL url = new URL(server + ext);
  17.  
  18. URLConnection connection = url.openConnection();
  19. HttpURLConnection httpConnection = (HttpURLConnection)connection;
  20. httpConnection.setRequestProperty("Content-Type", "text/x-fasta");
  21.  
  22. InputStream response = connection.getInputStream();
  23. int responseCode = httpConnection.getResponseCode();
  24.  
  25. if(responseCode != 200) {
  26. throw new RuntimeException("Response code was not 200. Detected response was "+responseCode);
  27. }
  28.  
  29. String output;
  30. Reader reader = null;
  31. try {
  32. reader = new BufferedReader(new InputStreamReader(response, "UTF-8"));
  33. StringBuilder builder = new StringBuilder();
  34. char[] buffer = new char[8192];
  35. int read;
  36. while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
  37. builder.append(buffer, 0, read);
  38. }
  39. output = builder.toString();
  40. }
  41. finally {
  42. if (reader != null) try {
  43. reader.close();
  44. } catch (IOException logOrIgnore) {
  45. logOrIgnore.printStackTrace();
  46. }
  47. }
  48.  
  49. System.out.println(output);
  50. }
  51. }
  52.  
  1. library(httr)
  2. library(jsonlite)
  3. library(xml2)
  4.  
  5. server <- "http://rest.ensembl.org"
  6. ext <- "/sequence/id/CCDS5863.1?object_type=transcript;db_type=otherfeatures;type=cds;species=human"
  7.  
  8. r <- GET(paste(server, ext, sep = ""), content_type("text/x-fasta"))
  9.  
  10. stop_for_status(r)
  11.  
  12.  
  13. print(content(r))
  14.  
  1.  
  2. curl 'http://rest.ensembl.org/sequence/id/CCDS5863.1?object_type=transcript;db_type=otherfeatures;type=cds;species=human' -H 'Content-type:text/x-fasta'
  3.  
  1. wget -q --header='Content-type:text/x-fasta' 'http://rest.ensembl.org/sequence/id/CCDS5863.1?object_type=transcript;db_type=otherfeatures;type=cds;species=human' -O -
  2.  

/sequence/id/ENST00000288602?type=cdna;content-type=text/x-fasta


  1. use strict;
  2. use warnings;
  3.  
  4. use HTTP::Tiny;
  5.  
  6. my $http = HTTP::Tiny->new();
  7.  
  8. my $server = 'http://rest.ensembl.org';
  9. my $ext = '/sequence/id/ENST00000288602?type=cdna';
  10. my $response = $http->get($server.$ext, {
  11. headers => { 'Content-type' => 'text/x-fasta' }
  12. });
  13.  
  14. die "Failed!\n" unless $response->{success};
  15.  
  16.  
  17. print "$response->{content}\n";
  18.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENST00000288602?type=cdna"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/x-fasta"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print r.text
  14.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENST00000288602?type=cdna"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/x-fasta"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print(r.text)
  14.  
  1. require 'net/http'
  2. require 'uri'
  3.  
  4. server='http://rest.ensembl.org'
  5. path = '/sequence/id/ENST00000288602?type=cdna'
  6.  
  7. url = URI.parse(server)
  8. http = Net::HTTP.new(url.host, url.port)
  9.  
  10. request = Net::HTTP::Get.new(path, {'Content-Type' => 'text/x-fasta'})
  11.  
  12. response = http.request(request)
  13.  
  14. if response.code != "200"
  15. puts "Invalid response: #{response.code}"
  16. puts response.body
  17. exit
  18. end
  19.  
  20.  
  21. puts response.body
  22.  
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import java.net.HttpURLConnection;
  4. import java.io.BufferedReader;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.IOException;
  8. import java.io.Reader;
  9.  
  10.  
  11. public class EnsemblRest {
  12.  
  13. public static void main(String[] args) throws Exception {
  14. String server = "http://rest.ensembl.org";
  15. String ext = "/sequence/id/ENST00000288602?type=cdna";
  16. URL url = new URL(server + ext);
  17.  
  18. URLConnection connection = url.openConnection();
  19. HttpURLConnection httpConnection = (HttpURLConnection)connection;
  20. httpConnection.setRequestProperty("Content-Type", "text/x-fasta");
  21.  
  22. InputStream response = connection.getInputStream();
  23. int responseCode = httpConnection.getResponseCode();
  24.  
  25. if(responseCode != 200) {
  26. throw new RuntimeException("Response code was not 200. Detected response was "+responseCode);
  27. }
  28.  
  29. String output;
  30. Reader reader = null;
  31. try {
  32. reader = new BufferedReader(new InputStreamReader(response, "UTF-8"));
  33. StringBuilder builder = new StringBuilder();
  34. char[] buffer = new char[8192];
  35. int read;
  36. while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
  37. builder.append(buffer, 0, read);
  38. }
  39. output = builder.toString();
  40. }
  41. finally {
  42. if (reader != null) try {
  43. reader.close();
  44. } catch (IOException logOrIgnore) {
  45. logOrIgnore.printStackTrace();
  46. }
  47. }
  48.  
  49. System.out.println(output);
  50. }
  51. }
  52.  
  1. library(httr)
  2. library(jsonlite)
  3. library(xml2)
  4.  
  5. server <- "http://rest.ensembl.org"
  6. ext <- "/sequence/id/ENST00000288602?type=cdna"
  7.  
  8. r <- GET(paste(server, ext, sep = ""), content_type("text/x-fasta"))
  9.  
  10. stop_for_status(r)
  11.  
  12.  
  13. print(content(r))
  14.  
  1.  
  2. curl 'http://rest.ensembl.org/sequence/id/ENST00000288602?type=cdna' -H 'Content-type:text/x-fasta'
  3.  
  1. wget -q --header='Content-type:text/x-fasta' 'http://rest.ensembl.org/sequence/id/ENST00000288602?type=cdna' -O -
  2.  

/sequence/id/ENST00000288602?content-type=text/x-fasta;type=cds


 >ENST00000288602.11
ATGGCGGCGCTGAGCGGTGGCGGTGGTGGCGGCGCGGAGCCGGGCCAGGCTCTGTTCAAC
GGGGACATGGAGCCCGAGGCCGGCGCCGGCGCCGGCGCCGCGGCCTCTTCGGCTGCGGAC
CCTGCCATTCCGGAGGAGGTGTGGAATATCAAACAAATGATTAAGTTGACACAGGAACAT
ATAGAGGCCCTATTGGACAAATTTGGTGGGGAGCATAATCCACCATCAATATATCTGGAG
GCCTATGAAGAATACACCAGCAAGCTAGATGCACTCCAACAAAGAGAACAACAGTTATTG
GAATCTCTGGGGAACGGAACTGATTTTTCTGTTTCTAGCTCTGCATCAATGGATACCGTT
ACATCTTCTTCCTCTTCTAGCCTTTCAGTGCTACCTTCATCTCTTTCAGTTTTTCAAAAT
CCCACAGATGTGGCACGGAGCAACCCCAAGTCACCACAAAAACCTATCGTTAGAGTCTTC
CTGCCCAACAAACAGAGGACAGTGGTACCTGCAAGGTGTGGAGTTACAGTCCGAGACAGT
CTAAAGAAAGCACTGATGATGAGAGGTCTAATCCCAGAGTGCTGTGCTGTTTACAGAATT
CAGGATGGAGAGAAGAAACCAATTGGTTGGGACACTGATATTTCCTGGCTTACTGGAGAA
GAATTGCATGTGGAAGTGTTGGAGAATGTTCCACTTACAACACACAACTTTGTACGAAAA
ACGTTTTTCACCTTAGCATTTTGTGACTTTTGTCGAAAGCTGCTTTTCCAGGGTTTCCGC
TGTCAAACATGTGGTTATAAATTTCACCAGCGTTGTAGTACAGAAGTTCCACTGATGTGT
GTTAATTATGACCAACTTGATTTGCTGTTTGTCTCCAAGTTCTTTGAACACCACCCAATA
CCACAGGAAGAGGCGTCCTTAGCAGAGACTGCCCTAACATCTGGATCATCCCCTTCCGCA
CCCGCCTCGGACTCTATTGGGCCCCAAATTCTCACCAGTCCGTCTCCTTCAAAATCCATT
CCAATTCCACAGCCCTTCCGACCAGCAGATGAAGATCATCGAAATCAATTTGGGCAACGA
GACCGATCCTCATCAGCTCCCAATGTGCATATAAACACAATAGAACCTGTCAATATTGAT
GACTTGATTAGAGACCAAGGATTTCGTGGTGATGGAGCCCCTTTGAACCAGCTGATGCGC
TGTCTTCGGAAATACCAATCCCGGACTCCCAGTCCCCTCCTACATTCTGTCCCCAGTGAA
ATAGTGTTTGATTTTGAGCCTGGCCCAGTGTTCAGAGGATCAACCACAGGTTTGTCTGCT
ACCCCCCCTGCCTCATTACCTGGCTCACTAACTAACGTGAAAGCCTTACAGAAATCTCCA
GGACCTCAGCGAGAAAGGAAGTCATCTTCATCCTCAGAAGACAGGAATCGAATGAAAACA
CTTGGTAGACGGGACTCGAGTGATGATTGGGAGATTCCTGATGGGCAGATTACAGTGGGA
CAAAGAATTGGATCTGGATCATTTGGAACAGTCTACAAGGGAAAGTGGCATGGTGATGTG
GCAGTGAAAATGTTGAATGTGACAGCACCTACACCTCAGCAGTTACAAGCCTTCAAAAAT
GAAGTAGGAGTACTCAGGAAAACACGACATGTGAATATCCTACTCTTCATGGGCTATTCC
ACAAAGCCACAACTGGCTATTGTTACCCAGTGGTGTGAGGGCTCCAGCTTGTATCACCAT
CTCCATATCATTGAGACCAAATTTGAGATGATCAAACTTATAGATATTGCACGACAGACT
GCACAGGGCATGGATTACTTACACGCCAAGTCAATCATCCACAGAGACCTCAAGAGTAAT
AATATATTTCTTCATGAAGACCTCACAGTAAAAATAGGTGATTTTGGTCTAGCTACAGTG
AAATCTCGATGGAGTGGGTCCCATCAGTTTGAACAGTTGTCTGGATCCATTTTGTGGATG
GCACCAGAAGTCATCAGAATGCAAGATAAAAATCCATACAGCTTTCAGTCAGATGTATAT
GCATTTGGAATTGTTCTGTATGAATTGATGACTGGACAGTTACCTTATTCAAACATCAAC
AACAGGGACCAGATAATTTTTATGGTGGGACGAGGATACCTGTCTCCAGATCTCAGTAAG
GTACGGAGTAACTGTCCAAAAGCCATGAAGAGATTAATGGCAGAGTGCCTCAAAAAGAAA
AGAGATGAGAGACCACTCTTTCCCCAAATTCTCGCCTCTATTGAGCTGCTGGCCCGCTCA
TTGCCAAAAATTCACCGCAGTGCATCAGAACCCTCCTTGAATCGGGCTGGTTTCCAAACA
GAGGATTTTAGTCTATATGCTTGTGCTTCTCCAAAAACACCCATCCAGGCAGGGGGATAT
GGTGCGTTTCCTGTCCACTGA
  1. use strict;
  2. use warnings;
  3.  
  4. use HTTP::Tiny;
  5.  
  6. my $http = HTTP::Tiny->new();
  7.  
  8. my $server = 'http://rest.ensembl.org';
  9. my $ext = '/sequence/id/ENST00000288602?type=cds';
  10. my $response = $http->get($server.$ext, {
  11. headers => { 'Content-type' => 'text/x-fasta' }
  12. });
  13.  
  14. die "Failed!\n" unless $response->{success};
  15.  
  16.  
  17. print "$response->{content}\n";
  18.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENST00000288602?type=cds"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/x-fasta"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print r.text
  14.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENST00000288602?type=cds"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/x-fasta"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print(r.text)
  14.  
  1. require 'net/http'
  2. require 'uri'
  3.  
  4. server='http://rest.ensembl.org'
  5. path = '/sequence/id/ENST00000288602?type=cds'
  6.  
  7. url = URI.parse(server)
  8. http = Net::HTTP.new(url.host, url.port)
  9.  
  10. request = Net::HTTP::Get.new(path, {'Content-Type' => 'text/x-fasta'})
  11.  
  12. response = http.request(request)
  13.  
  14. if response.code != "200"
  15. puts "Invalid response: #{response.code}"
  16. puts response.body
  17. exit
  18. end
  19.  
  20.  
  21. puts response.body
  22.  
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import java.net.HttpURLConnection;
  4. import java.io.BufferedReader;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.IOException;
  8. import java.io.Reader;
  9.  
  10.  
  11. public class EnsemblRest {
  12.  
  13. public static void main(String[] args) throws Exception {
  14. String server = "http://rest.ensembl.org";
  15. String ext = "/sequence/id/ENST00000288602?type=cds";
  16. URL url = new URL(server + ext);
  17.  
  18. URLConnection connection = url.openConnection();
  19. HttpURLConnection httpConnection = (HttpURLConnection)connection;
  20. httpConnection.setRequestProperty("Content-Type", "text/x-fasta");
  21.  
  22. InputStream response = connection.getInputStream();
  23. int responseCode = httpConnection.getResponseCode();
  24.  
  25. if(responseCode != 200) {
  26. throw new RuntimeException("Response code was not 200. Detected response was "+responseCode);
  27. }
  28.  
  29. String output;
  30. Reader reader = null;
  31. try {
  32. reader = new BufferedReader(new InputStreamReader(response, "UTF-8"));
  33. StringBuilder builder = new StringBuilder();
  34. char[] buffer = new char[8192];
  35. int read;
  36. while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
  37. builder.append(buffer, 0, read);
  38. }
  39. output = builder.toString();
  40. }
  41. finally {
  42. if (reader != null) try {
  43. reader.close();
  44. } catch (IOException logOrIgnore) {
  45. logOrIgnore.printStackTrace();
  46. }
  47. }
  48.  
  49. System.out.println(output);
  50. }
  51. }
  52.  
  1. library(httr)
  2. library(jsonlite)
  3. library(xml2)
  4.  
  5. server <- "http://rest.ensembl.org"
  6. ext <- "/sequence/id/ENST00000288602?type=cds"
  7.  
  8. r <- GET(paste(server, ext, sep = ""), content_type("text/x-fasta"))
  9.  
  10. stop_for_status(r)
  11.  
  12.  
  13. print(content(r))
  14.  
  1.  
  2. curl 'http://rest.ensembl.org/sequence/id/ENST00000288602?type=cds' -H 'Content-type:text/x-fasta'
  3.  
  1. wget -q --header='Content-type:text/x-fasta' 'http://rest.ensembl.org/sequence/id/ENST00000288602?type=cds' -O -
  2.  

/sequence/id/ENSE00001154485?content-type=text/x-fasta;type=genomic


 >ENSE00001154485.4 chromosome:GRCh38:7:140924566:140924742:-1
CCGACAGCGGCCGCTCGGGCCCCGGCTCTCGGTTATAAGATGGCGGCGCTGAGCGGTGGC
GGTGGTGGCGGCGCGGAGCCGGGCCAGGCTCTGTTCAACGGGGACATGGAGCCCGAGGCC
GGCGCCGGCGCCGGCGCCGCGGCCTCTTCGGCTGCGGACCCTGCCATTCCGGAGGAG
  1. use strict;
  2. use warnings;
  3.  
  4. use HTTP::Tiny;
  5.  
  6. my $http = HTTP::Tiny->new();
  7.  
  8. my $server = 'http://rest.ensembl.org';
  9. my $ext = '/sequence/id/ENSE00001154485?type=genomic';
  10. my $response = $http->get($server.$ext, {
  11. headers => { 'Content-type' => 'text/x-fasta' }
  12. });
  13.  
  14. die "Failed!\n" unless $response->{success};
  15.  
  16.  
  17. print "$response->{content}\n";
  18.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENSE00001154485?type=genomic"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/x-fasta"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print r.text
  14.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENSE00001154485?type=genomic"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/x-fasta"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print(r.text)
  14.  
  1. require 'net/http'
  2. require 'uri'
  3.  
  4. server='http://rest.ensembl.org'
  5. path = '/sequence/id/ENSE00001154485?type=genomic'
  6.  
  7. url = URI.parse(server)
  8. http = Net::HTTP.new(url.host, url.port)
  9.  
  10. request = Net::HTTP::Get.new(path, {'Content-Type' => 'text/x-fasta'})
  11.  
  12. response = http.request(request)
  13.  
  14. if response.code != "200"
  15. puts "Invalid response: #{response.code}"
  16. puts response.body
  17. exit
  18. end
  19.  
  20.  
  21. puts response.body
  22.  
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import java.net.HttpURLConnection;
  4. import java.io.BufferedReader;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.IOException;
  8. import java.io.Reader;
  9.  
  10.  
  11. public class EnsemblRest {
  12.  
  13. public static void main(String[] args) throws Exception {
  14. String server = "http://rest.ensembl.org";
  15. String ext = "/sequence/id/ENSE00001154485?type=genomic";
  16. URL url = new URL(server + ext);
  17.  
  18. URLConnection connection = url.openConnection();
  19. HttpURLConnection httpConnection = (HttpURLConnection)connection;
  20. httpConnection.setRequestProperty("Content-Type", "text/x-fasta");
  21.  
  22. InputStream response = connection.getInputStream();
  23. int responseCode = httpConnection.getResponseCode();
  24.  
  25. if(responseCode != 200) {
  26. throw new RuntimeException("Response code was not 200. Detected response was "+responseCode);
  27. }
  28.  
  29. String output;
  30. Reader reader = null;
  31. try {
  32. reader = new BufferedReader(new InputStreamReader(response, "UTF-8"));
  33. StringBuilder builder = new StringBuilder();
  34. char[] buffer = new char[8192];
  35. int read;
  36. while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
  37. builder.append(buffer, 0, read);
  38. }
  39. output = builder.toString();
  40. }
  41. finally {
  42. if (reader != null) try {
  43. reader.close();
  44. } catch (IOException logOrIgnore) {
  45. logOrIgnore.printStackTrace();
  46. }
  47. }
  48.  
  49. System.out.println(output);
  50. }
  51. }
  52.  
  1. library(httr)
  2. library(jsonlite)
  3. library(xml2)
  4.  
  5. server <- "http://rest.ensembl.org"
  6. ext <- "/sequence/id/ENSE00001154485?type=genomic"
  7.  
  8. r <- GET(paste(server, ext, sep = ""), content_type("text/x-fasta"))
  9.  
  10. stop_for_status(r)
  11.  
  12.  
  13. print(content(r))
  14.  
  1.  
  2. curl 'http://rest.ensembl.org/sequence/id/ENSE00001154485?type=genomic' -H 'Content-type:text/x-fasta'
  3.  
  1. wget -q --header='Content-type:text/x-fasta' 'http://rest.ensembl.org/sequence/id/ENSE00001154485?type=genomic' -O -
  2.  

/sequence/id/ENSE00001154485?type=genomic;content-type=text/x-fasta;expand_5prime=10


  1. use strict;
  2. use warnings;
  3.  
  4. use HTTP::Tiny;
  5.  
  6. my $http = HTTP::Tiny->new();
  7.  
  8. my $server = 'http://rest.ensembl.org';
  9. my $ext = '/sequence/id/ENSE00001154485?expand_5prime=10;type=genomic';
  10. my $response = $http->get($server.$ext, {
  11. headers => { 'Content-type' => 'text/x-fasta' }
  12. });
  13.  
  14. die "Failed!\n" unless $response->{success};
  15.  
  16.  
  17. print "$response->{content}\n";
  18.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENSE00001154485?expand_5prime=10;type=genomic"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/x-fasta"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print r.text
  14.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENSE00001154485?expand_5prime=10;type=genomic"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/x-fasta"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print(r.text)
  14.  
  1. require 'net/http'
  2. require 'uri'
  3.  
  4. server='http://rest.ensembl.org'
  5. path = '/sequence/id/ENSE00001154485?expand_5prime=10;type=genomic'
  6.  
  7. url = URI.parse(server)
  8. http = Net::HTTP.new(url.host, url.port)
  9.  
  10. request = Net::HTTP::Get.new(path, {'Content-Type' => 'text/x-fasta'})
  11.  
  12. response = http.request(request)
  13.  
  14. if response.code != "200"
  15. puts "Invalid response: #{response.code}"
  16. puts response.body
  17. exit
  18. end
  19.  
  20.  
  21. puts response.body
  22.  
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import java.net.HttpURLConnection;
  4. import java.io.BufferedReader;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.IOException;
  8. import java.io.Reader;
  9.  
  10.  
  11. public class EnsemblRest {
  12.  
  13. public static void main(String[] args) throws Exception {
  14. String server = "http://rest.ensembl.org";
  15. String ext = "/sequence/id/ENSE00001154485?expand_5prime=10;type=genomic";
  16. URL url = new URL(server + ext);
  17.  
  18. URLConnection connection = url.openConnection();
  19. HttpURLConnection httpConnection = (HttpURLConnection)connection;
  20. httpConnection.setRequestProperty("Content-Type", "text/x-fasta");
  21.  
  22. InputStream response = connection.getInputStream();
  23. int responseCode = httpConnection.getResponseCode();
  24.  
  25. if(responseCode != 200) {
  26. throw new RuntimeException("Response code was not 200. Detected response was "+responseCode);
  27. }
  28.  
  29. String output;
  30. Reader reader = null;
  31. try {
  32. reader = new BufferedReader(new InputStreamReader(response, "UTF-8"));
  33. StringBuilder builder = new StringBuilder();
  34. char[] buffer = new char[8192];
  35. int read;
  36. while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
  37. builder.append(buffer, 0, read);
  38. }
  39. output = builder.toString();
  40. }
  41. finally {
  42. if (reader != null) try {
  43. reader.close();
  44. } catch (IOException logOrIgnore) {
  45. logOrIgnore.printStackTrace();
  46. }
  47. }
  48.  
  49. System.out.println(output);
  50. }
  51. }
  52.  
  1. library(httr)
  2. library(jsonlite)
  3. library(xml2)
  4.  
  5. server <- "http://rest.ensembl.org"
  6. ext <- "/sequence/id/ENSE00001154485?expand_5prime=10;type=genomic"
  7.  
  8. r <- GET(paste(server, ext, sep = ""), content_type("text/x-fasta"))
  9.  
  10. stop_for_status(r)
  11.  
  12.  
  13. print(content(r))
  14.  
  1.  
  2. curl 'http://rest.ensembl.org/sequence/id/ENSE00001154485?expand_5prime=10;type=genomic' -H 'Content-type:text/x-fasta'
  3.  
  1. wget -q --header='Content-type:text/x-fasta' 'http://rest.ensembl.org/sequence/id/ENSE00001154485?expand_5prime=10;type=genomic' -O -
  2.  

/sequence/id/ENSG00000157764?content-type=text/x-seqxml%2Bxml;multiple_sequences=1;type=protein


  1. use strict;
  2. use warnings;
  3.  
  4. use HTTP::Tiny;
  5.  
  6. my $http = HTTP::Tiny->new();
  7.  
  8. my $server = 'http://rest.ensembl.org';
  9. my $ext = '/sequence/id/ENSG00000157764?multiple_sequences=1;type=protein';
  10. my $response = $http->get($server.$ext, {
  11. headers => { 'Content-type' => 'text/x-seqxml+xml' }
  12. });
  13.  
  14. die "Failed!\n" unless $response->{success};
  15.  
  16.  
  17. print "$response->{content}\n";
  18.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENSG00000157764?multiple_sequences=1;type=protein"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/x-seqxml+xml"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print r.text
  14.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENSG00000157764?multiple_sequences=1;type=protein"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "text/x-seqxml+xml"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12.  
  13. print(r.text)
  14.  
  1. require 'net/http'
  2. require 'uri'
  3.  
  4. server='http://rest.ensembl.org'
  5. path = '/sequence/id/ENSG00000157764?multiple_sequences=1;type=protein'
  6.  
  7. url = URI.parse(server)
  8. http = Net::HTTP.new(url.host, url.port)
  9.  
  10. request = Net::HTTP::Get.new(path, {'Content-Type' => 'text/x-seqxml+xml'})
  11.  
  12. response = http.request(request)
  13.  
  14. if response.code != "200"
  15. puts "Invalid response: #{response.code}"
  16. puts response.body
  17. exit
  18. end
  19.  
  20.  
  21. puts response.body
  22.  
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import java.net.HttpURLConnection;
  4. import java.io.BufferedReader;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.IOException;
  8. import java.io.Reader;
  9.  
  10.  
  11. public class EnsemblRest {
  12.  
  13. public static void main(String[] args) throws Exception {
  14. String server = "http://rest.ensembl.org";
  15. String ext = "/sequence/id/ENSG00000157764?multiple_sequences=1;type=protein";
  16. URL url = new URL(server + ext);
  17.  
  18. URLConnection connection = url.openConnection();
  19. HttpURLConnection httpConnection = (HttpURLConnection)connection;
  20. httpConnection.setRequestProperty("Content-Type", "text/x-seqxml+xml");
  21.  
  22. InputStream response = connection.getInputStream();
  23. int responseCode = httpConnection.getResponseCode();
  24.  
  25. if(responseCode != 200) {
  26. throw new RuntimeException("Response code was not 200. Detected response was "+responseCode);
  27. }
  28.  
  29. String output;
  30. Reader reader = null;
  31. try {
  32. reader = new BufferedReader(new InputStreamReader(response, "UTF-8"));
  33. StringBuilder builder = new StringBuilder();
  34. char[] buffer = new char[8192];
  35. int read;
  36. while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
  37. builder.append(buffer, 0, read);
  38. }
  39. output = builder.toString();
  40. }
  41. finally {
  42. if (reader != null) try {
  43. reader.close();
  44. } catch (IOException logOrIgnore) {
  45. logOrIgnore.printStackTrace();
  46. }
  47. }
  48.  
  49. System.out.println(output);
  50. }
  51. }
  52.  
  1. library(httr)
  2. library(jsonlite)
  3. library(xml2)
  4.  
  5. server <- "http://rest.ensembl.org"
  6. ext <- "/sequence/id/ENSG00000157764?multiple_sequences=1;type=protein"
  7.  
  8. r <- GET(paste(server, ext, sep = ""), content_type("text/x-seqxml+xml"))
  9.  
  10. stop_for_status(r)
  11.  
  12.  
  13. print(content(r))
  14.  
  1.  
  2. curl 'http://rest.ensembl.org/sequence/id/ENSG00000157764?multiple_sequences=1;type=protein' -H 'Content-type:text/x-seqxml+xml'
  3.  
  1. wget -q --header='Content-type:text/x-seqxml+xml' 'http://rest.ensembl.org/sequence/id/ENSG00000157764?multiple_sequences=1;type=protein' -O -
  2.  

/sequence/id/GENSCAN00000000001?content-type=application/json;object_type=predictiontranscript;type=protein;db_type=core;species=homo_sapiens


  1. use strict;
  2. use warnings;
  3.  
  4. use HTTP::Tiny;
  5.  
  6. my $http = HTTP::Tiny->new();
  7.  
  8. my $server = 'http://rest.ensembl.org';
  9. my $ext = '/sequence/id/GENSCAN00000000001?type=protein;db_type=core;species=homo_sapiens;object_type=predictiontranscript';
  10. my $response = $http->get($server.$ext, {
  11. headers => { 'Content-type' => 'application/json' }
  12. });
  13.  
  14. die "Failed!\n" unless $response->{success};
  15.  
  16.  
  17. use JSON;
  18. use Data::Dumper;
  19. if(length $response->{content}) {
  20. my $hash = decode_json($response->{content});
  21. local $Data::Dumper::Terse = 1;
  22. local $Data::Dumper::Indent = 1;
  23. print Dumper $hash;
  24. print "\n";
  25. }
  26.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/GENSCAN00000000001?type=protein;db_type=core;species=homo_sapiens;object_type=predictiontranscript"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "application/json"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12. decoded = r.json()
  13. print repr(decoded)
  14.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/GENSCAN00000000001?type=protein;db_type=core;species=homo_sapiens;object_type=predictiontranscript"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "application/json"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12. decoded = r.json()
  13. print(repr(decoded))
  14.  
  1. require 'net/http'
  2. require 'uri'
  3.  
  4. server='http://rest.ensembl.org'
  5. path = '/sequence/id/GENSCAN00000000001?type=protein;db_type=core;species=homo_sapiens;object_type=predictiontranscript'
  6.  
  7. url = URI.parse(server)
  8. http = Net::HTTP.new(url.host, url.port)
  9.  
  10. request = Net::HTTP::Get.new(path, {'Content-Type' => 'application/json'})
  11.  
  12. response = http.request(request)
  13.  
  14. if response.code != "200"
  15. puts "Invalid response: #{response.code}"
  16. puts response.body
  17. exit
  18. end
  19.  
  20.  
  21. require 'rubygems'
  22. require 'json'
  23. require 'yaml'
  24.  
  25. result = JSON.parse(response.body)
  26. puts YAML::dump(result)
  27.  
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import java.net.HttpURLConnection;
  4. import java.io.BufferedReader;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.IOException;
  8. import java.io.Reader;
  9.  
  10.  
  11. public class EnsemblRest {
  12.  
  13. public static void main(String[] args) throws Exception {
  14. String server = "http://rest.ensembl.org";
  15. String ext = "/sequence/id/GENSCAN00000000001?type=protein;db_type=core;species=homo_sapiens;object_type=predictiontranscript";
  16. URL url = new URL(server + ext);
  17.  
  18. URLConnection connection = url.openConnection();
  19. HttpURLConnection httpConnection = (HttpURLConnection)connection;
  20. httpConnection.setRequestProperty("Content-Type", "application/json");
  21.  
  22. InputStream response = connection.getInputStream();
  23. int responseCode = httpConnection.getResponseCode();
  24.  
  25. if(responseCode != 200) {
  26. throw new RuntimeException("Response code was not 200. Detected response was "+responseCode);
  27. }
  28.  
  29. String output;
  30. Reader reader = null;
  31. try {
  32. reader = new BufferedReader(new InputStreamReader(response, "UTF-8"));
  33. StringBuilder builder = new StringBuilder();
  34. char[] buffer = new char[8192];
  35. int read;
  36. while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
  37. builder.append(buffer, 0, read);
  38. }
  39. output = builder.toString();
  40. }
  41. finally {
  42. if (reader != null) try {
  43. reader.close();
  44. } catch (IOException logOrIgnore) {
  45. logOrIgnore.printStackTrace();
  46. }
  47. }
  48.  
  49. System.out.println(output);
  50. }
  51. }
  52.  
  1. library(httr)
  2. library(jsonlite)
  3. library(xml2)
  4.  
  5. server <- "http://rest.ensembl.org"
  6. ext <- "/sequence/id/GENSCAN00000000001?type=protein;db_type=core;species=homo_sapiens;object_type=predictiontranscript"
  7.  
  8. r <- GET(paste(server, ext, sep = ""), content_type("application/json"))
  9.  
  10. stop_for_status(r)
  11.  
  12. # use this if you get a simple nested list back, otherwise inspect its structure
  13. # head(data.frame(t(sapply(content(r),c))))
  14. head(fromJSON(toJSON(content(r))))
  15.  
  1.  
  2. curl 'http://rest.ensembl.org/sequence/id/GENSCAN00000000001?type=protein;db_type=core;species=homo_sapiens;object_type=predictiontranscript' -H 'Content-type:application/json'
  3.  
  1. wget -q --header='Content-type:application/json' 'http://rest.ensembl.org/sequence/id/GENSCAN00000000001?type=protein;db_type=core;species=homo_sapiens;object_type=predictiontranscript' -O -
  2.  

/sequence/id/ENSP00000288602?content-type=application/json


  1. use strict;
  2. use warnings;
  3.  
  4. use HTTP::Tiny;
  5.  
  6. my $http = HTTP::Tiny->new();
  7.  
  8. my $server = 'http://rest.ensembl.org';
  9. my $ext = '/sequence/id/ENSP00000288602?';
  10. my $response = $http->get($server.$ext, {
  11. headers => { 'Content-type' => 'application/json' }
  12. });
  13.  
  14. die "Failed!\n" unless $response->{success};
  15.  
  16.  
  17. use JSON;
  18. use Data::Dumper;
  19. if(length $response->{content}) {
  20. my $hash = decode_json($response->{content});
  21. local $Data::Dumper::Terse = 1;
  22. local $Data::Dumper::Indent = 1;
  23. print Dumper $hash;
  24. print "\n";
  25. }
  26.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENSP00000288602?"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "application/json"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12. decoded = r.json()
  13. print repr(decoded)
  14.  
  1. import requests, sys
  2.  
  3. server = "http://rest.ensembl.org"
  4. ext = "/sequence/id/ENSP00000288602?"
  5.  
  6. r = requests.get(server+ext, headers={ "Content-Type" : "application/json"})
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12. decoded = r.json()
  13. print(repr(decoded))
  14.  
  1. require 'net/http'
  2. require 'uri'
  3.  
  4. server='http://rest.ensembl.org'
  5. path = '/sequence/id/ENSP00000288602?'
  6.  
  7. url = URI.parse(server)
  8. http = Net::HTTP.new(url.host, url.port)
  9.  
  10. request = Net::HTTP::Get.new(path, {'Content-Type' => 'application/json'})
  11.  
  12. response = http.request(request)
  13.  
  14. if response.code != "200"
  15. puts "Invalid response: #{response.code}"
  16. puts response.body
  17. exit
  18. end
  19.  
  20.  
  21. require 'rubygems'
  22. require 'json'
  23. require 'yaml'
  24.  
  25. result = JSON.parse(response.body)
  26. puts YAML::dump(result)
  27.  
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import java.net.HttpURLConnection;
  4. import java.io.BufferedReader;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.IOException;
  8. import java.io.Reader;
  9.  
  10.  
  11. public class EnsemblRest {
  12.  
  13. public static void main(String[] args) throws Exception {
  14. String server = "http://rest.ensembl.org";
  15. String ext = "/sequence/id/ENSP00000288602?";
  16. URL url = new URL(server + ext);
  17.  
  18. URLConnection connection = url.openConnection();
  19. HttpURLConnection httpConnection = (HttpURLConnection)connection;
  20. httpConnection.setRequestProperty("Content-Type", "application/json");
  21.  
  22. InputStream response = connection.getInputStream();
  23. int responseCode = httpConnection.getResponseCode();
  24.  
  25. if(responseCode != 200) {
  26. throw new RuntimeException("Response code was not 200. Detected response was "+responseCode);
  27. }
  28.  
  29. String output;
  30. Reader reader = null;
  31. try {
  32. reader = new BufferedReader(new InputStreamReader(response, "UTF-8"));
  33. StringBuilder builder = new StringBuilder();
  34. char[] buffer = new char[8192];
  35. int read;
  36. while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
  37. builder.append(buffer, 0, read);
  38. }
  39. output = builder.toString();
  40. }
  41. finally {
  42. if (reader != null) try {
  43. reader.close();
  44. } catch (IOException logOrIgnore) {
  45. logOrIgnore.printStackTrace();
  46. }
  47. }
  48.  
  49. System.out.println(output);
  50. }
  51. }
  52.  
  1. library(httr)
  2. library(jsonlite)
  3. library(xml2)
  4.  
  5. server <- "http://rest.ensembl.org"
  6. ext <- "/sequence/id/ENSP00000288602?"
  7.  
  8. r <- GET(paste(server, ext, sep = ""), content_type("application/json"))
  9.  
  10. stop_for_status(r)
  11.  
  12. # use this if you get a simple nested list back, otherwise inspect its structure
  13. # head(data.frame(t(sapply(content(r),c))))
  14. head(fromJSON(toJSON(content(r))))
  15.  
  1.  
  2. curl 'http://rest.ensembl.org/sequence/id/ENSP00000288602?' -H 'Content-type:application/json'
  3.  
  1. wget -q --header='Content-type:application/json' 'http://rest.ensembl.org/sequence/id/ENSP00000288602?' -O -
  2.  

Resource Information

MethodsGET
Response formatsfasta
json
seqxml
text
yaml
jsonp
Slice length1e7