diff options
author | Andreas Maunz <andreas@maunz.de> | 2012-10-26 11:53:42 +0200 |
---|---|---|
committer | Andreas Maunz <andreas@maunz.de> | 2012-10-26 11:53:42 +0200 |
commit | 3eb7d48387e802ad08813f67bfa228013d1efa17 (patch) | |
tree | 3ff9602f44906b1d8c80eb36d430ed6c1affd8a7 | |
parent | edad943c5ef4b04a018f763aa8dd86e19521ce72 (diff) |
CSV: Removed unnecessary get()s and fixed header escapes
-rw-r--r-- | application.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/application.rb b/application.rb index 54a89a2..43b685f 100644 --- a/application.rb +++ b/application.rb @@ -294,16 +294,15 @@ module OpenTox table = [] if ordered? sparql = "SELECT DISTINCT ?s FROM <#{@uri}> WHERE {?s <#{RDF.type}> <#{RDF::OT.Feature}> . ?s <#{RDF::OLO.index}> ?i} ORDER BY ?i" - features = FourStore.query(sparql, accept).split("\n").collect{|uri| OpenTox::Feature.new uri} + features = FourStore.query(sparql, accept).split("\n").collect{|uri| OpenTox::Feature.new uri}.each { |f| f.get } quoted_features = features.each_with_index.collect { |f,idx| - f.get if (f[RDF.type].include?(RDF::OT.NominalFeature) or f[RDF.type].include?(RDF::OT.StringFeature) and !f[RDF.type].include?(RDF::OT.NumericFeature)) idx+1 end }.compact - table << ["InChI"] + features.collect{ |f| f.get; f[RDF::DC.title] } + table << ["InChI"] + features.collect{ |f| "\"" + f[RDF::DC.title] + "\"" } sparql = "SELECT DISTINCT ?i FROM <#{@uri}> WHERE {?s <#{RDF.type}> <#{RDF::OT.DataEntry}> . ?s <#{RDF::OLO.index}> ?i} ORDER BY ?i" FourStore.query(sparql, accept).split("\n").each do |data_entry_idx| sparql = "SELECT DISTINCT ?compound FROM <#{@uri}> WHERE { @@ -326,16 +325,15 @@ module OpenTox end else sparql = "SELECT DISTINCT ?s FROM <#{@uri}> WHERE {?s <#{RDF.type}> <#{RDF::OT.Feature}>}" - features = FourStore.query(sparql, accept).split("\n").collect{|uri| OpenTox::Feature.new uri} + features = FourStore.query(sparql, accept).split("\n").collect{|uri| OpenTox::Feature.new uri}.each { |f| f.get } quoted_features = features.each_with_index.collect { |f,idx| - f.get if (f[RDF.type].include?(RDF::OT.NominalFeature) or f[RDF.type].include?(RDF::OT.StringFeature) and !f[RDF.type].include?(RDF::OT.NumericFeature)) idx+1 end }.compact - table << ["InChI"] + features.collect{ |f| f.get; f[RDF::DC.title] } + table << ["InChI"] + features.collect{ |f| "\"" + f[RDF::DC.title] + "\"" } sparql = "SELECT ?s FROM <#{@uri}> WHERE {?s <#{RDF.type}> <#{RDF::OT.Compound}>. }" compounds = FourStore.query(sparql, accept).split("\n").collect{|uri| OpenTox::Compound.new uri} compounds.each do |compound| |