From 461a20d9071ad80f334d7a3d8c334e2e085821d2 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Wed, 31 Oct 2012 17:19:20 +0100 Subject: Compounds removed from allnde target --- lib/dataset.rb | 17 ++++++++++++++--- lib/utils/sparql/dataset.rb | 5 ++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/dataset.rb b/lib/dataset.rb index 288e4d3..4ce5fc4 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -37,23 +37,34 @@ module OpenTox # AM: read ordered dataset from RDF if ordered + # Read only some data as rdf unless have_rdf self.parse_rdfxml( RestClient.get([@uri,"allnde"].join("/"),{:accept => "application/rdf+xml"}), true ) end - @compounds = self.find_compounds_rdf - @features = self.find_features_rdf + # Features + @features = self.find_features_rdf numeric_features = @features.collect{|f| f.get f[RDF.type].include?(RDF::OT.NumericFeature) or f[RDF.type].include?(RDF::OT.Substructure) } + + # Compounds + if have_rdf + @compounds = self.find_compounds_rdf + else + @compounds = RestClient.get([@uri,"compounds"].join("/"),{:accept => "text/uri-list"}).split("\n").collect { |cmpd| OpenTox::Compound.new cmpd } + end + + # Data Entries if have_rdf - table = find_data_entries_rdf + table = self.find_data_entries_rdf else values = OpenTox::Dataset.find_data_entries_sparql(@uri) table = values + Array.new(@compounds.size*@features.size-values.size, "") end + clim=(@compounds.size-1) cidx = fidx = 0 num=numeric_features[fidx] diff --git a/lib/utils/sparql/dataset.rb b/lib/utils/sparql/dataset.rb index 7ba57ee..ecf55b6 100644 --- a/lib/utils/sparql/dataset.rb +++ b/lib/utils/sparql/dataset.rb @@ -51,9 +51,8 @@ module OpenTox # @return [Array] compounds Compounds in order def self.find_compounds_sparql(uri) sparql = "SELECT DISTINCT ?compound FROM <#{uri}> WHERE { - ?s <#{RDF.type}> <#{RDF::OT.DataEntry}> ; - <#{RDF::OLO.index}> ?cidx; - <#{RDF::OT.compound}> ?compound + ?compound <#{RDF.type}> <#{RDF::OT.Compound}> ; + <#{RDF::OLO.index}> ?cidx; } ORDER BY ?cidx" OpenTox::Backend::FourStore.query(sparql, "text/uri-list").split("\n").collect { |uri| OpenTox::Compound.new uri.strip } end -- cgit v1.2.3