Class | Bio::PDB::Chain
In: | lib/bio/db/pdb/chain.rb
Parent: | Object

Bio::PDB::Chain is a class to store a chain.

The object would contain some residues (Bio::PDB::Residue objects) and some heterogens (Bio::PDB::Heterogen objects).

### Methods

<=> [] aaseq addLigand addResidue atom_seq each each_heterogen each_residue get_heterogen_by_id get_residue_by_id inspect new rehash rehash_heterogens rehash_residues to_s

### Included Modules

Utils AtomFinder ResidueFinder HetatmFinder HeterogenFinder Enumerable Comparable

### External Aliases

chain_id | -> | id
| alias

### Attributes

chain_id | [RW] | Identifier of this chain
heterogens | [R] | heterogens in this chain
model | [R] | the model to which this chain belongs.
residues | [R] | residues in this chain

### Public Class methods

new(id = nil, model = nil)

Creates a new chain object.

[Source]

        # File lib/bio/db/pdb/chain.rb, line 39
    39:       def initialize(id = nil, model = nil)
    40:
    41:         @chain_id  = id
    42:
    43:         @model    = model
    44:
    45:         @residues   = []
    46:         @residues_hash = {}
    47:         @heterogens = []
    48:         @heterogens_hash = {}
    49:       end

### Public Instance methods

<=>(other)

Operator aimed to sort based on chain id

[Source]

         # File lib/bio/db/pdb/chain.rb, line 165
    165:       def <=>(other)
    166:         return @chain_id <=> other.chain_id
    167:       end

[](key)

get the residue by id.

Compatibility Note: Now, you cannot find HETATMS in this method. To add "LIGAND" to the id is no longer available. To get heterogens, you must use `get_heterogen_by_id`.

[Source]

        # File lib/bio/db/pdb/chain.rb, line 76
    76:       def [](key)
    77:         get_residue_by_id(key)
    78:       end

aaseq()

gets an amino acid sequence of this chain from ATOM records

[Source]

         # File lib/bio/db/pdb/chain.rb, line 181
    181:       def aaseq
    182:         unless defined? @aaseq
    183:           string = ""
    184:           last_residue_num = nil
    185:           @residues.each do |residue|
    186:             if last_residue_num and
    187:                 (x = (residue.resSeq.to_i - last_residue_num).abs) > 1 then
    188:               x.times { string << 'X' }
    189:             end
    190:             tlc = residue.resName.capitalize
    191:             olc = (begin
    192:                      Bio::AminoAcid.three2one(tlc)
    193:                    rescue ArgumentError
    194:                      nil
    195:                    end || 'X')
    196:             string << olc
    197:           end
    198:           @aaseq = Bio::Sequence::AA.new(string)
    199:         end
    200:         @aaseq
    201:       end

addLigand(ligand)

Add a heterogen (ligand) to this chain

[Source]

         # File lib/bio/db/pdb/chain.rb, line 99
     99:       def addLigand(ligand)
    100:         raise "Expecting a Bio::PDB::Residue" unless ligand.is_a? Bio::PDB::Residue
    101:         @heterogens.push(ligand)
    102:         if @heterogens_hash[ligand.residue_id] then
    103:           $stderr.puts "Warning: heterogen_id (residue_id) #{ligand.residue_id.inspect} is already used" if $VERBOSE
    104:         else
    105:           @heterogens_hash[ligand.residue_id] = ligand
    106:         end
    107:         self
    108:       end

addResidue(residue)

Add a residue to this chain

[Source]

        # File lib/bio/db/pdb/chain.rb, line 87
    87:       def addResidue(residue)
    88:         raise "Expecting a Bio::PDB::Residue" unless residue.is_a? Bio::PDB::Residue
    89:         @residues.push(residue)
    90:         if @residues_hash[residue.residue_id] then
    91:           $stderr.puts "Warning: residue_id #{residue.residue_id.inspect} is already used" if $VERBOSE
    92:         else
    93:           @residues_hash[residue.residue_id] = residue
    94:         end
    95:         self
    96:       end

atom_seq()

Alias for aaseq

each() {|residue| ...}

Iterates over each residue

[Source]

         # File lib/bio/db/pdb/chain.rb, line 153
    153:       def each(&x) #:yields: residue
    154:         @residues.each(&x)
    155:       end

each_heterogen() {|heterogen| ...}

Iterates over each hetero-compound

[Source]

         # File lib/bio/db/pdb/chain.rb, line 160
    160:       def each_heterogen(&x) #:yields: heterogen
    161:         @heterogens.each(&x)
    162:       end

each_residue()

Alias for each

get_heterogen_by_id(key)

get the heterogen (ligand) by id

[Source]

        # File lib/bio/db/pdb/chain.rb, line 81
    81:       def get_heterogen_by_id(key)
    82:         #@heterogens.find { |r| r.residue_id == key }
    83:         @heterogens_hash[key]
    84:       end

get_residue_by_id(key)

get the residue by id

[Source]

        # File lib/bio/db/pdb/chain.rb, line 66
    66:       def get_residue_by_id(key)
    67:         #@residues.find { |r| r.residue_id == key }
    68:         @residues_hash[key]
    69:       end

inspect()

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

[Source]

         # File lib/bio/db/pdb/chain.rb, line 176
    176:       def inspect
    177:         "#<#{self.class.to_s} id=#{chain_id.inspect} model.serial=#{(model ? model.serial : nil).inspect} residues.size=#{residues.size} heterogens.size=#{heterogens.size} aaseq=#{aaseq.inspect}>"
    178:       end

rehash()

rehash residues hash and heterogens hash

[Source]

         # File lib/bio/db/pdb/chain.rb, line 147
    147:       def rehash
    148:         rehash_residues
    149:         rehash_heterogens
    150:       end

rehash_heterogens()

rehash heterogens hash

[Source]

         # File lib/bio/db/pdb/chain.rb, line 129
    129:       def rehash_heterogens
    130:         begin
    131:           heterogens_bak = @heterogens
    132:           heterogens_hash_bak = @heterogens_hash
    133:           @heterogens = []
    134:           @heterogens_hash = {}
    135:           heterogens_bak.each do |heterogen|
    136:             self.addLigand(heterogen)
    137:           end
    138:         rescue RuntimeError
    139:           @heterogens = heterogens_bak
    140:           @heterogens_hash = heterogens_hash_bak
    141:           raise
    142:         end
    143:         self
    144:       end

rehash_residues()

rehash residues hash

[Source]

         # File lib/bio/db/pdb/chain.rb, line 111
    111:       def rehash_residues
    112:         begin
    113:           residues_bak = @residues
    114:           residues_hash_bak = @residues_hash
    115:           @residues = []
    116:           @residues_hash = {}
    117:           residues_bak.each do |residue|
    118:             self.addResidue(residue)
    119:           end
    120:         rescue RuntimeError
    121:           @residues = residues_bak
    122:           @residues_hash = residues_hash_bak
    123:           raise
    124:         end
    125:         self
    126:       end

to_s()

Stringifies each residue

[Source]

         # File lib/bio/db/pdb/chain.rb, line 170
    170:       def to_s
    171:         @residues.join('') + "TER\n" + @heterogens.join('')
    172:       end

[Validate]