Class: OpenTox::PhysChem
- Inherits:
-
NumericFeature
- Object
- Feature
- NumericFeature
- OpenTox::PhysChem
- Defined in:
- lib/physchem.rb
Overview
Feature for physico-chemical descriptors
Constant Summary collapse
- JAVA_DIR =
File.join(File.dirname(__FILE__),"..","java")
- CDK_JAR =
Dir[File.join(JAVA_DIR,"cdk-*jar")].last
- JOELIB_JAR =
File.join(JAVA_DIR,"joelib2.jar")
- LOG4J_JAR =
File.join(JAVA_DIR,"log4j.jar")
- JMOL_JAR =
File.join(JAVA_DIR,"Jmol.jar")
- OBDESCRIPTORS =
Hash[OpenBabel::OBDescriptor.list_as_string("descriptors").split("\n").collect do |d| name,description = d.split(/\s+/,2) ["Openbabel."+name,description] unless obexclude.include? name end.compact.sort{|a,b| a[0]
- CDK_DESCRIPTIONS =
YAML.load(`java -classpath #{CDK_JAR}:#{JAVA_DIR} CdkDescriptorInfo`)
- CDKDESCRIPTORS =
cdkdescriptors- JOELIBDESCRIPTORS =
strip Joelib messages from stdout
- DESCRIPTORS =
OBDESCRIPTORS.merge(CDKDESCRIPTORS.merge(JOELIBDESCRIPTORS))
Class Method Summary collapse
- .cdk_descriptors ⇒ Object
- .descriptors(desc = DESCRIPTORS) ⇒ Object
- .joelib_descriptors ⇒ Object
- .openbabel_descriptors ⇒ Object
- .unique_descriptors ⇒ Object
Instance Method Summary collapse
- #calculate(compound) ⇒ Object
- #cdk(descriptor, compound) ⇒ Object
- #joelib(descriptor, compound) ⇒ Object
- #openbabel(descriptor, compound) ⇒ Object
Methods inherited from NumericFeature
Constructor Details
This class inherits a constructor from OpenTox::NumericFeature
Class Method Details
.cdk_descriptors ⇒ Object
71 72 73 |
# File 'lib/physchem.rb', line 71 def self.cdk_descriptors descriptors CDKDESCRIPTORS end |
.descriptors(desc = DESCRIPTORS) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/physchem.rb', line 42 def self.descriptors desc=DESCRIPTORS desc.collect do |name,description| lib,desc = name.split('.',2) self.find_or_create_by(:name => name, :library => lib, :descriptor => desc, :description => description, :measured => false, :calculated => true, :numeric => true, :nominal => false) end end |
.joelib_descriptors ⇒ Object
75 76 77 |
# File 'lib/physchem.rb', line 75 def self.joelib_descriptors descriptors JOELIBDESCRIPTORS end |
.openbabel_descriptors ⇒ Object
67 68 69 |
# File 'lib/physchem.rb', line 67 def self.openbabel_descriptors descriptors OBDESCRIPTORS end |
.unique_descriptors ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/physchem.rb', line 49 def self.unique_descriptors udesc = [] UNIQUEDESCRIPTORS.each do |name| lib,desc = name.split('.',2) if lib == "Cdk" CDK_DESCRIPTIONS.select{|d| desc == d[:java_class].split('.').last.sub('Descriptor','') }.first[:names].each do |n| dname = "#{name}.#{n}" description = DESCRIPTORS[dname] udesc << self.find_or_create_by(:name => dname, :library => lib, :descriptor => desc, :description => description, :measured => false, :calculated => true, :numeric => true, :nominal => false) end else description = DESCRIPTORS[name] udesc << self.find_or_create_by(:name => name, :library => lib, :descriptor => desc, :description => description, :measured => false, :calculated => true, :numeric => true, :nominal => false) end end udesc end |
Instance Method Details
#calculate(compound) ⇒ Object
79 80 81 82 |
# File 'lib/physchem.rb', line 79 def calculate compound result = send library.downcase,descriptor,compound result[self.name] end |
#cdk(descriptor, compound) ⇒ Object
93 94 95 |
# File 'lib/physchem.rb', line 93 def cdk descriptor, compound java_descriptor "cdk", descriptor, compound end |
#joelib(descriptor, compound) ⇒ Object
97 98 99 |
# File 'lib/physchem.rb', line 97 def joelib descriptor, compound java_descriptor "joelib", descriptor, compound end |
#openbabel(descriptor, compound) ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/physchem.rb', line 84 def openbabel descriptor, compound obdescriptor = OpenBabel::OBDescriptor.find_type descriptor obmol = OpenBabel::OBMol.new obconversion = OpenBabel::OBConversion.new obconversion.set_in_format 'smi' obconversion.read_string obmol, compound.smiles {"#{library.capitalize}.#{descriptor}" => fix_value(obdescriptor.predict(obmol))} end |