summaryrefslogtreecommitdiff
path: root/scripts/functional-groups.rb
blob: 1dd0e3ec857f67507d59c7bff542c3aff1a1c021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require_relative '../../lazar/lib/lazar'
include OpenTox
old = Dataset.from_csv_file File.join(File.dirname(__FILE__),"..","regression","LOAEL_mg_corrected_smiles_mmol.csv")
new = Dataset.from_csv_file File.join(File.dirname(__FILE__),"..","regression","swissRat_chron_LOAEL_mmol.csv")

functional_groups = {}
table = []
File.open("functional-groups.txt").each_line do |line|
  name, smarts = line.chomp.split ": "
  if smarts
    smarts_feature = Smarts.from_smarts smarts
    oldcount = 0
    old.compounds.each do |c|
      oldcount += Algorithm::Descriptor.smarts_match(c,smarts_feature).first.to_i
    end
    newcount = 0
    new.compounds.each do |c|
      newcount += Algorithm::Descriptor.smarts_match(c,smarts_feature).first.to_i
    end
    puts "#{name}, #{oldcount}, #{newcount}" if oldcount > 0 and newcount > 0
  else
    p name, smarts
  end
    #table << [name, oldcount, newcount]
end