It seems a reasonable idea to only keep good mapping reads.Īs the SAM-format contains at column 5 the \(MAPQ\) value, which we established earlier is the “MAPping Quality” in Phred-scaled, this seems easily achieved. In this section we want to sub-select reads based on the quality of the mapping. One line of a mapped read can be seen here: Variable OPTional fields in the format TAG:VTYPE:VALUE Query QUALity (ASCII-33 gives the Phred base quality) Query SEQuence on the same strand as the reference Mate Reference sequence NaMe (‘=’ if same as RNAME) ¶ġ-based leftmost POSition/coordinate of clipped sequence The columns of such a line in the mapping file are described in Table 5.1. Then, for each read, that mapped to the reference, there is one line. Have a look into the sam-file that was created by either program.Ī quick overview of the sam-format can be found here and even more information can be found here.īriefly, first there are a lot of header lines. If only positional data (refID, position, CIGAR ops, alignment flags, etc.) are required, consider using GetNextAlignmentCore() for a significant performance boost.BWA, like most mappers, will produce a mapping file in sam-format. This function fully populates all of the alignment's available data fields, including the string data fields (read name, bases, qualities, tags, filename). In this case, there is no point to continue reading, assuming properly sorted alignments. the next alignment loaded is beyond the region), the function aborts and returns false. If the actual 'next' alignment record in the BAM file does not overlap this region, then this function will read sequentially through the file until the next alignment that overlaps this region is found. If a region has been set, via Jump() or SetRegion(), an alignment is only considered valid if it overlaps the region. If no region is currently set, then the next alignment available is always considered valid. Constructor & Destructor DocumentationĪttempts to read the next alignment record from BAM file, and checks to see if it overlaps the current region. Returns a human-readable description of the last error that occurred. OpenIndex (const std::string &indexFilename) Looks in BAM file's directory for a matching index file. LocateIndex (const BamIndex::IndexType &preferredType=BamIndex::STANDARD)
Returns the ID of the reference with this name.ĬreateIndex (const BamIndex::IndexType &type=BamIndex::STANDARD)Ĭreates an index file for current BAM file. GetReferenceID (const std::string &refName) const Returns SAM header data, as SAM-formatted text. Retrieves next available alignment, without populating the alignment's string data fields. GetNextAlignmentCore ( BamAlignment &alignment) GetNextAlignment ( BamAlignment &alignment) SetRegion (const int &leftRefID, const int &leftPosition, const int &rightRefID, const int &rightPosition) Returns the internal file pointer to the first alignment record. Performs a random-access jump within BAM file.
Returns true if a BAM file is open for reading.