<p>Hello everyone!<br />
I am trying to learn more about the SAM/BAM format and how reads are mapped to the genome.<br />
I understand that reads can be mapped to the forward (sense) and reverse (antisense) strand.<br />
I understand that in every read pair there is a first-in-pair and a second-in-pair read - and that this probably has something to do with the order in which they came off the sequencer and not the position in the genome? (but maybe im wrong)<br />
I understand that weird things can happen. A pair of reads can map millions of base pairs apart. Both reads can map to the same strand. But can reads map in both upstream and downstream direction - i.e. the read sequence once reversed (but not reversed complimented) was mapped.<br />
<br />
With three variables thats 32 different combinations for paired reads (and another 4 for singletons).<br />
With two variables, there&#39;s only 8 different combinations (and 2 for singletons)<br />
Regardless, does anyone know of any tool available which will give you the statistics for the 32+4 or 8+2 combinations in your BAM file? If not, i will add it to the new version of metaflagstat.<br />
<br />
Here&#39;s a picture of what i&#39;m trying to explain :)</p>

<p><img alt="" src="http://ac.gt/example.png" /></p>

I was planning on posting this along with the two programs that uses these read types (a QC program which counts these read types, and a pileup tool (like bedtools, etc) where you can filter on read type - but since they're a long way from being published I'll just post the list for now :)

EDIT: I should add that the formula on the right are also not 100% true. I fell into the trap of assuming the read end is the read start plus the length of the sequence. Its not - you have to parse the CIGAR string. So wherever you see `len(SEQ)`, that really means `len(of_all_the_mapped_and_skipped_bases)`. But that didn't fit. Also the variable PSEQ doesn't exist, which means some values cannot be calculated without knowing the mate's read data too.

<img alt="" src="http://i.imgur.com/DCMrtwe.jpg" style="height:1052px; width:800px" />