18 #if !defined(_CIGAR_H)
36 #include "StringBasics.h"
101 static const int MAX_OP_VALUE =
pad;
119 : operation(operation), count(count) {};
155 if (operation==rhs.operation)
165 return !((*this) == rhs) ;
293 return(
isClip(op.operation));
323 friend std::ostream &
operator << (std::ostream &stream,
const Cigar& cigar);
328 clearQueryAndReferenceIndexes();
350 return cigarOperations[i];
356 return cigarOperations[i];
366 return cigarOperations.size();
374 std::cout << cigarString ;
432 int32_t
getRefPosition(int32_t queryIndex, int32_t queryStartPos);
437 int32_t
getQueryIndex(int32_t refPosition, int32_t queryStartPos);
453 int32_t queryStartPos);
483 uint32_t
getNumOverlaps(int32_t start, int32_t end, int32_t queryStartPos);
496 void clearQueryAndReferenceIndexes();
499 void setQueryAndReferenceIndexes();
502 std::vector<CigarOperator> cigarOperations;
509 std::vector<int32_t> queryToRef;
515 std::vector<int32_t> refToQuery;
521 std::vector<int32_t> refToCigar;
527 std::vector<int32_t> queryToCigar;
529 std::string myExpandedCigar;
535 stream << o.count << o.
getChar();
542 stream << cigar.cigarOperations;
static bool foundInQuery(const CigarOperator &op)
Return true if the specified operation is found in the query sequence, false if not.
This class represents the CIGAR without any methods to set the cigar (see CigarRoller for that).
Operation
Enum for the cigar operations.
bool operator==(const CigarOperator &rhs) const
Compare only on the operator, true if they are the same, false if not. Match and mismatch are conside...
static bool isClip(Operation op)
Return true if the specified operation is a clipping operation, false if not.
int32_t getExpandedCigarIndexFromRefOffset(int32_t refOffset)
Returns the index into the expanded cigar for the cigar associated with the specified reference offse...
static bool isMatchOrMismatch(Operation op)
Return true if the specified operation is a match/mismatch operation, false if not.
@ pad
Padding (not in reference or query). Associated with CIGAR Operation "P".
friend std::ostream & operator<<(std::ostream &stream, const Cigar &cigar)
Writes all of the cigar operations contained in the cigar to the passed in stream.
@ none
no operation has been set.
@ insert
insertion to the reference (the query sequence contains bases that have no corresponding base in the ...
int getNumEndClips() const
Return the number of clips that are at the end of the cigar.
static bool foundInReference(char op)
Return true if the specified operation is found in the reference sequence, false if not.
@ hardClip
Hard clip on the read (clipped sequence not present in the query sequence or reference)....
static bool isMatchOrMismatch(const CigarOperator &op)
Return true if the specified operation is a match/mismatch operation, false if not.
void getCigarString(String &cigarString) const
Set the passed in String to the string reprentation of the Cigar operations in this object.
static const int32_t INDEX_NA
Value associated with an index that is not applicable/does not exist, used for converting between que...
static bool isClip(const CigarOperator &op)
Return true if the specified operation is a clipping operation, false if not.
void Dump() const
Write this object as a string to cout.
static bool foundInReference(Operation 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(char op)
Return true if the specified operation is found in the query sequence, false if not.
@ match
match/mismatch operation. Associated with CIGAR Operation "M"
@ skip
skipped region from the reference (the reference contains bases that have no corresponding base in th...
@ softClip
Soft clip on the read (clipped sequence present in the query sequence, but not in reference)....
char getCigarCharOp(int32_t expandedCigarIndex)
Return the character code of the cigar operator associated with the specified expanded CIGAR index.
static bool foundInQuery(Operation op)
Return true if the specified operation is found in the query sequence, false if not.
int size() const
Return the number of cigar operations.
int getExpectedReferenceBaseCount() const
Return the number of bases in the reference that this CIGAR "spans".
int getNumBeginClips() const
Return the number of clips that are at the beginning of the cigar.
bool operator==(Cigar &rhs) const
Return true if the 2 Cigars are the same (the same operations of the same sizes).
static bool isClip(char op)
Return true if the specified operation is a clipping operation, false if not.
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 fa...
bool operator!=(const CigarOperator &rhs) const
Compare only on the operator, false if they are the same, true if not. Match and mismatch are conside...
char getChar() const
Get the character code (M, I, D, N, S, H, or P) associated with this operation.
Cigar()
Default constructor initializes as a CIGAR with no operations.
@ mismatch
mismatch operation. Associated with CIGAR Operation "M"
char getCigarCharOpFromRefPos(int32_t refPosition, int32_t queryStartPos)
Return the character code of the cigar operator associated with the specified reference position.
int32_t getQueryIndex(int32_t refOffset)
Return the query index associated with the specified reference offset or INDEX_NA based on this cigar...
bool hasIndel()
Return whether or not the cigar has indels (insertions or delections)
@ del
deletion from the reference (the reference contains bases that have no corresponding base in the quer...
int32_t getExpandedCigarIndexFromRefPos(int32_t refPosition, int32_t queryStartPos)
Returns the index into the expanded cigar for the cigar associated with the specified reference posit...
int32_t getRefOffset(int32_t queryIndex)
Return the reference offset associated with the specified query index or INDEX_NA based on this cigar...
void getExpandedString(std::string &s) const
Sets the specified string to a valid CIGAR string of characters that represent the cigar with no digi...
char getCigarCharOpFromQueryIndex(int32_t queryIndex)
Return the character code of the cigar operator associated with the specified queryIndex.
const CigarOperator & operator[](int i) const
Return the Cigar Operation at the specified index (starting at 0).
char getCigarCharOpFromRefOffset(int32_t refOffset)
Return the character code of the cigar operator associated with the specified reference offset.
int32_t getExpandedCigarIndexFromQueryIndex(int32_t queryIndex)
Returns the index into the expanded cigar for the cigar associated with the specified queryIndex.
int getExpectedQueryBaseCount() const
Return the length of the read that corresponds to the current CIGAR string.
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 cig...
const CigarOperator & getOperator(int i) const
Return the Cigar Operation at the specified index (starting at 0).
CigarOperator(Operation operation, uint32_t count)
Set the cigar operator with the specified operation and count length.