Python: Adding Read Group (@RG) tags to BAM or SAM files

The SAM specification now requires @RG tags to be included in all SAM/BAM alignments. If you are using GATK you have probably noticed that it will not run without them. Since @RG tags weren’t standard until recently, I’ve written a script to add them  in post hoc. You’ll need to install pysam and python2.7 to get it to work.