Loading...
Searching...
No Matches
PileupElementBaseQual Class Reference

This class inherits from the base class and stores base and qualities. More...

`#include <PileupElementBaseQual.h>`

Inheritance diagram for PileupElementBaseQual:
[legend]
Collaboration diagram for PileupElementBaseQual:
[legend]

## Public Member Functions

| PileupElementBaseQual (const PileupElementBaseQual &q)
virtual void | addEntry (SamRecord &record)
| Add an entry to this pileup element.
virtual void | analyze ()
| Perform the analysis associated with this class.
virtual void | reset (int32_t refPosition)
| Resets the entry, setting the new position associated with this element.
Public Member Functions inherited from PileupElement
| PileupElement ()
| Pileup element constructor.
| PileupElement (const PileupElement &q)
| Constructor that resets the pileup element, does not copy, just resets.
virtual | ~PileupElement ()
| Pileup element destructor.
const char * | getChromosome () const
| Get the chromosome name stored in this element.
int32_t | getRefPosition () const
| Get the reference position stored in this element.
char | getRefBase ()
| Returns the reference base for this pileup element.

## Additional Inherited Members

Static Public Member Functions inherited from PileupElement
static void | setReference (GenomeSequence *reference)
| Set the reference to use for all pilepElements.
Static Public Attributes inherited from PileupElement
static const int32_t | UNSET_POSITION = -1
Static Protected Member Functions inherited from PileupElement
static GenomeSequence * | getReference ()
| Get a pointer to the reference.

## Detailed Description

This class inherits from the base class and stores base and qualities.

Definition at line 25 of file PileupElementBaseQual.h.

## Constructor & Destructor Documentation

## PileupElementBaseQual() [1/2]

PileupElementBaseQual::PileupElementBaseQual | ( |  | ) |

Definition at line 22 of file PileupElementBaseQual.cpp.

: PileupElement(),
myBases(NULL),
myQualities(NULL),
myAllocatedSize(0),
myIndex(-1),
myAddDelAsBase(false)
{
myAllocatedSize = 1024;
myBases = (char*)malloc(myAllocatedSize + 1);
myQualities = (char*)malloc(myAllocatedSize + 1);
if((myBases == NULL ) || (myQualities == NULL))
{
// TODO, check for malloc failures.
std::cerr << "Failed Memory Allocation\n";
}
}
PileupElement::PileupElement
PileupElement()
Pileup element constructor.
Definition PileupElement.cpp:24

## PileupElementBaseQual() [2/2]

PileupElementBaseQual::PileupElementBaseQual | ( | const PileupElementBaseQual & | q | ) |

Definition at line 41 of file PileupElementBaseQual.cpp.

: PileupElement(),
myBases(NULL),
myQualities(NULL),
myAllocatedSize(0),
myIndex(-1)
{
myAllocatedSize = 1024;
myBases = (char*)malloc(myAllocatedSize + 1);
myQualities = (char*)malloc(myAllocatedSize + 1);
myAddDelAsBase = q.myAddDelAsBase;
if((myBases == NULL ) || (myQualities == NULL))
{
// TODO, check for malloc failures.
std::cerr << "Failed Memory Allocation\n";
}
}

## ~PileupElementBaseQual()

PileupElementBaseQual::~PileupElementBaseQual | ( |  | ) |

virtual

Definition at line 60 of file PileupElementBaseQual.cpp.

{
if(myBases != NULL)
{
free(myBases);
myBases = NULL;
}
if(myQualities != NULL)
{
free(myQualities);
myQualities = NULL;
}
}

## Member Function Documentation

## addEntry()

void PileupElementBaseQual::addEntry | ( | SamRecord & | record | ) |

virtual

Add an entry to this pileup element.

Reimplemented from PileupElement.

Definition at line 76 of file PileupElementBaseQual.cpp.

{
// Call the base class:
PileupElement::addEntry(record);
// Increment the index
++myIndex;
// if the index has gone beyond the allocated space, double the size.
if(myIndex >= myAllocatedSize)
{
char* tempBuffer = (char*)realloc(myBases, myAllocatedSize * 2);
if(tempBuffer == NULL)
{
std::cerr << "Memory Allocation Failure\n";
// TODO
return;
}
myBases = tempBuffer;
tempBuffer = (char*)realloc(myQualities, myAllocatedSize * 2);
if(tempBuffer == NULL)
{
std::cerr << "Memory Allocation Failure\n";
// TODO
return;
}
myQualities = tempBuffer;
myAllocatedSize = myAllocatedSize * 2;
}
Cigar* cigar = record.getCigarInfo();
if(cigar == NULL)
{
throw std::runtime_error("Failed to retrieve cigar info from the record.");
}
int32_t readIndex =
cigar->getQueryIndex(getRefPosition(), record.get0BasedPosition());
// If the readPosition is N/A, this is a deletion.
if(readIndex != CigarRoller::INDEX_NA)
{
char base = record.getSequence(readIndex);
char qual = record.getQuality(readIndex);
if(qual == UNSET_QUAL)
{
qual = ' ';
}
myBases[myIndex] = base;
myQualities[myIndex] = qual;
}
else if(myAddDelAsBase)
{
// This version adds deletions as bases.
myBases[myIndex] = '-';
myQualities[myIndex] = '0';
}
else
{
// Do not add a deletion.
// Did not add any entries, so decrement the index counter since the
// index was not used.
--myIndex;
}
}
Cigar
This class represents the CIGAR without any methods to set the cigar (see CigarRoller for that).
Definition Cigar.h:84
Cigar::INDEX_NA
static const int32_t INDEX_NA
Value associated with an index that is not applicable/does not exist, used for converting between que...
Definition Cigar.h:492
Cigar::getQueryIndex
int32_t getQueryIndex(int32_t refOffset)
Return the query index associated with the specified reference offset or INDEX_NA based on this cigar...
Definition Cigar.cpp:202
PileupElement::getRefPosition
int32_t getRefPosition() const
Get the reference position stored in this element.
Definition PileupElement.h:54
PileupElement::addEntry
virtual void addEntry(SamRecord &record)
Add an entry to this pileup element.
Definition PileupElement.cpp:44
SamRecord::getCigarInfo
Cigar * getCigarInfo()
Returns a pointer to the Cigar object associated with this record.
Definition SamRecord.cpp:1836
SamRecord::get0BasedPosition
int32_t get0BasedPosition()
Get the 0-based(BAM) leftmost position of the record.
Definition SamRecord.cpp:1319
SamRecord::getQuality
const char * getQuality()
Returns the SAM formatted quality string (QUAL).
Definition SamRecord.cpp:1638
SamRecord::getSequence
const char * getSequence()
Returns the SAM formatted sequence string (SEQ), translating the base as specified by setSequenceTran...
Definition SamRecord.cpp:1568

References PileupElement::addEntry(), SamRecord::get0BasedPosition(), SamRecord::getCigarInfo(), SamRecord::getQuality(), Cigar::getQueryIndex(), PileupElement::getRefPosition(), SamRecord::getSequence(), and Cigar::INDEX_NA.

## analyze()

void PileupElementBaseQual::analyze | ( |  | ) |

virtual

Perform the analysis associated with this class.

Reimplemented from PileupElement.

Reimplemented in TestPileupElement.

Definition at line 144 of file PileupElementBaseQual.cpp.

{
if(getRefPosition() != UNSET_POSITION)
{
myBases[myIndex+1] = '\0';
myQualities[myIndex+1] = '\0';
std::cout << getChromosome() << "\t" << getRefPosition() << "\tN\t" << myIndex+1 << "\t";
std::cout << myBases << "\t";
std::cout << myQualities;
std::cout << "\n";
}
}
PileupElement::getChromosome
const char * getChromosome() const
Get the chromosome name stored in this element.
Definition PileupElement.h:51

References PileupElement::getChromosome(), and PileupElement::getRefPosition().

## reset()

void PileupElementBaseQual::reset | ( | int32_t | refPosition | ) |

virtual

Resets the entry, setting the new position associated with this element.

Reimplemented from PileupElement.

Definition at line 157 of file PileupElementBaseQual.cpp.

{
// Call the base class.
PileupElement::reset(refPosition);
myIndex = -1;
}
PileupElement::reset
virtual void reset(int32_t refPosition)
Resets the entry, setting the new position associated with this element.
Definition PileupElement.cpp:67

References PileupElement::reset().

The documentation for this class was generated from the following files:

- bam/PileupElementBaseQual.h
- bam/PileupElementBaseQual.cpp