Module: EnsemblRest::Mapping

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

Class Method Summary collapse

Class Method Details

._map_generic(id, region, type, opts = {}) ⇒ Object

generic mapping from cdna and cds



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bio-ensembl-rest/mapping.rb', line 40

def self._map_generic(id, region, type, opts = {}) # :nodoc:
  opts = EnsemblRest.parse_options opts
  path = EnsemblRest.build_path "/map/#{type}/#{id}/#{region}", opts

  # TODO: ruby object?
  if opts['content-type'] == 'ruby'
    plain_opts = opts.clone
    plain_opts['content-type'] = 'application/json'
    return JSON.parse _map_generic id, region, type, plain_opts
  end

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

.map(asm_one, asm_two, species, region, opts = {}) ⇒ Object

Convert the co-ordinates of one assembly to another



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

def self.map(asm_one, asm_two, species, region, opts = {})
  opts = EnsemblRest.parse_options opts
  path = EnsemblRest.build_path "/map/#{species}/#{asm_one}/#{region}/#{asm_two}", opts

  # TODO: ruby object?
  if opts['content-type'] == 'ruby'
    plain_opts = opts.clone
    plain_opts['content-type'] = 'application/json'
    return JSON.parse map asm_one, asm_two, species, region, plain_opts
  end

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

.map_from_cdna(id, region, opts = {}) ⇒ Object

Convert from CDNA coordinates to genomic coordinates



23
24
25
# File 'lib/bio-ensembl-rest/mapping.rb', line 23

def self.map_from_cdna(id, region, opts = {})
  return _map_generic id, region, 'cdna', opts       
end

.map_from_cds(id, region, opts = {}) ⇒ Object

Convert from CDS coordinates to genomic coordinates



29
30
31
# File 'lib/bio-ensembl-rest/mapping.rb', line 29

def self.map_from_cds(id, region, opts = {})
  return _map_generic id, region, 'cds', opts
end

.map_from_translation(id, region, opts = {}) ⇒ Object

Convert from protein (translation) coordinates to genomic coordinates



35
36
37
# File 'lib/bio-ensembl-rest/mapping.rb', line 35

def self.map_from_translation(id, region, opts = {})
  return _map_generic id, region, 'translation', opts
end