Modify.cpp

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 "SamFile.h"
00019 #include "Modify.h"
00020 
00021 void testModify()
00022 {
00023     modify modTest;
00024     modTest.testModify("testFiles/testSam.sam");
00025     modTest.testModify("testFiles/testBam.bam");
00026 }
00027 
00028 
00029 void modify::testModify(const char* filename)
00030 {
00031     myFilename = filename;
00032 
00033     modifyPosition();
00034     modifyCigar();
00035 }
00036 
00037 void modify::modifyPosition()
00038 {
00039     openAndRead1Rec();
00040    
00041     // Verify the initial bin.
00042     assert(samRecord.getBin() == 4681);
00043 
00044     // Change the position and verify that the bin is updated.
00045     assert(samRecord.set0BasedPosition(33768));
00046 
00047     // Verify the bin was updated.
00048     assert(samRecord.getBin() == 4683);
00049     assert(samRecord.get0BasedPosition() == 33768);
00050 }
00051 
00052 
00053 void modify::modifyCigar()
00054 {
00055     openAndRead1Rec();
00056    
00057     // Verify the initial bin.
00058     assert(samRecord.getBin() == 4681);
00059 
00060     // Change the Cigar such that it modifies the bin.
00061     assert(samRecord.setCigar("33768M"));
00062 
00063     // Verify the bin was updated.
00064     assert(samRecord.getBin() == 585);
00065 }
00066 
00067 
00068 void modify::openAndRead1Rec()
00069 {
00070     // Open the file for reading.   
00071     assert(samIn.OpenForRead(myFilename));
00072 
00073     // Read the sam header.
00074     assert(samIn.ReadHeader(samHeader));
00075    
00076     // Read the first record.   
00077     assert(samIn.ReadRecord(samHeader, samRecord));
00078 }
Generated on Wed Nov 17 15:38:27 2010 for StatGen Software by  doxygen 1.6.3