Class: Chem::XYZ::XyzMolecule

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

Constant Summary

Constants included from Molecule

Molecule::EpsHeader, Molecule::MDLCountLineFormat

Instance Attribute Summary

Attributes included from Molecule

#name, #source

Attributes included from Graph

#adjacencies, #edges, #nodes

Instance Method Summary collapse

Methods included from Molecule

#-, #assign_2d_geometry, #breadth_first_search, #canonical_ring, #composition, #connected?, #deep_dup, #delete, #delete_bond, #depth_first_search, #divide, #find_smallest_ring, #find_sssr, #induced_sub, #molecular_weight, #n_hydrogen, #oxidation_number, #save, #save_as_mdl, #save_as_pdf, #search_pubchem, #subset_in_composition?, #to_cansmi, #to_eps, #to_sybyl, #trim

Methods included from Graph

#adj_matrix, #adjacency_list, #adjacent_to, #clustering_coefficient, #connection, #each, #match_by_adj_mat, #match_by_ullmann, #match_exhaustively, #matchable, #matchable_old, #morgan

Constructor Details

#initializeXyzMolecule

Returns a new instance of XyzMolecule.



16
17
18
19
# File 'lib/chem/db/xyz.rb', line 16

def initialize
  super
  @nodes = []
end

Instance Method Details

#open_xyz(filename) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/chem/db/xyz.rb', line 21

def open_xyz filename
  xyz = open(filename, "r")
  n_atoms = xyz.readline.to_i
  title = xyz.readline
  n_atoms.times do |n|
    array = xyz.readline.split
    a = XyzAtom.new
    a.element, a.x, a.y, a.z = array[0].intern, array[1].to_f, array[2].to_f, array[3].to_f
    @nodes.push(a)
  end
  self
end