diff options
author | Andreas Maunz <andreas@maunz.de> | 2012-08-15 15:34:20 +0200 |
---|---|---|
committer | Andreas Maunz <andreas@maunz.de> | 2012-08-15 15:34:20 +0200 |
commit | 2372b0a475c9b12e989bc078a687aaac2e002160 (patch) | |
tree | 095b6851e3de51c0e875c560f687e4bd269ad729 | |
parent | 20963ebcfb6929c3e2aed6849dcadb20ff086603 (diff) |
Bugfix: sorting CSV columns and appending line break to CSV
-rw-r--r-- | lib/serializer.rb | 19 |
1 files 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 |