This function corrects a DNA sequence based on a provided CIGAR string. It first expands the CIGAR string, then inserts 'D's into the DNA sequence at positions corresponding to 'D's in the expanded CIGAR string. It also replaces characters in the DNA sequence with 'I's at positions corresponding to 'I's in the CIGAR string. After applying these modifications, the function calls clean_insertions to clean up the sequence.

correct_seq(cigar, sequence)

Arguments

cigar

A string representing the CIGAR sequence. Each character in the CIGAR string (such as M, I, D) represents a type of alignment operation.

sequence

A string representing the DNA sequence that needs to be corrected based on the CIGAR string.

Value

A DNA sequence string that has been corrected based on the CIGAR string. The function returns the sequence after applying deletions, insertions, and further cleaning through the clean_insertions function.