Line 1: |
Line 1: |
− | = CigarRoller= | + | = Cigar= |
| This class is part of [[C++ Library: libcsg|libcsg]]. | | This class is part of [[C++ Library: libcsg|libcsg]]. |
| | | |
− | This purpose of this class is to provide utilities for creating and processing CIGAR strings. | + | This purpose of this class is to provide utilities for processing CIGARs. It has read-only operators that do not allow modification to the class other than for lazy-evaluation. |
| | | |
| == Public Methods == | | == Public Methods == |
Line 9: |
Line 9: |
| ! Method Name !! Description | | ! Method Name !! Description |
| |- | | |- |
− | | <code>CigarRoller::CigarRoller()</code> | + | | <code>Cigar::Cigar()</code> |
| | Default constructor initializes as a CIGAR with no operations. | | | Default constructor initializes as a CIGAR with no operations. |
| |- | | |- |
− | | <code>CigarRoller::CigarRoller(const char *cigarString)</code> | + | | <code>void Cigar::getCigarString(String& cigarString)</code> |
− | | Constructor that initializes the object with the specified cigarString. | + | | Sets the passed in String to the string representation of this CIGAR object. |
− | |-
| |
− | | <code>CigarRoller & CigarRoller::operator += (CigarRoller &rhs)</code>
| |
− | | Add the contents of the specified CigarRoller to this object.
| |
− | |-
| |
− | | <code>CigarRoller & CigarRoller::operator += (CigarOperator &rhs)</code>
| |
− | | Append the specified cigar operation to this object.
| |
− | |-
| |
− | | <code>void CigarRoller::Add(Operation operation, int count)</code>
| |
− | | Adds the specified operation with the specified count to this object.
| |
− | |-
| |
− | | <code>void CigarRoller::Add(const char *cigarString)</code>
| |
− | | Adds the specified cigarString to this object.
| |
| |- | | |- |
− | | <code>void CigarRoller::Set(const char *cigarString)</code> | + | | <code>void Cigar::getExpandedString(std::string &s)</code> |
− | | Sets this object to the specified cigarString.
| |
− | |-
| |
− | | ''' DEPRECATED''' <code>int CigarRoller::getMatchPositionOffset()</code>
| |
− | | DO NOT USE.
| |
− | |-
| |
− | | <code>const char * CigarRoller::getString()</code>
| |
− | | Returns the string representation of this CIGAR object.
| |
− | |-
| |
− | | <code>void CigarRoller::getExpandedString(std::string &s)</code>
| |
| | Sets the specified string to a string of characters that represent this cigar with no digits (a CIGAR of "3M" would return "MMM") | | | Sets the specified string to a string of characters that represent this cigar with no digits (a CIGAR of "3M" would return "MMM") |
| |- | | |- |
− | | <code>void CigarRoller::clear()</code>
| + | | <code>CigarOperator & Cigar::operator [] (int i)</code> |
− | | Clear this object so that it has 0 Cigar Operations.
| |
− | |-
| |
− | | <code>CigarOperator & CigarRoller::operator [] (int i)</code> | |
| | Return the Cigar Operation at the specified index (starting at 0). | | | Return the Cigar Operation at the specified index (starting at 0). |
| |- | | |- |
− | | <code>bool CigarRoller::operator == (CigarRoller &rhs)</code> | + | | <code>bool Cigar::operator == (CigarRoller &rhs)</code> |
− | | Returns true if two Cigar Rollers are the same (the same operations of the same sizes) | + | | Returns true if two Cigars are the same (the same operations of the same sizes) |
| |- | | |- |
− | | <code>int CigarRoller::size()</code> | + | | <code>int Cigar::size()</code> |
| | Return the number of cigar operations in this object. | | | Return the number of cigar operations in this object. |
| |- | | |- |
− | | <code>void CigarRoller::Dump()</code> | + | | <code>void Cigar::Dump()</code> |
| | Write this object as a string to cout. | | | Write this object as a string to cout. |
| |- | | |- |
− | | <code>int CigarRoller::getExpectedQueryBaseCount()</code> | + | | <code>int Cigar::getExpectedQueryBaseCount()</code> |
| | Returns the expected read length | | | Returns the expected read length |
| |- | | |- |
− | | <code>int CigarRoller::getExpectedReferenceBaseCount()</code> | + | | <code>int Cigar::getExpectedReferenceBaseCount()</code> |
| | Return how many bases in the reference are spanned by the given CIGAR string | | | Return how many bases in the reference are spanned by the given CIGAR string |
| |- | | |- |
− | | <code>int32_t CigarRoller::getRefOffset(int32_t queryIndex)</code> | + | | <code>int Cigar::getNumBeginClips()</code> |
| + | | Return the number of clips that are at the beginning of the cigar. |
| + | |- |
| + | | <code>int Cigar::getNumEndClips()</code> |
| + | | Return the number of clips that are at the end of the cigar. |
| + | |- |
| + | | <code>int32_t Cigar::getRefOffset(int32_t queryIndex)</code> |
| |Return the reference offset associated with the specified query index or INDEX_NA based on this cigar. | | |Return the reference offset associated with the specified query index or INDEX_NA based on this cigar. |
| See [[C++ Class: CigarRoller#Mapping Between Reference and Read/Query|Mapping Between Reference and Read/Query]] for a more detailed explanation with examples as to how it works. | | See [[C++ Class: CigarRoller#Mapping Between Reference and Read/Query|Mapping Between Reference and Read/Query]] for a more detailed explanation with examples as to how it works. |
| |- | | |- |
− | | <code>int32_t CigarRoller::getQueryIndex(int32_t refOffset)</code> | + | | <code>int32_t Cigar::getQueryIndex(int32_t refOffset)</code> |
| | Return the query index associated with the specified reference offset or INDEX_NA based on this cigar. | | | Return the query index associated with the specified reference offset or INDEX_NA based on this cigar. |
| See [[C++ Class: CigarRoller#Mapping Between Reference and Read/Query|Mapping Between Reference and Read/Query]] for a more detailed explanation with examples as to how it works. | | See [[C++ Class: CigarRoller#Mapping Between Reference and Read/Query|Mapping Between Reference and Read/Query]] for a more detailed explanation with examples as to how it works. |
| |- | | |- |
− | | <code>int32_t CigarRoller::getRefPosition(int32_t queryIndex, int32_t queryStartPos)</code> | + | | <code>int32_t Cigar::getRefPosition(int32_t queryIndex, int32_t queryStartPos)</code> |
| |Return the reference position associated with the specified query index or INDEX_NA based on this cigar and the specified queryStartPos. | | |Return the reference position associated with the specified query index or INDEX_NA based on this cigar and the specified queryStartPos. |
| queryStartPops is the leftmost mapping position of the first matching base in the query. | | queryStartPops is the leftmost mapping position of the first matching base in the query. |
Line 74: |
Line 56: |
| See [[C++ Class: CigarRoller#Mapping Between Reference and Read/Query|Mapping Between Reference and Read/Query]] for a more detailed explanation with examples as to how it works. | | See [[C++ Class: CigarRoller#Mapping Between Reference and Read/Query|Mapping Between Reference and Read/Query]] for a more detailed explanation with examples as to how it works. |
| |- | | |- |
− | | <code>int32_t CigarRoller::getQueryIndex(int32_t refPosition, int32_t queryStartPos)</code> | + | | <code>int32_t Cigar::getQueryIndex(int32_t refPosition, int32_t queryStartPos)</code> |
| | Return the query index associated with the specified reference position and queryStartPos or INDEX_NA based on this cigar. | | | Return the query index associated with the specified reference position and queryStartPos or INDEX_NA based on this cigar. |
| queryStartPops is the leftmost mapping position of the first matching base in the query. | | queryStartPops is the leftmost mapping position of the first matching base in the query. |
Line 80: |
Line 62: |
| See [[C++ Class: CigarRoller#Mapping Between Reference and Read/Query|Mapping Between Reference and Read/Query]] for a more detailed explanation with examples as to how it works. | | See [[C++ Class: CigarRoller#Mapping Between Reference and Read/Query|Mapping Between Reference and Read/Query]] for a more detailed explanation with examples as to how it works. |
| |- | | |- |
− | | <code>uint32_t getNumOverlaps(int32_t start, int32_t end, int32_t queryStartPos)</code> | + | | <code>uint32_t Cigar::getNumOverlaps(int32_t start, int32_t end, int32_t queryStartPos)</code> |
| | Return the number of bases that overlap the reference and the read associated with this cigar that falls within the specified region. | | | Return the number of bases that overlap the reference and the read associated with this cigar that falls within the specified region. |
| start : inclusive start position (reference position) of the region to check for overlaps in. (-1 indicates to start at the beginning of the reference.) | | start : inclusive start position (reference position) of the region to check for overlaps in. (-1 indicates to start at the beginning of the reference.) |
Line 100: |
Line 82: |
| ! Method Name !! Description | | ! Method Name !! Description |
| |- | | |- |
− | | <code> std::ostream &operator << (std::ostream &stream, const CigarRoller& roller)</code> | + | | <code> std::ostream &operator << (std::ostream &stream, const Cigar& cigar)</code> |
− | | Writes all of the cigar operations contained in this roller to the passed in stream. | + | | Writes all of the cigar operations contained in the cigar to the passed in stream. |
| |- | | |- |
− | | <code> std::ostream &operator << (std::ostream &stream, const CigarRoller::CigarOperator& o)</code> | + | | <code> std::ostream &operator << (std::ostream &stream, const Cigar::CigarOperator& o)</code> |
| | Writes the specified cigar operation to the specified stream as <count><char> (3M). | | | Writes the specified cigar operation to the specified stream as <count><char> (3M). |
| |} | | |} |
Line 188: |
Line 170: |
| | | |
| | | |
− | == Mapping Between Reference and Read/Query == | + | = CigarRoller= |
− | <code>int32_t CigarRoller::getRefOffset(int32_t queryIndex)</code> and <code>int32_t CigarRoller::getQueryIndex(int32_t refOffset)</code> are used to map between the reference and the read. | + | This class is part of [[C++ Library: libcsg|libcsg]]. |
| + | |
| + | The purpose of this class is to provide accessors for setting, updating, modifying the CIGAR object. It is a child class of Cigar. |
| + | |
| + | == Public Methods == |
| + | {| style="margin: 1em 1em 1em 0; background-color: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" border="1" |
| + | |-style="background: #f2f2f2; text-align: center;" |
| + | ! Method Name !! Description |
| + | |- |
| + | | <code>CigarRoller::CigarRoller()</code> |
| + | | Default constructor initializes as a CIGAR with no operations. |
| + | |- |
| + | | <code>CigarRoller::CigarRoller(const char *cigarString)</code> |
| + | | Constructor that initializes the object with the specified cigarString. |
| + | |- |
| + | | <code>CigarRoller & CigarRoller::operator += (CigarRoller &rhs)</code> |
| + | | Add the contents of the specified CigarRoller to this object. |
| + | |- |
| + | | <code>CigarRoller & CigarRoller::operator += (CigarOperator &rhs)</code> |
| + | | Append the specified cigar operation to this object. |
| + | |- |
| + | | <code>void CigarRoller::Add(Operation operation, int count)</code> |
| + | | Adds the specified operation with the specified count to this object. |
| + | |- |
| + | | <code>void CigarRoller::Add(const char *cigarString)</code> |
| + | | Adds the specified cigarString to this object. |
| + | |- |
| + | | <code>void CigarRoller::Add(CigarRoller &rhs)</code> |
| + | | Adds the specified CIGAR to this object. |
| + | |- |
| + | | <code>void CigarRoller::Set(const char *cigarString)</code> |
| + | | Sets this object to the specified cigarString. |
| + | |- |
| + | | <code>void CigarRoller::Set(const uint32_t* cigarBuffer, uint16_t bufferLen)</code> |
| + | | Sets this object to the BAM formatted cigar found at the beginning of the specified buffer which is bufferLen long. |
| + | |- |
| + | | ''' DEPRECATED''' <code>int CigarRoller::getMatchPositionOffset()</code> |
| + | | DO NOT USE. |
| + | |- |
| + | | <code>const char * CigarRoller::getString()</code> |
| + | | Returns the string representation of this CIGAR object. |
| + | |- |
| + | | <code>void CigarRoller::clear()</code> |
| + | | Clear this object so that it has 0 Cigar Operations. |
| + | |} |
| + | |
| + | |
| + | == Overloaded Streaming Operators == |
| + | {| style="margin: 1em 1em 1em 0; background-color: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" border="1" |
| + | |-style="background: #f2f2f2; text-align: center;" |
| + | ! Method Name !! Description |
| + | |- |
| + | | <code> std::ostream &operator << (std::ostream &stream, const CigarRoller& roller)</code> |
| + | | Writes all of the cigar operations contained in this roller to the passed in stream. |
| + | |} |
| + | |
| + | |
| + | = Mapping Between Reference and Read/Query = |
| + | <code>int32_t Cigar::getRefOffset(int32_t queryIndex)</code> and <code>int32_t Cigar::getQueryIndex(int32_t refOffset)</code> are used to map between the reference and the read. |
| | | |
| The queryIndex is the index in the read - from 0 to (read length - 1). | | The queryIndex is the index in the read - from 0 to (read length - 1). |
Line 233: |
Line 273: |
| | | |
| | | |
− | === Determining the Number of Reference and Read/Query Overlaps ===
| + | == Determining the Number of Reference and Read/Query Overlaps == |
| | | |
| A useful concept is determining the number of bases that overlap between the reference and the read in a given region. | | A useful concept is determining the number of bases that overlap between the reference and the read in a given region. |