From 2372b0a475c9b12e989bc078a687aaac2e002160 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Wed, 15 Aug 2012 15:34:20 +0200 Subject: Bugfix: sorting CSV columns and appending line break to CSV --- lib/serializer.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/serializer.rb b/lib/serializer.rb index 5ab2c68..1e660e4 100644 --- a/lib/serializer.rb +++ b/lib/serializer.rb @@ -462,13 +462,7 @@ module OpenTox features = dataset.features.keys - # prepare for subgraphs - have_substructures = features.collect{ |id| dataset.features[id][RDF.type].include? OT.Substructure}.compact.uniq - if have_substructures.size == 1 && have_substructures[0] - features_smarts = features.collect{ |id| "\"" + dataset.features[id][OT.smarts] + "\"" } - end - - # gather missing features + # remove missing features delete_features = [] features.each{ |id| dataset.features[id][RDF.type].each { |typestr| @@ -479,6 +473,15 @@ module OpenTox } features = features - delete_features + # sort features + features.sort! + + # prepare for subgraphs + have_substructures = features.collect{ |id| dataset.features[id][RDF.type].include? OT.Substructure}.compact.uniq + if have_substructures.size == 1 && have_substructures[0] + features_smarts = features.collect{ |id| "\"" + dataset.features[id][OT.smarts] + "\"" } + end + # detect nr duplicates per compound compound_sizes = {} dataset.compounds.each do |compound| @@ -497,6 +500,7 @@ module OpenTox # get headers features_smarts && @rows.first << features_smarts || @rows.first << features @rows.first.flatten! + LOGGER.debug @rows.first.to_yaml # feature positions pre-calculated feature_positions = features.inject({}) { |h,f| @@ -543,6 +547,7 @@ module OpenTox result = "" result << rows.shift.collect { |f| f.split('/').last }.join(",") << "\n" # only feature name result << rows.collect{ |r| r.join(",") }.join("\n") + result << "\n" end # Convert to spreadsheet workbook -- cgit v1.2.3