Class: Bio::PDB::Residue
- Includes:
- AtomFinder, Utils, Comparable, Enumerable
- Defined in:
- lib/bio/db/pdb/residue.rb
Overview
Bio::PDB::Residue is a class to store a residue. The object would contain some atoms (Bio::PDB::Record::ATOM objects).
Direct Known Subclasses
Constant Summary
Constants included from Utils
Instance Attribute Summary collapse
-
#atoms ⇒ Object
readonly
atoms in this residue.
-
#chain ⇒ Object
the chain to which this residue belongs.
-
#iCode ⇒ Object
iCode.
-
#residue_id ⇒ Object
(also: #id)
readonly
residue id (String or nil).
-
#resName ⇒ Object
resName (residue name).
-
#resSeq ⇒ Object
resSeq.
Class Method Summary collapse
-
.get_residue_id_from_atom(atom) ⇒ Object
Creates residue id from an ATOM (or HETATM) object.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Sorts based on resSeq and iCode if need be.
-
#[](key) ⇒ Object
Keyed access to atoms based on atom name e.g.
-
#addAtom(atom) ⇒ Object
Adds an atom to this residue.
-
#each ⇒ Object
(also: #each_atom)
Iterator over the atoms.
-
#hetatm ⇒ Object
Always returns false.
-
#initialize(resName = nil, resSeq = nil, iCode = nil, chain = nil) ⇒ Residue
constructor
Creates a new Residue object.
-
#inspect ⇒ Object
returns a string containing human-readable representation of this object.
-
#to_s ⇒ Object
Stringifies each atom.
Methods included from AtomFinder
Methods included from Utils
acos, calculatePlane, #centreOfGravity, convert_to_xyz, dihedral_angle, distance, #finder, #geometricCentre, rad2deg, to_xyz
Constructor Details
#initialize(resName = nil, resSeq = nil, iCode = nil, chain = nil) ⇒ Residue
Creates a new Residue object.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bio/db/pdb/residue.rb', line 39 def initialize(resName = nil, resSeq = nil, iCode = nil, chain = nil) @resName = resName @resSeq = resSeq @iCode = iCode @chain = chain @atoms = [] update_residue_id end |
Instance Attribute Details
#atoms ⇒ Object (readonly)
atoms in this residue. (Array)
53 54 55 |
# File 'lib/bio/db/pdb/residue.rb', line 53 def atoms @atoms end |
#chain ⇒ Object
the chain to which this residue belongs
56 57 58 |
# File 'lib/bio/db/pdb/residue.rb', line 56 def chain @chain end |
#residue_id ⇒ Object (readonly) Also known as: id
residue id (String or nil). The id is a composite of resSeq and iCode.
63 64 65 |
# File 'lib/bio/db/pdb/residue.rb', line 63 def residue_id @residue_id end |
#resName ⇒ Object
resName (residue name)
59 60 61 |
# File 'lib/bio/db/pdb/residue.rb', line 59 def resName @resName end |
Class Method Details
.get_residue_id_from_atom(atom) ⇒ Object
Creates residue id from an ATOM (or HETATM) object.
34 35 36 |
# File 'lib/bio/db/pdb/residue.rb', line 34 def self.get_residue_id_from_atom(atom) "#{atom.resSeq}#{atom.iCode.strip}".strip end |
Instance Method Details
#<=>(other) ⇒ Object
Sorts based on resSeq and iCode if need be
119 120 121 122 123 124 125 |
# File 'lib/bio/db/pdb/residue.rb', line 119 def <=>(other) if @resSeq != other.resSeq return @resSeq <=> other.resSeq else return @iCode <=> other.iCode end end |
#[](key) ⇒ Object
Keyed access to atoms based on atom name e.g. [“CA”]
69 70 71 |
# File 'lib/bio/db/pdb/residue.rb', line 69 def [](key) @atoms.find{ |atom| key == atom.name } end |
#addAtom(atom) ⇒ Object
Adds an atom to this residue
105 106 107 108 109 |
# File 'lib/bio/db/pdb/residue.rb', line 105 def addAtom(atom) raise "Expecting ATOM or HETATM" unless atom.is_a? Bio::PDB::Record::ATOM @atoms.push(atom) self end |
#each ⇒ Object Also known as: each_atom
Iterator over the atoms
112 113 114 |
# File 'lib/bio/db/pdb/residue.rb', line 112 def each @atoms.each{ |atom| yield atom } end |
#hetatm ⇒ Object
Always returns false.
If the residue is HETATM, returns true. Otherwise, returns false.
142 143 144 |
# File 'lib/bio/db/pdb/residue.rb', line 142 def hetatm false end |
#inspect ⇒ Object
returns a string containing human-readable representation of this object.
134 135 136 |
# File 'lib/bio/db/pdb/residue.rb', line 134 def inspect "#<#{self.class.to_s} resName=#{resName.inspect} id=#{residue_id.inspect} chain.id=#{(chain ? chain.id : nil).inspect} resSeq=#{resSeq.inspect} iCode=#{iCode.inspect} atoms.size=#{atoms.size}>" end |
#to_s ⇒ Object
Stringifies each atom
128 129 130 |
# File 'lib/bio/db/pdb/residue.rb', line 128 def to_s @atoms.join('') end |