ensemblrest 0.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ensemblrest.rb +12 -13
- data/lib/ensemblrest/archive.rb +34 -0
- data/lib/ensemblrest/comparativegenomics.rb +75 -0
- data/lib/ensemblrest/connect.rb +36 -13
- data/lib/ensemblrest/info.rb +134 -0
- data/lib/ensemblrest/lookup.rb +54 -0
- data/lib/ensemblrest/map.rb +44 -17
- data/lib/ensemblrest/ontoandtaxo.rb +95 -0
- data/lib/ensemblrest/overlap.rb +47 -0
- data/lib/ensemblrest/regulation.rb +27 -0
- data/lib/ensemblrest/sequence.rb +40 -8
- data/lib/ensemblrest/variation.rb +36 -0
- data/lib/ensemblrest/variationga4gh.rb +45 -0
- data/lib/ensemblrest/vep.rb +69 -0
- data/lib/ensemblrest/version.rb +1 -1
- data/lib/ensemblrest/xref.rb +49 -0
- data/lib/test.rb +129 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61c74f74f07aaedc9f7f77b799d7965ab583f306
|
4
|
+
data.tar.gz: 4138d77a8d0fe8c1ee791500c55fca7b6b0d0b15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98a42e9f686cce15bb8d0c376957df4420d2e75620bfdf29fa1d165671a9743ea0b28960f1bac049d1863d4d34d664eb037df7b6bcc6a658385f8d1749a0ff74
|
7
|
+
data.tar.gz: d62c2fc1e5b6feaa29a553a4b7e976d6e26588c90c70e49373e047acfa0ed5c95d78e80186991e613e732c0f574d199464c2d888926d66acfeae27329277a31b
|
data/lib/ensemblrest.rb
CHANGED
@@ -20,19 +20,18 @@ require 'json'
|
|
20
20
|
require 'csv'
|
21
21
|
require 'digest'
|
22
22
|
|
23
|
+
require 'ensemblrest/version'
|
23
24
|
require 'ensemblrest/connect'
|
24
25
|
require 'ensemblrest/sequence'
|
25
26
|
require 'ensemblrest/map'
|
26
|
-
require 'ensemblrest/
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
#p EnsemblREST::sequence_id('ENST00000288602', type: 'cdna').seq.length
|
38
|
-
#p EnsemblREST::sequence_id('ENST00000288602', type: 'cds').seq.length
|
27
|
+
require 'ensemblrest/vep'
|
28
|
+
require 'ensemblrest/overlap'
|
29
|
+
require 'ensemblrest/archive'
|
30
|
+
require 'ensemblrest/comparativegenomics'
|
31
|
+
require 'ensemblrest/xref'
|
32
|
+
require 'ensemblrest/info'
|
33
|
+
require 'ensemblrest/lookup'
|
34
|
+
require 'ensemblrest/ontoandtaxo'
|
35
|
+
require 'ensemblrest/regulation'
|
36
|
+
require 'ensemblrest/variation'
|
37
|
+
require 'ensemblrest/variationga4gh'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Bio-ensemblrest
|
2
|
+
#
|
3
|
+
# Copyright (C) 2015
|
4
|
+
#
|
5
|
+
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
6
|
+
#
|
7
|
+
# Documentation: Natapol Pornputtapong (RDoc'd and embellished by William Webber)
|
8
|
+
#
|
9
|
+
|
10
|
+
# raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
11
|
+
|
12
|
+
module EnsemblREST
|
13
|
+
|
14
|
+
module Archive
|
15
|
+
module_function
|
16
|
+
# Uses the given identifier to return the archived sequence
|
17
|
+
#
|
18
|
+
# @param [String] An Ensembl stable ID
|
19
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/archive_id_get
|
20
|
+
# @return [JSON] Variants consequences
|
21
|
+
def id_get(id, options = {})
|
22
|
+
return EnsemblREST.get("archive/id/#{id}", {format: 'json'}.merge(options))
|
23
|
+
end
|
24
|
+
|
25
|
+
# Retrieve the archived sequence for a set of identifiers
|
26
|
+
#
|
27
|
+
# @param [Array] Ensembl stable IDs
|
28
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/archive_id_post
|
29
|
+
# @return [JSON] Requested response
|
30
|
+
def id_post(ids, options = {})
|
31
|
+
return EnsemblREST.post("archive/id", {"id" => ids}, {format: 'json'}.merge(options))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Bio-ensemblrest
|
2
|
+
#
|
3
|
+
# Copyright (C) 2015
|
4
|
+
#
|
5
|
+
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
6
|
+
#
|
7
|
+
# Documentation: Natapol Pornputtapong (RDoc'd and embellished by William Webber)
|
8
|
+
#
|
9
|
+
|
10
|
+
# raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
11
|
+
|
12
|
+
module EnsemblREST
|
13
|
+
|
14
|
+
module Comparative
|
15
|
+
|
16
|
+
module_function
|
17
|
+
|
18
|
+
# Retrieves a gene tree dump for a gene tree stable identifier
|
19
|
+
#
|
20
|
+
# @param [String] An Ensembl genetree ID
|
21
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/genetree
|
22
|
+
# @return [JSON] a gene tree
|
23
|
+
def genetree(id, options = {})
|
24
|
+
return EnsemblREST.get("genetree/id/#{id}", {format: 'json'}.merge(options))
|
25
|
+
end
|
26
|
+
|
27
|
+
# Retrieves a gene tree that contains the stable identifier
|
28
|
+
#
|
29
|
+
# @param [String] An Ensembl stable ID
|
30
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/genetree_member_id
|
31
|
+
# @return [JSON] gene trees
|
32
|
+
def genetree_member_id(id, options = {})
|
33
|
+
return EnsemblREST.get("genetree/member/id/#{id}", {format: 'json'}.merge(options))
|
34
|
+
end
|
35
|
+
|
36
|
+
# Retrieves a gene tree containing the gene identified by a symbol
|
37
|
+
#
|
38
|
+
# @param [String] Symbol or display name of a gene
|
39
|
+
# @param [String] Species name/alias
|
40
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/genetree_member_symbol
|
41
|
+
# @return [JSON] gene trees
|
42
|
+
def genetree_member_symbol(symbol, species = 'human', options = {})
|
43
|
+
return EnsemblREST.get("genetree/member/symbol/#{species}/#{symbol}", {format: 'json'}.merge(options))
|
44
|
+
end
|
45
|
+
|
46
|
+
# Retrieves genomic alignments as separate blocks based on a region and species
|
47
|
+
#
|
48
|
+
# @param [String] Query region. A maximum of 10Mb is allowed to be requested at any one time
|
49
|
+
# @param [String] Species name/alias
|
50
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/genomic_alignment_region
|
51
|
+
# @return [JSON] an alignment
|
52
|
+
def genomic_alignment_region(region, species = 'human', options = {})
|
53
|
+
return EnsemblREST.get("alignment/region/#{species}/#{region}", {format: 'json'}.merge(options))
|
54
|
+
end
|
55
|
+
|
56
|
+
# Retrieves homology information (orthologs) by Ensembl gene id
|
57
|
+
#
|
58
|
+
# @param [String] An Ensembl stable ID
|
59
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/homology_ensemblgene
|
60
|
+
# @return [JSON] a homology information
|
61
|
+
def homology_ensemblgene(id, options = {})
|
62
|
+
return EnsemblREST.get("homology/id/#{id}", {format: 'json'}.merge(options))
|
63
|
+
end
|
64
|
+
|
65
|
+
# Retrieves homology information (orthologs) by symbol
|
66
|
+
#
|
67
|
+
# @param [String] Symbol or display name of a gene
|
68
|
+
# @param [String] Species name/alias
|
69
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/homology_symbol
|
70
|
+
# @return [JSON] gene trees
|
71
|
+
def homology_symbol(symbol, species = 'human', options = {})
|
72
|
+
return EnsemblREST.get("homology/symbol/#{species}/#{symbol}", {format: 'json'}.merge(options))
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/ensemblrest/connect.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
2
1
|
# Bio-ensemblrest
|
3
|
-
#
|
2
|
+
#
|
3
|
+
# Copyright (C) 2015
|
4
4
|
#
|
5
5
|
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
6
6
|
#
|
@@ -27,33 +27,48 @@ module EnsemblREST
|
|
27
27
|
'xml' => 'text/xml',
|
28
28
|
'yaml' => 'text/x-yaml'
|
29
29
|
}
|
30
|
+
|
31
|
+
class InvalidResponse < Exception
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
class ServiceNotFound < Exception
|
30
36
|
|
37
|
+
end
|
31
38
|
|
32
39
|
module_function
|
33
40
|
|
41
|
+
# Connect to Ensembl REST Service
|
42
|
+
#
|
43
|
+
# @param [String] Base Ensembl REST Service URL
|
34
44
|
def connect(server)
|
35
45
|
@@url = URI.parse(server)
|
36
46
|
@@http_connect = Net::HTTP.new(@@url.host, @@url.port)
|
37
47
|
end
|
38
48
|
|
49
|
+
# Switch to use GRCh37 assembly version
|
39
50
|
def use_GRCh37
|
40
51
|
@@url = URI.parse('http://grch37.rest.ensembl.org/')
|
41
52
|
@@http_connect = Net::HTTP.new(@@url.host, @@url.port)
|
42
53
|
end
|
43
54
|
|
55
|
+
# Switch to use GRCh37 assembly version
|
44
56
|
def use37
|
45
57
|
EnsemblREST::use_GRCh37
|
46
58
|
end
|
47
59
|
|
60
|
+
# Switch to use GRCh38 assembly version
|
48
61
|
def use_GRCh38
|
49
62
|
@@url = URI.parse('http://rest.ensembl.org/')
|
50
63
|
@@http_connect = Net::HTTP.new(@@url.host, @@url.port)
|
51
64
|
end
|
52
65
|
|
66
|
+
# Switch to use GRCh38 assembly version
|
53
67
|
def use38
|
54
68
|
EnsemblREST::use_GRCh38
|
55
69
|
end
|
56
70
|
|
71
|
+
# Parse options use in the Module only
|
57
72
|
def parse_options(options)
|
58
73
|
parsed_options = {opts: [], format: {}}
|
59
74
|
options.each do |k, v|
|
@@ -62,13 +77,14 @@ module EnsemblREST
|
|
62
77
|
elsif k.to_s == 'content-type'
|
63
78
|
parsed_options[:format] = {'content-type' => v}
|
64
79
|
else
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
80
|
+
if v.is_a?(TrueClass)
|
81
|
+
parsed_options[:opts].push("#{k}=1")
|
82
|
+
elsif v.is_a?(FalseClass)
|
83
|
+
parsed_options[:opts].push("#{k}=0")
|
84
|
+
elsif v.is_a?(Array)
|
85
|
+
v.each {|member| parsed_options[:opts].push("#{k}=#{member}")}
|
70
86
|
else
|
71
|
-
"#{k}=#{v}"
|
87
|
+
parsed_options[:opts].push("#{k}=#{v}")
|
72
88
|
end
|
73
89
|
end
|
74
90
|
|
@@ -76,6 +92,7 @@ module EnsemblREST
|
|
76
92
|
return parsed_options
|
77
93
|
end
|
78
94
|
|
95
|
+
# Parse responses use in the Module only
|
79
96
|
def parse_response(response, type)
|
80
97
|
case response.code
|
81
98
|
when '200'
|
@@ -91,19 +108,25 @@ module EnsemblREST
|
|
91
108
|
else
|
92
109
|
return response.body
|
93
110
|
end
|
111
|
+
when '404'
|
112
|
+
raise EnsemblREST::ServiceNotFound, "Service not found"
|
94
113
|
else
|
95
|
-
raise "Invalid response: #{response.code}"
|
114
|
+
raise EnsemblREST::InvalidResponse, "Invalid response: #{response.code}"
|
96
115
|
end
|
97
116
|
end
|
98
117
|
|
118
|
+
# Do a get request
|
99
119
|
def get(get_path, options)
|
100
120
|
parsed_options = EnsemblREST::parse_options(options)
|
101
121
|
request = Net::HTTP::Get.new("#{get_path}#{parsed_options[:opts].empty? ? '' : "?#{parsed_options[:opts].join(';')}"}", parsed_options[:format])
|
102
122
|
return EnsemblREST::parse_response(@@http_connect.request(request), parsed_options[:format]['content-type'])
|
103
123
|
end
|
104
124
|
|
105
|
-
#
|
106
|
-
|
107
|
-
|
108
|
-
|
125
|
+
# Do a post request
|
126
|
+
def post(post_path, request_body, options)
|
127
|
+
parsed_options = EnsemblREST::parse_options(options)
|
128
|
+
request = Net::HTTP::Post.new(post_path, parsed_options[:format].merge({'Accept' => 'application/json'}))
|
129
|
+
request.body = request_body.to_json
|
130
|
+
return EnsemblREST::parse_response(@@http_connect.request(request), parsed_options[:format]['content-type'])
|
131
|
+
end
|
109
132
|
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# Bio-ensemblrest
|
2
|
+
#
|
3
|
+
# Copyright (C) 2015
|
4
|
+
#
|
5
|
+
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
6
|
+
#
|
7
|
+
# Documentation: Natapol Pornputtapong (RDoc'd and embellished by William Webber)
|
8
|
+
#
|
9
|
+
|
10
|
+
# raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
11
|
+
|
12
|
+
module EnsemblREST
|
13
|
+
|
14
|
+
module Info
|
15
|
+
module_function
|
16
|
+
|
17
|
+
# List the names of analyses involved in generating Ensembl data.
|
18
|
+
#
|
19
|
+
# @param [String] Species name/alias
|
20
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/analysis
|
21
|
+
# @return [JSON] List the names of analyses
|
22
|
+
def analysis(species = 'human', options = {})
|
23
|
+
return EnsemblREST.get("info/analysis/#{species}", {format: 'json'}.merge(options))
|
24
|
+
end
|
25
|
+
|
26
|
+
# List the currently available assemblies for a species.
|
27
|
+
#
|
28
|
+
# @param [String] Species name/alias
|
29
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/assembly_info
|
30
|
+
# @return [JSON] List the currently available assemblies
|
31
|
+
def assembly_info(species = 'human', options = {})
|
32
|
+
return EnsemblREST.get("info/assembly/#{species}", {format: 'json'}.merge(options))
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns information about the specified toplevel sequence region for the given species.
|
36
|
+
#
|
37
|
+
# @param [String] The (top level) sequence region name.
|
38
|
+
# @param [String] Species name/alias
|
39
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/assembly_stats
|
40
|
+
# @return [JSON] Returns information about the specified toplevel sequence region
|
41
|
+
def assembly_stats(region_name, species = 'human', options = {})
|
42
|
+
return EnsemblREST.get("info/assembly/#{species}/#{region_name}", {format: 'json'}.merge(options))
|
43
|
+
end
|
44
|
+
|
45
|
+
# List the functional classifications of gene models that Ensembl associates with a particular species.
|
46
|
+
# Useful for restricting the type of genes/transcripts retrieved by other endpoints.
|
47
|
+
#
|
48
|
+
# @param [String] Species name/alias
|
49
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/biotypes
|
50
|
+
# @return [JSON] List the currently available assemblies
|
51
|
+
def biotypes(species = 'human', options = {})
|
52
|
+
return EnsemblREST.get("info/biotypes/#{species}", {format: 'json'}.merge(options))
|
53
|
+
end
|
54
|
+
|
55
|
+
# List all compara analyses available (an analysis defines the type of comparative data).
|
56
|
+
#
|
57
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/compara_methods
|
58
|
+
# @return [JSON] List all compara analyses
|
59
|
+
def compara_methods(options = {})
|
60
|
+
return EnsemblREST.get("info/compara/methods", {format: 'json'}.merge(options))
|
61
|
+
end
|
62
|
+
|
63
|
+
# List all collections of species analysed with the specified compara method.
|
64
|
+
#
|
65
|
+
# @param [String] Filter by compara method. Use one the methods returned by /info/compara/methods endpoint.
|
66
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/compara_species_sets
|
67
|
+
# @return [JSON] List the currently available assemblies
|
68
|
+
def compara_species_sets(method, options = {})
|
69
|
+
return EnsemblREST.get("info/compara/species_sets/#{method}", {format: 'json'}.merge(options))
|
70
|
+
end
|
71
|
+
|
72
|
+
# Lists all available comparative genomics databases and their data release.
|
73
|
+
#
|
74
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/comparas
|
75
|
+
# @return [JSON] List all compara analyses
|
76
|
+
def comparas(options = {})
|
77
|
+
return EnsemblREST.get("info/comparas", {format: 'json'}.merge(options))
|
78
|
+
end
|
79
|
+
|
80
|
+
# Shows the data releases available on this REST server. May return more than one release (unfrequent non-standard Ensembl configuration).
|
81
|
+
#
|
82
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/data
|
83
|
+
# @return [JSON] Shows the data releases available on this REST server
|
84
|
+
def data(options = {})
|
85
|
+
return EnsemblREST.get("info/data", {format: 'json'}.merge(options))
|
86
|
+
end
|
87
|
+
|
88
|
+
# Lists all available external sources for a species.
|
89
|
+
#
|
90
|
+
# @param [String] Species name/alias
|
91
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/external_dbs
|
92
|
+
# @return [JSON] Lists all available external sources
|
93
|
+
def external_dbs(species = 'human', options = {})
|
94
|
+
return EnsemblREST.get("info/external_dbs/#{species}", {format: 'json'}.merge(options))
|
95
|
+
end
|
96
|
+
|
97
|
+
# Checks if the service is alive.
|
98
|
+
#
|
99
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/ping
|
100
|
+
# @return [Boolean] True/False
|
101
|
+
def ping(options = {})
|
102
|
+
begin
|
103
|
+
EnsemblREST.get("info/ping", {format: 'json'}.merge(options))
|
104
|
+
return true
|
105
|
+
rescue EnsemblREST::ServiceNotFound
|
106
|
+
return false
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Shows the current version of the Ensembl REST API.
|
111
|
+
#
|
112
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/rest
|
113
|
+
# @return [String] version of this REST server
|
114
|
+
def rest(options = {})
|
115
|
+
return EnsemblREST.get("info/rest", {format: 'json'}.merge(options))["release"]
|
116
|
+
end
|
117
|
+
|
118
|
+
# Shows the current version of the Ensembl API used by the REST server.
|
119
|
+
#
|
120
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/software
|
121
|
+
# @return [String] the current version of the Ensembl API
|
122
|
+
def software(options = {})
|
123
|
+
return EnsemblREST.get("info/software", {format: 'json'}.merge(options))["release"]
|
124
|
+
end
|
125
|
+
|
126
|
+
# Lists all available species, their aliases, available adaptor groups and data release.
|
127
|
+
#
|
128
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/species
|
129
|
+
# @return [String] Lists all available species
|
130
|
+
def species(options = {})
|
131
|
+
return EnsemblREST.get("info/species", {format: 'json'}.merge(options))
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Bio-ensemblrest
|
2
|
+
#
|
3
|
+
# Copyright (C) 2015
|
4
|
+
#
|
5
|
+
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
6
|
+
#
|
7
|
+
# Documentation: Natapol Pornputtapong (RDoc'd and embellished by William Webber)
|
8
|
+
#
|
9
|
+
|
10
|
+
# raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
11
|
+
|
12
|
+
module EnsemblREST
|
13
|
+
module Lookup
|
14
|
+
module_function
|
15
|
+
|
16
|
+
# Find the species and database for a symbol in a linked external database
|
17
|
+
#
|
18
|
+
# @param [String] A name or symbol from an annotation source has been linked to a genetic feature
|
19
|
+
# @param [String] Species name/alias
|
20
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/symbol_lookup
|
21
|
+
# @return [JSON] Cross references
|
22
|
+
def symbol(symbol, species = 'human', options = {})
|
23
|
+
return EnsemblREST.get("lookup/symbol/#{species}/#{symbol}", {format: 'json'}.merge(options))
|
24
|
+
end
|
25
|
+
|
26
|
+
# Find the species and database for a single identifier
|
27
|
+
#
|
28
|
+
# @param [String] An Ensembl Stable ID
|
29
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/lookup
|
30
|
+
# @return [JSON] Cross references
|
31
|
+
def id(id, options = {})
|
32
|
+
return EnsemblREST.get("lookup/id/#{id}", {format: 'json'}.merge(options))
|
33
|
+
end
|
34
|
+
|
35
|
+
# Find the species and database for a set of symbols in a linked external database. Unknown symbols are omitted from the response.
|
36
|
+
#
|
37
|
+
# @param [String] An array of names or symbols from an annotation source has been linked to a genetic feature
|
38
|
+
# @param [String] Species name/alias
|
39
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/symbol_post
|
40
|
+
# @return [JSON] Cross references
|
41
|
+
def symbol_post(symbols, species = 'human', options = {})
|
42
|
+
return EnsemblREST.post("lookup/symbol/#{species}", {'symbols' => symbols}, {format: 'json'}.merge(options))
|
43
|
+
end
|
44
|
+
|
45
|
+
# Find the species and database for several identifiers. IDs that are not found are returned with no data.
|
46
|
+
#
|
47
|
+
# @param [String] Ensembl Stable IDs
|
48
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/lookup_post
|
49
|
+
# @return [JSON] Cross references
|
50
|
+
def id_post(ids, options = {})
|
51
|
+
return EnsemblREST.post("lookup/id", {'ids' => ids}, {format: 'json'}.merge(options))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/ensemblrest/map.rb
CHANGED
@@ -11,22 +11,49 @@
|
|
11
11
|
|
12
12
|
module EnsemblREST
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
14
|
+
module Map
|
15
|
+
module_function
|
16
|
+
|
17
|
+
# Convert from cDNA coordinates to genomic coordinates. Output reflects forward orientation coordinates as returned from the Ensembl API.
|
18
|
+
#
|
19
|
+
# @param [String] An Ensembl stable ID
|
20
|
+
# @param [String] Query region
|
21
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/assembly_cdna
|
22
|
+
# @return [JSON] genomic coordinates
|
23
|
+
def cdna(id, region, options = {})
|
24
|
+
return EnsemblREST.get("map/cdna/#{id}/#{region}", {format: 'json'}.merge(options))
|
25
|
+
end
|
26
|
+
|
27
|
+
# Convert from CDS coordinates to genomic coordinates. Output reflects forward orientation coordinates as returned from the Ensembl API.
|
28
|
+
#
|
29
|
+
# @param [String] An Ensembl stable ID
|
30
|
+
# @param [String] Query region
|
31
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/assembly_cds
|
32
|
+
# @return [JSON] genomic coordinates
|
33
|
+
def cds(id, region, options = {})
|
34
|
+
return EnsemblREST.get("map/cds/#{id}/#{region}", {format: 'json'}.merge(options))
|
35
|
+
end
|
36
|
+
|
37
|
+
# Convert the co-ordinates of one assembly to another
|
38
|
+
#
|
39
|
+
# @param [String] Query region
|
40
|
+
# @param [String] Version of the input assembly
|
41
|
+
# @param [String] Version of the output assembly
|
42
|
+
# @param [String] Species name/alias
|
43
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/assembly_map
|
44
|
+
# @return [JSON] genomic coordinates
|
45
|
+
def map(region, asm_one, asm_two, species = 'human', options = {})
|
46
|
+
return EnsemblREST.get("map/#{species}/#{asm_one}/#{region}/#{asm_two}", {format: 'json'}.merge(options))
|
47
|
+
end
|
48
|
+
|
49
|
+
# Convert from protein (translation) coordinates to genomic coordinates. Output reflects forward orientation coordinates as returned from the Ensembl API.
|
50
|
+
#
|
51
|
+
# @param [String] An Ensembl stable ID
|
52
|
+
# @param [String] Query region
|
53
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/assembly_translation
|
54
|
+
# @return [JSON] genomic coordinates
|
55
|
+
def translation(id, region, options = {})
|
56
|
+
return EnsemblREST.get("map/translation/#{id}/#{region}", {format: 'json'}.merge(options))
|
57
|
+
end
|
30
58
|
end
|
31
|
-
|
32
59
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# Bio-ensemblrest
|
2
|
+
#
|
3
|
+
# Copyright (C) 2015
|
4
|
+
#
|
5
|
+
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
6
|
+
#
|
7
|
+
# Documentation: Natapol Pornputtapong (RDoc'd and embellished by William Webber)
|
8
|
+
#
|
9
|
+
|
10
|
+
# raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
11
|
+
|
12
|
+
module EnsemblREST
|
13
|
+
|
14
|
+
module Ontology
|
15
|
+
|
16
|
+
module_function
|
17
|
+
|
18
|
+
# Reconstruct the entire ancestry of a term from is_a and part_of relationships
|
19
|
+
#
|
20
|
+
# @param [String] An ontology term identifier
|
21
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/ontology_ancestors
|
22
|
+
# @return [JSON] the entire ancestry of a term
|
23
|
+
def ancestors(id, options = {})
|
24
|
+
return EnsemblREST.get("ontology/ancestors/#{id}", {format: 'json'}.merge(options))
|
25
|
+
end
|
26
|
+
|
27
|
+
# Reconstruct the entire ancestry of a term from is_a and part_of relationships.
|
28
|
+
#
|
29
|
+
# @param [String] An ontology term identifier
|
30
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/ontology_ancestors_chart
|
31
|
+
# @return [JSON] the entire ancestry of a term
|
32
|
+
def ancestors_chart(id, options = {})
|
33
|
+
return EnsemblREST.get("ontology/ancestors/chart/#{id}", {format: 'json'}.merge(options))
|
34
|
+
end
|
35
|
+
|
36
|
+
# Find all the terms descended from a given term. By default searches are conducted within the namespace of the given identifier
|
37
|
+
#
|
38
|
+
# @param [String] An ontology term identifier
|
39
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/ontology_descendants
|
40
|
+
# @return [JSON] the terms descended from a given term
|
41
|
+
def descendants(id, options = {})
|
42
|
+
return EnsemblREST.get("ontology/descendants/#{id}", {format: 'json'}.merge(options))
|
43
|
+
end
|
44
|
+
|
45
|
+
# Search for an ontological term by its namespaced identifier
|
46
|
+
#
|
47
|
+
# @param [String] An ontology term identifier
|
48
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/ontology_id
|
49
|
+
# @return [JSON] an ontological term
|
50
|
+
def id(name, options = {})
|
51
|
+
return EnsemblREST.get("ontology/id/#{name}", {format: 'json'}.merge(options))
|
52
|
+
end
|
53
|
+
|
54
|
+
# Search for a list of ontological terms by their name
|
55
|
+
#
|
56
|
+
# @param [String] An ontology name. SQL wildcards are supported
|
57
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/ontology_name
|
58
|
+
# @return [JSON] a list of ontological terms
|
59
|
+
def name(name, options = {})
|
60
|
+
return EnsemblREST.get("ontology/name/#{URI.escape(name)}", {format: 'json'}.merge(options))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
module Taxonomy
|
65
|
+
|
66
|
+
module_function
|
67
|
+
|
68
|
+
# Return the taxonomic classification of a taxon node
|
69
|
+
#
|
70
|
+
# @param [String] A taxon identifier. Can be a NCBI taxon id or a name
|
71
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/taxonomy_classification
|
72
|
+
# @return [JSON] the taxonomic classification
|
73
|
+
def classification(id, options = {})
|
74
|
+
return EnsemblREST.get("taxonomy/classification/#{id}", {format: 'json'}.merge(options))
|
75
|
+
end
|
76
|
+
|
77
|
+
# Search for a taxonomic term by its identifier or name
|
78
|
+
#
|
79
|
+
# @param [String] A taxon identifier. Can be a NCBI taxon id or a name
|
80
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/taxonomy_id
|
81
|
+
# @return [JSON] the taxonomic classification
|
82
|
+
def id(id, options = {})
|
83
|
+
return EnsemblREST.get("taxonomy/id/#{id}", {format: 'json'}.merge(options))
|
84
|
+
end
|
85
|
+
|
86
|
+
# Search for a taxonomic id by a non-scientific name
|
87
|
+
#
|
88
|
+
# @param [String] A non-scientific species name. Can include SQL wildcards
|
89
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/taxonomy_name
|
90
|
+
# @return [JSON] the taxonomic classification
|
91
|
+
def name(name, options = {})
|
92
|
+
return EnsemblREST.get("taxonomy/name/#{URI.escape(name)}", {format: 'json'}.merge(options))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Copyright (C) 2015
|
2
|
+
#
|
3
|
+
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
4
|
+
#
|
5
|
+
# Documentation: Natapol Pornputtapong (RDoc'd and embellished by William Webber)
|
6
|
+
#
|
7
|
+
|
8
|
+
# raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
9
|
+
|
10
|
+
module EnsemblREST
|
11
|
+
|
12
|
+
module Overlap
|
13
|
+
module_function
|
14
|
+
|
15
|
+
# Request multiple types of sequence by a list of regions.
|
16
|
+
#
|
17
|
+
# @param [Array] Query regions. A maximum of 10Mb is allowed to be requested at any one time
|
18
|
+
# @param [Array] The type of feature to retrieve. Multiple values are accepted. Array of gene, transcript, cds, exon, repeat, simple, misc, variation, somatic_variation,
|
19
|
+
# structural_variation, somatic_structural_variation, constrained, regulatory, segmentation, motif, chipseq, array_probe
|
20
|
+
# @param [String] Species name/alias
|
21
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/overlap_region
|
22
|
+
# @return [JSON] Requested response
|
23
|
+
def region(region, features = [], species = 'human', options = {})
|
24
|
+
return EnsemblREST.get("overlap/region/#{species}/#{region}", {format: 'json', feature: features}.merge(options))
|
25
|
+
end
|
26
|
+
|
27
|
+
# Retrieves features (e.g. genes, transcripts, variations etc.) that overlap a region defined by the given identifier.
|
28
|
+
#
|
29
|
+
# @param [String] An Ensembl stable ID
|
30
|
+
# @param [Array] The type of feature to retrieve. Multiple values are accepted. Array of gene, transcript, cds, exon, repeat, simple, misc, variation, somatic_variation,
|
31
|
+
# structural_variation, somatic_structural_variation, constrained, regulatory, segmentation, motif, chipseq, array_probe
|
32
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/overlap_id
|
33
|
+
# @return [JSON] Requested response
|
34
|
+
def id(id, features = [], options = {})
|
35
|
+
return EnsemblREST.get("overlap/id/#{id}", {format: 'json', feature: features}.merge(options))
|
36
|
+
end
|
37
|
+
|
38
|
+
# Retrieve features related to a specific Translation as described by its stable ID (e.g. domains, variations).
|
39
|
+
#
|
40
|
+
# @param [String] An Ensembl stable ID
|
41
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/overlap_translation
|
42
|
+
# @return [JSON] Requested response
|
43
|
+
def translation(id, options = {})
|
44
|
+
return EnsemblREST.get("overlap/translation/#{id}", {format: 'json'}.merge(options))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Bio-ensemblrest
|
2
|
+
#
|
3
|
+
# Copyright (C) 2015
|
4
|
+
#
|
5
|
+
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
6
|
+
#
|
7
|
+
# Documentation: Natapol Pornputtapong (RDoc'd and embellished by William Webber)
|
8
|
+
#
|
9
|
+
|
10
|
+
# raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
11
|
+
|
12
|
+
module EnsemblREST
|
13
|
+
|
14
|
+
module Regulation
|
15
|
+
module_function
|
16
|
+
|
17
|
+
# Returns a RegulatoryFeature given its stable ID (e.g. ENSR00001348195)
|
18
|
+
#
|
19
|
+
# @param [String] RegulatoryFeature stable ID
|
20
|
+
# @param [String] Species name/alias
|
21
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/regulatory_id
|
22
|
+
# @return [JSON] the entire ancestry of a term
|
23
|
+
def id(id, species = 'human', options = {})
|
24
|
+
return EnsemblREST.get("regulatory/#{species}/#{id}", {format: 'json'}.merge(options))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/ensemblrest/sequence.rb
CHANGED
@@ -11,13 +11,45 @@
|
|
11
11
|
|
12
12
|
module EnsemblREST
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
return
|
14
|
+
module Sequence
|
15
|
+
module_function
|
16
|
+
|
17
|
+
# Request multiple types of sequence by stable identifier.
|
18
|
+
#
|
19
|
+
# @param [String] An Ensembl stable ID
|
20
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/sequence_id
|
21
|
+
# @return [FastaFormat] requested sequence
|
22
|
+
def id(id, options = {})
|
23
|
+
return EnsemblREST.get("sequence/id/#{id}", {format: 'fasta'}.merge(options))
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the genomic sequence of the specified region of the given species.
|
27
|
+
#
|
28
|
+
# @param [String] Query region. A maximum of 10Mb is allowed to be requested at any one time
|
29
|
+
# @param [String] Species name/alias
|
30
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/sequence_region
|
31
|
+
# @return [FastaFormat] requested sequence
|
32
|
+
def region(region, species = 'human', options = {})
|
33
|
+
return EnsemblREST.get("sequence/region/#{species}/#{region}", {format: 'fasta'}.merge(options))
|
34
|
+
end
|
35
|
+
|
36
|
+
# Request multiple types of sequence by a stable identifier list.
|
37
|
+
#
|
38
|
+
# @param [Array] Ensembl stable IDs
|
39
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/sequence_id_post
|
40
|
+
# @return [JSON] Requested response
|
41
|
+
def id_post(ids, options = {})
|
42
|
+
return EnsemblREST.post("sequence/id", {"ids" => ids}, {format: 'json'}.merge(options))
|
43
|
+
end
|
44
|
+
|
45
|
+
# Request multiple types of sequence by a list of regions.
|
46
|
+
#
|
47
|
+
# @param [Array] Query regions. A maximum of 10Mb is allowed to be requested at any one time
|
48
|
+
# @param [String] Species name/alias
|
49
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/sequence_region_post
|
50
|
+
# @return [JSON] Requested response
|
51
|
+
def region_post(regions, species = 'human', options = {})
|
52
|
+
return EnsemblREST.post("sequence/region/#{species}", {"regions" => regions}, {format: 'json'}.merge(options))
|
53
|
+
end
|
22
54
|
end
|
23
55
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Bio-ensemblrest
|
2
|
+
#
|
3
|
+
# Copyright (C) 2015
|
4
|
+
#
|
5
|
+
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
6
|
+
#
|
7
|
+
# Documentation: Natapol Pornputtapong (RDoc'd and embellished by William Webber)
|
8
|
+
#
|
9
|
+
|
10
|
+
# raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
11
|
+
|
12
|
+
module EnsemblREST
|
13
|
+
|
14
|
+
module Variation
|
15
|
+
module_function
|
16
|
+
|
17
|
+
# Uses a variation identifier (e.g. rsID) to return the variation features
|
18
|
+
#
|
19
|
+
# @param [String] RegulatoryFeature stable ID
|
20
|
+
# @param [String] Species name/alias
|
21
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/variation_id
|
22
|
+
# @return [JSON] the variation features
|
23
|
+
def id(id, species = 'human', options = {})
|
24
|
+
return EnsemblREST.get("variation/#{species}/#{id}", {format: 'json'}.merge(options))
|
25
|
+
end
|
26
|
+
|
27
|
+
# Uses a list of variation identifiers (e.g. rsID) to return the variation features
|
28
|
+
#
|
29
|
+
# @param [String] Species name/alias
|
30
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/variation_post
|
31
|
+
# @return [JSON] the variation features
|
32
|
+
def post(ids, species = 'human', options = {})
|
33
|
+
return EnsemblREST.post("variation/#{species}", {"ids" => ids}, {format: 'json'}.merge(options))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Bio-ensemblrest
|
2
|
+
#
|
3
|
+
# Copyright (C) 2015
|
4
|
+
#
|
5
|
+
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
6
|
+
#
|
7
|
+
# Documentation: Natapol Pornputtapong (RDoc'd and embellished by William Webber)
|
8
|
+
#
|
9
|
+
|
10
|
+
# raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
11
|
+
|
12
|
+
module EnsemblREST
|
13
|
+
|
14
|
+
module GA4GH
|
15
|
+
module_function
|
16
|
+
|
17
|
+
# Return a list of sets of genotype calls for specific samples in GA4GH format
|
18
|
+
#
|
19
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/gacallSet
|
20
|
+
# @return [JSON] a list of sets of genotype calls for specific samples
|
21
|
+
def gacallSet(options = {})
|
22
|
+
return EnsemblREST.post("ga4gh/callsets/search", {}, {format: 'json'}.merge(options))
|
23
|
+
end
|
24
|
+
|
25
|
+
# Return variant call information in GA4GH format for a region on a reference sequence
|
26
|
+
#
|
27
|
+
# @param [Integer] Start position of region (zero-based, inclusive)
|
28
|
+
# @param [Integer] End position of region (zero-based, exclusive)
|
29
|
+
# @param [String] Reference sequence name
|
30
|
+
# @param [String] Return variant data for specific variantSets
|
31
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/gavariants
|
32
|
+
# @return [JSON] variant call information in GA4GH format
|
33
|
+
def gavariants(start, stop, referenceName, variantSetIds, options = {})
|
34
|
+
return EnsemblREST.post("ga4gh/variants/search", {"variantSetIds" => variantSetIds, "referenceName" => referenceName,"start" => start ,"end" => stop}, {format: 'json'}.merge(options))
|
35
|
+
end
|
36
|
+
|
37
|
+
# Return a list of variant sets in GA4GH format
|
38
|
+
#
|
39
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/gavariantset
|
40
|
+
# @return [JSON] a list of variant sets in GA4GH format
|
41
|
+
def gavariantset(options = {})
|
42
|
+
return EnsemblREST.post("ga4gh/variantsets/search", {}, {format: 'json'}.merge(options))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Bio-ensemblrest
|
2
|
+
#
|
3
|
+
# Copyright (C) 2015
|
4
|
+
#
|
5
|
+
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
6
|
+
#
|
7
|
+
# Documentation: Natapol Pornputtapong (RDoc'd and embellished by William Webber)
|
8
|
+
#
|
9
|
+
|
10
|
+
# raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
11
|
+
|
12
|
+
module EnsemblREST
|
13
|
+
|
14
|
+
module VEP
|
15
|
+
|
16
|
+
module_function
|
17
|
+
|
18
|
+
# Fetch variant consequences
|
19
|
+
#
|
20
|
+
# @param [String] Variation allele, Example Values: 'C', 'DUP'
|
21
|
+
# @param [String] Query region. Example Values: '9:22125503-22125502:1', '7:100318423-100321323:1'
|
22
|
+
# @param [String] Species name/alias
|
23
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/vep_region_get
|
24
|
+
# @return [JSON] Variants consequences
|
25
|
+
def region_get(allele, region, species = 'human', options = {})
|
26
|
+
return EnsemblREST.get("vep/#{species}/region/#{region}/#{allele}", {format: 'json'}.merge(options))
|
27
|
+
end
|
28
|
+
|
29
|
+
# Fetch variant consequences based on a variation identifier
|
30
|
+
#
|
31
|
+
# @param [String] Query ID. Supports dbSNP, COSMIC and HGMD identifiers
|
32
|
+
# @param [String] Species name/alias
|
33
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/vep_region_get
|
34
|
+
# @return [JSON] Variants consequences
|
35
|
+
def id_get(id, species = 'human', options = {})
|
36
|
+
return EnsemblREST.get("vep/#{species}/id/#{id}", {format: 'json'}.merge(options))
|
37
|
+
end
|
38
|
+
|
39
|
+
# Fetch variant consequences based on a HGVS notation
|
40
|
+
#
|
41
|
+
# @param [String] HGVS notation. May be genomic (g), coding (c) or protein (p), with reference to chromosome name, gene name, transcript ID or protein ID.
|
42
|
+
# @param [String] Species name/alias
|
43
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/vep_hgvs_get
|
44
|
+
# @return [JSON] Variants consequences
|
45
|
+
def hgvs_get(hgvs_notation, species = 'human', options = {})
|
46
|
+
return EnsemblREST.get("vep/#{species}/hgvs/#{hgvs_notation}", {format: 'json'}.merge(options))
|
47
|
+
end
|
48
|
+
|
49
|
+
# Fetch variant consequences for multiple ids
|
50
|
+
#
|
51
|
+
# @param [Array] Query IDs. Supports dbSNP, COSMIC and HGMD identifiers
|
52
|
+
# @param [String] Species name/alias
|
53
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/vep_id_post
|
54
|
+
# @return [JSON] Variants consequences
|
55
|
+
def id_post(ids, species = 'human', options = {})
|
56
|
+
return EnsemblREST.post("vep/#{species}/id", {"ids" => ids}, {format: 'json'}.merge(options))
|
57
|
+
end
|
58
|
+
|
59
|
+
# Fetch variant consequences for multiple regions
|
60
|
+
#
|
61
|
+
# @param [Array] input lines for VEP. Example Values: ["21 26960070 rs116645811 G A . . .", "21 26965148 rs1135638 G A . . ." ]
|
62
|
+
# @param [String] Species name/alias
|
63
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/vep_region_get
|
64
|
+
# @return [JSON] Variants consequences
|
65
|
+
def region_post(variants, species = 'human', options = {})
|
66
|
+
return EnsemblREST.post("vep/#{species}/region", {"variants" => variants}, {format: 'json'}.merge(options))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/ensemblrest/version.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Bio-ensemblrest
|
2
|
+
#
|
3
|
+
# Copyright (C) 2015
|
4
|
+
#
|
5
|
+
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
6
|
+
#
|
7
|
+
# Documentation: Natapol Pornputtapong (RDoc'd and embellished by William Webber)
|
8
|
+
#
|
9
|
+
|
10
|
+
# raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
11
|
+
|
12
|
+
module EnsemblREST
|
13
|
+
|
14
|
+
module Xref
|
15
|
+
module_function
|
16
|
+
|
17
|
+
# Looks up an external symbol and returns all Ensembl objects linked to it.
|
18
|
+
# This can be a display name for a gene/transcript/translation, a synonym or an externally linked reference.
|
19
|
+
# If a gene's transcript is linked to the supplied symbol the service will return both gene and transcript (it supports transient links).
|
20
|
+
#
|
21
|
+
# @param [String] Symbol or display name of a gene
|
22
|
+
# @param [String] Species name/alias
|
23
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/xref_external
|
24
|
+
# @return [JSON] Cross references
|
25
|
+
def external(symbol, species = 'human', options = {})
|
26
|
+
return EnsemblREST.get("xrefs/symbol/#{species}/#{symbol}", {format: 'json'}.merge(options))
|
27
|
+
end
|
28
|
+
|
29
|
+
# Perform lookups of Ensembl Identifiers and retrieve their external references in other databases
|
30
|
+
#
|
31
|
+
# @param [String] An Ensembl Stable ID
|
32
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/xref_id
|
33
|
+
# @return [JSON] Cross references
|
34
|
+
def id(id, options = {})
|
35
|
+
return EnsemblREST.get("xrefs/id/#{id}", {format: 'json'}.merge(options))
|
36
|
+
end
|
37
|
+
|
38
|
+
# Performs a lookup based upon the primary accession or display label of
|
39
|
+
# an external reference and returning the information we hold about the entry
|
40
|
+
#
|
41
|
+
# @param [String] Symbol or display name of a gene
|
42
|
+
# @param [String] Species name/alias
|
43
|
+
# @param [Hash] Optional arguments for the service please goto http://rest.ensembl.org/documentation/info/xref_name
|
44
|
+
# @return [JSON] Cross references
|
45
|
+
def name(name, species = 'human', options = {})
|
46
|
+
return EnsemblREST.get("xrefs/name/#{species}/#{name}", {format: 'json'}.merge(options))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/test.rb
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
# Bio-ensemblrest
|
2
|
+
#
|
3
|
+
# Copyright (C) 2015
|
4
|
+
#
|
5
|
+
# author: Natapol Pornputtapong <natapol.por@gmail.com>
|
6
|
+
#
|
7
|
+
# Documentation: Natapol Pornputtapong (RDoc'd and embellished by William Webber)
|
8
|
+
#
|
9
|
+
|
10
|
+
# raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
11
|
+
|
12
|
+
require_relative 'ensemblrest'
|
13
|
+
require_relative 'ensemblrest/connect'
|
14
|
+
require_relative 'ensemblrest/sequence'
|
15
|
+
require_relative 'ensemblrest/map'
|
16
|
+
require_relative 'ensemblrest/vep'
|
17
|
+
require_relative 'ensemblrest/overlap'
|
18
|
+
require_relative 'ensemblrest/archive'
|
19
|
+
require_relative 'ensemblrest/comparativegenomics'
|
20
|
+
require_relative 'ensemblrest/xref'
|
21
|
+
require_relative 'ensemblrest/info'
|
22
|
+
require_relative 'ensemblrest/lookup'
|
23
|
+
require_relative 'ensemblrest/ontoandtaxo'
|
24
|
+
require_relative 'ensemblrest/regulation'
|
25
|
+
require_relative 'ensemblrest/variation'
|
26
|
+
require_relative 'ensemblrest/variationga4gh'
|
27
|
+
|
28
|
+
require "test/unit"
|
29
|
+
|
30
|
+
class TestEnsemblREST < Test::Unit::TestCase
|
31
|
+
|
32
|
+
def test_archive
|
33
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Archive::id_get('ENSG00000157764')}
|
34
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Archive::id_post(["ENSG00000157764", "ENSG00000248378"])}
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_map
|
38
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Map::cdna("ENST00000288602", "100..300")}
|
39
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Map::cds('ENST00000288602', '1..1000')}
|
40
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Map::map('X:1000000..1000100:1', 'GRCh37', 'GRCh38')}
|
41
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Map::translation('ENSP00000288602', '100..300')}
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_genetree
|
45
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Comparative::genetree('ENSGT00390000003602')}
|
46
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Comparative::genetree_member_id('ENSG00000157764')}
|
47
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Comparative::genetree_member_symbol('BRCA2')}
|
48
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Comparative::genomic_alignment_region('X:1000000..1000100:1')}
|
49
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Comparative::homology_ensemblgene('ENSG00000157764')}
|
50
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Comparative::homology_symbol('BRCA2')}
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_info
|
54
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Info::analysis}
|
55
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Info::assembly_info}
|
56
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Info::assembly_stats('X')}
|
57
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Info::biotypes}
|
58
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Info::compara_methods}
|
59
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Info::compara_species_sets('EPO')}
|
60
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Info::comparas}
|
61
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Info::data}
|
62
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Info::external_dbs}
|
63
|
+
assert(EnsemblREST::Info::ping)
|
64
|
+
assert_instance_of(String, EnsemblREST::Info::rest)
|
65
|
+
assert_instance_of(Fixnum, EnsemblREST::Info::software)
|
66
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Info::species}
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_lookup
|
70
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Lookup::id('ENSG00000157764')}
|
71
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Lookup::symbol('BRCA2')}
|
72
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Lookup::id_post(["ENSG00000157764", "ENSG00000248378"])}
|
73
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Lookup::symbol_post(["BRCA2", "BRAF"])}
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_onto
|
77
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Ontology::ancestors('GO:0005667')}
|
78
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Ontology::ancestors_chart('GO:0005667')}
|
79
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Ontology::descendants('GO:0005667')}
|
80
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Ontology::id('GO:0005667')}
|
81
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Ontology::name("transcription factor complex")}
|
82
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Taxonomy::classification('9606')}
|
83
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Taxonomy::id('9606')}
|
84
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Taxonomy::name('Homo%25')}
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_overlap
|
88
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Overlap::id('ENSG00000157764', 'gene')}
|
89
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Overlap::region('7:140424943-140624564', ['gene', 'transcript', 'cds', 'exon'])}
|
90
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Overlap::translation('ENSP00000288602')}
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_regulation
|
94
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Regulation::id('ENSR00001348195')}
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_sequence
|
98
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Sequence::id("ENSP00000288602")}
|
99
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Sequence::region("X:1000000..1000100:1", 'human')}
|
100
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Sequence::id_post(["ENSG00000157764", "ENSG00000248378"])}
|
101
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Sequence::region_post(["X:1000000..1000100:1", "ABBA01004489.1:1..100"])}
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_variation
|
105
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Variation::id("rs116035550")}
|
106
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Variation::post(["rs116035550", "COSM476"])}
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_variationga4gh
|
110
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::GA4GH::gacallSet}
|
111
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::GA4GH::gavariants(17191024, 17671934, '22', [70])}
|
112
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::GA4GH::gavariantset}
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_vep
|
116
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::VEP::hgvs_get('AGT:c.803T>C')}
|
117
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::VEP::id_get('COSM476')}
|
118
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::VEP::region_get('C', '9:22125503-22125502:1')}
|
119
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::VEP::id_post(["rs116035550", "COSM476" ])}
|
120
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::VEP::region_post(["21 26960070 rs116645811 G A . . .", "21 26965148 rs1135638 G A . . ." ])}
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_xref
|
124
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Xref::external('BRCA2')}
|
125
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Xref::id('ENSG00000157764')}
|
126
|
+
assert_nothing_raised(EnsemblREST::InvalidResponse, NoMethodError) {EnsemblREST::Xref::name('BRCA2')}
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ensemblrest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Natapol Pornputtapong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bio
|
@@ -32,10 +32,22 @@ extra_rdoc_files: []
|
|
32
32
|
files:
|
33
33
|
- ensemblrest.gemspec
|
34
34
|
- lib/ensemblrest.rb
|
35
|
+
- lib/ensemblrest/archive.rb
|
36
|
+
- lib/ensemblrest/comparativegenomics.rb
|
35
37
|
- lib/ensemblrest/connect.rb
|
38
|
+
- lib/ensemblrest/info.rb
|
39
|
+
- lib/ensemblrest/lookup.rb
|
36
40
|
- lib/ensemblrest/map.rb
|
41
|
+
- lib/ensemblrest/ontoandtaxo.rb
|
42
|
+
- lib/ensemblrest/overlap.rb
|
43
|
+
- lib/ensemblrest/regulation.rb
|
37
44
|
- lib/ensemblrest/sequence.rb
|
45
|
+
- lib/ensemblrest/variation.rb
|
46
|
+
- lib/ensemblrest/variationga4gh.rb
|
47
|
+
- lib/ensemblrest/vep.rb
|
38
48
|
- lib/ensemblrest/version.rb
|
49
|
+
- lib/ensemblrest/xref.rb
|
50
|
+
- lib/test.rb
|
39
51
|
homepage: http://rubygems.org/gems/ensemblrest
|
40
52
|
licenses:
|
41
53
|
- GPL
|