From 8423ed4295385c4205614fe5dbaab312600342ab Mon Sep 17 00:00:00 2001 From: Ruibin Liu Date: Wed, 4 Oct 2023 14:17:04 -0400 Subject: [PATCH] skip missing pdbx columns --- moldf/pdb_dataframe.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/moldf/pdb_dataframe.py b/moldf/pdb_dataframe.py index 61b222f..4e3597f 100644 --- a/moldf/pdb_dataframe.py +++ b/moldf/pdb_dataframe.py @@ -154,13 +154,13 @@ def _pdbx_to_pdb(self, keep_original: bool = False): keep_original (optional): whether to keep the original columns in the PDBx '_atom_site' DataFrame. Defaults to **False**. """ - for pdb_name, pdbx_name in PDBX_COLS.items(): + pdbx_cols = {k: v for k, v in PDBX_COLS.items() if v in self.columns} + for pdb_name, pdbx_name in pdbx_cols.items(): self[pdb_name] = self[pdbx_name] if not keep_original: - drop_columns = [col for col in self.columns if col not in PDBX_COLS.keys()] + drop_columns = [col for col in self.columns if col not in pdbx_cols.keys()] self.drop(columns=drop_columns, inplace=True) self._pdb_format = "PDBx" - self = self[list(PDBX_COLS.keys())] @property def pdb_format(self) -> str: