diff --git a/proteinflow/data/__init__.py b/proteinflow/data/__init__.py index c58c919..086ffcb 100644 --- a/proteinflow/data/__init__.py +++ b/proteinflow/data/__init__.py @@ -575,6 +575,9 @@ def rename_chains(self, chain_dict): A dictionary mapping old chain IDs to new chain IDs """ + for chain in self.get_chains(): + if chain not in chain_dict: + chain_dict[chain] = chain self._rename_chains({k: k * 5 for k in self.get_chains()}) self._rename_chains({k * 5: v for k, v in chain_dict.items()}) @@ -988,6 +991,10 @@ def to_pdb( Title of the PDB file (by default either the protein id or "Untitled") """ + if any([x[0].upper() != x for x in self.get_chains()]): + raise ValueError( + "Chain IDs must be single uppercase letters, please rename with `rename_chains` before saving." + ) pdb_builder = PDBBuilder( self, only_ca=only_ca, diff --git a/proteinflow/data/utils.py b/proteinflow/data/utils.py index 7304ace..d64a066 100644 --- a/proteinflow/data/utils.py +++ b/proteinflow/data/utils.py @@ -256,7 +256,8 @@ def _make_SEQRES(self): def save_pdb(self, path, title="UntitledProtein"): """Write out the generated PDB file as a string to the specified path.""" with open(path, "w") as outfile: - outfile.write(self.get_pdb_string(title)) + text = self.get_pdb_string(title) + outfile.write(text) def _split_every(n, iterable):