class Bio::PDB::Record::ATOM
ATOM record class
Attributes
anisou[RW]
ANISOU record
residue[RW]
residue the atom belongs to.
sigatm[RW]
SIGATM record
ter[RW]
TER record
Public Instance Methods
<=>(other)
click to toggle source
Sorts based on serial numbers
# File lib/bio/db/pdb/pdb.rb, line 974 def <=>(other) return serial <=> other.serial end
do_parse()
click to toggle source
# File lib/bio/db/pdb/pdb.rb, line 978 def do_parse return self if @parsed or !@str self.serial = @str[6..10].to_i self.name = @str[12..15].strip self.altLoc = @str[16..16] self.resName = @str[17..19].strip self.chainID = @str[21..21] self.resSeq = @str[22..25].to_i self.iCode = @str[26..26].strip self.x = @str[30..37].to_f self.y = @str[38..45].to_f self.z = @str[46..53].to_f self.occupancy = @str[54..59].to_f self.tempFactor = @str[60..65].to_f self.segID = @str[72..75].to_s.rstrip self.element = @str[76..77].to_s.lstrip self.charge = @str[78..79].to_s.strip @parsed = true self end
to_a()
click to toggle source
Returns an array of the xyz positions
# File lib/bio/db/pdb/pdb.rb, line 969 def to_a [ x, y, z ] end
to_s()
click to toggle source
# File lib/bio/db/pdb/pdb.rb, line 1046 def to_s atomname = justify_atomname sprintf("%-6s%5d %-4s%-1s%3s %-1s%4d%-1s %8.3f%8.3f%8.3f%6.2f%6.2f %-4s%2s%-2s\n", self.record_name, self.serial, atomname, self.altLoc, self.resName, self.chainID, self.resSeq, self.iCode, self.x, self.y, self.z, self.occupancy, self.tempFactor, self.segID, self.element, self.charge) end
xyz()
click to toggle source
Returns a Coordinate class instance of the xyz positions
# File lib/bio/db/pdb/pdb.rb, line 964 def xyz Coordinate[ x, y, z ] end
Private Instance Methods
justify_atomname()
click to toggle source
# File lib/bio/db/pdb/pdb.rb, line 999 def justify_atomname atomname = self.name.to_s return atomname[0, 4] if atomname.length >= 4 case atomname.length when 0 return ' ' when 1 return ' ' + atomname + ' ' when 2 if /\A[0-9]/ =~ atomname then return sprintf('%-4s', atomname) elsif /[0-9]\z/ =~ atomname then return sprintf(' %-3s', atomname) end when 3 if /\A[0-9]/ =~ atomname then return sprintf('%-4s', atomname) end end # ambiguous case for two- or three-letter name elem = self.element.to_s.strip if elem.size > 0 and i = atomname.index(elem) then if i == 0 and elem.size == 1 then return sprintf(' %-3s', atomname) else return sprintf('%-4s', atomname) end end if self.kind_of?(HETATM) then if /\A(B[^AEHIKR]|C[^ADEFLMORSU]|F[^EMR]|H[^EFGOS]|I[^NR]|K[^R]|N[^ABDEIOP]|O[^S]|P[^ABDMORTU]|S[^BCEGIMNR]|V|W|Y[^B])/ =~ atomname then return sprintf(' %-3s', atomname) else return sprintf('%-4s', atomname) end else # ATOM if /\A[CHONSP]/ =~ atomname then return sprintf(' %-3s', atomname) else return sprintf('%-4s', atomname) end end # could not be reached here raise 'bug!' end