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.
Several years ago we have written a tool for this: http://kodomo.fbb.msu.ru/~avkitex/projects/pdbparser.html
https://github.com/avkitex/pdbparserTools

The description is only in Russian but you can contact the author.