Skip to content

Commit

Permalink
implemented new methods in Information module
Browse files Browse the repository at this point in the history
  • Loading branch information
ALTree committed Sep 27, 2013
1 parent c48b2d4 commit 7a22ddd
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
64 changes: 64 additions & 0 deletions lib/bio-ensembl-rest/information.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,70 @@ def self.assembly_info_region(species, region, opts = {})
end


##
# Lists the available analyses by logic name and the database type those logic names are found in.
def self.info_analysis(species, opts = {})
opts = EnsemblRest.parse_options opts
path = EnsemblRest.build_path "/info/analysis/#{species}", opts

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

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


##
# Lists all available biotypes for the given species.
def self.info_biotypes(species, opts = {})
opts = EnsemblRest.parse_options opts
path = EnsemblRest.build_path "/info/biotypes/#{species}", opts

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

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

##
#
def self.info_compara_methods(opts = {})
opts = EnsemblRest.parse_options opts
path = EnsemblRest.build_path "/info/compara/methods", opts

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

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


##
#
def self.info_compara_species_sets_method(method, opts = {})
opts = EnsemblRest.parse_options opts
path = EnsemblRest.build_path "/info/compara/species_sets/#{method}", opts

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

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



##
# Lists all available comparative genomics databases and their data release
def self.info_comparas(opts = {})
Expand Down
57 changes: 57 additions & 0 deletions test/test-information.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,63 @@ class TestInformation < Test::Unit::TestCase

end

context 'info_analysis' do

setup do
EnsemblRest.connect_db
end

should 'support a basic call and return the correct data' do
assert_nothing_raised do
info = Information.info_analysis 'homo sapiens'
end
end

end

context 'info_biotypes' do

setup do
EnsemblRest.connect_db
end

should 'support a basic call and return the correct data' do
assert_nothing_raised do
info = Information.info_biotypes 'homo sapiens'
end
end

end

context 'info_compara_methods' do

setup do
EnsemblRest.connect_db
end

should 'support a basic call and return the correct data' do
assert_nothing_raised do
info = Information.info_compara_methods
end
end

end

context 'info_compara_species_sets_method' do

setup do
EnsemblRest.connect_db
end

should 'support a basic call and return the correct data' do
assert_nothing_raised do
info = Information.info_compara_species_sets_method 'EPO'
end
end

end



context 'info_comparas' do

Expand Down

0 comments on commit 7a22ddd

Please sign in to comment.