<p>I am using 'bwa' to map Illumina reads to a large database and would like to be able to store (and analyse) the information on multiple hits. I have forced this very brutishly using the following:</p>

<pre><code>bwa samse -n 1000 database.fasta aln_sa.sai reads.fasta &gt; aln_1000.sam
</code></pre>

<p>However, the output is no longer in <a href="http://samtools.sourceforge.net/SAM1.pdf">classical .sam</a> format (<em>i.e.</em> no flags, no CIGAR string, ...). Would someone know how to force a real .sam output?</p>

<p>Just as an example, here is the kind of output I get:</p>

<pre><code>&gt;1-815511 3 3
bta-mir-21    +8    0
mRNA___ENSBTAG00000029897|ENSBTAT00000042276|bta-mir-21|bta-mir-21    +18    0
19    +11033079    0
&gt;2-592417 3 3
bta-mir-21    +8    0
mRNA___ENSBTAG00000029897|ENSBTAT00000042276|bta-mir-21|bta-mir-21    +18    0
19    +11033079    0
...
</code></pre>

<p>What I have tried so far with no luck:</p>

<ul>
<li>use the <a href="http://sourceforge.net/mailarchive/forum.php?thread_name=BANLkTi=8_H74NUU%2bFa2vd-kR8DzMJSq%2bxQ@mail.gmail.com&amp;forum_name=bio-bwa-help">xa2multi.pl</a> script which parses the information in the XA:Z: (information on other hits when their number is inferior to the value of the -n option) to output one line per hit -- this scripts is now part of the 'bwa' package.</li>
</ul>

<p>Unfortunately, the output of a normal:</p>

<pre><code>bwa samse database.fasta aln_sa.sai reads.fasta &gt; aln.sam
</code></pre>

<p>does not contain any XA:Z: field... Even for read 2-592417 which has several hits:</p>

<pre><code>1-815511    0    mRNA___ENSBTAG00000029897|ENSBTAT00000042276|bta-mir-21|bta-mir-21    18    0    23M    *    0    0    TAGCTTATCAGACTGATGTTGAC    *    XT:A:R    NM:i:0    X0:i:3    X1:i:0    XM:i:0    XO:i:0    XG:i:0    MD:Z:23
2-592417    0    19    11033079    0    22M    *    0    0    TAGCTTATCAGACTGATGTTGA    *    XT:A:R    NM:i:0    X0:i:3    X1:i:0    XM:i:0    XO:i:0    XG:i:0MD:Z:22
</code></pre>

<ul>
<li>install the previous <a href="http://sourceforge.net/projects/bio-bwa/files/">bwa-0.5.7</a> version for which a patch doing exactly what I need has been developed at <a href="http://sourceforge.net/mailarchive/forum.php?thread_name=DA517199-F188-4C11-9F85-FEC38BA869E2@sanger.ac.uk&amp;forum_name=bio-bwa-help">Broad Institute</a>. But the patch has vanished from its ftp site and is now unavailable.</li>
</ul>

<p>Any ideas?</p>

<p>Thanks to Istvan's suggestion, in the latest bwa version, the output is in a fully populated SAM file (XA:Z: field is now present). I just then run the xa2multi.pl on it to obtain one hit per line.</p>
