[BioRuby] Bug in writing PDB ATOM

Yen-Ju Chen yjchenx at gmail.com
Sat Feb 10 14:13:25 UTC 2007


On 2/9/07, GOTO Naohisa <ngoto at gen-info.osaka-u.ac.jp> wrote:
> Hi, Yen-Ju,
>
> Which bioruby version do you use?
> By using CVS HEAD 'pdb.rb,v 1.16 2006/06/27 14:23:45',
> it seems fine.

I tried both 1.0 and CVS.
And your example indeed works fine.
Here is the data and script I used:

ATOM      1  CB  TYR A   4      46.803  20.433  46.159  1.00130.00
ATOM      2  CG  TYR A   4      46.708  19.122  46.931  1.00130.00
ATOM      3  CD1 TYR A   4      46.708  17.892  46.257  1.00130.00
ATOM      4  CE1 TYR A   4      46.596  16.691  46.961  1.00130.00
ATOM      5  CD2 TYR A   4      46.599  19.109  48.336  1.00130.00

#########
require 'bio'

file = File.new('a.pdb').gets(nil)
structure = Bio::PDB.new(file)

structure.each do |model|
  model.each do |chain|
    chain.each do |residue|
      residue.each do |atom|
        atom.resSeq += 400
      end
    end
  end
end

File.open('x.pdb', 'w') do |file|
  file << structure.to_s
end

Yen-Ju

>
> #### sample script
>   require 'bio'
>   atom = Bio::PDB::Record::ATOM.new
>   atom.serial = 61
>   atom.name = 'OD1'
>   atom.altLoc = ''
>   atom.resName = 'ASN'
>   atom.chainID = 'A'
>   atom.resSeq = 8
>   atom.iCode = ''
>   atom.x = 102.025
>   atom.y = 27.929
>   atom.z = 144.984
>   atom.occupancy = 1.0
>   atom.tempFactor = 88.56
>   atom.segID = ''
>   atom.element = 'O'
>   atom.charge = ''
>   print atom.to_s
>   # "ATOM     61  OD1 ASN A   8     102.025  27.929 144.984  1.00 88.56  O  \n"
> #### end of sample script
>
> However, it still fails in some rare cases.
>
>   require 'bio'
>   # record from PDB 1CX1
>   str = "ATOM    376 HH   TYR A  25       " +
>           "4.479  12.801  -3.919  1.00  1.72           H  "
>   atom = Bio::PDB::Record::ATOM.new.initialize_from_string(str)
>   print atom.to_s
>   #
>   # "ATOM    376  HH  TYR A  25       4.479  12.801  -3.919  1.00  1.72  H  \n"
>   #              ^ an excess space!!
>
> I'll make changes in the CVS to give more accurate results,
> but it'll be still imperfect (becase of ambiguity, as Alex said).
>
> Thanks,
>
> Naohisa Goto
> ng at bioruby.org / ngoto at gen-info.osaka-u.ac.jp
>
> On Thu, 8 Feb 2007 14:54:09 -0800
> "Yen-Ju Chen" <yjchenx at gmail.com> wrote:
>
> > In bio/db/pdb/pdb.rb line 1019,
> > the ATOM entry is written as:
> >
> >           sprintf("%-6s%5d %-4s%-1s%3s %-1s%4d%-1s
> >
> > It results an ATOM entry as:
> > ATOM     61 OD1  ASN A   8     102.025  27.929 144.984  1.00 88.56           O
> >
> > But the right ATOM entry should be
> > ATOM     61  OD1 ASN A   8     102.025  27.929 144.984  1.00 88.56           O
> >
> > Note there are 2 spaces after '61' and one space before 'ASN'
> > I change this line to:
> >
> >           sprintf("%-6s%5d  %-3s%-1s%3s %-1s%4d%-1s
> >
> > and it works fine now.
> > But I am new to Ruby and not familiar with the format yet.
> >
> > Yen-Ju
> > _______________________________________________
> > BioRuby mailing list
> > BioRuby at lists.open-bio.org
> > http://lists.open-bio.org/mailman/listinfo/bioruby
> >
>



More information about the BioRuby mailing list