From 0efd4f5b31ca093d5a5269aedc60cd719f4f842f Mon Sep 17 00:00:00 2001 From: Patrick Kunzmann Date: Fri, 12 Jan 2024 15:37:51 +0100 Subject: [PATCH] Allow invalid CRYST1 records --- python-src/fastpdb/__init__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/python-src/fastpdb/__init__.py b/python-src/fastpdb/__init__.py index da190b7..fd8a934 100644 --- a/python-src/fastpdb/__init__.py +++ b/python-src/fastpdb/__init__.py @@ -4,6 +4,7 @@ __version__ = "1.3.0" import os +import warnings import numpy as np from biotite.file import is_text import biotite.structure as struc @@ -166,10 +167,13 @@ def get_structure(self, model=None, altloc="first", extra_fields=None, include_b raise ValueError(f"Unknown extra field: {field}") - box = self._pdb_file.parse_box() - if box is None: - atoms.box = None - else: + try: + box = self._pdb_file.parse_box() + except: + warnings.warn( + "File contains invalid 'CRYST1' record, box is ignored" + ) + if box is not None: len_a, len_b, len_c, alpha, beta, gamma = box box = struc.vectors_from_unitcell( len_a, len_b, len_c,