franciscoadasme / chem.cr

Library for dealing with computational chemistry files
https://franciscoadasme.github.io/chem.cr/
MIT License
23 stars 1 forks source link

Chem::ParseException reading a PDB with empty REMARK field #222

Closed maurobedoya closed 2 months ago

maurobedoya commented 2 months ago

When reading a PDB generated by Packmol, an empty REMARK field is generated before the atom fields and this causes the parsing error. Example:

HEADER 
TITLE     Built with Packmol                                             
REMARK   Packmol generated pdb file 
REMARK   Home-Page: http://m3g.iqm.unicamp.br/packmol
REMARK
HETATM    1  C1  LIG A   1      -0.463  -1.344   0.002  0.00  1.00           C  
HETATM    2  C2  LIG A   1      -1.369  -0.309   0.001  0.00  1.00           C  
HETATM    3  C3  LIG A   1      -0.895   1.105  -0.002  0.00  1.00           C  
...

The error:

Unhandled exception: Cursor out of current line (Chem::ParseException)
  from /path/lib/chem/src/chem/pull_parser.cr:396:7 in 'error'
  from /path/lib/chem/src/chem/pull_parser.cr:99:34 in 'at'
  from /path/lib/chem/src/chem/formats/pdb.cr:145:16 in 'decode_header'
  from /path/lib/chem/src/chem/formats/pdb.cr:39:7 in 'next_entry'
  from /path/lib/chem/src/chem/format_reader.cr:181:7 in 'read_entry'
  from /path/lib/chem/src/chem/register_format.cr:270:1 in 'from_pdb'
  from /path/src/utilities/testing.cr:116:5 in '__crystal_main'
  from /opt/crystal-1.13.1-1/share/crystal/src/crystal/main.cr:118:5 in 'main_user_code'
  from /opt/crystal-1.13.1-1/share/crystal/src/crystal/main.cr:104:7 in 'main'
  from /opt/crystal-1.13.1-1/share/crystal/src/crystal/main.cr:130:3 in 'main'
  from /lib/x86_64-linux-gnu/libc.so.6 in '__libc_start_main'
  from /path/bin/testing in '_start'
  from ???