TestFilter.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "TestFilter.h"
00019 #include "TestValidate.h"
00020 #include "SamFilter.h"
00021 #include <assert.h>
00022
00023 void testFilter()
00024 {
00025
00026
00027 FilterTest::testFilter(FilterTest::SAM);
00028 #ifdef __ZLIB_AVAILABLE__
00029 FilterTest::testFilter(FilterTest::BAM);
00030 #endif
00031 }
00032
00033
00034 void FilterTest::testFilter(FileType inputType)
00035 {
00036 SamFile inSam;
00037
00038 if(inputType == SAM)
00039 {
00040 assert(inSam.OpenForRead("testFiles/testSam.sam"));
00041 }
00042 else
00043 {
00044 assert(inSam.OpenForRead("testFiles/testBam.bam"));
00045 }
00046
00047
00048 SamFileHeader samHeader;
00049 assert(inSam.ReadHeader(samHeader));
00050 validateHeader(samHeader);
00051
00052 SamRecord samRecord;
00053 assert(inSam.ReadRecord(samHeader, samRecord) == true);
00054 validateRead1(samRecord);
00055
00056
00057
00058 assert(SamFilter::softClip(samRecord, 2, 2) == SamFilter::CLIPPED);
00059 assert(samRecord.get0BasedPosition() == TestValidate::READ1_POS + 2);
00060 std::string expectedCigar = "2S1M2S";
00061 assert(samRecord.getCigar() == expectedCigar);
00062 assert(samRecord.getSequence() == TestValidate::READ1_SEQ);
00063 assert(samRecord.getQuality() == TestValidate::READ1_QUAL);
00064
00065 assert(samRecord.get0BasedAlignmentEnd() == TestValidate::READ1_POS + 2);
00066 assert(samRecord.getAlignmentLength() == 1);
00067 assert(samRecord.get0BasedUnclippedStart() == TestValidate::READ1_UNCLIP_START);
00068
00069
00070 assert(samRecord.get0BasedUnclippedEnd() == TestValidate::READ1_UNCLIP_END - 2);
00071
00072
00073 assert(inSam.ReadRecord(samHeader, samRecord) == true);
00074 validateRead2(samRecord);
00075
00076 assert(inSam.ReadRecord(samHeader, samRecord) == true);
00077 validateRead3(samRecord);
00078
00079 assert(inSam.ReadRecord(samHeader, samRecord) == true);
00080 validateRead4(samRecord);
00081
00082 assert(inSam.ReadRecord(samHeader, samRecord) == true);
00083 validateRead5(samRecord);
00084
00085 assert(inSam.ReadRecord(samHeader, samRecord) == true);
00086 validateRead6(samRecord);
00087
00088
00089 assert(SamFilter::softClip(samRecord, 5, 2) == SamFilter::CLIPPED);
00090 assert(samRecord.get0BasedPosition() == TestValidate::READ6_POS + 2);
00091 expectedCigar = "2H5S1M2S";
00092 assert(samRecord.getCigar() == expectedCigar);
00093 assert(samRecord.getSequence() == TestValidate::READ6_SEQ);
00094 assert(samRecord.getQuality() == TestValidate::READ6_QUAL);
00095
00096 assert(samRecord.get0BasedAlignmentEnd() == TestValidate::READ6_POS + 2);
00097 assert(samRecord.getAlignmentLength() == 1);
00098 assert(samRecord.get0BasedUnclippedStart() == TestValidate::READ6_UNCLIP_START);
00099 assert(samRecord.get0BasedUnclippedEnd() == TestValidate::READ6_UNCLIP_END);
00100
00101 assert(inSam.ReadRecord(samHeader, samRecord) == true);
00102 validateRead7(samRecord);
00103
00104
00105 assert(SamFilter::softClip(samRecord, 5, 3) == SamFilter::CLIPPED);
00106 assert(samRecord.get0BasedPosition() == TestValidate::READ7_POS + 2);
00107 expectedCigar = "5S1M3S3H";
00108 assert(samRecord.getCigar() == expectedCigar);
00109 assert(samRecord.getSequence() == TestValidate::READ7_SEQ);
00110 assert(samRecord.getQuality() == TestValidate::READ7_QUAL);
00111
00112 assert(samRecord.get0BasedAlignmentEnd() == TestValidate::READ7_POS + 2);
00113 assert(samRecord.getAlignmentLength() == 1);
00114 assert(samRecord.get0BasedUnclippedStart() == TestValidate::READ7_UNCLIP_START);
00115 assert(samRecord.get0BasedUnclippedEnd() == TestValidate::READ7_UNCLIP_END);
00116
00117 assert(inSam.ReadRecord(samHeader, samRecord) == true);
00118 validateRead8(samRecord);
00119
00120 assert(inSam.ReadRecord(samHeader, samRecord) == true);
00121 validateRead9(samRecord);
00122
00123 assert(inSam.ReadRecord(samHeader, samRecord) == true);
00124 validateRead10(samRecord);
00125 }
00126