Command to recreate per lane bam from a merged bam

Refer to AT-658, this command tool is needed to recreate per lane bam from a merged bam. The steps involved are: extract read group bam, compare flagstat, revert markdup tag, reheader bam, create bam index, create bam md5, move outputs over.
ok, I will change to this with fewer lines.