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 40
    40:       def initialize(id = nil, model = nil)
    41:
    42:         @chain_id  = id
    43:
    44:         @model    = model
    45:
    46:         @residues   = []
    47:         @residues_hash = {}
    48:         @heterogens = []
    49:         @heterogens_hash = {}
    50:       end

### Public Instance methods

<=>(other)

Operator aimed to sort based on chain id

[Source]

         # File lib/bio/db/pdb/chain.rb, line 166
    166:       def <=>(other)
    167:         return @chain_id <=> other.chain_id
    168:       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 77
    77:       def [](key)
    78:         get_residue_by_id(key)
    79:       end

aaseq()

gets an amino acid sequence of this chain from ATOM records

[Source]

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

addLigand(ligand)

Add a heterogen (ligand) to this chain

[Source]

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

addResidue(residue)

Add a residue to this chain

[Source]

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

atom_seq()

Alias for aaseq

each() {|residue| ...}

Iterates over each residue

[Source]

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

each_heterogen() {|heterogen| ...}

Iterates over each hetero-compound

[Source]

         # File lib/bio/db/pdb/chain.rb, line 161
    161:       def each_heterogen(&x) #:yields: heterogen
    162:         @heterogens.each(&x)
    163:       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 82
    82:       def get_heterogen_by_id(key)
    83:         #@heterogens.find { |r| r.residue_id == key }
    84:         @heterogens_hash[key]
    85:       end

get_residue_by_id(key)

get the residue by id

[Source]

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

inspect()

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

[Source]

         # File lib/bio/db/pdb/chain.rb, line 177
    177:       def inspect
    178:         "#<#{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}>"
    179:       end

rehash()

rehash residues hash and heterogens hash

[Source]

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

rehash_heterogens()

rehash heterogens hash

[Source]

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

rehash_residues()

rehash residues hash

[Source]

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

to_s()

Stringifies each residue

[Source]

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

[Validate]