Skip to content

Commit

Permalink
Fix negative residue IDs in PDB saving (resolves #29)
Browse files Browse the repository at this point in the history
  • Loading branch information
samirelanduk committed Nov 5, 2020
1 parent 4a9ff38 commit d6e738b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion atomium/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ def atom_to_atom_line(a, lines):
if a.het:
id_, residue_name = a.het.id, a.het._name
chain_id = a.chain.id if a.chain is not None else ""
residue_id = int("".join([c for c in id_ if c.isdigit()]))
residue_id = int("".join([c for c in id_ if c.isdigit() or c == "-"]))
insert_code = id_[-1] if id_ and id_[-1].isalpha() else ""
atom_name = a._name or ""
atom_name = " " + atom_name if len(atom_name) < 4 else atom_name
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/test_file_saving.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def check_file_saving(self, filename):
self.assertEqual(chain1.sequence, chain2.sequence)
self.assertEqual(chain1.id, chain2.id)
self.assertEqual(chain1, chain2)
for res1, res2 in zip(sorted(chain1.residues(), key=lambda r: r.id),
sorted(chain2.residues(), key=lambda r: r.id)):
self.assertEqual(res1.id, res2.id)
self.assertEqual(res1.name, res2.name)
self.assertEqual(res1, res2)
for lig1, lig2 in zip(sorted(f.model.ligands(), key=lambda c: c.id),
sorted(f2.model.ligands(), key=lambda c: c.id)):
self.assertEqual(lig1.name, lig2.name)
Expand Down

0 comments on commit d6e738b

Please sign in to comment.