# Is there a standard way to clean a PDB file and re-number its residues?

Is there a pre-existing tool which will tidy up the numbering of a PDB file?

Firstly, I would like to re-number the residues on inserts to make the icode an actual residue in the chain (by that I mean it's own number, shifting everything after it, so 45A becomes 46).

Secondly, I would also like to re-number so that each residue is one after another, as there are skips in the numbering, in spite of the two residues being physically next to each other.

I could do this in-house with a python script, but I thought I would ask specifically if there is a library or pre-existing tool?

Worst case scenario I have found this Perl script that does similar.

Thanks.

• "make the icode an actual residue in the chain" -- something is confused here. Insertion code is part of the residue id, together with the sequence number. – marcin Feb 1 '18 at 17:26
• @marcin Yes sorry you're right it is, but for example when using the biopython PDB to FASTA parser it is not recognized and the chain is truncated from beyond there. So either I would need to ignore it (as I am at the moment) or change it from 1, 2, 3, 3A, 4 to 1, 2, 3, 4, 5. – TW93 Feb 1 '18 at 17:54
• @TW93 You almost certainly want to either ignore them, or deal with them separately. They usually represent different wildtypes/isoforms. E.g. the same protein within different species which contains some minor sequence alternations! If you include the same residue twice or more, obviously, that will cause steric clashes and mess up any calculations that you run! – Aalawlx Mar 5 '18 at 5:58
• I think there is a confusion here between insertion code and alternative location ID. Insertion codes allow for unified numbering between proteins of slightly different sequences, but everything with a unique residue ID (residue number and insertion code) is a separate residue in the chain and cannot be ignored. The question asked by the OP is hence valid. You wouldn't want to have multiple residues with the same residue ID but different alternative location IDs renumbered, but that wasn't the question. – jgreener Sep 17 '19 at 11:24

The pdb-tools suite has pdb_delinsertion and pdb_reres for this task. Something like:
pdb_delinsertion 1CTF.pdb | pdb_reres > out.pdb