Class Bio::PDB::Model
In: lib/bio/db/pdb/model.rb
Parent: Object

Bio::PDB::Model is a class to store a model.

The object would contain some chains (Bio::PDB::Chain objects).

Methods

<=>   []   addChain   addSolvent   each   each_chain   inspect   new   rehash   removeSolvent   to_s  

Included Modules

Utils AtomFinder ResidueFinder ChainFinder HetatmFinder HeterogenFinder Enumerable Comparable

External Aliases

serial -> model_serial
  for backward compatibility

Attributes

chains  [R]  chains in this model
serial  [RW]  serial number of this model. (Integer or nil)
solvents  [R]  (OBSOLETE) solvents (water, HOH) in this model
structure  [R]  (reserved for future extension)

Public Class methods

Creates a new Model object

[Source]

    # File lib/bio/db/pdb/model.rb, line 39
39:       def initialize(serial = nil, structure = nil)
40:         
41:         @serial = serial
42:         @structure = structure
43:         @chains = []
44:         @chains_hash = {}
45:         @solvents = Chain.new('', self)
46:       end

Public Instance methods

Operator aimed to sort models based on serial number

[Source]

     # File lib/bio/db/pdb/model.rb, line 112
112:       def <=>(other)
113:         return @serial <=> other.model_serial
114:       end

Keyed access to chains

[Source]

     # File lib/bio/db/pdb/model.rb, line 117
117:       def [](key)
118:         #chain = @chains.find{ |chain| key == chain.id }
119:         @chains_hash[key]
120:       end

Adds a chain to this model

[Source]

    # File lib/bio/db/pdb/model.rb, line 64
64:       def addChain(chain)
65:         raise "Expecting a Bio::PDB::Chain" unless chain.is_a? Bio::PDB::Chain
66:         @chains.push(chain)
67:         if @chains_hash[chain.chain_id] then
68:           $stderr.puts "Warning: chain_id #{chain.chain_id.inspect} is already used" if $VERBOSE
69:         else
70:           @chains_hash[chain.chain_id] = chain
71:         end
72:         self
73:       end

(OBSOLETE) Adds a solvent molecule to this model

[Source]

    # File lib/bio/db/pdb/model.rb, line 94
94:       def addSolvent(solvent)
95:         raise "Expecting a Bio::PDB::Residue" unless solvent.is_a? Bio::PDB::Residue
96:         @solvents.addResidue(solvent)
97:       end

Iterates over each chain

[Source]

     # File lib/bio/db/pdb/model.rb, line 105
105:       def each(&x) #:yields: chain
106:         @chains.each(&x)
107:       end
each_chain()

Alias for each

returns a string containing human-readable representation of this object.

[Source]

     # File lib/bio/db/pdb/model.rb, line 140
140:       def inspect
141:         "#<#{self.class.to_s} serial=#{serial.inspect} chains.size=#{chains.size}>"
142:       end

rehash chains hash

[Source]

    # File lib/bio/db/pdb/model.rb, line 76
76:       def rehash
77:         begin
78:           chains_bak = @chains
79:           chains_hash_bak = @chains_hash
80:           @chains = []
81:           @chains_hash = {}
82:           chains_bak.each do |chain|
83:             self.addChain(chain)
84:           end
85:         rescue RuntimeError
86:           @chains = chains_bak
87:           @chains_hash = chains_hash_bak
88:           raise
89:         end
90:         self
91:       end

(OBSOLETE) not recommended to use this method

[Source]

     # File lib/bio/db/pdb/model.rb, line 100
100:       def removeSolvent
101:         @solvents = nil
102:       end

stringifies to chains

[Source]

     # File lib/bio/db/pdb/model.rb, line 123
123:       def to_s
124:         string = ""
125:         if model_serial
126:           string = "MODEL     #{model_serial}\n" #Should use proper formatting
127:         end
128:         @chains.each{ |chain| string << chain.to_s }
129:         #if solvent
130:         #  string << @solvent.to_s
131:         #end
132:         if model_serial
133:           string << "ENDMDL\n"
134:         end
135:         return string
136:       end

[Validate]