21 #include "CigarRoller.h" 31 std::vector<CigarOperator>::iterator i;
32 for (i = rhs.cigarOperations.begin(); i != rhs.cigarOperations.end(); i++)
47 clearQueryAndReferenceIndexes();
53 else if (cigarOperations.empty() || cigarOperations.back() != rhs)
55 cigarOperations.push_back(rhs);
60 cigarOperations.back().count += rhs.count;
126 std::cerr <<
"ERROR " 127 <<
"(" << __FILE__ <<
":" << __LINE__ <<
"): " 128 <<
"Parsing CIGAR - invalid character found " 129 <<
"with parameter " << operation <<
" and " << count
138 int operationCount = 0;
141 if (isdigit(*cigarString))
144 operationCount = strtol((
char *) cigarString, &endPtr, 10);
145 cigarString = endPtr;
149 Add(*cigarString, operationCount);
158 if((index < 0) || ((
unsigned int)index >= cigarOperations.size()))
163 cigarOperations.erase(cigarOperations.begin() + index);
166 clearQueryAndReferenceIndexes();
173 if((index < 0) || ((
unsigned int)index >= cigarOperations.size()))
178 cigarOperations[index].count += increment;
182 clearQueryAndReferenceIndexes();
189 if((index < 0) || ((
unsigned int)index >= cigarOperations.size()))
194 cigarOperations[index].operation = op;
195 cigarOperations[index].count = count;
199 clearQueryAndReferenceIndexes();
216 for (
int i = 0; i < bufferLen; i++)
218 int opLen = cigarBuffer[i] >> 4;
220 Add(cigarBuffer[i] & 0xF, opLen);
247 std::vector<CigarOperator>::iterator i;
249 for (i = cigarOperations.begin(); i != cigarOperations.end(); i++)
251 switch (i->operation)
278 static char *ret = NULL;
279 static unsigned int retSize = 0;
283 retSize = cigarOperations.size() * 12 + 1;
284 ret = (
char*) malloc(
sizeof(
char) * retSize);
291 if (retSize > cigarOperations.size() * 12 + 1)
296 retSize = cigarOperations.size() * 12 + 1;
298 ret = (
char*) malloc(
sizeof(
char) * retSize);
306 std::vector<CigarOperator>::iterator i;
312 for (i = cigarOperations.begin(); i != cigarOperations.end(); i++)
314 sprintf(buf,
"%d%c", (*i).count, (*i).getChar());
329 clearQueryAndReferenceIndexes();
330 cigarOperations.clear();
void Set(const char *cigarString)
Sets this object to the specified cigarString.
insertion to the reference (the query sequence contains bases that have no corresponding base in the ...
Padding (not in reference or query). Associated with CIGAR Operation "P".
Operation
Enum for the cigar operations.
void Add(Operation operation, int count)
Append the specified operation with the specified count to this object.
bool Update(int index, Operation op, int count)
Updates the operation at the specified index to be the specified operation and have the specified cou...
skipped region from the reference (the reference contains bases that have no corresponding base in th...
CigarRoller & operator+=(CigarRoller &rhs)
Add the contents of the specified CigarRoller to this object.
Hard clip on the read (clipped sequence not present in the query sequence or reference). Associated with CIGAR Operation "H".
void clear()
Clear this object so that it has no Cigar Operations.
const char * getString()
Get the string reprentation of the Cigar operations in this object, caller must delete the returned v...
Soft clip on the read (clipped sequence present in the query sequence, but not in reference)...
match/mismatch operation. Associated with CIGAR Operation "M"
bool IncrementCount(int index, int increment)
Increments the count for the operation at the specified index by the specified value, specify a negative value to decrement.
deletion from the reference (the reference contains bases that have no corresponding base in the quer...
int getMatchPositionOffset()
DEPRECATED - do not use, there are better ways to accomplish that by using read lengths, reference lengths, span of the read, etc.
The purpose of this class is to provide accessors for setting, updating, modifying the CIGAR object...
CigarRoller & operator=(CigarRoller &rhs)
Set this object to be equal to the specified CigarRoller.
bool Remove(int index)
Remove the operation at the specified index.