class Bio::PDB::Residue

Bio::PDB::Residue is a class to store a residue. The object would contain some atoms (Bio::PDB::Record::ATOM objects).

Attributes

atoms[R]

atoms in this residue. (Array)

chain[RW]

the chain to which this residue belongs

iCode[R]

iCode

id[R]

residue id (String or nil). The id is a composite of resSeq and iCode.

resName[RW]

resName (residue name)

resSeq[R]

resSeq

residue_id[R]

residue id (String or nil). The id is a composite of resSeq and iCode.

Public Class Methods

get_residue_id_from_atom(atom) click to toggle source

Creates residue id from an ATOM (or HETATM) object.

# File lib/bio/db/pdb/residue.rb, line 34
def self.get_residue_id_from_atom(atom)
  "#{atom.resSeq}#{atom.iCode.strip}".strip
end
new(resName = nil, resSeq = nil, iCode = nil, chain = nil) click to toggle source

Creates a new Residue object.

# 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

Public Instance Methods

<=>(other) click to toggle source

Sorts based on resSeq and iCode if need be

# 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) click to toggle source

Keyed access to atoms based on atom name e.g. [“CA”]

# File lib/bio/db/pdb/residue.rb, line 69
def [](key)
  @atoms.find{ |atom| key == atom.name }
end
addAtom(atom) click to toggle source

Adds an atom to this residue

# 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() { |atom| ... } click to toggle source

Iterator over the atoms

# File lib/bio/db/pdb/residue.rb, line 112
def each
  @atoms.each{ |atom| yield atom }
end
Also aliased as: each_atom
each_atom()

Alias to override Bio::PDB::AtomFinder#each_atom

Alias for: each
hetatm() click to toggle source

Always returns false.

If the residue is HETATM, returns true. Otherwise, returns false.

# File lib/bio/db/pdb/residue.rb, line 142
def hetatm
  false
end
iCode=(iCode) click to toggle source

iCode=()

# File lib/bio/db/pdb/residue.rb, line 98
def iCode=(iCode)
  @iCode = iCode
  update_residue_id
  @iCode
end
inspect() click to toggle source

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

# 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
resSeq=(resSeq) click to toggle source

resSeq=()

# File lib/bio/db/pdb/residue.rb, line 88
def resSeq=(resSeq)
  @resSeq = resSeq.to_i
  update_residue_id
  @resSeq
end
to_s() click to toggle source

Stringifies each atom

# File lib/bio/db/pdb/residue.rb, line 128
def to_s
  @atoms.join('')
end