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
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

<=>(other) click to toggle source

Operator aimed to sort models based on serial number

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

Keyed access to chains

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

Adds a chain to this model

   # File lib/bio/db/pdb/model.rb
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
addSolvent(solvent) click to toggle source

(OBSOLETE) Adds a solvent molecule to this model

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

Iterates over each chain

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

Alias to override ChainFinder#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
140 def inspect
141   "#<#{self.class.to_s} serial=#{serial.inspect} chains.size=#{chains.size}>"
142 end
rehash() click to toggle source

rehash chains hash

   # File lib/bio/db/pdb/model.rb
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
removeSolvent() click to toggle source

(OBSOLETE) not recommended to use this method

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

stringifies to chains

    # File lib/bio/db/pdb/model.rb
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