Question: Get Reference file from BAM
0
gravatar for win
4.2 years ago by
win810
India
win810 wrote:

Is is possible to determine the reference file from a BAM file? I want to programatically determine the reference file that was used during alignment and use it for variant detection.

bam • 1.4k views
ADD COMMENTlink modified 4.2 years ago by donfreed1.4k • written 4.2 years ago by win810

Are you wanting to compute the content of the reference (i.e. the FASTA sequence) or just the name of the reference file?

ADD REPLYlink written 4.2 years ago by Dan D6.7k

i just need the name of the reference file so i can use it for pulling up variants.

ADD REPLYlink written 4.2 years ago by win810
3
gravatar for donfreed
4.2 years ago by
donfreed1.4k
Mountain View, CA
donfreed1.4k wrote:

Besides the @SQ header lines, the bam file header may have information on the reference used in the @PG lines. If this header line is present, you can parse it to determine the reference which was used for alignment. An example line from a BWA mem aligned bam file is below.

@PG    ID:bwa  PN:bwa  VN:0.7.9a-r788-dirty    CL:bwa mem -t 6 -R @RG\tID:foo\tSM:bar /mnt/data/reference/hs37d5.fa ../ERR194147_1.fastq.gz ../ERR194147_2.fastq.gz

Which shows that this bam file was aligned to hs37d5.fa

ADD COMMENTlink modified 4.2 years ago • written 4.2 years ago by donfreed1.4k

thanks. is there a way to extract this info programatically?

ADD REPLYlink written 4.2 years ago by win810
Please log in to add an answer.

Help
Access

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