Class: Bio::PDB::Model
- Includes:
- AtomFinder, ChainFinder, HetatmFinder, HeterogenFinder, ResidueFinder, Utils, Comparable, Enumerable
- Defined in:
- lib/bio/db/pdb/model.rb
Overview
Bio::PDB::Model is a class to store a model.
The object would contain some chains (Bio::PDB::Chain objects).
Constant Summary
Constants included from Utils
Instance Attribute Summary collapse
-
#chains ⇒ Object
readonly
chains in this model.
-
#serial ⇒ Object
(also: #model_serial)
serial number of this model.
-
#solvents ⇒ Object
readonly
(OBSOLETE) solvents (water, HOH) in this model.
-
#structure ⇒ Object
readonly
(reserved for future extension).
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Operator aimed to sort models based on serial number.
-
#[](key) ⇒ Object
Keyed access to chains.
-
#addChain(chain) ⇒ Object
Adds a chain to this model.
-
#addSolvent(solvent) ⇒ Object
(OBSOLETE) Adds a solvent molecule to this model.
-
#each(&x) ⇒ Object
(also: #each_chain)
Iterates over each chain.
-
#initialize(serial = nil, structure = nil) ⇒ Model
constructor
Creates a new Model object.
-
#inspect ⇒ Object
returns a string containing human-readable representation of this object.
-
#rehash ⇒ Object
rehash chains hash.
-
#removeSolvent ⇒ Object
(OBSOLETE) not recommended to use this method.
-
#to_s ⇒ Object
stringifies to chains.
Methods included from HeterogenFinder
#each_heterogen, #find_heterogen, #heterogens
Methods included from HetatmFinder
#each_hetatm, #find_hetatm, #hetatms
Methods included from ChainFinder
Methods included from ResidueFinder
#each_residue, #find_residue, #residues
Methods included from AtomFinder
#atoms, #each_atom, #find_atom
Methods included from Utils
acos, calculatePlane, #centreOfGravity, convert_to_xyz, dihedral_angle, distance, #finder, #geometricCentre, rad2deg, to_xyz
Constructor Details
Instance Attribute Details
#chains ⇒ Object (readonly)
chains in this model
49 50 51 |
# File 'lib/bio/db/pdb/model.rb', line 49 def chains @chains end |
#serial ⇒ Object Also known as: model_serial
serial number of this model. (Integer or nil)
55 56 57 |
# File 'lib/bio/db/pdb/model.rb', line 55 def serial @serial end |
#solvents ⇒ Object (readonly)
(OBSOLETE) solvents (water, HOH) in this model
52 53 54 |
# File 'lib/bio/db/pdb/model.rb', line 52 def solvents @solvents end |
#structure ⇒ Object (readonly)
(reserved for future extension)
61 62 63 |
# File 'lib/bio/db/pdb/model.rb', line 61 def structure @structure end |
Instance Method Details
#<=>(other) ⇒ Object
Operator aimed to sort models based on serial number
112 113 114 |
# File 'lib/bio/db/pdb/model.rb', line 112 def <=>(other) return @serial <=> other.model_serial end |
#[](key) ⇒ Object
Keyed access to chains
117 118 119 120 |
# File 'lib/bio/db/pdb/model.rb', line 117 def [](key) #chain = @chains.find{ |chain| key == chain.id } @chains_hash[key] end |
#addChain(chain) ⇒ Object
Adds a chain to this model
64 65 66 67 68 69 70 71 72 73 |
# 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) ⇒ Object
(OBSOLETE) Adds a solvent molecule to this model
94 95 96 97 |
# 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(&x) ⇒ Object Also known as: each_chain
Iterates over each chain
105 106 107 |
# File 'lib/bio/db/pdb/model.rb', line 105 def each(&x) #:yields: chain @chains.each(&x) end |
#inspect ⇒ Object
returns a string containing human-readable representation of this object.
140 141 142 |
# File 'lib/bio/db/pdb/model.rb', line 140 def inspect "#<#{self.class.to_s} serial=#{serial.inspect} chains.size=#{chains.size}>" end |
#rehash ⇒ Object
rehash chains hash
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# 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 ⇒ Object
(OBSOLETE) not recommended to use this method
100 101 102 |
# File 'lib/bio/db/pdb/model.rb', line 100 def removeSolvent @solvents = nil end |
#to_s ⇒ Object
stringifies to chains
123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# 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 |