# Converting a PDB file to XYZ file

I am trying to convert a pdb file of gold nanoparticle to the xyz file format to get the atomic coordinates. But when I try to use openbabel to do this, I get the following error.

*** Open Babel Error  in ReadMolecule
ERROR: not a valid PDB file


My command is obabel shelxpro.pdb -O shelxpro.xyz

(shelxpro.pdb is at http://www.sciencemag.org/content/318/5849/430/suppl/DC1 inside the .zip folder 1148624_data.zip)

Also when I try to visualize this structure with Jmol or VMD, I get only part of the expected structure.

Is there a way to fix either one of these issues?

• Point of clarification: A CIF file is not a PDB file - they're completely different formats. (The file you point to is a PDB file, though.) – R.M. Nov 2 '15 at 20:39

## 1 Answer

The conversion issue you're seeing is because the PDB you're using is not technically well-formatted. If you take a look at the output, you see a bunch of the following warnings.

==============================
*** Open Babel Warning  in parseAtomRecord
WARNING: Problems reading a PDB file
Problems reading a HETATM or ATOM record.
According to the PDB specification,
columns 77-78 should contain the element symbol of an atom.
but OpenBabel found '  ' (atom 276)
==============================


This thread from the OpenBabel mailing list goes into more details. Basically, the official PDB specification requires that the atom names be present off to the right-hand side of each ATOM/HETATM line. Older PDBs (and lazy PDB-outputting software) don't do that.

For the most part that works, as the atom name entry normally contains the element designation. Parsing this is tricky, though, as it doesn't always work.

That's what's causing Open Babel to choke. Your PDB contains gold atoms, and Open Babel doesn't know how to handle the "AU" atoms. If you manually edit the ATOM lines to contain the letters "Au" in columns 77-78, then Open Babel is able to make the conversion, but still warns about the C/N/O atoms which don't have their elements correctly designated. - But for C/N/O it's okay, as Open Babel is able to figure out the element from the atom name.

If you don't want to manually edit the lines, you just need to pass the PDB file through a program that can make sense of the AU atoms, and will output the element name in the appropriate colum. VMD doesn't seem to help (it reads things fine, but doesn't add the element annotation), but PyMol is able to read in the file and when re-saving the molecule will put the correct values in columns 77-78.

Regarding the "missing atoms", the PDB file contains a crystallographic symmetry record in the first four lines. (CRYST1, SCALE1, SCALE2 and SCALE3 records). I'm guessing the atoms you're missing are related by crystallographic symmetry to the ones that are present. To generate those atoms, use a program which can use the PDB symmetry records to generate the symmetric partners. (PyMol is one such program.)