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