Skip to content

Commit

Permalink
Merge pull request #138 from adaptyvbio/pdb_format
Browse files Browse the repository at this point in the history
fix: add a check for to_pdb
  • Loading branch information
elkoz committed Feb 7, 2024
2 parents eb4f0fa + bc3fe91 commit 4a64f50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions proteinflow/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()})

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion proteinflow/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 4a64f50

Please sign in to comment.