libStatGen Software
1
|
This class represents the CIGAR without any methods to set the cigar (see CigarRoller for that). More...
#include <Cigar.h>
Classes | |
struct | CigarOperator |
Public Types | |
enum | Operation { none =0 , match , mismatch , insert , del , skip , softClip , hardClip , pad } |
Enum for the cigar operations. More... | |
Public Member Functions | |
Cigar () | |
Default constructor initializes as a CIGAR with no operations. | |
void | getCigarString (String &cigarString) const |
Set the passed in String to the string reprentation of the Cigar operations in this object. | |
void | getCigarString (std::string &cigarString) const |
Set the passed in std::string to the string reprentation of the Cigar operations in this object. | |
void | getExpandedString (std::string &s) const |
Sets the specified string to a valid CIGAR string of characters that represent the cigar with no digits (a CIGAR of "3M" would return "MMM"). More... | |
const CigarOperator & | operator[] (int i) const |
Return the Cigar Operation at the specified index (starting at 0). | |
const CigarOperator & | getOperator (int i) const |
Return the Cigar Operation at the specified index (starting at 0). | |
bool | operator== (Cigar &rhs) const |
Return true if the 2 Cigars are the same (the same operations of the same sizes). | |
int | size () const |
Return the number of cigar operations. | |
void | Dump () const |
Write this object as a string to cout. | |
int | getExpectedQueryBaseCount () const |
Return the length of the read that corresponds to the current CIGAR string. More... | |
int | getExpectedReferenceBaseCount () const |
Return the number of bases in the reference that this CIGAR "spans". More... | |
int | getNumBeginClips () const |
Return the number of clips that are at the beginning of the cigar. | |
int | getNumEndClips () const |
Return the number of clips that are at the end of the cigar. | |
int32_t | getRefOffset (int32_t queryIndex) |
Return the reference offset associated with the specified query index or INDEX_NA based on this cigar. | |
int32_t | getQueryIndex (int32_t refOffset) |
Return the query index associated with the specified reference offset or INDEX_NA based on this cigar. | |
int32_t | getRefPosition (int32_t queryIndex, int32_t queryStartPos) |
Return the reference position associated with the specified query index or INDEX_NA based on this cigar and the specified queryStartPos which is the leftmost mapping position of the first matching base in the query. | |
int32_t | getQueryIndex (int32_t refPosition, int32_t queryStartPos) |
Return the query index or INDEX_NA associated with the specified reference offset when the query starts at the specified reference position. | |
int32_t | getExpandedCigarIndexFromQueryIndex (int32_t queryIndex) |
Returns the index into the expanded cigar for the cigar associated with the specified queryIndex. More... | |
int32_t | getExpandedCigarIndexFromRefOffset (int32_t refOffset) |
Returns the index into the expanded cigar for the cigar associated with the specified reference offset. More... | |
int32_t | getExpandedCigarIndexFromRefPos (int32_t refPosition, int32_t queryStartPos) |
Returns the index into the expanded cigar for the cigar associated with the specified reference position and queryStartPos. More... | |
char | getCigarCharOp (int32_t expandedCigarIndex) |
Return the character code of the cigar operator associated with the specified expanded CIGAR index. More... | |
char | getCigarCharOpFromQueryIndex (int32_t queryIndex) |
Return the character code of the cigar operator associated with the specified queryIndex. More... | |
char | getCigarCharOpFromRefOffset (int32_t refOffset) |
Return the character code of the cigar operator associated with the specified reference offset. More... | |
char | getCigarCharOpFromRefPos (int32_t refPosition, int32_t queryStartPos) |
Return the character code of the cigar operator associated with the specified reference position. More... | |
uint32_t | getNumOverlaps (int32_t start, int32_t end, int32_t queryStartPos) |
Return the number of bases that overlap the reference and the read associated with this cigar that falls within the specified region. More... | |
bool | hasIndel () |
Return whether or not the cigar has indels (insertions or delections) More... | |
Static Public Member Functions | |
static bool | foundInReference (Operation op) |
Return true if the specified operation is found in the reference sequence, false if not. | |
static bool | foundInReference (char op) |
Return true if the specified operation is found in the reference sequence, false if not. | |
static bool | foundInReference (const CigarOperator &op) |
Return true if the specified operation is found in the reference sequence, false if not. | |
static bool | foundInQuery (Operation op) |
Return true if the specified operation is found in the query sequence, false if not. | |
static bool | foundInQuery (char op) |
Return true if the specified operation is found in the query sequence, false if not. | |
static bool | foundInQuery (const CigarOperator &op) |
Return true if the specified operation is found in the query sequence, false if not. | |
static bool | isClip (Operation op) |
Return true if the specified operation is a clipping operation, false if not. | |
static bool | isClip (char op) |
Return true if the specified operation is a clipping operation, false if not. | |
static bool | isClip (const CigarOperator &op) |
Return true if the specified operation is a clipping operation, false if not. | |
static bool | isMatchOrMismatch (Operation op) |
Return true if the specified operation is a match/mismatch operation, false if not. | |
static bool | isMatchOrMismatch (const CigarOperator &op) |
Return true if the specified operation is a match/mismatch operation, false if not. | |
Static Public Attributes | |
static const int | MAX_OP_VALUE = pad |
static const int32_t | INDEX_NA = -1 |
Value associated with an index that is not applicable/does not exist, used for converting between query and reference indexes/offsets when an associated index/offset does not exist. | |
Protected Member Functions | |
void | clearQueryAndReferenceIndexes () |
void | setQueryAndReferenceIndexes () |
Protected Attributes | |
std::vector< CigarOperator > | cigarOperations |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const Cigar &cigar) |
Writes all of the cigar operations contained in the cigar to the passed in stream. | |
This class represents the CIGAR without any methods to set the cigar (see CigarRoller for that).
This class represents the CIGAR. It contains methods for converting to strings and extracting information from the cigar on how a read maps to the reference.
It only contains read only methods. There are no ways to set values. To set a value, a child class must be used.
enum Cigar::Operation |
Enum for the cigar operations.
Definition at line 87 of file Cigar.h.
char Cigar::getCigarCharOp | ( | int32_t | expandedCigarIndex | ) |
Return the character code of the cigar operator associated with the specified expanded CIGAR index.
'?' is returned for an out of range index.
Definition at line 295 of file Cigar.cpp.
Referenced by getCigarCharOpFromQueryIndex(), getCigarCharOpFromRefOffset(), and getCigarCharOpFromRefPos().
char Cigar::getCigarCharOpFromQueryIndex | ( | int32_t | queryIndex | ) |
Return the character code of the cigar operator associated with the specified queryIndex.
'?' is returned for an out of range index.
Definition at line 314 of file Cigar.cpp.
References getCigarCharOp(), and getExpandedCigarIndexFromQueryIndex().
char Cigar::getCigarCharOpFromRefOffset | ( | int32_t | refOffset | ) |
Return the character code of the cigar operator associated with the specified reference offset.
'?' is returned for an out of range offset.
Definition at line 320 of file Cigar.cpp.
References getCigarCharOp(), and getExpandedCigarIndexFromRefOffset().
char Cigar::getCigarCharOpFromRefPos | ( | int32_t | refPosition, |
int32_t | queryStartPos | ||
) |
Return the character code of the cigar operator associated with the specified reference position.
'?' is returned for an out of range reference position.
Definition at line 326 of file Cigar.cpp.
References getCigarCharOp(), and getExpandedCigarIndexFromRefPos().
int32_t Cigar::getExpandedCigarIndexFromQueryIndex | ( | int32_t | queryIndex | ) |
Returns the index into the expanded cigar for the cigar associated with the specified queryIndex.
INDEX_NA returned if the index is out of range.
Definition at line 258 of file Cigar.cpp.
References INDEX_NA.
Referenced by getCigarCharOpFromQueryIndex().
int32_t Cigar::getExpandedCigarIndexFromRefOffset | ( | int32_t | refOffset | ) |
Returns the index into the expanded cigar for the cigar associated with the specified reference offset.
INDEX_NA returned if the offset is out of range.
Definition at line 273 of file Cigar.cpp.
References INDEX_NA.
Referenced by getCigarCharOpFromRefOffset(), and getExpandedCigarIndexFromRefPos().
int32_t Cigar::getExpandedCigarIndexFromRefPos | ( | int32_t | refPosition, |
int32_t | queryStartPos | ||
) |
Returns the index into the expanded cigar for the cigar associated with the specified reference position and queryStartPos.
INDEX_NA returned if the position is out of range.
Definition at line 288 of file Cigar.cpp.
References getExpandedCigarIndexFromRefOffset().
Referenced by getCigarCharOpFromRefPos().
void Cigar::getExpandedString | ( | std::string & | s | ) | const |
Sets the specified string to a valid CIGAR string of characters that represent the cigar with no digits (a CIGAR of "3M" would return "MMM").
The returned string is actually also a valid CIGAR string. In theory this makes it easier to parse some reads.
Definition at line 63 of file Cigar.cpp.
int Cigar::getExpectedQueryBaseCount | ( | ) | const |
Return the length of the read that corresponds to the current CIGAR string.
For validation, we should expect that a sequence read in a SAM file will be the same length as the value returned by this method.
Example: 3M2D3M describes a read with three bases matching the reference, then skips 2 bases, then has three more bases that match the reference (match/mismatch). In this case, the read length is expected to be 6.
Example: 3M2I3M describes a read with 3 match/mismatch bases, two extra bases, and then 3 more match/mistmatch bases. The total in this example is 8 bases.
Definition at line 95 of file Cigar.cpp.
References insert, match, mismatch, and softClip.
Referenced by SamValidator::isValidCigar(), and SamFilter::softClip().
int Cigar::getExpectedReferenceBaseCount | ( | ) | const |
Return the number of bases in the reference that this CIGAR "spans".
When doing range checking, we occassionally need to know how many total bases the CIGAR string represents as compared to the reference.
Examples: 3M2D3M describes a read that overlays 8 bases in the reference. 3M2I3M describes a read with 3 bases that match the reference, two additional bases that aren't in the reference, and 3 more bases that match the reference, so it spans 6 bases in the reference.
Definition at line 120 of file Cigar.cpp.
References del, match, mismatch, and skip.
Referenced by SamTags::createMDTag().
uint32_t Cigar::getNumOverlaps | ( | int32_t | start, |
int32_t | end, | ||
int32_t | queryStartPos | ||
) |
Return the number of bases that overlap the reference and the read associated with this cigar that falls within the specified region.
start | : inclusive 0-based start position (reference position) of the region to check for overlaps in (-1 indicates to start at the beginning of the reference.) |
end | : exclusive 0-based end position (reference position) of the region to check for overlaps in (-1 indicates to go to the end of the reference.) |
queryStartPos | : 0-based leftmost mapping position of the first matcihng base in the query. |
Definition at line 334 of file Cigar.cpp.
References getRefOffset().
Referenced by SamRecord::getNumOverlaps().
bool Cigar::hasIndel | ( | ) |