ShiftIndels.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
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 }