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 #include "PileupElement.h" 00019 00020 PileupElement::PileupElement() 00021 : myRefPosition(UNSET_POSITION), 00022 myChromosome("") 00023 { 00024 } 00025 00026 00027 PileupElement::~PileupElement() 00028 { 00029 } 00030 00031 00032 PileupElement::PileupElement(const PileupElement& q) 00033 : myRefPosition(UNSET_POSITION), 00034 myChromosome("") 00035 { 00036 00037 } 00038 00039 00040 // Add an entry to this pileup element. 00041 void PileupElement::addEntry(SamRecord& record) 00042 { 00043 if(myChromosome.empty()) 00044 { 00045 // First entry, save chromosme name. 00046 myChromosome = record.getReferenceName(); 00047 } 00048 00049 00050 } 00051 00052 00053 // Perform the alalysis associated with this class. May be a simple print, 00054 // a calculation, or something else. Typically performed when this element 00055 // has been fully populated by all records that cover the reference position. 00056 void PileupElement::analyze() 00057 { 00058 if(myRefPosition != UNSET_POSITION) 00059 { 00060 std::cout << myChromosome << "\t" << myRefPosition << "\n"; 00061 } 00062 } 00063 00064 00065 // Resets the entry, setting the new position associated with this element. 00066 void PileupElement::reset(int32_t refPosition) 00067 { 00068 myChromosome.clear(); 00069 myRefPosition = refPosition; 00070 }