Class: Chem::CMLMolecule

Inherits:
Object
  • Object
show all
Includes:
Molecule
Defined in:
lib/chem/db/cml.rb

Constant Summary

Constants included from Molecule

Molecule::DESCRIPTORNAME, Molecule::ELEMNUM, Molecule::EpsHeader, Molecule::MDLCountLineFormat, Molecule::MDLHeaderLine2Format

Instance Attribute Summary

Attributes included from Molecule

#cdk2atom, #cdk_mol, #name, #ob_mol, #source

Attributes included from Graph

#adjacencies, #edges, #nodes

Instance Method Summary collapse

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

Methods included from Graph

#adjacent_to, #clustering_coefficient, #each, #morgan, #terminal_nodes

Constructor Details

#initialize(str) ⇒ CMLMolecule

Returns a new instance of CMLMolecule.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/chem/db/cml.rb', line 30

def initialize(str)
  @nodes = []
  @edges = []
  atom_refs = {}

  xml = REXML::Document.new(str)
  xml.elements.each("cml/molecule") do |molecule|
    molecule.elements.each("atomArray/atom") do |atom_element|
      atom = CMLAtom.new(atom_element.attributes["elementType"],
                         atom_element.attributes["id"])
      @nodes << atom
      atom_refs[atom.node_id] = atom
    end
    molecule.elements.each("bondArray/bond") do |bond_element|
      from, to = (bond_element.attributes["atomRefs2"]).split(" ")
      valence  = bond_element.attributes["order"].to_i
      @edges << [CMLBond.new(valence), atom_refs[from], atom_refs[to]]
    end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chem::Molecule