class Bio::PDB::Model

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

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

Attributes

chains[R]

chains in this model

model_serial[RW]

serial number of this model. (Integer or nil)

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

new(serial = nil, structure = nil) click to toggle source

Creates a new Model object

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

Public Instance Methods

<=>(other) click to toggle source

Operator aimed to sort models based on serial number

# File lib/bio/db/pdb/model.rb, line 112
def <=>(other)
  return @serial <=> other.model_serial
end
[](key) click to toggle source

Keyed access to chains

# File lib/bio/db/pdb/model.rb, line 117
def [](key)
  #chain = @chains.find{ |chain| key == chain.id }
  @chains_hash[key]
end
addChain(chain) click to toggle source

Adds a chain to this model

# File lib/bio/db/pdb/model.rb, line 64
def addChain(chain)
  raise "Expecting a Bio::PDB::Chain" unless chain.is_a? Bio::PDB::Chain
  @chains.push(chain)
  if @chains_hash[chain.chain_id] then
    $stderr.puts "Warning: chain_id #{chain.chain_id.inspect} is already used" if $VERBOSE
  else
    @chains_hash[chain.chain_id] = chain
  end
  self
end
addSolvent(solvent) click to toggle source

(OBSOLETE) Adds a solvent molecule to this model

# File lib/bio/db/pdb/model.rb, line 94
def addSolvent(solvent)
  raise "Expecting a Bio::PDB::Residue" unless solvent.is_a? Bio::PDB::Residue
  @solvents.addResidue(solvent)
end
each() { |chain| ... } click to toggle source

Iterates over each chain

# File lib/bio/db/pdb/model.rb, line 105
def each(&x) #:yields: chain
  @chains.each(&x)
end
Also aliased as: each_chain
each_chain()
Alias for: each
inspect() click to toggle source

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

# File lib/bio/db/pdb/model.rb, line 140
def inspect
  "#<#{self.class.to_s} serial=#{serial.inspect} chains.size=#{chains.size}>"
end
rehash() click to toggle source

rehash chains hash

# File lib/bio/db/pdb/model.rb, line 76
def rehash
  begin
    chains_bak = @chains
    chains_hash_bak = @chains_hash
    @chains = []
    @chains_hash = {}
    chains_bak.each do |chain|
      self.addChain(chain)
    end
  rescue RuntimeError
    @chains = chains_bak
    @chains_hash = chains_hash_bak
    raise
  end
  self
end
removeSolvent() click to toggle source

(OBSOLETE) not recommended to use this method

# File lib/bio/db/pdb/model.rb, line 100
def removeSolvent
  @solvents = nil
end
to_s() click to toggle source

stringifies to chains

# File lib/bio/db/pdb/model.rb, line 123
def to_s
  string = ""
  if model_serial
    string = "MODEL     #{model_serial}\n" #Should use proper formatting
  end
  @chains.each{ |chain| string << chain.to_s }
  #if solvent
  #  string << @solvent.to_s
  #end
  if model_serial
    string << "ENDMDL\n"
  end
  return string
end