From c37cc91893457cb91ddb2a32b9ac76090bd6c521 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Tue, 8 Feb 2011 08:57:31 +0100 Subject: not using rapper directly, use rest client and tmp-file --- lib/model.rb | 4 ++-- lib/parser.rb | 12 ++++++++++-- lib/task.rb | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/model.rb b/lib/model.rb index ae793e8..64d178f 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -31,7 +31,7 @@ module OpenTox return nil unless uri model = Generic.new(uri) model.load_metadata(subjectid) - raise "could not load model metadata" if model.metadata==nil or model.metadata.size==0 + raise "could not load model metadata '"+uri.to_s+"'" if model.metadata==nil or model.metadata.size==0 model end @@ -134,7 +134,7 @@ module OpenTox OT.parameters => [{DC.title => "dataset_uri", OT.paramValue => dataset_uri}] }) d = Dataset.new(dataset_uri,subjectid) - d.load_compounds + d.load_compounds(subjectid) count = 0 d.compounds.each do |compound_uri| begin diff --git a/lib/parser.rb b/lib/parser.rb index e055eec..27dfeee 100644 --- a/lib/parser.rb +++ b/lib/parser.rb @@ -35,10 +35,18 @@ module OpenTox else uri = @uri end - uri += "?subjectid=#{CGI.escape(subjectid)}" if subjectid + # avoid using rapper directly because of 2 reasons: + # * http errors wont be noticed + # * subjectid cannot be sent as header + ##uri += "?subjectid=#{CGI.escape(subjectid)}" if subjectid + ## `rapper -i rdfxml -o ntriples #{uri} 2>/dev/null`.each_line do |line| + file = Tempfile.new("ot-rdfxml") + file.puts OpenTox::RestClientWrapper.get @uri,{:subjectid => subjectid,:accept => "application/rdf+xml"} + file.close + file = "file://"+file.path statements = [] parameter_ids = [] - `rapper -i rdfxml -o ntriples #{uri} 2>/dev/null`.each_line do |line| + `rapper -i rdfxml -o ntriples #{file} 2>/dev/null`.each_line do |line| triple = line.to_triple @metadata[triple[1]] = triple[2].split('^^').first if triple[0] == @uri and triple[1] != RDF['type'] statements << triple diff --git a/lib/task.rb b/lib/task.rb index 73d880e..ca18d7b 100644 --- a/lib/task.rb +++ b/lib/task.rb @@ -303,7 +303,7 @@ module OpenTox class SubTask def initialize(task, min, max) - raise "not a task or subtask" unless task.is_a?(Task) or task.is_a?(SubTask) + raise "not a task or subtask" if task!=nil and !(task.is_a?(Task) or task.is_a?(SubTask)) raise "invalid max ("+max.to_s+"), min ("+min.to_s+") params" unless min.is_a?(Numeric) and max.is_a?(Numeric) and min >= 0 and max <= 100 and max > min @task = task -- cgit v1.2.3