Loading...
Searching...
No Matches
PileupElement.cpp
/*
* Copyright (C) 2010 Regents of the University of Michigan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PileupElement.h"
GenomeSequence* PileupElement::myRefPtr = NULL;
PileupElement::PileupElement()
: myRefPosition(UNSET_POSITION),
myChromosome("")
{
}
// NOTE that this method does not actually copy, it just resets.
PileupElement::PileupElement(const PileupElement& q)
: myRefPosition(UNSET_POSITION),
myChromosome("")
{
}
PileupElement::~PileupElement()
{
}
// Add an entry to this pileup element.
void PileupElement::addEntry(SamRecord& record)
{
if(myChromosome.empty())
{
// First entry, save chromosme name.
myChromosome = record.getReferenceName();
}
}
// Perform the alalysis associated with this class. May be a simple print,
// a calculation, or something else. Typically performed when this element
// has been fully populated by all records that cover the reference position.
void PileupElement::analyze()
{
if(myRefPosition != UNSET_POSITION)
{
std::cout << myChromosome << "\t" << myRefPosition << "\n";
}
}
// Resets the entry, setting the new position associated with this element.
void PileupElement::reset(int32_t refPosition)
{
myChromosome.clear();
myRefPosition = refPosition;
}
char PileupElement::getRefBase()
{
if(myRefPtr != NULL)
{
// Add 1 to pos because getBase expects 1-based index.
return(myRefPtr->getBase(myChromosome.c_str(), myRefPosition+1));
}
return('N');
}
// Resets the entry, setting the new position associated with this element.
void PileupElement::setReference(GenomeSequence* reference)
{
myRefPtr = reference;
}
GenomeSequence
Create/Access/Modify/Load Genome Sequences stored as binary mapped files.
Definition GenomeSequence.h:100
GenomeSequence::getBase
char getBase(const char *chromosomeName, unsigned int chromosomeIndex) const
given a chromosome name and 1-based position, return the reference base.
Definition GenomeSequence.h:388
PileupElement
This is a base class pileup component, representing the information for one reference position.
Definition PileupElement.h:27
PileupElement::setReference
static void setReference(GenomeSequence *reference)
Set the reference to use for all pilepElements.
Definition PileupElement.cpp:86
PileupElement::PileupElement
PileupElement()
Pileup element constructor.
Definition PileupElement.cpp:24
PileupElement::addEntry
virtual void addEntry(SamRecord &record)
Add an entry to this pileup element.
Definition PileupElement.cpp:44
PileupElement::analyze
virtual void analyze()
Perform the analysis associated with this class.
Definition PileupElement.cpp:57
PileupElement::~PileupElement
virtual ~PileupElement()
Pileup element destructor.
Definition PileupElement.cpp:38
PileupElement::reset
virtual void reset(int32_t refPosition)
Resets the entry, setting the new position associated with this element.
Definition PileupElement.cpp:67
PileupElement::getRefBase
char getRefBase()
Returns the reference base for this pileup element.
Definition PileupElement.cpp:74
SamRecord
Class providing an easy to use interface to get/set/operate on the fields in a SAM/BAM record.
Definition SamRecord.h:52
SamRecord::getReferenceName
const char * getReferenceName()
Get the reference sequence name (RNAME) of the record.
Definition SamRecord.cpp:1298