20#include "CigarHelper.h"
24 int32_t refPosition0Based,
26 int32_t &new0BasedPosition)
54 int32_t readClipPosition = 0;
55 bool clipWritten =
false;
57 for(
int i = 0; i < cigar->
size(); i++)
80 new0BasedPosition += op->count;
91 if(refPosition0Based < new0BasedPosition)
94 numKeep = new0BasedPosition - refPosition0Based - 1;
96 if(numKeep > op->count)
107 readClipPosition += (op->count - numKeep);
114 new0BasedPosition -= numKeep;
120 newCigar.
Add(op->operation, numKeep);
141 else if(i == (cigar->
size() - 1))
145 if(clipWritten ==
false)
161 readClipPosition += op->count;
169 if(clipWritten ==
false)
179 return(readClipPosition - 1);
185 int32_t refPosition0Based,
215 int32_t readClipPosition = 0;
216 for(
int i = 0; i < cigar->
size(); i++)
227 currentRefPosition += op->count;
231 if(refPosition0Based < currentRefPosition)
238 numKeep = op->count - (currentRefPosition - refPosition0Based);
241 newCigar.
Add(op->operation, numKeep);
242 readClipPosition += numKeep;
248 newCigar.
Add(op->operation, op->count);
259 else if(refPosition0Based == currentRefPosition)
264 readClipPosition += op->count;
275 readClipPosition += op->count;
284 for(
int j = newCigar.
size() - 1; j >= 0; j--)
297 readClipPosition -= op->count;
308 int32_t numSoftClips = record.
getReadLength() - readClipPosition;
322 if(cigar->
size() != 0)
332 return(readClipPosition);
static int32_t softClipBeginByRefPos(SamRecord &record, int32_t refPosition0Based, CigarRoller &newCigar, int32_t &new0BasedPosition)
Soft clip the cigar from the beginning of the read at the specified reference position.
static int32_t softClipEndByRefPos(SamRecord &record, int32_t refPosition0Based, CigarRoller &newCigar)
Soft clip the cigar from the back of the read at the specified reference position.
The purpose of this class is to provide accessors for setting, updating, modifying the CIGAR object....
bool Remove(int index)
Remove the operation at the specified index.
void Add(Operation operation, int count)
Append the specified operation with the specified count to this object.
void clear()
Clear this object so that it has no Cigar Operations.
void Set(const char *cigarString)
Sets this object to the specified cigarString.
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.
static bool foundInReference(Operation op)
Return true if the specified operation is found in the reference sequence, false if not.
static bool foundInQuery(Operation op)
Return true if the specified operation is found in the query sequence, false if not.
@ hardClip
Hard clip on the read (clipped sequence not present in the query sequence or reference)....
@ softClip
Soft clip on the read (clipped sequence present in the query sequence, but not in reference)....
const CigarOperator & getOperator(int i) const
Return the Cigar Operation at the specified index (starting at 0).
static bool isClip(Operation op)
Return true if the specified operation is a clipping operation, false if not.
static void handleError(const char *message, HandlingType handlingType=EXCEPTION)
Handle an error based on the error handling type.
Class providing an easy to use interface to get/set/operate on the fields in a SAM/BAM record.
Cigar * getCigarInfo()
Returns a pointer to the Cigar object associated with this record.
int32_t getReadLength()
Get the length of the read.
int32_t get0BasedAlignmentEnd()
Returns the 0-based inclusive rightmost position of the clipped sequence.
int32_t get0BasedPosition()
Get the 0-based(BAM) leftmost position of the record.
const char * getCigar()
Returns the SAM formatted CIGAR string.