Have you tried using samtools mpileup in.bam [in2.bam [...]]
? Here's information about the output format from the manual pageoutput format from the manual page:
The first three columns give the position and reference:
- Chromosome name.
- 1-based position on the chromosome.
- Reference base at this position (this will be “N” on all lines if -f/--fasta-ref has not been used).
The remaining columns show the pileup data, and are repeated for each input BAM file specified:
- Number of reads covering this position.
- Read bases. This encodes information on matches, mismatches, indels, strand, mapping quality, and starts and ends of reads.
This format seems nearly identical to what you've asked for, so hopefully is close enough for you to tweak your downstream analyses.