summaryrefslogtreecommitdiff
path: root/reach_reports
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2011-02-08 09:00:57 +0100
committermguetlein <martin.guetlein@gmail.com>2011-02-08 09:00:57 +0100
commitc17b549f4a48d1bec843017b3b951eb9b0c109e8 (patch)
tree2baf528a9921ddaaa676f5b23e3ea0b992fb4d5f /reach_reports
parentd99823f61fc3b2f463bc1a51db0a952c965c2141 (diff)
fix create qmrf report, remove not-found-test from unit-test
Diffstat (limited to 'reach_reports')
-rwxr-xr-xreach_reports/reach_service.rb19
-rwxr-xr-xreach_reports/reach_test.rb52
2 files changed, 55 insertions, 16 deletions
diff --git a/reach_reports/reach_service.rb b/reach_reports/reach_service.rb
index 028a53c..53acb62 100755
--- a/reach_reports/reach_service.rb
+++ b/reach_reports/reach_service.rb
@@ -71,7 +71,7 @@ module ReachReports
# TODO QSAR_models -> sparql same endpoint
r.qsar_identifier.qsar_software << QsarSoftware.new( :url => model.uri,
:name => model.metadata[DC.title], :contact => model.metadata[DC.creator] )
- algorithm = OpenTox::Algorithm::Generic.find(model.metadata[OT.algorithm]) if model.metadata[OT.algorithm]
+ algorithm = OpenTox::Algorithm::Generic.find(model.metadata[OT.algorithm], r.subjectid) if model.metadata[OT.algorithm]
r.qsar_identifier.qsar_software << QsarSoftware.new( :url => algorithm.uri, :name => algorithm.metadata[DC.title] )
task.progress(10) if task
@@ -108,9 +108,11 @@ module ReachReports
# TODO app_domain_description, app_domain_method, app_domain_software, applicability_limits
#training_dataset = model.trainingDataset ? OpenTox::Dataset.find(model.trainingDataset+"/metadata") : nil
- begin
- training_dataset = model.metadata[OT.trainingDataset] ? OpenTox::Dataset.find(model.metadata[OT.trainingDataset]) : nil
- rescue
+ if ( OpenTox::Dataset.exist?(model.metadata[OT.trainingDataset]) )
+ training_dataset = OpenTox::Dataset.new( model.metadata[OT.trainingDataset] )
+ training_dataset.load_metadata( r.subjectid )
+ else
+ training_dataset = nil
LOGGER.warn "build qmrf: training_dataset not found "+model.metadata[OT.trainingDataset].to_s
end
task.progress(50) if task
@@ -264,14 +266,13 @@ module ReachReports
:url => training_dataset.uri} ) if training_dataset
val_datasets.each do |data_uri|
- begin
- d = OpenTox::Dataset.find(data_uri) #+"/metadata")
+ if OpenTox::Dataset.exist?(data_uri, r.subjectid)
+ d = OpenTox::Dataset.new(data_uri)
+ d.load_metadata( r.subjectid)
r.qsar_miscellaneous.attachment_validation_data << AttachmentValidationData.new(
{ :description => d.title,
:filetype => "owl-dl",
- :url => data_uri} ) if d
- rescue
- LOGGER.warn "could not add dataset: "+data_uri.to_s
+ :url => data_uri} )
end
end
task.progress(90) if task
diff --git a/reach_reports/reach_test.rb b/reach_reports/reach_test.rb
index 7d1569d..47e5158 100755
--- a/reach_reports/reach_test.rb
+++ b/reach_reports/reach_test.rb
@@ -1,3 +1,11 @@
+
+require "rubygems"
+require "sinatra"
+before {
+ request.env['HTTP_HOST']="local-ot/validation"
+ request.env["REQUEST_URI"]=request.env["PATH_INFO"]
+}
+
require "uri"
require "yaml"
ENV['RACK_ENV'] = 'test'
@@ -11,6 +19,19 @@ LOGGER = OTLogger.new(STDOUT)
LOGGER.datetime_format = "%Y-%m-%d %H:%M:%S "
LOGGER.formatter = Logger::Formatter.new
+if AA_SERVER
+ TEST_USER = "mgtest"
+ TEST_PW = "mgpasswd"
+# TEST_USER = "guest"
+# TEST_PW = "guest"
+ SUBJECTID = OpenTox::Authorization.authenticate(TEST_USER,TEST_PW)
+ raise "could not log in" unless SUBJECTID
+ puts "logged in: "+SUBJECTID.to_s
+else
+ puts "AA disabled"
+ SUBJECTID = nil
+end
+
#Rack::Test::DEFAULT_HOST = "local-ot/validation"
module Sinatra
module UrlForHelper
@@ -24,8 +45,11 @@ module Sinatra
"#{BASE}#{url_fragment}"
end
end
+ set :raise_errors, false
+ set :show_exceptions, false
end
+
#DataMapper::Model.raise_on_save_failure = true
#
#class TestResourceX
@@ -76,10 +100,12 @@ class ReachTest < Test::Unit::TestCase
def test_it
- delete '/reach_report/QMRF/3'
- puts last_response.body
+ begin
+
+ # delete '/reach_report/QMRF/3'
+ # puts last_response.body
- exit
+ #exit
# testResource = TestResource.new
#
# TestResource.info
@@ -120,7 +146,10 @@ class ReachTest < Test::Unit::TestCase
#model_uri = "http://ambit.uni-plovdiv.bg:8080/ambit2/model/173393"
- model_uri = "http://local-ot/majority/class/model/58"
+ #model_uri = "http://local-ot/majority/class/model/58"
+
+ model_uri = "http://local-ot/model/104"
+
# m = OpenTox::Model::Generic.find(model_uri)
# puts m.metadata[OT.algorithm] if m
# a = OpenTox::Algorithm::Generic.find(m.metadata[OT.algorithm])
@@ -132,13 +161,15 @@ class ReachTest < Test::Unit::TestCase
#model_uri = "http://local-ot/majority/class/model/15"
# model_uri = "http://local-ot/majority/class/model/91"
#model_uri = "http://apps.ideaconsult.net:8080/ambit2/model/2"
- post '/reach_report/qmrf',:model_uri=>model_uri #http://local-ot/model/1"
+ post '/reach_report/qmrf', {:model_uri=>model_uri}, {:subjectid => SUBJECTID} #http://local-ot/model/1"
##post '/reach_report/qprf',:compound_uri=>"http://local-ot/compound/XYZ"
uri = last_response.body
puts "task: "+uri.to_s
uri = Lib::TestUtil.wait_for_task(uri)
- id = uri.split("/")[-1]
- puts uri
+ if uri
+ id = uri.split("/")[-1]
+ puts uri
+ end
# id = "8"
@@ -164,6 +195,13 @@ class ReachTest < Test::Unit::TestCase
#File.new("/home/martin/tmp/qmr_rep_del_me.xml","w").puts last_response.body
#File.new("/home/martin/win/home/qmr_rep_del_me.xml","w").puts last_response.body
#File.new("/home/martin/info_home/.public_html/qmr_rep_del_me.xml","w").puts last_response.body
+
+ rescue => ex
+ rep = OpenTox::ErrorReport.create(ex, "")
+ puts rep.to_yaml
+ end
+
+
end
end