Could not read cif file with Openmm

The functionality of OpenMM will (eventually) include everything that one would need to run modern molecular simulation.
POST REPLY
User avatar
Pawel Bryk
Posts: 4
Joined: Wed Mar 13, 2019 10:14 am

Could not read cif file with Openmm

Post by Pawel Bryk » Wed Mar 13, 2019 10:30 am

Hi all,
I have a beginner's problem.
Openmm cannot read my .cif file (pdb reads fine).
This is my two-molecule water (spce model) cif file (created from spce.pdb provided by OpenMM package)

Code: Select all

data_water1
#
_symmetry.entry_id                         water1
_symmetry.space_group_name_H-M             'P 1'
#
_cell.entry_id           water1
_cell.length_a           30.0000
_cell.length_b           30.0000
_cell.length_c           30.0000
_cell.angle_alpha        90.00
_cell.angle_beta         90.00
_cell.angle_gamma        90.00
_cell.Z_PDB              1
#
loop_
_atom_site.group_PDB
_atom_site.id
_atom_site.type_symbol
_atom_site.label_atom_id
_atom_site.label_alt_id
_atom_site.label_comp_id
_atom_site.label_asym_id
_atom_site.label_entity_id
_atom_site.label_seq_id
_atom_site.pdbx_label_seq_num
_atom_site.Cartn_x
_atom_site.Cartn_y
_atom_site.Cartn_z
_atom_site.occupancy
_atom_site.B_iso_or_equiv
ATOM 1 O O . HOH A 1 . 27.552 11.051 7.172 1.00 0.00
ATOM 2 H H1 . HOH A 1 . 27.900 10.721 8.050 1.00 0.00
ATOM 3 H H2 . HOH A 1 . 26.606 11.355 7.281 1.00 0.00
ATOM 4 O O . HOH A 1 . 15.041 22.415 5.577 1.00 0.00
ATOM 5 H H1 . HOH A 1 . 15.438 21.792 6.251 1.00 0.00
ATOM 6 H H2 . HOH A 1 . 15.775 22.861 5.063 1.00 0.00
#
This is my "advanced" py script

Code: Select all

from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
from sys import stdout
import simtk.unit as units
import time
platform=Platform.getPlatformByName('CUDA')
CIFName='water1.cif'
pdb = PDBxFile(CIFName)
print('CIF taken- '+CIFName)
I get the following error:

Code: Select all

Traceback (most recent call last):
  File "/home/pawel/anaconda3/lib/python3.7/site-packages/simtk/openmm/app/internal/pdbx/reader/PdbxReader.py", line 359, in __tokenizer
    line = next(fileIter)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./NHIntegrator1.py", line 14, in <module>
    pdb = PDBxFile(CIFName)
  File "/home/pawel/anaconda3/lib/python3.7/site-packages/simtk/openmm/app/pdbxfile.py", line 77, in __init__
    reader.read(data)
  File "/home/pawel/anaconda3/lib/python3.7/site-packages/simtk/openmm/app/internal/pdbx/reader/PdbxReader.py", line 71, in read
    self.__parser(self.__tokenizer(self.__ifh), containerList)
  File "/home/pawel/anaconda3/lib/python3.7/site-packages/simtk/openmm/app/internal/pdbx/reader/PdbxReader.py", line 273, in __parser
    curCatName,curAttName,curQuotedString,curWord = next(tokenizer)
RuntimeError: generator raised StopIteration

I get the same error when reading any other cif file, even the ones downloaded from cif databese, like, for example 107d.cif
https://rostlab.org/rost-db-data/_stabl ... 7/107d.cif

My system: CUDA 9.2, OpenMM 7.3, python3.7

User avatar
Peter Eastman
Posts: 1728
Joined: Thu Aug 09, 2007 1:25 pm

Re: Could not read cif file with Openmm

Post by Peter Eastman » Tue Mar 19, 2019 3:08 pm

There's an error in your file. Look at the _atom_site section. It lists 15 fields that should appear on each line. Now look at the data lines. Each one only has 14 columns.

User avatar
Pawel Bryk
Posts: 4
Joined: Wed Mar 13, 2019 10:14 am

Re: Could not read cif file with Openmm

Post by Pawel Bryk » Wed Mar 20, 2019 7:52 am

Thanks a lot for the response.
Indeed I had a bad number of columns. Unfortunately, with the correct number of columns the
behaviour is exactly the same.

Code: Select all

data_water1
#
_symmetry.entry_id                         water1
_symmetry.space_group_name_H-M             'P 1'
#
_cell.entry_id           water1
_cell.length_a           30.0000
_cell.length_b           30.0000
_cell.length_c           30.0000
_cell.angle_alpha        90.00
_cell.angle_beta         90.00
_cell.angle_gamma        90.00
_cell.Z_PDB              1
#
loop_
_atom_site.group_PDB
_atom_site.id
_atom_site.type_symbol
_atom_site.label_atom_id
_atom_site.label_alt_id
_atom_site.label_comp_id
_atom_site.label_asym_id
_atom_site.label_entity_id
_atom_site.label_seq_id
_atom_site.pdbx_label_seq_num
_atom_site.Cartn_x
_atom_site.Cartn_y
_atom_site.Cartn_z
_atom_site.occupancy
_atom_site.B_iso_or_equiv
ATOM 1 O O . HOH A 1 . 1 27.552 11.051 7.172 1.00 0.00
ATOM 2 H H1 . HOH A 1 . 1  27.900 10.721 8.050 1.00 0.00
ATOM 3 H H2 . HOH A 1 . 1 26.606 11.355 7.281 1.00 0.00
ATOM 4 O O . HOH A 1 . 2 15.041 22.415 5.577 1.00 0.00
ATOM 5 H H1 . HOH A 1 . 2 15.438 21.792 6.251 1.00 0.00
ATOM 6 H H2 . HOH A 1 . 2 15.775 22.861 5.063 1.00 0.00
#
I have also tried to read some cif files found on the internet. In ALL cases I get the same error (a link to a sample cif file downloaded from the internet is in my original post). It seems to me like PDBxFile() does not work with python3.7.

User avatar
Peter Eastman
Posts: 1728
Joined: Thu Aug 09, 2007 1:25 pm

Re: Could not read cif file with Openmm

Post by Peter Eastman » Wed Mar 20, 2019 12:48 pm

It works fine for me. Using the updated version of the file posted above the script runs without complaint.

Code: Select all

$ python test.py 
CIF taken- water1.cif
That's using Python 3.7.1.

User avatar
Artur Terzyk
Posts: 6
Joined: Mon Jun 06, 2016 11:44 pm

Re: Could not read cif file with Openmm

Post by Artur Terzyk » Thu Apr 04, 2019 12:23 am

Hi Peter, few days ago I sent you e-mail with the description of the problem above. Could you please help us? Regards,

Artur

User avatar
Peter Eastman
Posts: 1728
Joined: Thu Aug 09, 2007 1:25 pm

Re: Could not read cif file with Openmm

Post by Peter Eastman » Thu Apr 04, 2019 2:21 pm

All I did was run the script you posted to load the fixed version of your file. It worked perfectly using the latest version of OpenMM. I think you're somehow still pointing it at the old (broken) version of the file.

User avatar
Pawel Bryk
Posts: 4
Joined: Wed Mar 13, 2019 10:14 am

Re: Could not read cif file with Openmm

Post by Pawel Bryk » Tue Apr 16, 2019 5:45 am

Turns out to be a bug associated with a new version of python starting from python3.7.
A bug report has been submitted.

User avatar
Peter Eastman
Posts: 1728
Joined: Thu Aug 09, 2007 1:25 pm

Re: Could not read cif file with Openmm

Post by Peter Eastman » Tue Apr 16, 2019 5:45 pm

Could you try using the latest version of the source code? It looks like this was fixed internally some months ago, which would explain why it works for me:

https://github.com/pandegroup/openmm/pull/2198

User avatar
Pawel Bryk
Posts: 4
Joined: Wed Mar 13, 2019 10:14 am

Re: Could not read cif file with Openmm

Post by Pawel Bryk » Wed Apr 17, 2019 7:44 am

Yes, the compiled from source version does work! It says its OpenMM version 7.4 though.

User avatar
Peter Eastman
Posts: 1728
Joined: Thu Aug 09, 2007 1:25 pm

Re: Could not read cif file with Openmm

Post by Peter Eastman » Thu Apr 18, 2019 9:02 am

Ok, good. This will be in the next release. Sorry this didn't get into 7.3.1. The PR didn't mention anything about including a bug fix, so I didn't realize it included this.

POST REPLY