Module: OpenTox::Ontology::Echa

Defined in:
lib/ontology.rb

Class Method Summary collapse

Class Method Details

.datasets(endpoint) ⇒ Object



54
55
56
# File 'lib/ontology.rb', line 54

def self.datasets(endpoint)
  RestClientWrapper.get("http://apps.ideaconsult.net:8080/ambit2/dataset?feature_sameas=#{URI.encode endpoint}", :accept => "text/uri-list").split("\n")
end

.echa_endpoints(endpoint) ⇒ Array

Gets Endpoints of specific level from ontology service Top level with endpoint=“Endpoints” e.G. Ecotoxic effects endpoints with endpoint=“EcotoxicEffects” if ontology service is not reachable it returns an empty array

Parameters:

Returns:



41
42
43
44
45
46
47
48
# File 'lib/ontology.rb', line 41

def self.echa_endpoints(endpoint)
  begin
    RestClientWrapper.get("#{ONTOLOGY_SERVER}?query=#{querystring(endpoint)}",:accept => "text/csv").collect{|l| l.gsub("\r\n", "") if l.match(/^http/)}.uniq.compact.sort
  rescue
    LOGGER.warn "OpenTox::Ontology::Echa.echa_endpoints ontology service is not reachable."
    []
  end
end

.endpointsObject



50
51
52
# File 'lib/ontology.rb', line 50

def self.endpoints
  RestClientWrapper.get("http://apps.ideaconsult.net:8080/ambit2/query/ndatasets_endpoint",:accept => "text/csv").collect { |line| line.split(',').first if line.match(/^http/) }.compact
end

.get_endpoint_name(endpointuri) ⇒ String

Gets Endpoint name of a specific endpoint URI

Parameters:

Returns:

  • (String)

    endpointname: e.G.: “Ecotoxic effects”



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ontology.rb', line 20

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
end

.querystring(classname = "Endpoints") ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/ontology.rb', line 5

def self.querystring(classname="Endpoints")
  return CGI.escape("PREFIX ot:<http://www.opentox.org/api/1.1#>
  PREFIX dc:<http://purl.org/dc/elements/1.1/>
  PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  PREFIX otee:<http://www.opentox.org/echaEndpoints.owl#>
  select *
    where {
      ?endpoint  rdfs:subClassOf  otee:#{classname}.
      ?endpoint dc:title ?title.
    }")
end