Thanks, Istvan. I'm not surprised it's a poor example. I just made something up to try to illustrate the point. You've answered the question regarding soft clips.
Here's a short piece of output. I'm looking only for mismatches, where the CIGAR indicates an X -- all ChrY:
calc'd_pos, allele, flags, mapq, qual, start_pos
6350287 C 163 3 ' 6350225
6350344 G 163 5 F 6350276
6350353 A 163 7 F 6350341
6350438 A 163 7 0 6350341
6350418 C 147 7 ' 6350344
6350422 G 147 7 F 6350344
6350485 A 83 13 F 6350370
6350410 C 147 13 0 6350377
It seems straight forward. But the indels were screwing up the calculated positions. My last look at a one position finally yielded consistent results with this:
foreach $base (@bases)
{
if ($cigararray[$x] eq 'I') {$pos++;}
if ($cigararray[$x] eq 'D') {$pos--;}
.
.
.
Previously, the only inconsistency were in reads that had a deletion indicated in the CIGAR. I haven't looked yet to see if the inserts are correct.
That's all I'm really trying to accomplish right now -- assign the proper positions to the bases. Before I realized I had a problem with my data, I'd written scripts that found all the known SNPs and filtered out variants that sat in the middle of STRs and palindromes. I haven't really looked yet at mapq and qual, but have started to throw out stuff based on a couple of flags.
Thanks, Michael
Why exactly are you reinventing the wheel (
samtools mpileupwill give you a format that's trivial to parse)? Why aren't you just using one of the many many many many variant callers?