libStatGen Software
1
|
00001 /* 00002 * Copyright (C) 2012 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 "TestSamRecordHelper.h" 00019 #include "TestValidate.h" 00020 #include "SamRecordHelper.h" 00021 #include <assert.h> 00022 00023 void testSamRecordHelper() 00024 { 00025 // Call generic test. 00026 SamRecordHelperTest::testSamRecordHelper("testFiles/testSam.sam"); 00027 // SamRecordHelperTest::testSamRecordHelper("testFiles/testBam.bam"); 00028 } 00029 00030 00031 void SamRecordHelperTest::testSamRecordHelper(const char* fileName) 00032 { 00033 SamFile inSam; 00034 assert(inSam.OpenForRead(fileName)); 00035 SamFileHeader samHeader; 00036 assert(inSam.ReadHeader(samHeader)); 00037 validateHeader(samHeader); 00038 00039 SamRecord samRecord; 00040 assert(inSam.ReadRecord(samHeader, samRecord) == true); 00041 validateRead1(samRecord); 00042 00043 // Validate the entire sequence matches. 00044 assert(SamRecordHelper::checkSequence(samRecord, 00045 TestValidate::READ1_POS, 00046 TestValidate::READ1_SEQ.c_str()) == 0); 00047 00048 // The read start position is 1010. 00049 // The sequence is CCGAA. 00050 assert(SamRecordHelper::checkSequence(samRecord, 1010, "CCGAA") == 0); 00051 00052 // Test not matching. 00053 assert(SamRecordHelper::checkSequence(samRecord, 1010, "NNNNN") == -1); 00054 00055 // Test match, but not at the start. 00056 assert(SamRecordHelper::checkSequence(samRecord, 1011, "CGA") == 1); 00057 00058 // Test match not at the start, but to the end. 00059 assert(SamRecordHelper::checkSequence(samRecord, 1011, "CGAA") == 1); 00060 00061 // Test run over the end. 00062 assert(SamRecordHelper::checkSequence(samRecord, 1011, "CGAAC") == -1); 00063 00064 } 00065 00066