Unverified Commit e688b86e authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Fix error reading CONECT records in PDB with multiple models (#5179)

parent 82703dff
...@@ -4,7 +4,7 @@ pdbstructure.py: Used for managing PDB formatted files. ...@@ -4,7 +4,7 @@ pdbstructure.py: Used for managing PDB formatted files.
This is part of the OpenMM molecular simulation toolkit. This is part of the OpenMM molecular simulation toolkit.
See https://openmm.org/development. See https://openmm.org/development.
Portions copyright (c) 2012-2021 Stanford University and the Authors. Portions copyright (c) 2012-2026 Stanford University and the Authors.
Authors: Christopher M. Bruns Authors: Christopher M. Bruns
Contributors: Peter Eastman Contributors: Peter Eastman
...@@ -153,11 +153,14 @@ class PdbStructure(object): ...@@ -153,11 +153,14 @@ class PdbStructure(object):
def _load(self, input_stream): def _load(self, input_stream):
self._reset_atom_numbers() self._reset_atom_numbers()
self._reset_residue_numbers() self._reset_residue_numbers()
skip_remaining_models = False
# Read one line at a time # Read one line at a time
for pdb_line in input_stream: for pdb_line in input_stream:
if not isinstance(pdb_line, str): if not isinstance(pdb_line, str):
pdb_line = pdb_line.decode('utf-8') pdb_line = pdb_line.decode('utf-8')
command = pdb_line[:6] command = pdb_line[:6]
if skip_remaining_models and command != "CONECT":
continue
# Look for atoms # Look for atoms
if command == "ATOM " or command == "HETATM": if command == "ATOM " or command == "HETATM":
self._add_atom(Atom(pdb_line, self, self.extraParticleIdentifier)) self._add_atom(Atom(pdb_line, self, self.extraParticleIdentifier))
...@@ -179,7 +182,7 @@ class PdbStructure(object): ...@@ -179,7 +182,7 @@ class PdbStructure(object):
elif command == "ENDMDL": elif command == "ENDMDL":
self._current_model._finalize() self._current_model._finalize()
if not self.load_all_models: if not self.load_all_models:
break skip_remaining_models = True
elif pdb_line[:3] == "END": elif pdb_line[:3] == "END":
self._current_model._finalize() self._current_model._finalize()
if not self.load_all_models: if not self.load_all_models:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment