diff options
author | mguetlein <martin.guetlein@gmail.com> | 2014-10-27 15:48:01 +0100 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2014-10-27 15:48:01 +0100 |
commit | 36ea2f865014a761be9fe74719f4c88dbaffeb81 (patch) | |
tree | baf3f9799cf0d3b3896699845bdd2548eadd27a5 /nch/04_get_feature_names.rb | |
parent | 9892566a309ac99c21adad9fee5a2e625d8d4042 (diff) |
inital commit more documentation will be added
Diffstat (limited to 'nch/04_get_feature_names.rb')
-rwxr-xr-x | nch/04_get_feature_names.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/nch/04_get_feature_names.rb b/nch/04_get_feature_names.rb new file mode 100755 index 0000000..b22f68b --- /dev/null +++ b/nch/04_get_feature_names.rb @@ -0,0 +1,45 @@ +#!/usr/bin/env ruby + +require "csv" +require "uri" + +require "./config.rb" + +require "bundler" +Bundler.require + +feature_names = OpenTox::RestClientWrapper.get("http://localhost:8081/algorithm/descriptor/physchem/list_values").split("\n") +puts "derived #{feature_names.size} features from algorithm service" + +DATA.each do |d| + $stderr.puts "\ndataset name #{d}" + + next if d=="LOAEL-mg" + + orig_features = nil + CSV.foreach("data/02/#{d}_orig-features.csv") do |row| + raise "first column is not InChI: #{row}" unless row[0]=="InChI" + orig_features = row[1..-1] + break + end + #puts orig_features.inspect + #puts "->" + + matches = [] + orig_features.each do |f| + m = [] + feature_names.each do |n| + m << n if n=~/#{f}$/ + end + raise "could not match #{f}: #{m.inspect}" unless m.size==1 + matches += m + end + #matches.sort! + # puts matches.inspect + # puts "" + + File.open("data/04/#{d}.feature_names","w").puts matches.join(",") + $stderr.puts "written #{matches.size} features to data/04/#{d}.feature_names" +end + + |