[BioRuby] Bug in writing PDB ATOM

GOTO Naohisa ngoto at gen-info.osaka-u.ac.jp
Sat Feb 10 07:32:40 UTC 2007


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.

#### 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