diff options
author | Micha Rautenberg <rautenberg@in-silico.ch> | 2015-10-15 12:40:36 +0200 |
---|---|---|
committer | Micha Rautenberg <rautenberg@in-silico.ch> | 2015-10-15 12:40:36 +0200 |
commit | 501f382a3bcac1ecfc0c9790cf6da61736a2e63b (patch) | |
tree | 8012b11dd8a9569c11c57b6bab96c35dfed4a7f1 | |
parent | 77dec55b418faa4e20f24e3a65085c0ca2555eed (diff) |
expand GET /algorithm/descriptor route to get single descriptor-descriptions
-rw-r--r-- | application.rb | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/application.rb b/application.rb index c95547b..382a183 100644 --- a/application.rb +++ b/application.rb @@ -74,33 +74,18 @@ post "/model/:id/?" do return prediction.to_json end -# Get a list of all descriptors +# Get a list of a single or all descriptors # @param [Header] Accept one of text/plain, application/json +# @param [Path] Descriptor name (e.G.: Openbabel.HBA1) # @return [text/plain, application/json] list of all prediction models -get "/algorithm/descriptor/?" do +get "/algorithm/descriptor/?:descriptor?" do case @accept - when "text/plain" - return OpenTox::Algorithm::Descriptor::DESCRIPTORS.collect{|k, v| "#{k}: #{v}\n"} when "application/json" - return JSON.pretty_generate OpenTox::Algorithm::Descriptor::DESCRIPTORS - end -end - -=begin -post "/model/?" do - parse_input - case @content_type - when "text/csv", "text/comma-separated-values" - model = OpenTox::Model::Prediction.from_csv_file @body + return "#{JSON.pretty_generate OpenTox::Algorithm::Descriptor::DESCRIPTORS} " unless params[:descriptor] + return {params[:descriptor] => OpenTox::Algorithm::Descriptor.description(params[:descriptor])}.to_json else - bad_request_error "Mime type #{@content_type} is not supported." + return OpenTox::Algorithm::Descriptor::DESCRIPTORS.collect{|k, v| "#{k}: #{v}\n"} unless params[:descriptor] + return OpenTox::Algorithm::Descriptor.description params[:descriptor] end - response['Content-Type'] = "text/uri-list" - model.model_id end -delete "model/:id/?" do - model = OpenTox::Model::Lazar.find params[:id] - model.delete -end -=end |