Skip to content

Commit

Permalink
More graceful handling of non-critical errors in PDB headers.
Browse files Browse the repository at this point in the history
Fixes #170
  • Loading branch information
sobolevnrm committed Dec 27, 2020
1 parent 34458b6 commit 8c810ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Changes

* Improved documentation of constants in modules.

* Improved handling of improperly formatted PDB records that are not ``HETATM`` or ``ATOM``.

******************
3.1.0 (2020-12-22)
******************
Expand Down
17 changes: 10 additions & 7 deletions pdb2pqr/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2578,13 +2578,16 @@ def read_pdb(file_):
klass = LINE_PARSERS[record]
obj = klass(line)
pdblist.append(obj)
except KeyError as details:
errlist.append(record)
_LOGGER.error(f"Error parsing line: {details}")
_LOGGER.error(f"<{line.strip()}>")
_LOGGER.error(
f"Truncating remaining errors for record type:{record}"
)
except (KeyError, ValueError) as details:
if record not in ["HETATM", "ATOM"]:
errlist.append(record)
_LOGGER.error(f"Error parsing line: {details}")
_LOGGER.error(f"<{line.strip()}>")
_LOGGER.error(
f"Truncating remaining errors for record type:{record}"
)
else:
raise details
except IndexError as details:
if record in ["ATOM", "HETATM"]:
try:
Expand Down

0 comments on commit 8c810ca

Please sign in to comment.