So I have a sam file with extended CIGAR format like this:

    17H87=1D12=1D2=3D32=1D4=2D5=2D13=....

And I want to convert it to a sam file containing regular CIGAR format that will look like this:

    17S83M1D14M1D4M3D31M1D2M2D6M...

 (they do not represent the same reads... I want only to visualize the problem)

Anyone knows some software/script that will convert sam/bam with extended CIGAR to a sam/bam with regular CIGAR?
It seems like a standard problem that might already have a solution so I want to ask here before solving it the hard way(coding)
I've quickly written one: https://github.com/lindenb/jvarkit/wiki/Biostar234081


     $ cat toy.sam 
    @SQ	SN:ref	LN:45
    @SQ	SN:ref2	LN:40
    r001	163	ref	7	30	1M2X5=4I4M1D3M	=	37	39	TTAGATAAAGAGGATACTG*XX:B:S,12561,2,20,112
    
     $ java -jar dist/biostar234081.jar toy.sam 
    @HD	VN:1.5	SO:unsorted
    @SQ	SN:ref	LN:45
    @SQ	SN:ref2	LN:40
    r001	163	ref	7	30	8M4I4M1D3M	=	37	39	TTAGATAAAGAGGATACTG*XX:B:S,12561,2,20,112



