summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/compound.rb8
-rw-r--r--lib/model.rb2
2 files changed, 5 insertions, 5 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