summaryrefslogtreecommitdiff
path: root/lib/ontology.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ontology.rb')
-rw-r--r--lib/ontology.rb43
1 files changed, 16 insertions, 27 deletions
diff --git a/lib/ontology.rb b/lib/ontology.rb
index ad7ba7b..2c20c59 100644
--- a/lib/ontology.rb
+++ b/lib/ontology.rb
@@ -4,13 +4,9 @@ module OpenTox
def self.querystring(classname="Endpoints")
return CGI.escape("PREFIX ot:<http://www.opentox.org/api/1.1#>
- PREFIX ota:<http://www.opentox.org/algorithms.owl#>
- PREFIX owl:<http://www.w3.org/2002/07/owl#>
PREFIX dc:<http://purl.org/dc/elements/1.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX otee:<http://www.opentox.org/echaEndpoints.owl#>
- PREFIX toxcast:<http://www.opentox.org/toxcast.owl#>
select *
where {
?endpoint rdfs:subClassOf otee:#{classname}.
@@ -18,25 +14,22 @@ module OpenTox
}")
end
- def self.make_option_list(endpoint="Endpoints", level=1)
- out = ""
- results = echa_endpoints(endpoint) rescue results = []
- results.each do |result|
- r = result.split(',')
- endpointname = r.first.split("#").last
- title = r[1..r.size-1]
- out += "<option value='#{r.first}' id='#{endpointname}' class='level_#{level}'>#{title}</option>\n"
- out += make_option_list(endpointname, level + 1)
+ # Gets Endpoint name of a specific endpoint URI
+ # @param [String] endpointuri e.G. "http://www.opentox.org/echaEndpoints.owl#EcotoxicEffects"
+ # @return [String] endpointname: e.G.: "Ecotoxic effects"
+ def self.get_endpoint_name(endpointuri)
+ qstring = CGI.escape("PREFIX dc:<http://purl.org/dc/elements/1.1/>
+ select distinct ?title
+ where {
+ ?endpoint dc:title ?title.
+ FILTER (?endpoint = <#{endpointuri}>)
+ }")
+ begin
+ RestClientWrapper.get("#{ONTOLOGY_SERVER}?query=#{qstring}",:accept => "text/csv").collect{|l| l.gsub("\r\n", "") if l.to_s != "title\r\n"}.uniq.compact.sort.first.to_s
+ rescue
+ LOGGER.warn "OpenTox::Ontology::Echa.get_endpoint_name(#{endpointuri}) ontology service is not reachable."
+ []
end
- return out
- end
-
- def self.endpoint_option_list(include_blank=true)
- out = "<select id='endpoint' name='endpoint'>\n"
- out += "<option value='' id='please_select'>Please select</option>\n" if include_blank
- out += make_option_list
- out += "</select>\n"
- return out
end
# Gets Endpoints of specific level from ontology service
@@ -115,11 +108,8 @@ module OpenTox
# Query string to find a registered model
# @param [String] uri, model URI
def self.querystring(uri)
- return CGI.escape("PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
- PREFIX owl:<http://www.w3.org/2002/07/owl#>
+ return CGI.escape("PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc:<http://purl.org/dc/elements/1.1/>
- PREFIX dcterms:<http://purl.org/dc/terms/>
PREFIX ot:<http://www.opentox.org/api/1.1#>
select distinct ?model ?title ?creator ?trainingDataset ?algorithm
where {
@@ -132,6 +122,5 @@ module OpenTox
}")
end
end
-
end
end \ No newline at end of file