summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2012-01-31 11:54:14 +0100
committermguetlein <martin.guetlein@gmail.com>2012-01-31 11:54:14 +0100
commit4cca6ea7b4c88ebd58974cd998db205600e34232 (patch)
treeacdd81649e28114c4432958ddcc52ce50671271c
parent5fdf86d55f47fa3bdca0bb8f5482a7fd33f60987 (diff)
extend matching to 'nr_hits'
-rw-r--r--fminer.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/fminer.rb b/fminer.rb
index 36e242e..620e147 100644
--- a/fminer.rb
+++ b/fminer.rb
@@ -87,6 +87,7 @@ end
# Creates same features for dataset <dataset_uri> that have been created
# with fminer in dataset <feature_dataset_uri>
+# accept params[:nr_hits] as used in other fminer methods
post '/fminer/:method/match?' do
raise OpenTox::BadRequestError.new "feature_dataset_uri not given" unless params[:feature_dataset_uri]
raise OpenTox::BadRequestError.new "dataset_uri not given" unless params[:dataset_uri]
@@ -101,7 +102,12 @@ post '/fminer/:method/match?' do
res_dataset.add_compound(c)
comp = OpenTox::Compound.new(c)
f_dataset.features.each do |f,m|
- res_dataset.add(c,f,1) if comp.match?(m[OT.smarts])
+ if params[:nr_hits] == "true"
+ hits = comp.match_hits([m[OT.smarts]])
+ res_dataset.add(c,f,hits[m[OT.smarts]]) if hits[m[OT.smarts]]
+ else
+ res_dataset.add(c,f,1) if comp.match?(m[OT.smarts])
+ end
end
end
res_dataset.save