Dear Biostars,

Could I please know, If there is some way to view the reads in BAM file according to user defined Insert Size range. I would like to visualize all the reads falling between certain Insert Size ranges, not all the reads.

Your ideas and resources would help me a lot. Thanks in advance.

~Prakki Rama.
<p>This is a hack but it might be good enough? Parse the input bam to extract alignments within a given *template* size range, here between 0 and 200:</p>

<pre>
<code>samtools view -h read.pe.bam \
| awk &#39;{if (($0 ~ /^@/) || (sqrt($9^2) &gt; 0 &amp;&amp; sqrt($9^2) &lt; 200)) {print $0}}&#39; \
| samtools view -Sb - &gt; insert.bam &amp;&amp;</code>
<code>samtools index insert.bam</code></pre>

<p>Now load <code>insert.bam</code> in your favourite browser.</p>
