Class: Chem::PdbDic
- Inherits:
-
Object
- Object
- Chem::PdbDic
- Defined in:
- lib/chem/db/pdb_dic.rb
Defined Under Namespace
Classes: PdbDicAtom, PdbDicBond, PdbDicMolecule
Instance Attribute Summary collapse
-
#mols ⇒ Object
readonly
Returns the value of attribute mols.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file, &block) ⇒ PdbDic
constructor
A new instance of PdbDic.
- #parse(file, &block) ⇒ Object
Constructor Details
#initialize(file, &block) ⇒ PdbDic
Returns a new instance of PdbDic.
59 60 61 62 |
# File 'lib/chem/db/pdb_dic.rb', line 59 def initialize file, &block @mols = {} parse(file, &block) end |
Instance Attribute Details
#mols ⇒ Object (readonly)
Returns the value of attribute mols.
58 59 60 |
# File 'lib/chem/db/pdb_dic.rb', line 58 def mols @mols end |
Class Method Details
Instance Method Details
#parse(file, &block) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/chem/db/pdb_dic.rb', line 64 def parse file, &block i = 0 @input = File.open(file, 'r') res = nil while !@input.eof? line = @input.readline case line when /^RESIDUE/ mol = PdbDicMolecule.new res = line.split[1] @mols[res] = mol # if line.split[1] == 'ACY' # puts 'Found ACY' # exit # end # puts "'%s'" % line[0..5] when /^CONECT/ atom = mol.atoms[line[11..15].strip] ||= PdbDicAtom.new(line[11..15].strip) line[20..-1].chop.split.each do |atom_id| if ! mol.atoms[atom_id] atom2 = PdbDicAtom.new(atom_id) mol.atoms[atom_id] = atom2 bond = PdbDicBond.new bond.b = atom bond.e = atom2 bond.v = 1 mol.bonds.push(bond) end end when "\n" mol.bonds.each do |bond| bond.b.neighbor.push(bond.e) if ! bond.b.neighbor.include?(bond.e) bond.e.neighbor.push(bond.b) if ! bond.e.neighbor.include?(bond.b) end # i += 1 if block yield res, mol end return if i >= 100 else # puts line end end end |