Module: EnsemblRest::Features

Defined in:
lib/bio-ensembl-rest/features.rb

Class Method Summary collapse

Class Method Details

.feature_id(id, features, opts = {}) ⇒ Object

Uses the given identifier as a way of indicating the Slice of features required



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/bio-ensembl-rest/features.rb', line 6

def self.feature_id(id, features, opts = {})
  opts = EnsemblRest.parse_options opts

  # features is a required parameter, but we need to encode it into the url
  encoded_query = ""
  features.each {|f| encoded_query << "feature=#{f};"}

  path = (EnsemblRest.build_path "/feature/id/#{id}", opts) + encoded_query

  if opts['content-type'] == 'ruby'
    plain_opts = opts.clone
    plain_opts['content-type'] = 'application/json'
    return JSON.parse feature_id id, features, plain_opts
  end

  return EnsemblRest.fetch_data path, opts, 'features'   
end

.feature_region(species, region, features, opts = {}) ⇒ Object

Retrieves multiple types of features for a given region



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bio-ensembl-rest/features.rb', line 27

def self.feature_region(species, region, features, opts = {})
  opts = EnsemblRest.parse_options opts

  # features is a required parameter, but we need to encode it into the url
  encoded_query = ""
  features.each {|f| encoded_query << "feature=#{f};"}

  path = (EnsemblRest.build_path "/feature/region/#{species}/#{region}", opts) + encoded_query

  if opts['content-type'] == 'ruby'
    plain_opts = opts.clone
    plain_opts['content-type'] = 'application/json'
    return JSON.parse feature_region species, region, features, plain_opts
  end

  return EnsemblRest.fetch_data path, opts, 'features'   
end

.feature_translation(id, opts = {}) ⇒ Object

Uses the given identifier to return translation related features.



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/bio-ensembl-rest/features.rb', line 47

def self.feature_translation(id, opts = {})
  opts = EnsemblRest.parse_options opts
  path = EnsemblRest.build_path "/feature/translation/#{id}", opts

  if opts['content-type'] == 'ruby'
    plain_opts = opts.clone
    plain_opts['content-type'] = 'application/json'
    return JSON.parse feature_translation id, plain_opts
   end 

   return EnsemblRest.fetch_data path, opts, 'features'

end