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