Thank you so much Pierre. didn't realize that it can be so complicated. The manipulation of CIGAR strings is illuminating, never thought of that.
But I am still now sure how to interpret the results from the example, at which positions are those sequences in the example output?
I think it's a good idea to let you know what I am trying to do because I may have gone a long way to achieve a simple task. Here is my ultimate goal:
I know some functional mutations and their positions, all I want to do is to extract the *mers (eg. 9mers) around it from a aligned bam file, and translate these polymers into peptide, ideally in fasta format, so that I can make some functional predictions.
The above question that you helped solving is one step towards my goal, but there may be shortcuts.
Do you have experience in this and can you advise?
Thanks,
Gene
it's not clear to me.
Thanks Pierre, the position 129208172-129208196 has 25 bases, the reads fetched by samtools bam2fq is longer than that. So I think the sequence that I am interested should be a sub sequence of that?
I am a novice please correct me if I am wrong.
Thanks