Class: Bio::PDB::ChemicalComponent

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/db/pdb/chemicalcomponent.rb

Overview

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

Defined Under Namespace

Classes: Record

Constant Summary collapse

DELIMITER =

delimiter for reading via Bio::FlatFile

RS = "\n\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ ChemicalComponent

Creates a new object.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/bio/db/pdb/chemicalcomponent.rb', line 123

def initialize(str)
  @data = str.split(/[\r\n]+/)
  @hash = {}

  #Flag to say whether the current line is part of a continuation
  cont = false
  
  #Goes through each line and replace that line with a PDB::Record
  @data.collect! do |line|
    #Go to next if the previous line was contiunation able, and
    #add_continuation returns true. Line is added by add_continuation
    next if cont and cont = cont.add_continuation(line)

    #Make the new record
    f = Record.get_record_class(line).new.initialize_from_string(line)
    #p f
    #Set cont
    cont = f if f.continue?
    #Set the hash to point to this record either by adding to an
    #array, or on it's own
    key = f.record_name
    if a = @hash[key] then
      a << f
    else
      @hash[key] = [ f ]
    end
    f
  end #each
  #At the end we need to add the final model
  @data.compact!
end

Instance Attribute Details

#dataObject (readonly)

all records in this entry as an array.



156
157
158
# File 'lib/bio/db/pdb/chemicalcomponent.rb', line 156

def data
  @data
end

#hashObject (readonly)

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



159
160
161
# File 'lib/bio/db/pdb/chemicalcomponent.rb', line 159

def hash
  @hash
end

Instance Method Details

#conectObject

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



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/bio/db/pdb/chemicalcomponent.rb', line 192

def conect
  unless defined? @conect
    c = {}
    @hash["CONECT"].each do |e|
      key = e.name.to_s.strip
      unless key.empty?
        val = e.other_atoms.collect { |x| x.strip }
        #warn "Warning: #{key}: atom name conflict?" if c[key]
        c[key] = val
      end
    end
    @conect = c
  end
  @conect
end

#entry_idObject

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



162
163
164
# File 'lib/bio/db/pdb/chemicalcomponent.rb', line 162

def entry_id
  @data[0].hetID
end

#formulObject

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



186
187
188
# File 'lib/bio/db/pdb/chemicalcomponent.rb', line 186

def formul
  @hash["FORMUL"][0].text
end

#hetnamObject

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



180
181
182
# File 'lib/bio/db/pdb/chemicalcomponent.rb', line 180

def hetnam
  @hash["HETNAM"][0].text
end

#hetsynObject

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



167
168
169
170
171
172
173
174
175
176
# File 'lib/bio/db/pdb/chemicalcomponent.rb', line 167

def hetsyn
  unless defined? @hetsyn
    if r = @hash["HETSYN"]
      @hetsyn = r[0].hetSynonyms.to_s.split(/\;\s*/)
    else
      return []
    end
  end
  @hetsyn
end

#record(name = nil) ⇒ Object

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



217
218
219
# File 'lib/bio/db/pdb/chemicalcomponent.rb', line 217

def record(name = nil)
  name ? @hash[name] : @hash
end