Class: Chem::CompoundDB

Inherits:
Object
  • Object
show all
Defined in:
lib/chem/utils/ullmann.rb

Overview

Database Specification

  • idx file

32 bit : n_bytes

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ CompoundDB

Returns a new instance of CompoundDB.



145
146
147
148
149
150
# File 'lib/chem/utils/ullmann.rb', line 145

def initialize(name)
  @current_id = 0
  @mat = File.open(name + ".mat", "w")
  @idx = File.open(name + ".idx", "w")
  @typ = File.open(name + ".typ", "w")
end

Instance Method Details

#closeObject



166
167
168
169
170
171
172
# File 'lib/chem/utils/ullmann.rb', line 166

def close
  @idx.print [-1, -1, -1].pack("l*")

  @mat.close
  @idx.close
  @typ.close
end

#store(mol) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/chem/utils/ullmann.rb', line 152

def store(mol)
  bm = mol.bit_mat
  @current_id += 1

  if bm.has_matrix
    @idx.print [bm.height, bm.n_bytes, @mat.tell, 0].pack("l*")
    @mat.print bm.bit_str
  else
    @idx.print [bm.height, bm.n_bytes, @mat.tell, -1].pack("l*")
  end
  @typ.print mol.typ_str
  @current_id
end