samirelanduk / atomium

Python macromolecular parsing (with .pdb/.cif/.mmtf parsing and production)
https://atomium.bio
MIT License
102 stars 19 forks source link

Unable to write atoms with negative residue id #29

Closed staszekdh closed 3 years ago

staszekdh commented 3 years ago

In atom_to_atom_line (atomium.pdb) there is a fragment:

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()]))
    insert_code = id_[-1] if id_ and id_[-1].isalpha() else ""

It handles the insert codes nicely (e.g. 10A) but removes the minus sign in negative residue ids. If we have residues -1 and 1, both will end up being 1 in the PDB file.

staszekdh commented 3 years ago

A possible fix:

residue_id = int("".join([c for c in id_ if c.isdigit() or c =='-']))

samirelanduk commented 3 years ago

Thanks for flagging this! Should be fixed now in 1.0.7 (just released). I used exactly the fix you suggested.