Entering edit mode
12.9 years ago
TwoFaces
▴
10
I need to analyse a bam file with bamtools for C/C++. Can anyone help me reading the bases (A or C or G or T ) of the reads from a bam file? I also need to know the quality of bases (base quality) and reads (mapping quality), but unfortunately I have no idea how to do it.
At the moment i'm only able to open the bam file:
# include "sam.h"
int main (int argc, char *argv[])
{
bamFile bam_sorted_file;
if (argc == 2 )
{
bam_sorted_file = bam_open(argv[1], "rb");
if ( bam_sorted_file==0 )
{
cout << "Fail to open BAM file " << argv[1] << endl;
return 1;
}
bam_close(bam_sorted_file);
}
return 0;
}
thanks in advance.
thanks! I'm analyzing the code, trying to understand the functions. What is the hexadecimal code 0xff for t[0] ( if t [0] == 0xff ) and consequently the "*" ? and in either case, what is 33 showing in t [i] + 33?
thanks!!
another question: watching the type "bam1_core_t" at http://samtools.sourceforge.net/samtools/bam/index.html?Functions/Functions.html#//apple_ref/c/func/bam_write1, there is the explanation of the "strand" field, which if I understand it indicates if the filament is forward or backward ... but is not implemented in the structure bam1_core_t
if t [0] == 0xff = no data available , i+33 = quality is shifted with 33 to make it as a printable as an ASCII character.