summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2012-10-31 17:19:20 +0100
committerAndreas Maunz <andreas@maunz.de>2012-10-31 17:19:20 +0100
commit461a20d9071ad80f334d7a3d8c334e2e085821d2 (patch)
tree225eef328e8219b4481c274a0c04498c31043632
parent8a2b749ccef94b229a32ec716c93388f5c7495d7 (diff)
Compounds removed from allnde target
-rw-r--r--lib/dataset.rb17
-rw-r--r--lib/utils/sparql/dataset.rb5
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