Skip to content

Commit

Permalink
Added Bio::PDB::Record::ATOM#to_s and modified Bio::PDB::*.to_s.
Browse files Browse the repository at this point in the history
Note that Bio::PDB#to_s and Bio::PDB::{Model,Chain,Residue,Heterogen}#to_s is still imcomplete.
Note that Bio::PDB::Record::ATOM#to_s (and Bio::PDB::Record::HETATM#to_s)
may return invalid data when giving inordinary data.
  • Loading branch information
ngoto committed Jan 20, 2006
1 parent cb6c0e6 commit f1625af
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/bio/db/pdb/chain.rb
Expand Up @@ -6,7 +6,7 @@
# Naohisa Goto <ng@bioruby.org>
# License:: LGPL
#
# $Id: chain.rb,v 1.5 2006/01/09 11:22:36 ngoto Exp $
# $Id: chain.rb,v 1.6 2006/01/20 13:54:08 ngoto Exp $
#
#--
# This library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -185,7 +185,7 @@ def <=>(other)

# Stringifies each residue
def to_s
@residues.join('') + "TER\n"
@residues.join('') + "TER\n" + @heterogens.join('')
end

# gets an amino acid sequence of this chain from ATOM records
Expand Down
6 changes: 3 additions & 3 deletions lib/bio/db/pdb/model.rb
Expand Up @@ -6,7 +6,7 @@
# Naohisa Goto <ng@bioruby.org>
# License:: LGPL
#
# $Id: model.rb,v 1.6 2006/01/09 11:22:36 ngoto Exp $
# $Id: model.rb,v 1.7 2006/01/20 13:54:08 ngoto Exp $
#
#--
# This library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -139,14 +139,14 @@ def [](key)
def to_s
string = ""
if model_serial
string = "MODEL #{model_serial}" #Should use proper formatting
string = "MODEL #{model_serial}\n" #Should use proper formatting
end
@chains.each{ |chain| string << chain.to_s }
#if solvent
# string << @solvent.to_s
#end
if model_serial
string << "ENDMDL"
string << "ENDMDL\n"
end
return string
end
Expand Down
22 changes: 20 additions & 2 deletions lib/bio/db/pdb/pdb.rb
Expand Up @@ -6,7 +6,7 @@
# Alex Gutteridge <alexg@ebi.ac.uk>
# License:: LGPL
#
# $Id: pdb.rb,v 1.12 2006/01/08 12:59:04 ngoto Exp $
# $Id: pdb.rb,v 1.13 2006/01/20 13:54:08 ngoto Exp $
#
#--
# This library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -1009,6 +1009,24 @@ def do_parse
@parsed = true
self
end

def to_s
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,
self.name,
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
end #class ATOM

# SIGATM record class
Expand Down Expand Up @@ -1576,7 +1594,7 @@ def [](key)
def to_s
string = ""
@models.each{ |model| string << model.to_s }
string << "END"
string << "END\n"
return string
end

Expand Down
6 changes: 2 additions & 4 deletions lib/bio/db/pdb/residue.rb
Expand Up @@ -6,7 +6,7 @@
# Naohisa Goto <ng@bioruby.org>
# License:: LGPL
#
# $Id: residue.rb,v 1.9 2006/01/09 11:22:36 ngoto Exp $
# $Id: residue.rb,v 1.10 2006/01/20 13:54:08 ngoto Exp $
#
#--
# This library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -142,9 +142,7 @@ def <=>(other)

# Stringifies each atom
def to_s
string = ""
@atoms.each{ |atom| string << atom.to_s << "\n" }
return string
@atoms.join('')
end

# Always returns false.
Expand Down

0 comments on commit f1625af

Please sign in to comment.