Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with reading/writing CONECT records in PDB files with many atoms #988

Closed
BartoszBartmanski opened this issue Sep 15, 2016 · 4 comments · Fixed by #3670
Closed

Problem with reading/writing CONECT records in PDB files with many atoms #988

BartoszBartmanski opened this issue Sep 15, 2016 · 4 comments · Fixed by #3670

Comments

@BartoszBartmanski
Copy link

BartoszBartmanski commented Sep 15, 2016

Expected behaviour

Reading in a pdb file using the standard MDAnalysis.Universe("file_name.pdb")

Actual behaviour

Fails with the following error message:

Traceback (most recent call last):
  File "./run_simulation.py", line 19, in <module>
    md_simulation.use_packmol()
  File "/sansom/s118/shil4444/Documents/Influenza_model/Input_files/md_simulation.py", line 405, in use_packmol
    shapes.add_rpo(ip)
  File "/sansom/s118/shil4444/Documents/Influenza_model/Input_files/shapes.py", line 462, in add_rpo
    u_vesicle = MDAnalysis.Universe(ip["filename"]+".pdb")
  File "/sansom/s118/shil4444/.local/lib/python2.7/site-packages/MDAnalysis-0.15.1.dev0-py2.7-linux-x86_64.egg/MDAnalysis/core/AtomGroup.py", line 4339, in __init__
    self._topology = p.parse()
  File "/sansom/s118/shil4444/.local/lib/python2.7/site-packages/MDAnalysis-0.15.1.dev0-py2.7-linux-x86_64.egg/MDAnalysis/topology/PDBParser.py", line 90, in parse
    bonds = self._parsebonds(atoms)
  File "/sansom/s118/shil4444/.local/lib/python2.7/site-packages/MDAnalysis-0.15.1.dev0-py2.7-linux-x86_64.egg/MDAnalysis/topology/PDBParser.py", line 181, in _parsebonds
    atom, atoms = _parse_conect(line.strip())
  File "/sansom/s118/shil4444/.local/lib/python2.7/site-packages/MDAnalysis-0.15.1.dev0-py2.7-linux-x86_64.egg/MDAnalysis/topology/PDBParser.py", line 215, in _parse_conect
    "record: {}".format(conect))
RuntimeError: Bond atoms aren't aligned proberly for CONECT record: CONECT100001100000100002100007

Code to reproduce the behaviour

import MDAnalysis as mda

u = mda.Universe("Flu_membrane_capsule.pdb")

Flu_membrane_capsule.txt

Currently version of MDAnalysis:

0.15.1-dev0

@orbeckst
Copy link
Member

I think the problem is that you have so many atoms that the PDB format runs out of atom indices and then the CONECT records become meaningless. If you remove the CONECT records

wget -O Flu_membrane_capsule.pdb  https://github.com/MDAnalysis/mdanalysis/files/474513/Flu_membrane_capsule.txt
grep -v CONECT Flu_membrane_capsule.pdb > Flu_membrane_capsule_noCONECT.pdb

then it can be read successfully:

>>> import MDAnalysis as mda
>>> u = mda.Universe("./Flu_membrane_capsule_noCONECT.pdb")
>>> print(u.atoms.n_atoms)
188513

Now, it seems that you wrote this PDB file with MDAnalysis (is this true?) and it was the MDAnalysis PDB write that put the CONECT records there. I think this indicates a bug in the PDBWriter in that it should not write CONECT records if it generates an illegal PDB file.

@orbeckst
Copy link
Member

As a workaround, can use other formats in your workflow, such as GRO?

@richardjgowers
Copy link
Member

I think there's 2 things here, the PDBParser should still work, it should just give up on trying to read the CONECT records (with a warning). And it looks like the PDBWriter shouldn't have made an unusable file.

@BartoszBartmanski
Copy link
Author

BartoszBartmanski commented Sep 15, 2016

The way that I create this file is by using packmol and then importing it into MDAnalysis to change it. The error message I received was when I imported it again. But, thank you for the advice.

Best,

Bartosz


From: Oliver Beckstein [notifications@github.com]
Sent: 15 September 2016 20:48
To: MDAnalysis/mdanalysis
Cc: Bartosz Bartmanski; Author
Subject: Re: [MDAnalysis/mdanalysis] Problem with reading in PDB files (#988)

I think the problem is that you have so many atoms that the PDB format runs out of atom indices and then the CONECT records become meaningless. If you remove the CONECT records

wget -O Flu_membrane_capsule.pdb https://github.com/MDAnalysis/mdanalysis/files/474513/Flu_membrane_capsule.txt
grep -v CONECT Flu_membrane_capsule.pdb > Flu_membrane_capsule_noCONECT.pdb

then it can be read successfully:

import MDAnalysis as mda
u = mda.Universe("./Flu_membrane_capsule_noCONECT.pdb")
print(u.atoms.n_atoms)
188513

Now, it seems that you wrote this PDB file with MDAnalysis (is this true?) and it was the MDAnalysis PDB write that put the CONECT records there. I think this indicates a bug in the PDBWriter in that it should not write CONECT records if it generates an illegal PDB file.

@orbeckst orbeckst changed the title Problem with reading in PDB files Problem with reading/writing CONECT records in PDB files with many atoms Sep 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants