TestSamCoordOutput.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "TestSamCoordOutput.h"
00019 #include "TestValidate.h"
00020 #include "SamCoordOutput.h"
00021 #include "SamRecordPool.h"
00022 #include <assert.h>
00023
00024 void testSamCoordOutput()
00025 {
00026
00027 SamCoordOutputTest::testSamCoordOutput();
00028 }
00029
00030
00031 void SamCoordOutputTest::testSamCoordOutput()
00032 {
00033 SamRecordPool pool(3);
00034
00035 SamCoordOutput outputBuffer(pool);
00036
00037 SamFile inSam;
00038 SamFile outSam;
00039 SamFileHeader samHeader;
00040 SamRecord* rec1 = NULL;
00041 SamRecord* rec2 = NULL;
00042 SamRecord* rec3 = NULL;
00043
00044
00045 #ifdef __ZLIB_AVAILABLE__
00046 assert(inSam.OpenForRead("testFiles/testBam.bam"));
00047 #else
00048 assert(inSam.OpenForRead("testFiles/testSam.sam"));
00049 #endif
00050 assert(inSam.ReadHeader(samHeader));
00051 validateHeader(samHeader);
00052
00053
00054 assert(!outputBuffer.add(rec1));
00055
00056
00057 rec1 = pool.getRecord();
00058 assert(inSam.ReadRecord(samHeader, *rec1) == true);
00059 validateRead1(*rec1);
00060 rec2 = pool.getRecord();
00061 assert(inSam.ReadRecord(samHeader, *rec2) == true);
00062 validateRead2(*rec2);
00063 rec3 = pool.getRecord();
00064 assert(inSam.ReadRecord(samHeader, *rec3) == true);
00065 validateRead3(*rec3);
00066 assert(pool.getRecord() == NULL);
00067
00068
00069
00070 assert(outputBuffer.add(rec1));
00071 assert(outputBuffer.add(rec2));
00072 assert(outputBuffer.add(rec3));
00073
00074
00075
00076 assert(!outputBuffer.flush(0, 100));
00077
00078
00079 outputBuffer.setOutputFile(&outSam, &samHeader);
00080
00081
00082 assert(outSam.OpenForWrite("results/TestSamCoordOutput.sam"));
00083 assert(outSam.WriteHeader(samHeader));
00084
00085
00086 rec1 = pool.getRecord();
00087 assert(inSam.ReadRecord(samHeader, *rec1) == true);
00088 validateRead4(*rec1);
00089 assert(outputBuffer.add(rec1));
00090
00091 rec1 = pool.getRecord();
00092 assert(rec1 == NULL);
00093
00094
00095
00096 assert(outputBuffer.flush(0, 1011));
00097
00098
00099 rec1 = pool.getRecord();
00100 assert(inSam.ReadRecord(samHeader, *rec1) == true);
00101 validateRead5(*rec1);
00102 assert(outputBuffer.add(rec1));
00103
00104 rec1 = pool.getRecord();
00105 assert(inSam.ReadRecord(samHeader, *rec1) == true);
00106 validateRead6(*rec1);
00107 assert(outputBuffer.add(rec1));
00108
00109
00110
00111
00112
00113 rec1 = pool.getRecord();
00114 assert(rec1 != NULL);
00115
00116
00117 assert(outputBuffer.flush(0, 1012));
00118
00119
00120 assert(inSam.ReadRecord(samHeader, *rec1) == true);
00121 validateRead7(*rec1);
00122 assert(outputBuffer.add(rec1));
00123 assert(pool.getRecord() == NULL);
00124
00125
00126 assert(outputBuffer.flush(0, -1));
00127
00128
00129 rec1 = pool.getRecord();
00130 assert(inSam.ReadRecord(samHeader, *rec1) == true);
00131 validateRead8(*rec1);
00132 assert(outputBuffer.add(rec1));
00133 assert(pool.getRecord() == NULL);
00134
00135
00136 assert(outputBuffer.flush(2, 0));
00137
00138
00139 rec1 = pool.getRecord();
00140 assert(inSam.ReadRecord(samHeader, *rec1) == true);
00141 validateRead9(*rec1);
00142 assert(outputBuffer.add(rec1));
00143 rec1 = pool.getRecord();
00144 assert(inSam.ReadRecord(samHeader, *rec1) == true);
00145 validateRead10(*rec1);
00146 assert(outputBuffer.add(rec1));
00147 assert(pool.getRecord() == NULL);
00148
00149
00150 assert(outputBuffer.flush(-1, -1));
00151 }