ShiftIndels.cpp

00001 /*
00002  *  Copyright (C) 2011  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 "ShiftIndels.h"
00019 #include "SamFile.h"
00020 
00021 void testShiftIndels()
00022 {
00023     ShiftIndelsTest::testShift("testFiles/testShift.sam", "results/testShift.sam");
00024     ShiftIndelsTest::testShift("testFiles/testShift.bam", "results/testShift.bam");
00025     ShiftIndelsTest::testShift("testFiles/testShift.bam", "results/testShiftFromBam.sam");
00026     ShiftIndelsTest::testShift("testFiles/testShift.sam", "results/testShiftFromSam.bam");
00027 }
00028 
00029 void ShiftIndelsTest::testShift(const char* input, const char* output)
00030 {
00031     SamFile inSam, outSam;
00032 
00033     assert(inSam.OpenForRead(input));
00034     assert(outSam.OpenForWrite(output));
00035 
00036 
00037     // Read the SAM Header.
00038     SamFileHeader samHeader;
00039     assert(inSam.ReadHeader(samHeader));
00040     assert(outSam.WriteHeader(samHeader));
00041 
00042 
00043    SamRecord samRecord;
00044    int readNum = 1;
00045    bool shiftResult = true;
00046    while(inSam.ReadRecord(samHeader, samRecord))
00047    {
00048        if((readNum == 3)|| (readNum == 5))
00049        {
00050            shiftResult = false;
00051        }
00052        else
00053        {
00054            shiftResult = true;
00055        }
00056        ++readNum;
00057 
00058        assert(samRecord.shiftIndelsLeft() == shiftResult);
00059        assert(outSam.WriteRecord(samHeader, samRecord));
00060    }
00061 
00062 }
Generated on Tue Sep 6 17:52:00 2011 for libStatGen Software by  doxygen 1.6.3