Module: Exodb::Ensembl::REST

Defined in:
lib/exodb/utils/ensemblrest.rb

Constant Summary collapse

@@url =
URI.parse('http://rest.ensembl.org')
@@http =
Net::HTTP.new(@@url.host, @@url.port)

Class Method Summary collapse

Class Method Details

.assembly_map(region, asm_two, asm_one = Exodb::DEFAULTASSEMBLY, species = 'human', options = {}) ⇒ Object

Converse coordinate from one asembly to another from rest.ensembl.org/documentation/info/assembly_map

Parameters:

  • location (String)

    string in chromosome:start..stop format

  • target (String)

    assembly or asm_two

  • original (String)

    assembly default: exodb::DEFAULTASSEMBLY

  • species (String) (defaults to: 'human')

    of genome

  • option (Hash)


51
52
53
# File 'lib/exodb/utils/ensemblrest.rb', line 51

def assembly_map(region, asm_two, asm_one = Exodb::DEFAULTASSEMBLY, species = 'human', options = {})
	return Exodb::Ensembl::REST.get("map/#{species.gsub(/\s+/, '_')}/#{Exodb::ASSEMBLY[asm_one.downcase]}/#{region}/#{Exodb::ASSEMBLY[asm_two.downcase]}", options)
end

.get(get_path, options) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/exodb/utils/ensemblrest.rb', line 22

def get(get_path, options)
	request = Net::HTTP::Get.new(get_path, {'Content-Type' => 'application/json'}.merge(options))
	response = @@http.request(request)
	if response.code != "200"
		riase InvalidResponse, "Invalid response: #{response.code}"
	else
		return JSON.parse(response.body)
	end
end

.sequence_region(region, species, options = {}) ⇒ Object

Returns the genomic sequence of the specified region of the given species. from rest.ensembl.org/documentation/info/sequence_region

Parameters:

  • location (String)

    string in chromosome:start..stop format

  • species (String)

    of genome

  • Return (Fasta)

    sequence



61
62
63
# File 'lib/exodb/utils/ensemblrest.rb', line 61

def sequence_region(region, species, options = {})
	return Exodb::Ensembl::REST.get("sequence/region/#{species}/#{region}", {'Content-Type' => 'text/x-fasta', 'coord_system_version' => Exodb::DEFAULTASSEMBLY}.merge(options))
end

.vep_hgvs_get(hgvs, species, options = {}) ⇒ Object



39
40
41
# File 'lib/exodb/utils/ensemblrest.rb', line 39

def vep_hgvs_get(hgvs, species, options = {})
	return Exodb::Ensembl::REST.get("vep/#{species}/hgvs/#{region}/allele", options)
end

.vep_region_get(region, allele, species, options = {}) ⇒ Object



34
35
36
# File 'lib/exodb/utils/ensemblrest.rb', line 34

def vep_region_get(region, allele, species, options = {})
	return Exodb::Ensembl::REST.get("vep/#{species}/region/#{region}/allele", options)
end