summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2012-04-04 14:53:52 +0200
committerAndreas Maunz <andreas@maunz.de>2012-04-04 14:53:52 +0200
commita0b2904a9fc6421b5f600bf985739f91515832ca (patch)
tree8b5034751bec09395ba7c6201d1f9b67a02395ff
parent68ebd8d6f81472233e8ac4f0480834057a3eaa89 (diff)
Supporint lookup
-rw-r--r--lib/algorithm.rb2
-rw-r--r--lib/compound.rb10
-rw-r--r--lib/model.rb3
-rw-r--r--lib/utils.rb6
4 files changed, 8 insertions, 13 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb
index ebd2019..d38b79a 100644
--- a/lib/algorithm.rb
+++ b/lib/algorithm.rb
@@ -546,7 +546,7 @@ module OpenTox
# @param [Hash] required keys: compound, features, feature_dataset_uri, pc_type
# @return [Hash] Hash with matching Smarts and number of hits
def self.lookup(params)
- params[:compound].lookup(params[:features], params[:feature_dataset_uri],params[:pc_type])
+ params[:compound].lookup(params[:features], params[:feature_dataset_uri],params[:pc_type], params[:lib])
end
end
diff --git a/lib/compound.rb b/lib/compound.rb
index 5024af1..f02d403 100644
--- a/lib/compound.rb
+++ b/lib/compound.rb
@@ -240,8 +240,9 @@ module OpenTox
# @param [Array] Array of feature names
# @param [String] Feature dataset uri
# @param [String] Comma separated pc types
+ # @param [String] Comma separated lib
# @return [Hash] Hash with feature name as key and value as value
- def lookup(feature_array,feature_dataset_uri,pc_type)
+ def lookup(feature_array,feature_dataset_uri,pc_type,lib)
ds = OpenTox::Dataset.find(feature_dataset_uri)
#entry = ds.data_entries[self.uri]
@@ -252,18 +253,15 @@ module OpenTox
break
end
}
-
LOGGER.debug "#{entry.size} entries in feature ds for query." unless entry.nil?
-
if entry.nil?
- temp_ds = OpenTox::Dataset.create; temp_ds.add_compound(self.uri)
- uri = RestClientWrapper.post(temp_ds.save + "/pcdesc", {:pc_type => pc_type})
+ temp_ds = OpenTox::Dataset.create; temp_ds.add_compound(self.uri); temp_uri = temp_ds.save
+ uri = RestClientWrapper.post(File.join(CONFIG[:services]["opentox-algorithm"], "/pc"), {:dataset_uri => temp_uri, :pc_type => pc_type, :lib => lib})
ds = OpenTox::Dataset.find(uri)
entry = ds.data_entries[self.uri]
ds.delete
temp_ds.delete
end
-
features = entry.keys
features.each { |feature|
new_feature = File.join(feature_dataset_uri, "feature", feature.split("/").last)
diff --git a/lib/model.rb b/lib/model.rb
index b3de1a3..057c537 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -261,7 +261,8 @@ module OpenTox
:compound => @compound,
:features => @features,
:feature_dataset_uri => @metadata[OT.featureDataset],
- :pc_type => self.parameter(\"pc_type\")
+ :pc_type => self.parameter(\"pc_type\"),
+ :lib => self.parameter(\"lib\")
})")
# Adding fingerprint of query compound with features and values(p_value*nr_hits)
diff --git a/lib/utils.rb b/lib/utils.rb
index e00d2f9..cee3dc7 100644
--- a/lib/utils.rb
+++ b/lib/utils.rb
@@ -84,10 +84,6 @@ module OpenTox
parser.dataset = ds
ds = parser.load_csv(master.collect{|r| r.join(",")}.join("\n"),false,true)
- ds.features.each { |k,v|
- LOGGER.debug "#{k}: #{v.to_yaml}"
- }
-
# # # add feature metadata
ambit_ids && ambit_ids.each_with_index { |id,idx|
raise "Feature not found" if ! ds.features[File.join(ds.uri, "feature", id.to_s)]
@@ -371,7 +367,7 @@ module OpenTox
if ambit_result_uri.size > 0
(1...ambit_result_uri.size).collect { |idx|
curr_uri = ambit_result_uri[0] + ambit_result_uri[idx]
- LOGGER.debug "Requesting #{curr_uri}"
+ #LOGGER.debug "Requesting #{curr_uri}"
csv_data = CSV.parse( OpenTox::RestClientWrapper.get(curr_uri, {:accept => "text/csv"}) )
if csv_data[0] && csv_data[0].size>1
if master.nil? # This is the smiles entry