summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--algorithm.rb3
-rw-r--r--authorization.rb11
-rw-r--r--dataset.rb22
-rw-r--r--feature.rb2
-rw-r--r--lazar.rb16
-rw-r--r--validate-owl.rb6
6 files changed, 37 insertions, 23 deletions
diff --git a/algorithm.rb b/algorithm.rb
index 055f0a2..94f3b5c 100644
--- a/algorithm.rb
+++ b/algorithm.rb
@@ -6,6 +6,7 @@ require "./validate-owl.rb"
class AlgorithmTest < Test::Unit::TestCase
def setup
+ @@subjectid = OpenTox::Authorization.authenticate(TEST_USER,TEST_PW)
@algorithms = [
File.join(CONFIG[:services]["opentox-algorithm"],"fminer","bbrc"),
File.join(CONFIG[:services]["opentox-algorithm"],"fminer","last"),
@@ -20,7 +21,7 @@ class AlgorithmTest < Test::Unit::TestCase
def test_metadata
@algorithms.each do |algorithm|
puts algorithm
- validate_owl(algorithm)
+ validate_owl(algorithm, @@subjectid)
end
end
diff --git a/authorization.rb b/authorization.rb
index 0d3508b..3772638 100644
--- a/authorization.rb
+++ b/authorization.rb
@@ -85,7 +85,16 @@ class TestOpenToxAuthorizationLDAP < Test::Unit::TestCase
logout(tok_anonymous)
end
-
+ def test_03_check_different_uris
+ res = OpenTox::Authorization.send_policy(TEST_URI, @@subjectid)
+ assert OpenTox::Authorization.uri_has_policy(TEST_URI, @@subjectid)
+ assert OpenTox::Authorization.authorize(TEST_URI, "GET", @@subjectid), "GET request"
+ policies = OpenTox::Authorization.list_uri_policies(TEST_URI, @@subjectid)
+ policies.each do |policy|
+ assert OpenTox::Authorization.delete_policy(policy, @@subjectid)
+ end
+
+ end
end
diff --git a/dataset.rb b/dataset.rb
index 812a060..cc8f50e 100644
--- a/dataset.rb
+++ b/dataset.rb
@@ -47,7 +47,7 @@ class DatasetTest < Test::Unit::TestCase
end
def test_all
- datasets = OpenTox::Dataset.all
+ datasets = OpenTox::Dataset.all(CONFIG[:services]["opentox-dataset"], @@subjectid)
assert_kind_of Array, datasets
end
@@ -67,14 +67,14 @@ class DatasetTest < Test::Unit::TestCase
def test_rest_csv
uri = OpenTox::RestClientWrapper.post(CONFIG[:services]["opentox-dataset"],{:accept => "text/uri-list"}, {:file => File.new("data/hamster_carcinogenicity.csv"), :subjectid => @@subjectid}).to_s.chomp
@dataset = OpenTox::Dataset.new uri
- @dataset.load_all
+ @dataset.load_all(@@subjectid)
hamster_carc?
end
def test_multicolumn_csv
uri = OpenTox::RestClientWrapper.post(CONFIG[:services]["opentox-dataset"],{:accept => "text/uri-list"}, {:file => File.new("data/multicolumn.csv"), :subjectid => @@subjectid}).to_s.chomp
@dataset = OpenTox::Dataset.new uri
- @dataset.load_all
+ @dataset.load_all(@@subjectid)
assert_equal 5, @dataset.features.size
assert_equal 4, @dataset.compounds.size
@@ -96,7 +96,7 @@ class DatasetTest < Test::Unit::TestCase
def test_load_metadata
@datasets.each do |uri,data|
- @dataset = OpenTox::Dataset.find(uri)
+ @dataset = OpenTox::Dataset.find(uri, @@subjectid)
assert @dataset.metadata.size != 0
end
end
@@ -104,7 +104,7 @@ class DatasetTest < Test::Unit::TestCase
def test_load_compounds
@datasets.each do |uri,data|
@dataset = OpenTox::Dataset.new(uri)
- @dataset.load_compounds
+ @dataset.load_compounds(@@subjectid)
assert_equal @dataset.compounds.size,data[:nr_compounds]
end
end
@@ -120,7 +120,7 @@ class DatasetTest < Test::Unit::TestCase
def test_load_all
@datasets.each do |uri,data|
@dataset = OpenTox::Dataset.new(uri)
- @dataset.load_all
+ @dataset.load_all(@@subjectid)
validate data
end
end
@@ -128,7 +128,7 @@ class DatasetTest < Test::Unit::TestCase
def test_yaml
@datasets.each do |uri,data|
@dataset = OpenTox::Dataset.new(uri)
- @dataset.load_all
+ @dataset.load_all(@@subjectid)
#@dataset = YAML.load @dataset.to_yaml
validate data
end
@@ -137,7 +137,7 @@ class DatasetTest < Test::Unit::TestCase
def test_csv
@datasets.each do |uri,data|
@dataset = OpenTox::Dataset.new(uri)
- @dataset.load_all
+ @dataset.load_all(@@subjectid)
csv = @dataset.to_csv.split("\n")
assert_equal csv.size, data[:nr_compounds]+1
assert_equal csv.first.split(", ").size, data[:nr_dataset_features]+1
@@ -147,7 +147,7 @@ class DatasetTest < Test::Unit::TestCase
def test_excel
@datasets.each do |uri,data|
@dataset = OpenTox::Dataset.new(uri)
- @dataset.load_all
+ @dataset.load_all(@@subjectid)
book = @dataset.to_spreadsheet
assert_kind_of Spreadsheet::Workbook, book
#File.open("#{@dataset.id}.xls","w+"){|f| book.write f.path}
@@ -157,7 +157,7 @@ class DatasetTest < Test::Unit::TestCase
def test_ntriples
@datasets.each do |uri,data|
@dataset = OpenTox::Dataset.new(uri)
- @dataset.load_all
+ @dataset.load_all(@@subjectid)
assert_kind_of String, @dataset.to_ntriples
end
end
@@ -165,7 +165,7 @@ class DatasetTest < Test::Unit::TestCase
def test_owl
@datasets.each do |uri,data|
@dataset = OpenTox::Dataset.new(uri)
- @dataset.load_all
+ @dataset.load_all(@@subjectid)
assert_kind_of String, @dataset.to_rdfxml
end
end
diff --git a/feature.rb b/feature.rb
index 9a9d9ab..7ed600c 100644
--- a/feature.rb
+++ b/feature.rb
@@ -25,7 +25,7 @@ class FeatureTest < Test::Unit::TestCase
def test_owl
#@features.each do |uri|
- validate_owl @features.first
+ validate_owl @features.first, @@subjectid
# Ambit does not validate
#end
end
diff --git a/lazar.rb b/lazar.rb
index 0ee7a43..280f917 100644
--- a/lazar.rb
+++ b/lazar.rb
@@ -14,11 +14,11 @@ class LazarTest < Test::Unit::TestCase
=end
def test_create_regression_model
model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => @@regression_training_dataset.uri, :subjectid => @@subjectid}).to_s
- lazar = OpenTox::Model::Lazar.find model_uri
+ lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid
assert_equal lazar.features.size, 222
compound = OpenTox::Compound.from_smiles("c1ccccc1NN")
prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid)
- prediction = OpenTox::LazarPrediction.find(prediction_uri)
+ prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid)
assert_equal prediction.value(compound).round_to(4), 0.149518871336721.round_to(4)
assert_equal prediction.confidence(compound).round_to(4), 0.615246530364447.round_to(4)
assert_equal prediction.neighbors(compound).size, 81
@@ -29,12 +29,12 @@ class LazarTest < Test::Unit::TestCase
def test_default_classification_model
# create model
model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => @@classification_training_dataset.uri, :subjectid => @@subjectid}).to_s
- lazar = OpenTox::Model::Lazar.find model_uri
+ lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid
assert_equal lazar.features.size, 41
# single prediction
compound = OpenTox::Compound.from_smiles("c1ccccc1NN")
prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid)
- prediction = OpenTox::LazarPrediction.find(prediction_uri)
+ prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid)
assert_equal prediction.value(compound), false
assert_equal prediction.confidence(compound).round_to(4), 0.25857114104619.round_to(4)
assert_equal prediction.neighbors(compound).size, 15
@@ -42,7 +42,7 @@ class LazarTest < Test::Unit::TestCase
# dataset activity
compound = OpenTox::Compound.from_smiles("CNN")
prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid)
- prediction = OpenTox::LazarPrediction.find prediction_uri
+ prediction = OpenTox::LazarPrediction.find prediction_uri, @@subjectid
assert !prediction.measured_activities(compound).empty?
puts prediction.measured_activities(compound).first.inspect
assert_equal prediction.measured_activities(compound).first, true
@@ -50,9 +50,13 @@ class LazarTest < Test::Unit::TestCase
prediction.delete(@@subjectid)
# dataset prediction
test_dataset = OpenTox::Dataset.create_from_csv_file("data/multicolumn.csv", @@subjectid)
- prediction = OpenTox::LazarPrediction.find lazar.run(:dataset_uri => test_dataset.uri, :subjectid => @@subjectid)
+ prediction = OpenTox::LazarPrediction.find lazar.run(:dataset_uri => test_dataset.uri, :subjectid => @@subjectid), @@subjectid
assert_equal prediction.compounds.size, 4
compound = OpenTox::Compound.new prediction.compounds.first
+ puts "compound"
+ puts compound.inspect
+ puts "prediction"
+ puts prediction.value(compound).inspect
assert_equal prediction.value(compound), false
prediction.delete(@@subjectid)
lazar.delete(@@subjectid)
diff --git a/validate-owl.rb b/validate-owl.rb
index 569813f..736531b 100644
--- a/validate-owl.rb
+++ b/validate-owl.rb
@@ -1,9 +1,9 @@
#require 'nokogiri'
-def validate_owl(uri)
+def validate_owl(uri, subjectid=nil)
if validator_available?
- owl = OpenTox::RestClientWrapper.get(uri,:accept => "application/rdf+xml")
- html = OpenTox::RestClientWrapper.post("http://www.mygrid.org.uk/OWL/Validator",{:rdf => owl, :level => "DL"})
+ owl = OpenTox::RestClientWrapper.get(uri,{:accept => "application/rdf+xml",:subjectid => subjectid})
+ html = OpenTox::RestClientWrapper.post("http://www.mygrid.org.uk/OWL/Validator",{:rdf => owl, :level => "DL",:subjectid => subjectid})
assert_match(/YES/,html)
else
puts "http://www.mygrid.org.uk/OWL/Validator offline"