Class: Chem::CDK::CDKMolecule
- Inherits:
-
Object
- Object
- Chem::CDK::CDKMolecule
- Defined in:
- lib/chem/utils/cdk.rb
Constant Summary
Constants included from Molecule
Molecule::DESCRIPTORNAME, Molecule::ELEMNUM, Molecule::EpsHeader, Molecule::MDLCountLineFormat, Molecule::MDLHeaderLine2Format
Instance Attribute Summary collapse
-
#cdk_mol ⇒ Object
readonly
Returns the value of attribute cdk_mol.
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Attributes included from Graph
Attributes included from Molecule
#cdk2atom, #name, #ob_mol, #source
Instance Method Summary collapse
-
#initialize(cdk_mol) ⇒ CDKMolecule
constructor
A new instance of CDKMolecule.
- #setup_nodes_and_edges ⇒ Object
Methods included from Graph
#adjacent_to, #clustering_coefficient, #each, #morgan, #terminal_nodes
Methods included from Molecule
#-, #adjacent_index, #assign_2d_geometry, #bit_mat, #box_size, #breadth_first_search, #canonical_ring, #cdk_BCUT, #cdk_CPSA, #cdk_RotatableBondsCount, #cdk_calc_descriptor, #cdk_calc_descriptors, #cdk_find_all_rings, #cdk_fingerprint, #cdk_gasteiger_marsili_partial_charges, #cdk_generate_2D, #cdk_generate_randomly, #cdk_generate_vicinity, #cdk_hose_code, #cdk_hueckel, #cdk_mcs, #cdk_properties, #cdk_rule_of_file, #cdk_save_as, #cdk_setup, #cdk_sssr, #cdk_wiener_numbers, #cdk_xlogp, #composition, #connected?, #deep_dup, #delete, #delete_bond, #depth_first_search, #divide, #f_dfs, #find_smallest_ring, #find_sssr, #fingerprint, #generate_pubchem_subskey, #hilight, #induced_sub, #match, #match_by_ullmann, #method_missing, #molecular_weight, #n_hydrogen, #ob_export_as, #ob_save_as, #oxidation_number, #pubchem_subskeys, #remove_hydrogens!, #save, #save_as_mdl, #save_as_pdf, #subset_in_composition?, #to_cansmi, #to_eps, #to_inchi, #to_sybyl, #typ_str, #use_open_babel
Constructor Details
#initialize(cdk_mol) ⇒ CDKMolecule
Returns a new instance of CDKMolecule.
50 51 52 53 |
# File 'lib/chem/utils/cdk.rb', line 50 def initialize(cdk_mol) @cdk_mol = cdk_mol setup_nodes_and_edges end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chem::Molecule
Instance Attribute Details
#cdk_mol ⇒ Object (readonly)
Returns the value of attribute cdk_mol.
49 50 51 |
# File 'lib/chem/utils/cdk.rb', line 49 def cdk_mol @cdk_mol end |
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
49 50 51 |
# File 'lib/chem/utils/cdk.rb', line 49 def edges @edges end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
49 50 51 |
# File 'lib/chem/utils/cdk.rb', line 49 def nodes @nodes end |
Instance Method Details
#setup_nodes_and_edges ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/chem/utils/cdk.rb', line 55 def setup_nodes_and_edges @nodes = [] @edges = [] @cdk2atom = {} enum = @cdk_mol.atoms while(enum.hasMoreElements) cdkatom = enum.nextElement atom = CDKAtom.new(cdkatom) @cdk2atom[cdkatom.hashCode] = atom @nodes << atom end tmp = {} @nodes.each do |from| tmp[from.cdk_atom.hashCode] ||= {} @cdk_mol.getConnectedAtoms(from.cdk_atom).each do |to| if tmp[from.cdk_atom.hashCode][to.hashCode].nil? bond = @cdk_mol.getBond(from.cdk_atom, to) tmp[from.cdk_atom.hashCode][to.hashCode] = bond tmp[to.hashCode] ||= {} tmp[to.hashCode][from.cdk_atom.hashCode] = bond @edges << [CDKBond.new(bond), from, @cdk2atom[to.hashCode]] end end end end |