libStatGen Software  1
PileupElement.h
00001 /*
00002  *  Copyright (C) 2010  Regents of the University of Michigan
00003  *
00004  *   This program is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef __PILEUP_ELEMENT_H__
00019 #define __PILEUP_ELEMENT_H__
00020 
00021 #include "SamRecord.h"
00022 
00023 /// This is a base class pileup component, representing the information
00024 /// for one reference position.  Child classes will be defined to detail more
00025 /// information that needs to be saved and how it should be analyzed.
00026 class PileupElement
00027 {
00028 public:
00029     static const int32_t UNSET_POSITION = -1;
00030 
00031     /// Pileup element constructor.
00032     PileupElement();
00033 
00034     /// Constructor that resets the pileup element, does not copy, just resets.
00035     PileupElement(const PileupElement& q);
00036 
00037     /// Pileup element destructor.
00038     virtual ~PileupElement();
00039 
00040 
00041     /// Add an entry to this pileup element.  
00042     virtual void addEntry(SamRecord& record);
00043 
00044     /// Perform the analysis associated with this class.
00045     virtual void analyze();
00046 
00047     /// Resets the entry, setting the new position associated with this element.
00048     virtual void reset(int32_t refPosition);
00049     
00050     /// Get the chromosome name stored in this element.
00051     const char* getChromosome() const { return(myChromosome.c_str()); }
00052 
00053     /// Get the reference position stored in this element.
00054     int32_t getRefPosition()  const { return(myRefPosition); }
00055 
00056     /// Returns the reference base for this pileup element.
00057     /// Only works if a reference has been set, otherwise, 'N' is returned.
00058     char getRefBase();
00059 
00060     /// Set the reference to use for all pilepElements.
00061     static void setReference(GenomeSequence* reference);
00062 
00063 protected:
00064     /// Get a pointer to the reference.
00065     static GenomeSequence* getReference() { return(myRefPtr); }
00066 
00067 private:
00068     int32_t myRefPosition;
00069     std::string myChromosome;
00070     static GenomeSequence* myRefPtr;
00071 };
00072 
00073 
00074 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends