Class: Chem::KEGG::KCF

Inherits:
Object
  • Object
show all
Includes:
Molecule, Enumerable
Defined in:
lib/chem/db/kcf.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

Class Method Summary collapse

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

#initialize(input) ⇒ KCF

Returns a new instance of KCF.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/chem/db/kcf.rb', line 60

def initialize input
  @nodes = []
  @edges = []
  hash = {}
  while ! /\/\/\//.match(line = input.readline)
    case line[0...12]
    when 'ENTRY       '
    when 'ATOM        '
      line.split[1].to_i.times do |n|
        atom = KCFAtom.new input.readline

        hash[atom.atom_id] = atom
        @nodes.push(atom)
      end
    when 'BOND        '
      line.split[1].to_i.times do |n|
        bond = KCFBond.new input.readline
        @edges.push([bond, hash[line[16...19].to_i], hash[line[19...23].to_i]])
      end
    end
  end
end

Class Method Details

.open(filename) ⇒ Object



83
84
85
86
# File 'lib/chem/db/kcf.rb', line 83

def KCF.open filename
  @input = File.open(filename)
  KCF.new(@input)
end