Thanks a lot "graff" your inputs were quite useful.
I could be able to write the code. (suggestions for the improvements are welcome)
This code take the inputs: 1. raw pileup file and the 2. consensus fasta sequence(here it is named as "input.fasta"). and modifies the consensus fasta sequence based on the nucleotide frequences (if above 5%) at each position (from the read column (column 9).
It also includes deletions if they above 5% in indel line (i.e. lines with * in the column 3)