Question: How Can I Distinguish Bam File Is Produced By Bwa Or Other Program?
gravatar for Bioscientist
9.2 years ago by
Bioscientist1.7k wrote:

I've got some bam files from other people. Because I've only tried BWA (not bowtie or other things) so I just take it for granted that it's produced by BWA.

Now I highly doubt if it's produced by BWA. I'm just wondering is there any way to check if bam file is produced by BWA or other programs? (say use samtools view?)


bam samtools bwa • 2.3k views
ADD COMMENTlink written 9.2 years ago by Bioscientist1.7k
gravatar for Brad Chapman
9.2 years ago by
Brad Chapman9.5k
Boston, MA
Brad Chapman9.5k wrote:

The @PG tag in the header will tell you this:

$ samtools view -H your_file.bam | grep PG
@PG ID:bowtie2  PN:bowtie2  VN:2.0.0-beta3

The SAM specification is a great resource for details:

ADD COMMENTlink written 9.2 years ago by Brad Chapman9.5k
gravatar for Damian Kao
9.2 years ago by
Damian Kao15k
Damian Kao15k wrote:

There is no requirements in the SAM format headers to display the mapping program used. You might be able to guess what mapping program was used by looking at the optional fields in each SAM mapping line.

If you look at the manuals for bowtie ( and bwa (

Bowtie can optionally generate: NM CM MD XA XM

BWA can optionally generate: NM MD AS BC X0 X1 XN XM XO XG XT XA XS XF XE

You can see if there are any BWA specific fields in your sAM entries. But it's kind of a hack honestly.

edit*** nevermind, Brad has the answer :)

ADD COMMENTlink modified 16 months ago by _r_am32k • written 9.2 years ago by Damian Kao15k

fwiw, I marked this reply as helpful because the @PG tags are optional, and you give some good suggestions of what to look for if the info is not in the bam header.

ADD REPLYlink written 9.1 years ago by Nina380
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1677 users visited in the last hour