class Bio::PDB::ChemicalComponent

Bio::PDB::ChemicalComponet is a parser for a entry of the PDB Chemical Component Dictionary.

The PDB Chemical Component Dictionary is available in deposit.pdb.org/het_dictionary.txt

Constants

DELIMITER

delimiter for reading via Bio::FlatFile

Attributes

data[R]

all records in this entry as an array.

hash[R]

all records in this entry as an hash accessed by record names.

Public Class Methods

new(str) click to toggle source

Creates a new object.

    # File lib/bio/db/pdb/chemicalcomponent.rb
124 def initialize(str)
125   @data = str.split(/[\r\n]+/)
126   @hash = {}
127 
128   #Flag to say whether the current line is part of a continuation
129   cont = false
130   
131   #Goes through each line and replace that line with a PDB::Record
132   @data.collect! do |line|
133     #Go to next if the previous line was contiunation able, and
134     #add_continuation returns true. Line is added by add_continuation
135     next if cont and cont = cont.add_continuation(line)
136 
137     #Make the new record
138     f = Record.get_record_class(line).new.initialize_from_string(line)
139     #p f
140     #Set cont
141     cont = f if f.continue?
142     #Set the hash to point to this record either by adding to an
143     #array, or on it's own
144     key = f.record_name
145     if a = @hash[key] then
146       a << f
147     else
148       @hash[key] = [ f ]
149     end
150     f
151   end #each
152   #At the end we need to add the final model
153   @data.compact!
154 end

Public Instance Methods

conect() click to toggle source

Returns an hash of bindings of atoms. Note that each white spaces are stripped for atom symbols.

    # File lib/bio/db/pdb/chemicalcomponent.rb
193 def conect
194   unless defined? @conect
195     c = {}
196     @hash["CONECT"].each do |e|
197       key = e.name.to_s.strip
198       unless key.empty?
199         val = e.other_atoms.collect { |x| x.strip }
200         #warn "Warning: #{key}: atom name conflict?" if c[key]
201         c[key] = val
202       end
203     end
204     @conect = c
205   end
206   @conect
207 end
entry_id() click to toggle source

Identifier written in the first line “RESIDUE” record. (e.g. CMP)

    # File lib/bio/db/pdb/chemicalcomponent.rb
163 def entry_id
164   @data[0].hetID
165 end
formul() click to toggle source

The chemical formula of the chemical component. Returns a string (or nil, if the entry is something wrong).

    # File lib/bio/db/pdb/chemicalcomponent.rb
187 def formul
188   @hash["FORMUL"][0].text
189 end
hetnam() click to toggle source

The name of the chemical component. Returns a string (or nil, if the entry is something wrong).

    # File lib/bio/db/pdb/chemicalcomponent.rb
181 def hetnam
182   @hash["HETNAM"][0].text
183 end
hetsyn() click to toggle source

Synonyms for the comical component. Returns an array of strings.

    # File lib/bio/db/pdb/chemicalcomponent.rb
168 def hetsyn
169   unless defined? @hetsyn
170     if r = @hash["HETSYN"]
171       @hetsyn = r[0].hetSynonyms.to_s.split(/\;\s*/)
172     else
173       return []
174     end
175   end
176   @hetsyn
177 end
record(name = nil) click to toggle source

Gets all records whose record type is name. Returns an array of Bio::PDB::Record::* objects.

if name is nil, returns hash storing all record data.

Example: p pdb.record('CONECT') p pdb.record

    # File lib/bio/db/pdb/chemicalcomponent.rb
218 def record(name = nil)
219   name ? @hash[name] : @hash
220 end