Will converting a MBR disk to GPT, formatting and the converting back to MBR remove a infected boot record. I am looking into writing a little program that will take a connected USB with a MBR infection and convert it to GPT and then format it before converting it back to MBR. Would this be sufficient to remove the threat of a MBR infection?
No, not unless the infection exclusively resides on the MBR. It can easily exist on the bootloader or any other stage in the boot process. Also note that GPT has two backup MBRs on it, though they are not executed by default. If you believe you have an MBR infection (which is quite unlikely), you should reinstall your OS, as an infection of the MBR requires such high privileges that your entire installation could be compromised.
Realistically, MBR viruses can only load if you boot into the disk directly, which usually means enabling USB hard drive booting and manually choosing to boot to the disk. As such, you probably shouldn't worry about MBR viruses unless you intend to boot from the disk.
Converting from MBR to GPT may theoretically preserve the boot code, in which case a format might not be sufficient. Instead, I recommend you just zero out the MBR and start over. Write 512 0x00 bytes to Sector 0/LBA 0, which will essentially tell any formatting utilities that this is an unitialized disk.
Afterwards, create the MBR, create your first partition, and then format the file system for that partition. This will set up all the required data structures without preserving anything that may have been there before. The entire process should take less than a minute and is less likely to leave leftover boot code that might survive the conversion.
Well MBR infection used to be common in the old time of floppy disks, and the common fix was just to reinstall the code of the boot record. Almost all Operating Systems have a option to (re-) install a brand new boot record on a physical disk without changing the partition information. Look for GRUB for Linux, booteasy for BSD, bootrec or bootsect for Windows. That is enough to re-install the code in the MBR without changing the partition table.