summaryrefslogtreecommitdiff
path: root/fminer.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.de>2010-03-10 19:17:47 +0100
committerChristoph Helma <helma@in-silico.de>2010-03-10 19:17:47 +0100
commita34f0510fec302ebbd420ab4d29abe52f558c903 (patch)
treed5dbfb320f2fb5b4a10ffc4335ce9519d5e9cc7d /fminer.rb
parent7e229b76a46bcb90d15eacc103da03baf6501b4c (diff)
owl-dl (temporarily) removed, switched to YAML representation
Diffstat (limited to 'fminer.rb')
-rw-r--r--fminer.rb64
1 files changed, 35 insertions, 29 deletions
diff --git a/fminer.rb b/fminer.rb
index 86f6876..944a308 100644
--- a/fminer.rb
+++ b/fminer.rb
@@ -1,11 +1,7 @@
-LOGGER.progname = File.expand_path(__FILE__)
-
ENV['FMINER_SMARTS'] = 'true'
ENV['FMINER_PVALUES'] = 'true'
@@fminer = Fminer::Fminer.new
@@fminer.SetAromatic(true)
-#@@fminer.SetConsoleOut(false)
-#@@fminer.SetChisqSig(0.95)
get '/fminer/?' do
response['Content-Type'] = 'application/rdf+xml'
@@ -19,8 +15,10 @@ post '/fminer/?' do
feature_uri = params[:feature_uri]
halt 404, "Please submit a feature_uri parameter." if feature_uri.nil?
begin
- LOGGER.debug "Retrieving #{params[:dataset_uri]}?feature_uris\\[\\]=#{CGI.escape(feature_uri)}"
- training_dataset = OpenTox::Dataset.find "#{params[:dataset_uri]}?feature_uris\\[\\]=#{CGI.escape(feature_uri)}"
+ #LOGGER.debug "Retrieving #{params[:dataset_uri]}?feature_uris\\[\\]=#{CGI.escape(feature_uri)}"
+ #training_dataset = OpenTox::Dataset.find "#{params[:dataset_uri]}?feature_uris\\[\\]=#{CGI.escape(feature_uri)}"
+ LOGGER.debug "Retrieving #{params[:dataset_uri]}"
+ training_dataset = OpenTox::Dataset.find "#{params[:dataset_uri]}"
rescue
LOGGER.error "Dataset #{params[:dataset_uri]} not found"
halt 404, "Dataset #{params[:dataset_uri]} not found." if training_dataset.nil?
@@ -38,13 +36,16 @@ post '/fminer/?' do
feature_dataset.title = title
feature_dataset.source = url_for('/fminer',:full)
bbrc_uri = url_for("/fminer#BBRC_representative",:full)
- bbrc_feature = feature_dataset.find_or_create_feature bbrc_uri
+ feature_dataset.features << bbrc_uri
+ #bbrc_feature = feature_dataset.find_or_create_feature bbrc_uri
id = 1 # fminer start id is not 0
compounds = []
@@fminer.Reset
LOGGER.debug "Fminer: initialising ..."
training_dataset.data.each do |c,features|
+ LOGGER.debug c
+ LOGGER.debug features
begin
smiles = OpenTox::Compound.new(:uri => c.to_s).smiles
rescue
@@ -54,26 +55,29 @@ post '/fminer/?' do
if smiles == '' or smiles.nil?
LOGGER.warn "Cannot find smiles for #{c.to_s}."
else
- compound = feature_dataset.find_or_create_compound(c.to_s)
- LOGGER.warn "No #{feature_uri} for #{c.to_s}." if features[feature_uri].size == 0
- features[feature_uri].each do |act|
- if act.nil?
- LOGGER.warn "No #{feature_uri} activiity for #{c.to_s}."
- else
- case act.to_s
- when "true"
- LOGGER.debug id.to_s + ' "' + smiles +'"' + "\t" + true.to_s
- activity = 1
- when "false"
- LOGGER.debug id.to_s + ' "' + smiles +'"' + "\t" + false.to_s
- activity = 0
- end
- compounds[id] = compound
- begin
- @@fminer.AddCompound(smiles,id)
- @@fminer.AddActivity(activity, id)
- rescue
- LOGGER.warn "Could not add " + smiles + "\t" + activity + " to fminer"
+ feature_dataset.compounds << c.to_s
+ if !features[feature_uri] or features[feature_uri].size == 0
+ LOGGER.warn "No #{feature_uri} for #{c.to_s}."
+ else
+ features[feature_uri].each do |act|
+ if act.nil?
+ LOGGER.warn "No #{feature_uri} activiity for #{c.to_s}."
+ else
+ case act.to_s
+ when "true"
+ LOGGER.debug id.to_s + ' "' + smiles +'"' + "\t" + true.to_s
+ activity = 1
+ when "false"
+ LOGGER.debug id.to_s + ' "' + smiles +'"' + "\t" + false.to_s
+ activity = 0
+ end
+ compounds[id] = c.to_s
+ begin
+ @@fminer.AddCompound(smiles,id)
+ @@fminer.AddActivity(activity, id)
+ rescue
+ LOGGER.warn "Could not add " + smiles + "\t" + activity + " to fminer"
+ end
end
end
end
@@ -97,10 +101,12 @@ post '/fminer/?' do
else
effect = 'deactivating'
end
- tuple = feature_dataset.create_tuple(bbrc_feature,{ url_for('/fminer#smarts',:full) => smarts, url_for('/fminer#p_value',:full) => p_value.to_f, url_for('/fminer#effect',:full) => effect })
+ tuple = { url_for('/fminer#smarts',:full) => smarts, url_for('/fminer#p_value',:full) => p_value.to_f, url_for('/fminer#effect',:full) => effect }
+ #tuple = feature_dataset.create_tuple(bbrc_feature,{ url_for('/fminer#smarts',:full) => smarts, url_for('/fminer#p_value',:full) => p_value.to_f, url_for('/fminer#effect',:full) => effect })
LOGGER.debug "#{f[0]}\t#{f[1]}\t#{effect}"
ids.each do |id|
- feature_dataset.add_tuple compounds[id], tuple
+ feature_dataset.data[compounds[id]] = {} unless feature_dataset.data[compounds[id]]
+ feature_dataset.data[compounds[id]][bbrc_uri] = tuple
end
end
end