Thanks. Is there a way to extract this info programmatically?
• 0 views
•
link
Is is possible to determine the reference file from a BAM file? I want to programmatically determine the reference file that was used during alignment and use it for variant detection.
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
Thanks. Is there a way to extract this info programmatically?
Log in to answer this question.
Are you wanting to compute the content of the reference (i.e. the FASTA sequence) or just the name of the reference file?
I just need the name of the reference file so I can use it for pulling up variants.