Class: SysMODB::SearchBiomodel
- Inherits:
-
Object
- Object
- SysMODB::SearchBiomodel
- Includes:
- Singleton
- Defined in:
- lib/search_biomodel.rb
Instance Method Summary collapse
- #get_all_models ⇒ Object
-
#get_model_name_by_id(search_string) ⇒ Object
more used for testing.
- #getModel(model_id) ⇒ Object
- #getSimpleModel(model_id) ⇒ Object
-
#initialize ⇒ SearchBiomodel
constructor
A new instance of SearchBiomodel.
- #models(search_string) ⇒ Object
-
#search_by_chebiid(search_string) ⇒ Object
search_by_chebiid search_by_name search_by_person.
- #search_by_name(search_string) ⇒ Object
- #search_by_person(search_string) ⇒ Object
Constructor Details
#initialize ⇒ SearchBiomodel
Returns a new instance of SearchBiomodel.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/search_biomodel.rb', line 12 def initialize @connection = Savon.configure do |config| config.log = false HTTPI.log = false config.raise_errors = false Savon::Client.new do wsdl.document = "http://www.ebi.ac.uk/biomodels-main/services/BioModelsWebServices?wsdl" wsdl.namespace = "http://biomodels.ebi.ac.uk" end end end |
Instance Method Details
#get_all_models ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/search_biomodel.rb', line 144 def get_all_models client = connection response = client.request(:biom, "get_all_models") do soap.body = {:modelName => "?", :attributes! => {:modelName => {"xsi:type" => "xsd:string"}}} end search_results = response.to_hash[:multi_ref][:item] unless response.nil? if search_results.nil? [] else search_results end end |
#get_model_name_by_id(search_string) ⇒ Object
more used for testing
131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/search_biomodel.rb', line 131 def get_model_name_by_id (search_string) client = connection response = client.request(:biom, "get_model_name_by_id") do soap.body = {:id => search_string, :attributes! => {:id => {"xsi:type" => "xsd:string"}}} end search_results = response.to_hash[:get_model_name_by_id_response][:get_model_name_by_id_return] if search_results.nil? || search_results.include?('is an invalid Model ID.') [] else search_results end end |
#getModel(model_id) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/search_biomodel.rb', line 51 def getModel(model_id) client = connection response = client.request(:biom, "get_model_by_id") do soap.body = {:id => model_id, :attributes! => {:id => {"xsi:type" => "xsd:string"}}} end search_results = response.to_hash[:get_model_by_id_response][:get_model_by_id_return] unless response.nil? if search_results.nil? [] else search_results end end |
#getSimpleModel(model_id) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/search_biomodel.rb', line 67 def getSimpleModel(model_id) client = connection response = client.request(:biom, "get_simple_model_by_id") do soap.body = {:id => model_id, :attributes! => {:id => {"xsi:type" => "xsd:string"}}} end if !response.nil? search_results = response.to_hash[:get_simple_model_by_id_response][:get_simple_model_by_id_return] end if search_results.nil? [] else search_results end end |
#models(search_string) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/search_biomodel.rb', line 26 def models(search_string) #collect results from sub-methods results = Array.new results << @connection.search_by_name(search_string) results << @connection.search_by_chebiid(search_string) results << @connection.search_by_person(search_string) #turn into one big array, remove duplicates and select first X results = results.flatten results = results.uniq results = results.first(10) sbml_results = Array.new results.each_with_index do |a, i| if !a.nil? sbml_results[i] = Hash.new sbml_results[i] = Nori.parse(@connection.getSimpleModel(a))[:simple_models][:simple_model] end end sbml_results end |
#search_by_chebiid(search_string) ⇒ Object
search_by_chebiid search_by_name search_by_person
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/search_biomodel.rb', line 87 def search_by_chebiid(search_string) client = connection response = client.request(:biom, "get_models_id_by_ch_ebi_id") do soap.body = {:ChEBBId => search_string, :attributes! => {:ChEBBId => {"xsi:type" => "xsd:string"}}} end search_results = response.to_hash[:get_models_id_by_ch_ebi_id_response][:get_models_id_by_ch_ebi_id_return][:get_models_id_by_ch_ebi_id_return] unless response.nil? if search_results.nil? [] else search_results end end |
#search_by_name(search_string) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/search_biomodel.rb', line 102 def search_by_name (search_string) client = connection response = client.request(:biom, "get_models_id_by_name") do soap.body = {:modelName => search_string, :attributes! => {:modelName => {"xsi:type" => "xsd:string"}}} end search_results = response.to_hash[:get_models_id_by_name_response][:get_models_id_by_name_return][:get_models_id_by_name_return] if search_results.nil? [] else search_results end end |
#search_by_person(search_string) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/search_biomodel.rb', line 115 def search_by_person (search_string) client = connection response = client.request(:biom, "get_models_id_by_person") do soap.body = {:personName => search_string, :attributes! => {:personName => {"xsi:type" => "xsd:string"}}} end search_results = response.to_hash[:get_models_id_by_person_response][:get_models_id_by_person_return][:get_models_id_by_person_return] if search_results.nil? [] else search_results end end |