20 #include "PileupElementBaseQual.h"
22 PileupElementBaseQual::PileupElementBaseQual()
30 myAllocatedSize = 1024;
31 myBases = (
char*)malloc(myAllocatedSize + 1);
32 myQualities = (
char*)malloc(myAllocatedSize + 1);
33 if((myBases == NULL ) || (myQualities == NULL))
36 std::cerr <<
"Failed Memory Allocation\n";
48 myAllocatedSize = 1024;
49 myBases = (
char*)malloc(myAllocatedSize + 1);
50 myQualities = (
char*)malloc(myAllocatedSize + 1);
51 myAddDelAsBase = q.myAddDelAsBase;
52 if((myBases == NULL ) || (myQualities == NULL))
55 std::cerr <<
"Failed Memory Allocation\n";
60 PileupElementBaseQual::~PileupElementBaseQual()
67 if(myQualities != NULL)
85 if(myIndex >= myAllocatedSize)
87 char* tempBuffer = (
char*)realloc(myBases, myAllocatedSize * 2);
88 if(tempBuffer == NULL)
90 std::cerr <<
"Memory Allocation Failure\n";
95 tempBuffer = (
char*)realloc(myQualities, myAllocatedSize * 2);
96 if(tempBuffer == NULL)
98 std::cerr <<
"Memory Allocation Failure\n";
102 myQualities = tempBuffer;
103 myAllocatedSize = myAllocatedSize * 2;
110 throw std::runtime_error(
"Failed to retrieve cigar info from the record.");
122 if(qual == UNSET_QUAL)
126 myBases[myIndex] = base;
127 myQualities[myIndex] = qual;
129 else if(myAddDelAsBase)
132 myBases[myIndex] =
'-';
133 myQualities[myIndex] =
'0';
148 myBases[myIndex+1] =
'\0';
149 myQualities[myIndex+1] =
'\0';
151 std::cout << myBases <<
"\t";
152 std::cout << myQualities;
This class represents the CIGAR without any methods to set the cigar (see CigarRoller for that).
static const int32_t INDEX_NA
Value associated with an index that is not applicable/does not exist, used for converting between que...
int32_t getQueryIndex(int32_t refOffset)
Return the query index associated with the specified reference offset or INDEX_NA based on this cigar...
This class inherits from the base class and stores base and qualities.
virtual void reset(int32_t refPosition)
Resets the entry, setting the new position associated with this element.
virtual void analyze()
Perform the analysis associated with this class.
virtual void addEntry(SamRecord &record)
Add an entry to this pileup element.
This is a base class pileup component, representing the information for one reference position.
int32_t getRefPosition() const
Get the reference position stored in this element.
const char * getChromosome() const
Get the chromosome name stored in this element.
virtual void addEntry(SamRecord &record)
Add an entry to this pileup element.
virtual void reset(int32_t refPosition)
Resets the entry, setting the new position associated with this element.
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 get0BasedPosition()
Get the 0-based(BAM) leftmost position of the record.
const char * getQuality()
Returns the SAM formatted quality string (QUAL).
const char * getSequence()
Returns the SAM formatted sequence string (SEQ), translating the base as specified by setSequenceTran...