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;
int32_t getExpandedCigarIndexFromQueryIndex(int32_t queryIndex)
Returns the index into the expanded cigar for the cigar associated with the specified queryIndex...
static bool isMatchOrMismatch(Operation op)
Return true if the specified operation is a match/mismatch operation, false if not.
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...
insertion to the reference (the query sequence contains bases that have no corresponding base in the ...
static bool isClip(Operation op)
Return true if the specified operation is a clipping operation, false if not.
Padding (not in reference or query). Associated with CIGAR Operation "P".
static bool foundInReference(char op)
Return true if the specified operation is found in the reference sequence, false if not...
int getNumEndClips() const
Return the number of clips that are at the end of the cigar.
static bool isMatchOrMismatch(const CigarOperator &op)
Return true if the specified operation is a match/mismatch operation, false if not.
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...
skipped region from the reference (the reference contains bases that have no corresponding base in th...
no operation has been set.
static bool foundInReference(Operation 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.
static bool isClip(const CigarOperator &op)
Return true if the specified operation is a clipping operation, false if not.
int size() const
Return the number of cigar operations.
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.
static bool foundInReference(const CigarOperator &op)
Return true if the specified operation is found in the reference sequence, false if not...
int getNumBeginClips() const
Return the number of clips that are at the beginning of the cigar.
static const int32_t INDEX_NA
Value associated with an index that is not applicable/does not exist, used for converting between que...
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...
char getCigarCharOp(int32_t expandedCigarIndex)
Return the character code of the cigar operator associated with the specified expanded CIGAR index...
Hard clip on the read (clipped sequence not present in the query sequence or reference). Associated with CIGAR Operation "H".
static bool foundInQuery(Operation op)
Return true if the specified operation is found in the query sequence, false if not.
void getCigarString(String &cigarString) const
Set the passed in String to the string reprentation of the Cigar operations in this object...
This class represents the CIGAR without any methods to set the cigar (see CigarRoller for that)...
void Dump() const
Write this object as a string to cout.
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...
int32_t getRefOffset(int32_t queryIndex)
Return the reference offset associated with the specified query index or INDEX_NA based on this cigar...
char getChar() const
Get the character code (M, I, D, N, S, H, or P) associated with this operation.
static bool isClip(char op)
Return true if the specified operation is a clipping operation, false if not.
char getCigarCharOpFromRefPos(int32_t refPosition, int32_t queryStartPos)
Return the character code of the cigar operator associated with the specified reference position...
mismatch operation. Associated with CIGAR Operation "M"
bool hasIndel()
Return whether or not the cigar has indels (insertions or delections)
void getExpandedString(std::string &s) const
Sets the specified string to a valid CIGAR string of characters that represent the cigar with no digi...
int getExpectedReferenceBaseCount() const
Return the number of bases in the reference that this CIGAR "spans".
Soft clip on the read (clipped sequence present in the query sequence, but not in reference)...
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...
match/mismatch operation. Associated with CIGAR Operation "M"
Cigar()
Default constructor initializes as a CIGAR with no operations.
int32_t getQueryIndex(int32_t refOffset)
Return the query index associated with the specified reference offset or INDEX_NA based on this cigar...
deletion from the reference (the reference contains bases that have no corresponding base in the quer...
int getExpectedQueryBaseCount() const
Return the length of the read that corresponds to the current CIGAR string.
const CigarOperator & getOperator(int i) const
Return the Cigar Operation at the specified index (starting at 0).
char getCigarCharOpFromQueryIndex(int32_t queryIndex)
Return the character code of the cigar operator associated with the specified queryIndex.
char getCigarCharOpFromRefOffset(int32_t refOffset)
Return the character code of the cigar operator associated with the specified reference offset...
const CigarOperator & operator[](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.
static bool foundInQuery(const CigarOperator &op)
Return true if the specified operation is found in the query sequence, 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...