summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2017-11-23 10:39:58 +0000
committergebele <gebele@in-silico.ch>2017-11-23 10:39:58 +0000
commitb5f557b3c0c2b4a7b39720c4f345e8514a61fbe6 (patch)
tree2257f3af26dadaa473a3e3baec22fd884291b423
parent50e36d3043cebbc5547e311586a7e9f260244d96 (diff)
consistent use of object class and update of description
-rw-r--r--api/api.json309
-rw-r--r--lib/lazar-rest.rb1
-rw-r--r--lib/model.rb18
3 files changed, 75 insertions, 253 deletions
diff --git a/api/api.json b/api/api.json
index df69149..7777f1e 100644
--- a/api/api.json
+++ b/api/api.json
@@ -32,17 +32,6 @@
"description": "Get a list of all prediction models",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "text/uri-list",
- "application/json"
- ]
- },
- {
"$ref": "#/parameters/subjectid"
}
],
@@ -75,27 +64,17 @@
"model"
],
"description": "Get model representation",
+ "produces": [
+ "application/json"
+ ],
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "application/json"
- ]
- },
- {
"$ref": "#/parameters/id"
},
{
"$ref": "#/parameters/subjectid"
}
],
- "produces": [
- "application/json"
- ],
"responses": {
"200": {
"$ref": "#/responses/200"
@@ -167,17 +146,6 @@
"description": "Get a list of QMRF reports",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "text/uri-list",
- "application/json"
- ]
- },
- {
"$ref": "#/parameters/subjectid"
}
],
@@ -209,19 +177,9 @@
"tags": [
"report"
],
- "description": "Get a QMRF report prototype",
+ "description": "Get QMRF for prediction model",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "application/xml"
- ]
- },
- {
"$ref": "#/parameters/id"
},
{
@@ -258,17 +216,6 @@
"description": "Get a list of all datasets",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "text/uri-list",
- "application/json"
- ]
- },
- {
"$ref": "#/parameters/subjectid"
}
],
@@ -303,17 +250,6 @@
"description": "Get dataset representation",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "application/json",
- "text/csv"
- ]
- },
- {
"$ref": "#/parameters/id"
},
{
@@ -339,6 +275,9 @@
},
"404": {
"$ref": "#/responses/404"
+ },
+ "500": {
+ "$ref": "#/responses/500"
}
}
}
@@ -351,16 +290,6 @@
"description": "Get dataset representation",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "application/json"
- ]
- },
- {
"name": "attribute",
"in": "path",
"description": "requested attribute",
@@ -398,6 +327,9 @@
},
"404": {
"$ref": "#/responses/404"
+ },
+ "500": {
+ "$ref": "#/responses/500"
}
}
}
@@ -410,17 +342,6 @@
"description": "Get a list of all substances",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "text/uri-list",
- "application/json"
- ]
- },
- {
"$ref": "#/parameters/subjectid"
}
],
@@ -455,16 +376,6 @@
"description": "Get substance representation",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "application/json"
- ]
- },
- {
"$ref": "#/parameters/id"
},
{
@@ -489,6 +400,9 @@
},
"404": {
"$ref": "#/responses/404"
+ },
+ "500": {
+ "$ref": "#/responses/500"
}
}
}
@@ -501,17 +415,6 @@
"description": "Get a list of all nanoparticles",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "text/uri-list",
- "application/json"
- ]
- },
- {
"$ref": "#/parameters/subjectid"
}
],
@@ -546,16 +449,6 @@
"description": "Get nanoparticle representation",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "application/json"
- ]
- },
- {
"$ref": "#/parameters/id"
},
{
@@ -580,6 +473,9 @@
},
"404": {
"$ref": "#/responses/404"
+ },
+ "500": {
+ "$ref": "#/responses/500"
}
}
}
@@ -589,18 +485,10 @@
"tags": [
"feature"
],
- "description": "Get a list of all features",
+ "description": "Get a list of ids for all features",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "text/uri-list",
- "application/json"
- ]
+ "$ref": "#/parameters/subjectid"
}
],
"produces": [
@@ -634,17 +522,10 @@
"description": "Get feature representation",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "application/json"
- ]
+ "$ref": "#/parameters/id"
},
{
- "$ref": "#/parameters/id"
+ "$ref": "#/parameters/subjectid"
}
],
"produces": [
@@ -665,6 +546,9 @@
},
"404": {
"$ref": "#/responses/404"
+ },
+ "500": {
+ "$ref": "#/responses/500"
}
}
}
@@ -677,15 +561,7 @@
"description": "Get a list of all validation types",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "text/uri-list",
- "application/json"
- ]
+ "$ref": "#/parameters/subjectid"
}
],
"produces": [
@@ -719,17 +595,6 @@
"description": "Get all validations of a validation type",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "text/uri-list",
- "application/json"
- ]
- },
- {
"$ref": "#/parameters/valtype"
},
{
@@ -755,6 +620,9 @@
},
"404": {
"$ref": "#/responses/404"
+ },
+ "500": {
+ "$ref": "#/responses/500"
}
}
}
@@ -767,16 +635,6 @@
"description": "Get validation representation",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "application/json"
- ]
- },
- {
"$ref": "#/parameters/valtype"
},
{
@@ -804,6 +662,9 @@
},
"404": {
"$ref": "#/responses/404"
+ },
+ "500": {
+ "$ref": "#/responses/500"
}
}
}
@@ -817,19 +678,11 @@
"description": "Get a list of all descriptors",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "text/plain",
- "application/json"
- ]
+ "$ref": "#/parameters/subjectid"
}
],
"produces": [
- "text/plain",
+ "text/plain; charset=utf-8",
"application/json"
],
"responses": {
@@ -862,18 +715,6 @@
],
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "text/csv",
- "application/json"
- ],
- "default": "text/csv"
- },
- {
"name": "identifier",
"in": "formData",
"description": "SMILES identifier",
@@ -926,26 +767,18 @@
"description": "Get a list of a descriptors",
"parameters": [
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-Type",
- "required": true,
- "type": "string",
- "enum": [
- "text/plain",
- "application/json"
- ]
- },
- {
"name": "descriptor",
"in": "path",
"description": "descriptor name or ID",
"required": true,
"type": "string"
+ },
+ {
+ "$ref": "#/parameters/subjectid"
}
],
"produces": [
- "text/plain",
+ "text/plain; charset=utf-8",
"application/json"
],
"responses": {
@@ -978,21 +811,7 @@
"$ref": "#/parameters/InChI"
},
{
- "name": "Accept",
- "in": "header",
- "description": "requested Content-type",
- "required": true,
- "type": "string",
- "enum": [
- "application/json",
- "chemical/x-daylight-smiles",
- "chemical/x-inchi",
- "chemical/x-mdl-sdfile",
- "chemical/x-mdl-molfile",
- "image/png",
- "image/svg+xml",
- "text/plain"
- ]
+ "$ref": "#/parameters/subjectid"
}
],
"produces": [
@@ -1046,11 +865,11 @@
"description": "Authentication against OpenSSO. Returns authentication token. Requires Username and Password.",
"operationId": "login",
"consumes": [
- "text/plain",
+ "text/plain; charset=utf-8",
"multipart/form-data"
],
"produces": [
- "text/plain"
+ "text/plain; charset=utf-8"
],
"parameters": [
{
@@ -1078,6 +897,9 @@
},
"401": {
"$ref": "#/responses/401"
+ },
+ "500": {
+ "$ref": "#/responses/500"
}
}
}
@@ -1091,11 +913,11 @@
"authentication"
],
"consumes": [
- "text/plain",
+ "text/plain; charset=utf-8",
"multipart/form-data"
],
"produces": [
- "text/plain"
+ "text/plain; charset=utf-8"
],
"parameters": [
{
@@ -1115,6 +937,9 @@
},
"401": {
"$ref": "#/responses/401"
+ },
+ "500": {
+ "$ref": "#/responses/500"
}
}
}
@@ -1148,11 +973,17 @@
"description": "authorization token",
"required": false,
"type": "string"
+ },
+ "subjectidRequired": {
+ "in": "header",
+ "name": "subjectid",
+ "description": "authorization token",
+ "required": true,
+ "type": "string"
}
},
"responses": {
"200": {
- "schema": {"type":"string"},
"description": "OK"
},
"400": {
@@ -1173,18 +1004,26 @@
},
"tags": [
{
- "name": "algorithm",
- "description": "Algorithm"
- },
- {
"name": "api",
"description": "Swagger API representation in JSON"
},
{
+ "name": "algorithm",
+ "description": "Algorithm"
+ },
+ {
"name": "authentication",
"description": "minimal Authentication service"
},
{
+ "name": "compound",
+ "description": "Compound"
+ },
+ {
+ "name": "dataset",
+ "description": "Dataset"
+ },
+ {
"name": "descriptor",
"description": "Descriptor"
},
@@ -1197,28 +1036,20 @@
"description": "Lazar Model Service"
},
{
- "name": "dataset",
- "description": "Dataset"
- },
- {
- "name": "validation",
- "description": "Validation"
+ "name": "nanoparticle",
+ "description": "Nanoparticle"
},
{
"name": "report",
"description": "QMRF Reporting"
},
{
- "name": "compound",
- "description": "Compound"
- },
- {
"name": "substance",
"description": "Substance"
},
{
- "name": "nanoparticle",
- "description": "Nanoparticle"
+ "name": "validation",
+ "description": "Validation"
}
]
}
diff --git a/lib/lazar-rest.rb b/lib/lazar-rest.rb
index 4fd806c..255c52f 100644
--- a/lib/lazar-rest.rb
+++ b/lib/lazar-rest.rb
@@ -3,6 +3,7 @@ require "sinatra/reloader"
require 'sinatra/cross_origin'
configure do
+ $logger = Logger.new(STDOUT)
enable :reloader #if development?
enable :cross_origin
disable :show_exceptions
diff --git a/lib/model.rb b/lib/model.rb
index 7a2fb47..52553fa 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -6,7 +6,7 @@ get "/model/?" do
models = Model::Validation.all
case @accept
when "text/uri-list"
- uri_list = models.collect{|model| uri("/model/#{model.model_id}")}
+ uri_list = models.collect{|model| uri("/model/#{model.id}")}
return uri_list.join("\n") + "\n"
when "application/json"
models = JSON.parse models.to_json
@@ -19,26 +19,16 @@ get "/model/?" do
end
get "/model/:id/?" do
- model = Model::Lazar.find params[:id]
+ model = Model::Validation.find params[:id]
not_found_error "Model with id: #{params[:id]} not found." unless model
- model[:URI] = uri("/model/#{model.id}")
- # model[:neighbor_algorithm_parameters][:feature_dataset_uri] = uri("/dataset/#{model[:neighbor_algorithm_parameters][:feature_dataset_id]}") if model[:neighbor_algorithm_parameters][:feature_dataset_id]
- model[:training_dataset_uri] = uri("/dataset/#{model.training_dataset_id}") if model.training_dataset_id
- model[:prediction_feature_uri] = uri("/dataset/#{model.prediction_feature_id}") if model.prediction_feature_id
return model.to_json
end
post "/model/:id/?" do
identifier = params[:identifier].split(",")
- begin
- # get compound from SMILES
- compounds = identifier.collect{ |i| Compound.from_smiles i.strip }
- rescue
- @error_report = "Attention, '#{params[:identifier]}' is not a valid SMILES string."
- return @error_report
- end
- model = Model::Lazar.find params[:id]
+ compounds = identifier.collect{ |i| Compound.from_smiles i.strip }
+ model = Model::Validation.find params[:id]
batch = {}
compounds.each do |compound|
prediction = model.predict(compound)