libStatGen Software  1
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 #ifdef __ZLIB_AVAILABLE__
00025     ShiftIndelsTest::testShift("testFiles/testShift.bam", "results/testShift.bam");
00026     ShiftIndelsTest::testShift("testFiles/testShift.bam", "results/testShiftFromBam.sam");
00027 #endif
00028     ShiftIndelsTest::testShift("testFiles/testShift.sam", "results/testShiftFromSam.bam");
00029 }
00030 
00031 void ShiftIndelsTest::testShift(const char* input, const char* output)
00032 {
00033     SamFile inSam, outSam;
00034 
00035     assert(inSam.OpenForRead(input));
00036     assert(outSam.OpenForWrite(output));
00037 
00038 
00039     // Read the SAM Header.
00040     SamFileHeader samHeader;
00041     assert(inSam.ReadHeader(samHeader));
00042     assert(outSam.WriteHeader(samHeader));
00043 
00044 
00045    SamRecord samRecord;
00046    int readNum = 1;
00047    bool shiftResult = true;
00048    while(inSam.ReadRecord(samHeader, samRecord))
00049    {
00050        if((readNum == 3)|| (readNum == 5))
00051        {
00052            shiftResult = false;
00053        }
00054        else
00055        {
00056            shiftResult = true;
00057        }
00058        ++readNum;
00059 
00060        assert(samRecord.shiftIndelsLeft() == shiftResult);
00061        assert(outSam.WriteRecord(samHeader, samRecord));
00062    }
00063 
00064 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends