Class: Bio::PDB::Residue

Inherits:
Object show all
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

Heterogen

Constant Summary

Constant Summary

Constants included from Utils

Utils::ElementMass

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AtomFinder

#find_atom

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

#atomsObject (readonly)

atoms in this residue. (Array)



53
54
55
# File 'lib/bio/db/pdb/residue.rb', line 53

def atoms
  @atoms
end

#chainObject

the chain to which this residue belongs



56
57
58
# File 'lib/bio/db/pdb/residue.rb', line 56

def chain
  @chain
end

#iCodeObject

iCode



95
96
97
# File 'lib/bio/db/pdb/residue.rb', line 95

def iCode
  @iCode
end

#residue_idObject (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

#resNameObject

resName (residue name)



59
60
61
# File 'lib/bio/db/pdb/residue.rb', line 59

def resName
  @resName
end

#resSeqObject

resSeq



85
86
87
# File 'lib/bio/db/pdb/residue.rb', line 85

def resSeq
  @resSeq
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

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

#hetatmObject

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

#inspectObject

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_sObject

Stringifies each atom



128
129
130
# File 'lib/bio/db/pdb/residue.rb', line 128

def to_s
  @atoms.join('')
end