summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrautenberg <rautenberg@in-silico.ch>2016-11-16 13:43:59 +0100
committerrautenberg <rautenberg@in-silico.ch>2016-11-16 13:43:59 +0100
commit43792e2322ded616c7eefb4b52083ba64e48e63c (patch)
tree0fa5eefa7a442e81ef06a5363b678bb7b59a1ab1
parent600501cf0a87d41332a7b96f4dc35948bf0c651c (diff)
adapt code to lazar 1.0.0
-rw-r--r--lib/compound.rb8
-rw-r--r--lib/model.rb2
-rw-r--r--test/aa.rb4
-rw-r--r--test/descriptor.rb4
4 files changed, 11 insertions, 7 deletions
diff --git a/lib/compound.rb b/lib/compound.rb
index 9390a96..01ba036 100644
--- a/lib/compound.rb
+++ b/lib/compound.rb
@@ -23,14 +23,14 @@ post "/compound/descriptor/?" do
descriptors.each do |descriptor|
physchem_descriptors << PhysChem.find_by(:name => descriptor)
end
- result = compound.physchem physchem_descriptors
- csv = result.collect{|k,v| "\"#{PhysChem.find(k).name}\",#{v}" }.join("\n")
- csv = "SMILES,#{params[:identifier]}\n#{csv}" if params[:identifier]
+ result = compound.calculate_properties physchem_descriptors
+ csv = (0..result.size-1).collect{|i| "\"#{physchem_descriptors[i].name}\",#{result[i]}"}.join("\n")
+ csv = "SMILES,\"#{params[:identifier]}\"\n#{csv}" if params[:identifier]
case @accept
when "text/csv","application/csv"
return csv
when "application/json"
- result_hash = result.collect{|k,v| {"#{PhysChem.find(k).name}" => "#{v}"}} # result.collect{|k,v| "\"#{PhysChem.find(k).name}\"" => "#{v}"}.join(",")
+ result_hash = (0..result.size-1).collect{|i| {"#{physchem_descriptors[i].name}" => "#{result[i]}"}}
data = {"compound" => {"SMILES" => "#{params[:identifier]}"}}
data["compound"]["InChI"] = "#{compound.inchi}" if compound.inchi
data["compound"]["results"] = result_hash
diff --git a/lib/model.rb b/lib/model.rb
index db0c190..a20850b 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -24,7 +24,7 @@ get "/model/:id/?" do
model = Model::Lazar.find params[:id]
resource_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[: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
diff --git a/test/aa.rb b/test/aa.rb
index 927bc35..f785900 100644
--- a/test/aa.rb
+++ b/test/aa.rb
@@ -2,6 +2,10 @@ require_relative "setup.rb"
class AATest < MiniTest::Test
+ def self.test_order
+ :alpha
+ end
+
def test_0_login
res = RestClientWrapper.post(File.join($host,"aa/authenticate"),{:username=>"guest", :password => "guest"},{:Accept => "text/plain"})
assert_equal res.code, 200
diff --git a/test/descriptor.rb b/test/descriptor.rb
index eae3ebf..db4b6c7 100644
--- a/test/descriptor.rb
+++ b/test/descriptor.rb
@@ -27,13 +27,13 @@ class DescriptorTest < MiniTest::Test
result = RestClientWrapper.get File.join($host, "compound/descriptor", bsonid), {}, {:accept => "application/json"}
json = JSON.parse(result)
assert_equal json["name"], "Openbabel.HBA1"
- assert_equal json["numeric"], true
+ assert_equal json["calculated"], true
end
def test_04_post_descriptor
result = RestClientWrapper.post File.join($host, "compound/descriptor"), {:identifier => "CC(=O)CC(C)C#N", :descriptor => "Joelib.LogP"}, {:accept => "application/csv"}
assert_equal result.code, 200
- assert_equal "SMILES,CC(=O)CC(C)C#N\n\"Joelib.LogP\",2.65908", result
+ assert_equal "SMILES,\"CC(=O)CC(C)C#N\"\n\"Joelib.LogP\",2.65908", result
end
# currently not applicable