Class Bio::PDB::Residue
In: lib/bio/db/pdb/residue.rb
Parent: Object

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

Methods

<=>   []   addAtom   each   each_atom   get_residue_id_from_atom   hetatm   iCode=   inspect   new   resSeq=   to_s  

Included Modules

Utils AtomFinder Enumerable Comparable

External Aliases

residue_id -> id
  Now, Residue#id is an alias of residue_id.

Attributes

atoms  [R]  atoms in this residue. (Array)
chain  [RW]  the chain to which this residue belongs
iCode  [R]  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

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

[Source]

    # File lib/bio/db/pdb/residue.rb, line 34
34:       def self.get_residue_id_from_atom(atom)
35:         "#{atom.resSeq}#{atom.iCode.strip}".strip
36:       end

Creates a new Residue object.

[Source]

    # File lib/bio/db/pdb/residue.rb, line 39
39:       def initialize(resName = nil, resSeq = nil, iCode = nil, 
40:                      chain = nil)
41:         
42:         @resName = resName
43:         @resSeq  = resSeq
44:         @iCode   = iCode
45:         
46:         @chain   = chain
47:         @atoms   = []
48: 
49:         update_residue_id
50:       end

Public Instance methods

Sorts based on resSeq and iCode if need be

[Source]

     # File lib/bio/db/pdb/residue.rb, line 119
119:       def <=>(other)
120:         if @resSeq != other.resSeq
121:           return @resSeq <=> other.resSeq
122:         else
123:           return @iCode <=> other.iCode
124:         end
125:       end

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

[Source]

    # File lib/bio/db/pdb/residue.rb, line 69
69:       def [](key)
70:         @atoms.find{ |atom| key == atom.name }
71:       end

Adds an atom to this residue

[Source]

     # File lib/bio/db/pdb/residue.rb, line 105
105:       def addAtom(atom)
106:         raise "Expecting ATOM or HETATM" unless atom.is_a? Bio::PDB::Record::ATOM
107:         @atoms.push(atom)
108:         self
109:       end

Iterator over the atoms

[Source]

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

Alias for each

Always returns false.

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

[Source]

     # File lib/bio/db/pdb/residue.rb, line 142
142:       def hetatm
143:         false
144:       end

iCode=()

[Source]

     # File lib/bio/db/pdb/residue.rb, line 98
 98:       def iCode=(iCode)
 99:         @iCode = iCode
100:         update_residue_id
101:         @iCode
102:       end

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

[Source]

     # File lib/bio/db/pdb/residue.rb, line 134
134:       def inspect
135:         "#<#{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}>"
136:       end

resSeq=()

[Source]

    # File lib/bio/db/pdb/residue.rb, line 88
88:       def resSeq=(resSeq)
89:         @resSeq = resSeq.to_i
90:         update_residue_id
91:         @resSeq
92:       end

Stringifies each atom

[Source]

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

[Validate]