class KaziusAlerts
Constants
- CONFIDENCES
- SMARTS
Public Class Methods
error(alert)
click to toggle source
# File lib/kazius-alerts.rb, line 77 def self.error(alert) if CONFIDENCES[alert[0]] return 1 - CONFIDENCES[alert[0]] else return 1 - CONFIDENCES["other SAs"] end end
predict(smiles)
click to toggle source
# File lib/kazius-alerts.rb, line 47 def self.predict smiles smi2mol = OpenBabel::OBConversion.new smi2mol.set_in_format("smi") mol = OpenBabel::OBMol.new smi2mol.read_string(mol, smiles) matches = [] prediction = false error_product = 1 smarts_pattern = OpenBabel::OBSmartsPattern.new SMARTS.each do |sma| if sma[2] smarts_pattern.init sma[1] if smarts_pattern.match(mol) smarts_pattern.init sma[2] matches << sma if !smarts_pattern.match(mol) end else smarts_pattern.init sma[1] matches << sma if smarts_pattern.match(mol) end end matches.each { |m| error_product *= error(m) } prediction = true if matches.size > 0 {:prediction => prediction, :error_product => error_product, :matches => matches} end