libStatGen Software 1
PileupElement Class Reference

This is a base class pileup component, representing the information for one reference position. More...

#include <PileupElement.h>

Inheritance diagram for PileupElement:

Public Member Functions

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

Static Public Member Functions

static void setReference (GenomeSequence *reference)
 Set the reference to use for all pilepElements. More...
 

Static Public Attributes

static const int32_t UNSET_POSITION = -1
 

Static Protected Member Functions

static GenomeSequencegetReference ()
 Get a pointer to the reference. More...
 

Detailed Description

This is a base class pileup component, representing the information for one reference position.

Child classes will be defined to detail more information that needs to be saved and how it should be analyzed.

Definition at line 26 of file PileupElement.h.

Constructor & Destructor Documentation

◆ PileupElement() [1/2]

PileupElement::PileupElement ( )

Pileup element constructor.

Definition at line 24 of file PileupElement.cpp.

25 : myRefPosition(UNSET_POSITION),
26 myChromosome("")
27{
28}

◆ PileupElement() [2/2]

PileupElement::PileupElement ( const PileupElement q)

Constructor that resets the pileup element, does not copy, just resets.

Definition at line 32 of file PileupElement.cpp.

33 : myRefPosition(UNSET_POSITION),
34 myChromosome("")
35{
36}

◆ ~PileupElement()

PileupElement::~PileupElement ( )
virtual

Pileup element destructor.

Definition at line 38 of file PileupElement.cpp.

39{
40}

Member Function Documentation

◆ addEntry()

void PileupElement::addEntry ( SamRecord record)
virtual

Add an entry to this pileup element.

Reimplemented in PileupElementBaseQual.

Definition at line 44 of file PileupElement.cpp.

45{
46 if(myChromosome.empty())
47 {
48 // First entry, save chromosme name.
49 myChromosome = record.getReferenceName();
50 }
51}
const char * getReferenceName()
Get the reference sequence name (RNAME) of the record.
Definition: SamRecord.cpp:1298

References SamRecord::getReferenceName().

Referenced by PileupElementBaseQual::addEntry().

◆ analyze()

void PileupElement::analyze ( )
virtual

Perform the analysis associated with this class.

Reimplemented in PileupElementBaseQual, and TestPileupElement.

Definition at line 57 of file PileupElement.cpp.

58{
59 if(myRefPosition != UNSET_POSITION)
60 {
61 std::cout << myChromosome << "\t" << myRefPosition << "\n";
62 }
63}

◆ getChromosome()

const char * PileupElement::getChromosome ( ) const
inline

Get the chromosome name stored in this element.

Definition at line 51 of file PileupElement.h.

51{ return(myChromosome.c_str()); }

Referenced by PileupElementBaseQual::analyze(), and TestPileupElement::analyze().

◆ getRefBase()

char PileupElement::getRefBase ( )

Returns the reference base for this pileup element.

Only works if a reference has been set, otherwise, 'N' is returned.

Definition at line 74 of file PileupElement.cpp.

75{
76 if(myRefPtr != NULL)
77 {
78 // Add 1 to pos because getBase expects 1-based index.
79 return(myRefPtr->getBase(myChromosome.c_str(), myRefPosition+1));
80 }
81 return('N');
82}
char getBase(const char *chromosomeName, unsigned int chromosomeIndex) const
given a chromosome name and 1-based position, return the reference base.

References GenomeSequence::getBase().

◆ getReference()

static GenomeSequence * PileupElement::getReference ( )
inlinestaticprotected

Get a pointer to the reference.

Definition at line 65 of file PileupElement.h.

65{ return(myRefPtr); }

◆ getRefPosition()

int32_t PileupElement::getRefPosition ( ) const
inline

Get the reference position stored in this element.

Definition at line 54 of file PileupElement.h.

54{ return(myRefPosition); }

Referenced by PileupElementBaseQual::addEntry(), PileupElementBaseQual::analyze(), and TestPileupElement::analyze().

◆ reset()

void PileupElement::reset ( int32_t  refPosition)
virtual

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

Reimplemented in PileupElementBaseQual.

Definition at line 67 of file PileupElement.cpp.

68{
69 myChromosome.clear();
70 myRefPosition = refPosition;
71}

Referenced by PileupElementBaseQual::reset().

◆ setReference()

void PileupElement::setReference ( GenomeSequence reference)
static

Set the reference to use for all pilepElements.

Definition at line 86 of file PileupElement.cpp.

87{
88 myRefPtr = reference;
89}

Member Data Documentation

◆ UNSET_POSITION

const int32_t PileupElement::UNSET_POSITION = -1
static

Definition at line 29 of file PileupElement.h.


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