<p>Hi everyone,</p>

<p>Is there a smart way to get all contig boundaries after assembly?
I know <a href='http://samtools.sourceforge.net/'>samtools</a> can get number of sequences covering a defined region. Then I could write a pipeline to find each contig's boundary by looking for a region flank by coverage of 0. It seems this costs a lot of time.
Is there an alternative and quicker way to know the start and end position of each contig?</p>

<p>Thanks a lot.</p>

<p>Dadi</p>

<p>You could use <strong>samtools mpileup</strong> and <strong>awk</strong> to get the contigs:</p>
<pre><code>samtools  mpileup file.bam |\
cut -d '        ' -f 1,2 |\
awk -F '        ' 'BEGIN {chr="";start=-1;end=-1} {if(chr!=$1 || int($2)!=end+1) { if(chr!="") {printf("%s:%d-%d\n",chr,start,end);} chr=$1;start=int($2);end=int($2);} else { end=end+1;}} END {if(chr!="") {printf("%s:%d-%d\n",chr,start,end); } }'
chr1:10044-10300
chr1:10330-10468
chr1:10504-10557
chr1:10585-10633
chr1:11302-11355
chr1:11594-11647
chr1:11696-11823
chr1:11827-13107
chr1:13122-13840
chr1:13874-13973
(...)
</code></pre>