ReadFiles.cpp
/*
* Copyright (C) 2010 Regents of the University of Michigan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ReadFiles.h"
#include "TestValidate.h"
#include "SamTags.h"
#include <assert.h>
void testReadSam()
{
SamFile inSam;
assert(inSam.OpenForRead("testFiles/testSam.sam"));
// Call generic test which since the sam and bam are identical, should
// contain the same results.
testRead(inSam);
inSam.Close();
testFlagRead("testFiles/testSam.sam");
}
void testReadBam()
{
SamFile inSam;
assert(inSam.OpenForRead("testFiles/testBam.bam"));
// Call generic test which since the sam and bam are identical, should
// contain the same results.
testRead(inSam);
inSam.Close();
testFlagRead("testFiles/testBam.bam");
}
void testRead(SamFile &inSam)
{
// Read the SAM Header.
SamFileHeader samHeader;
assert(inSam.ReadHeader(samHeader));
validateHeader(samHeader);
testCopyHeader(samHeader);
testModHeader(samHeader);
SamRecord samRecord;
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead1(samRecord);
// Set a new quality and get the buffer.
samRecord.setQuality("ABCDE");
validateRead1ModQuality(samRecord);
// void* buffer = samRecord.getRecordBuffer();
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead2(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead3(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead4(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead5(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead6(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead7(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead8(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead9(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead10(samRecord);
}
void testAddHeaderAndTagToFile(const char* inputName, const char* outputName)
{
SamFile inSam, outSam;
assert(inSam.OpenForRead(inputName));
assert(outSam.OpenForWrite(outputName));
// Read the SAM Header.
SamFileHeader samHeader;
assert(inSam.ReadHeader(samHeader));
// Add a header line.
assert(samHeader.addHeaderLine("@RG\tID:myID\tSM:mySM") == false);
assert(samHeader.addHeaderLine("@RG\tID:myID3\tSM:mySM") == true);
// Write Header
assert(outSam.WriteHeader(samHeader));
SamRecord samRecord;
assert(inSam.ReadRecord(samHeader, samRecord));
// validateRead1(samRecord);
// Add two tags.
assert(samRecord.addIntTag("XA", 123));
assert(samRecord.addIntTag("XA", 456));
assert(samRecord.addTag("RR", 'Z', "myID1"));
assert(samRecord.addTag("RR", 'Z', "myID2"));
// Write as Sam.
assert(outSam.WriteRecord(samHeader, samRecord));
// TODO, add test to verify it was written correctly.
// Read a couple of records to make sure it properly can read them even
// if they are bigger than the original.
assert(inSam.ReadRecord(samHeader, samRecord));
assert(inSam.ReadRecord(samHeader, samRecord));
// Check the MD tag, which requires the reference.
GenomeSequence reference("testFiles/chr1_partial.fa");
assert(SamTags::isMDTagCorrect(samRecord, reference) == false);
String newMDTag;
SamTags::createMDTag(newMDTag, samRecord, reference);
assert(newMDTag == "2T1N0");
assert(SamTags::updateMDTag(samRecord, reference));
// Write as Sam.
assert(outSam.WriteRecord(samHeader, samRecord));
}
// Test reading a file, validating it is sorted.
void testValidateSortedRead()
{
// Open a file for reading.
SamFile inSam(ErrorHandler::RETURN);
assert(inSam.OpenForRead("testFiles/testSam.sam"));
// Set the validation to COORDINATE.
inSam.setSortedValidation(SamFile::COORDINATE);
// Read the SAM Header.
SamFileHeader samHeader;
assert(inSam.ReadHeader(samHeader));
SamRecord samRecord;
// Succeed, first record.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead1(samRecord);
// Succeed, higher coordinate.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead2(samRecord);
// Failed sort order - due to coord.
assert(inSam.ReadRecord(samHeader, samRecord) == false);
validateRead3(samRecord);
// Failed sort order - due to coord.
assert(inSam.ReadRecord(samHeader, samRecord) == false);
validateRead4(samRecord);
// Succeed, new reference id
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead5(samRecord);
// Fail, previous reference id.
assert(inSam.ReadRecord(samHeader, samRecord) == false);
validateRead6(samRecord);
// Succeed, same reference id, higher coord.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead7(samRecord);
// Succeed, *, new reference id.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead8(samRecord);
// Fail, reference id is not *
assert(inSam.ReadRecord(samHeader, samRecord) == false);
validateRead9(samRecord);
// Succeed, valid reference id, and no coordinate.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead10(samRecord);
////////////////////////////////////////////
// Reopen the file for reading
assert(inSam.OpenForRead("testFiles/testSam.sam"));
// Set the validation to QUERY_NAME.
inSam.setSortedValidation(SamFile::QUERY_NAME);
// Read the SAM Header.
assert(inSam.ReadHeader(samHeader));
// Succeed, first record.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead1(samRecord);
// Succeed, same name.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead2(samRecord);
// Succeeds - numeric sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead3(samRecord);
// Succeeds - numeric sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead4(samRecord);
// Succeeds - numeric sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead5(samRecord);
// Succeeds - numeric sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead6(samRecord);
// Succeeds - numeric sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead7(samRecord);
// Succeed - std sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead8(samRecord);
// Succeed - numeric sort (Y<18)
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead9(samRecord);
// Succeed - std sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead10(samRecord);
////////////////////////////////////////////
// Reopen the file for reading
assert(inSam.OpenForRead("testFiles/testSam.sam"));
// Set the validation to the SO Flag. Not set, so it is UNSORTED, so
// all reads should pass.
inSam.setSortedValidation(SamFile::FLAG);
// Read the SAM Header.
assert(inSam.ReadHeader(samHeader));
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead1(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead2(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead3(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead4(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead5(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead6(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead7(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead8(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead9(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead10(samRecord);
////////////////////////////////////////////
// Reopen for reading SO FLAG set to coordinate.
assert(inSam.OpenForRead("testFiles/testSamSOcoord.sam"));
// Set the validation to SO FLAG which is set to coordinate.
inSam.setSortedValidation(SamFile::FLAG);
// Read the SAM Header.
assert(inSam.ReadHeader(samHeader));
// Succeed, first record.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead1(samRecord);
// Succeed, higher coordinate.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead2(samRecord);
// Failed sort order - due to coord.
assert(inSam.ReadRecord(samHeader, samRecord) == false);
validateRead3(samRecord);
// Failed sort order - due to coord.
assert(inSam.ReadRecord(samHeader, samRecord) == false);
validateRead4(samRecord);
// Succeed, new reference id
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead5(samRecord);
// Fail, previous reference id.
assert(inSam.ReadRecord(samHeader, samRecord) == false);
validateRead6(samRecord);
// Succeed, same reference id, higher coord.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead7(samRecord);
// Succeed, *, new reference id.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead8(samRecord);
// Fail, reference id is not *
assert(inSam.ReadRecord(samHeader, samRecord) == false);
validateRead9(samRecord);
// Succeed, valid reference id, and no coordinate.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead10(samRecord);
////////////////////////////////////////////
// Reopen the file for reading
assert(inSam.OpenForRead("testFiles/testSamSOquery.sam"));
// Set the validation to FLAG, SO set to queryname.
inSam.setSortedValidation(SamFile::FLAG);
// Read the SAM Header.
assert(inSam.ReadHeader(samHeader));
// Succeed, first record.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead1(samRecord);
// Succeed, same name.
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead2(samRecord);
// Succeeds - numeric sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead3(samRecord);
// Succeeds - numeric sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead4(samRecord);
// Succeeds - numeric sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead5(samRecord);
// Succeeds - numeric sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead6(samRecord);
// Succeeds - numeric sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead7(samRecord);
// Succeed - std sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead8(samRecord);
// Succeed - numeric sort (Y<18)
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead9(samRecord);
// Succeed - std sort
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead10(samRecord);
////////////////////////////////////////////
// Reopen the file for reading, SO flag set to junk.
assert(inSam.OpenForRead("testFiles/testSamSOinvalid.sam"));
// Set the validation to the SO Flag. Not set to anything valid,
// so it is considered UNSORTED, so all reads should pass.
inSam.setSortedValidation(SamFile::FLAG);
// Read the SAM Header.
assert(inSam.ReadHeader(samHeader));
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead1(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead2(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead3(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead4(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead5(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead6(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead7(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead8(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead9(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead10(samRecord);
}
void validateRead1ModQuality(SamRecord& samRecord)
{
//////////////////////////////////////////
// Validate Record 1
// Create record structure for validating.
int expectedBlockSize = 89;
const char* expectedReferenceName = "1";
const char* expectedMateReferenceName = "1";
const char* expectedMateReferenceNameOrEqual = "=";
bamRecordStruct* expectedRecordPtr =
(bamRecordStruct *) malloc(expectedBlockSize + sizeof(int));
char tag[3];
char type;
void* value;
bamRecordStruct* bufferPtr;
unsigned char* varPtr;
expectedRecordPtr->myBlockSize = expectedBlockSize;
expectedRecordPtr->myReferenceID = 0;
expectedRecordPtr->myPosition = 1010;
expectedRecordPtr->myReadNameLength = 23;
expectedRecordPtr->myMapQuality = 0;
expectedRecordPtr->myBin = 4681;
expectedRecordPtr->myCigarLength = 2;
expectedRecordPtr->myFlag = 73;
expectedRecordPtr->myReadLength = 5;
expectedRecordPtr->myMateReferenceID = 0;
expectedRecordPtr->myMatePosition = 1010;
expectedRecordPtr->myInsertSize = 0;
// Check the alignment end
assert(samRecord.get0BasedAlignmentEnd() == 1016);
assert(samRecord.get1BasedAlignmentEnd() == 1017);
assert(samRecord.getAlignmentLength() == 7);
assert(samRecord.get0BasedUnclippedStart() == 1010);
assert(samRecord.get1BasedUnclippedStart() == 1011);
assert(samRecord.get0BasedUnclippedEnd() == 1016);
assert(samRecord.get1BasedUnclippedEnd() == 1017);
// Check the accessors.
assert(samRecord.getBlockSize() == expectedRecordPtr->myBlockSize);
assert(samRecord.getReferenceID() == expectedRecordPtr->myReferenceID);
assert(strcmp(samRecord.getReferenceName(), expectedReferenceName) == 0);
assert(samRecord.get1BasedPosition() == expectedRecordPtr->myPosition + 1);
assert(samRecord.get0BasedPosition() == expectedRecordPtr->myPosition);
assert(samRecord.getReadNameLength() ==
expectedRecordPtr->myReadNameLength);
assert(samRecord.getMapQuality() == expectedRecordPtr->myMapQuality);
assert(samRecord.getBin() == expectedRecordPtr->myBin);
assert(samRecord.getCigarLength() == expectedRecordPtr->myCigarLength);
assert(samRecord.getFlag() == expectedRecordPtr->myFlag);
assert(samRecord.getReadLength() == expectedRecordPtr->myReadLength);
assert(samRecord.getMateReferenceID() ==
expectedRecordPtr->myMateReferenceID);
assert(strcmp(samRecord.getMateReferenceName(),
expectedMateReferenceName) == 0);
assert(strcmp(samRecord.getMateReferenceNameOrEqual(),
expectedMateReferenceNameOrEqual) == 0);
assert(samRecord.get1BasedMatePosition() ==
expectedRecordPtr->myMatePosition + 1);
assert(samRecord.get0BasedMatePosition() ==
expectedRecordPtr->myMatePosition);
assert(samRecord.getInsertSize() == expectedRecordPtr->myInsertSize);
assert(strcmp(samRecord.getReadName(), "1:1011:F:255+17M15D20M") == 0);
assert(strcmp(samRecord.getCigar(), "5M2D") == 0);
assert(strcmp(samRecord.getSequence(), "CCGAA") == 0);
assert(strcmp(samRecord.getQuality(), "ABCDE") == 0);
assert(samRecord.getNumOverlaps(1010, 1017) == 5);
assert(samRecord.getNumOverlaps(1010, 1016) == 5);
assert(samRecord.getNumOverlaps(1012, 1017) == 3);
assert(samRecord.getNumOverlaps(1015, 1017) == 0);
assert(samRecord.getNumOverlaps(1017, 1010) == 0);
assert(samRecord.getNumOverlaps(1013, 1011) == 0);
assert(samRecord.getNumOverlaps(-1, 1017) == 5);
// Reset the tag iter, since the tags have already been read.
samRecord.resetTagIter();
// Check the tags.
assert(samRecord.getNextSamTag(tag, type, &value) == true);
assert(tag[0] == 'A');
assert(tag[1] == 'M');
assert(type == 'i');
assert(*(char*)value == 0);
assert(samRecord.getNextSamTag(tag, type, &value) == true);
assert(tag[0] == 'M');
assert(tag[1] == 'D');
assert(type == 'Z');
assert(*(String*)value == "37");
assert(samRecord.getNextSamTag(tag, type, &value) == true);
assert(tag[0] == 'N');
assert(tag[1] == 'M');
assert(type == 'i');
assert(*(char*)value == 0);
assert(samRecord.getNextSamTag(tag, type, &value) == true);
assert(tag[0] == 'X');
assert(tag[1] == 'T');
assert(type == 'A');
assert(*(char*)value == 'R');
// No more tags, should return false.
assert(samRecord.getNextSamTag(tag, type, &value) == false);
assert(samRecord.getNextSamTag(tag, type, &value) == false);
// Get the record ptr.
bufferPtr = (bamRecordStruct*)samRecord.getRecordBuffer();
// Validate the buffers match.
assert(bufferPtr->myBlockSize == expectedRecordPtr->myBlockSize);
assert(bufferPtr->myReferenceID == expectedRecordPtr->myReferenceID);
assert(bufferPtr->myPosition == expectedRecordPtr->myPosition);
assert(bufferPtr->myReadNameLength == expectedRecordPtr->myReadNameLength);
assert(bufferPtr->myMapQuality == expectedRecordPtr->myMapQuality);
assert(bufferPtr->myBin == expectedRecordPtr->myBin);
assert(bufferPtr->myCigarLength == expectedRecordPtr->myCigarLength);
assert(bufferPtr->myFlag == expectedRecordPtr->myFlag);
assert(bufferPtr->myReadLength == expectedRecordPtr->myReadLength);
assert(bufferPtr->myMateReferenceID ==
expectedRecordPtr->myMateReferenceID);
assert(bufferPtr->myMatePosition == expectedRecordPtr->myMatePosition);
assert(bufferPtr->myInsertSize == expectedRecordPtr->myInsertSize);
// Validate the variable length fields in the buffer.
// Set the pointer to the start of the variable fields.
varPtr = (unsigned char*)(&(bufferPtr->myData[0]));
// Validate the readname.
for(int i = 0; i < expectedRecordPtr->myReadNameLength; i++)
{
assert(*varPtr == samRecord.getReadName()[i]);
varPtr++;
}
// Validate the cigar.
// The First cigar is 5M which is 5 << 4 | 0 = 80
assert(*(unsigned int*)varPtr == 80);
// Increment the varptr the size of an int.
varPtr += 4;
// The 2nd cigar is 2D which is 2 << 4 | 2 = 34
assert(*(unsigned int*)varPtr == 34);
// Increment the varptr the size of an int.
varPtr += 4;
// Validate the sequence.
// CC = 0x22
assert(*varPtr == 0x22);
varPtr++;
// GA = 0x41
assert(*varPtr == 0x41);
varPtr++;
// A = 0x10
assert(*varPtr == 0x10);
varPtr++;
// Validate the Quality
for(int i = 0; i < expectedRecordPtr->myReadLength; i++)
{
assert(*varPtr == samRecord.getQuality()[i] - 33);
varPtr++;
}
// Validate the tags.
assert(*varPtr == 'A');
varPtr++;
assert(*varPtr == 'M');
varPtr++;
assert(*varPtr == 'C');
varPtr++;
assert(*varPtr == 0);
varPtr++;
assert(*varPtr == 'M');
varPtr++;
assert(*varPtr == 'D');
varPtr++;
assert(*varPtr == 'Z');
varPtr++;
assert(*varPtr == '3');
varPtr++;
assert(*varPtr == '7');
varPtr++;
assert(*varPtr == 0);
varPtr++;
assert(*varPtr == 'N');
varPtr++;
assert(*varPtr == 'M');
varPtr++;
assert(*varPtr == 'C');
varPtr++;
assert(*varPtr == 0);
varPtr++;
assert(*varPtr == 'X');
varPtr++;
assert(*varPtr == 'T');
varPtr++;
assert(*varPtr == 'A');
varPtr++;
assert(*varPtr == 'R');
varPtr++;
}
void testModHeader(SamFileHeader& samHeader)
{
// Check the header line.
std::string headerString = "";
assert(samHeader.getHeaderString(headerString) == true);
assert(headerString == "@SQ\tSN:1\tLN:247249719\n@SQ\tSN:2\tLN:242951149\n@SQ\tSN:3\tLN:199501827\n@SQ\tSN:4\tLN:191273063\n@SQ\tSN:5\tLN:180857866\n@SQ\tSN:6\tLN:170899992\n@SQ\tSN:7\tLN:158821424\n@SQ\tSN:8\tLN:146274826\n@SQ\tSN:9\tLN:140273252\n@SQ\tSN:10\tLN:135374737\n@SQ\tSN:11\tLN:134452384\n@SQ\tSN:12\tLN:132349534\n@SQ\tSN:13\tLN:114142980\n@SQ\tSN:14\tLN:106368585\n@SQ\tSN:15\tLN:100338915\n@SQ\tSN:16\tLN:88827254\n@SQ\tSN:17\tLN:78774742\n@SQ\tSN:18\tLN:76117153\n@SQ\tSN:19\tLN:63811651\n@SQ\tSN:20\tLN:62435964\n@SQ\tSN:21\tLN:46944323\n@SQ\tSN:22\tLN:49691432\n@SQ\tSN:X\tLN:154913754\n@RG\tID:myID\tLB:library\tSM:sample\n@RG\tID:myID2\tSM:sample2\tLB:library2\n@CO\tComment 1\n@CO\tComment 2\n");
// Remove a tag - by setting it to "".
assert(samHeader.setRGTag("LB", "", "myID2") == true);
// Check the header line.
assert(samHeader.getHeaderString(headerString) == true);
assert(headerString == "@SQ\tSN:1\tLN:247249719\n@SQ\tSN:2\tLN:242951149\n@SQ\tSN:3\tLN:199501827\n@SQ\tSN:4\tLN:191273063\n@SQ\tSN:5\tLN:180857866\n@SQ\tSN:6\tLN:170899992\n@SQ\tSN:7\tLN:158821424\n@SQ\tSN:8\tLN:146274826\n@SQ\tSN:9\tLN:140273252\n@SQ\tSN:10\tLN:135374737\n@SQ\tSN:11\tLN:134452384\n@SQ\tSN:12\tLN:132349534\n@SQ\tSN:13\tLN:114142980\n@SQ\tSN:14\tLN:106368585\n@SQ\tSN:15\tLN:100338915\n@SQ\tSN:16\tLN:88827254\n@SQ\tSN:17\tLN:78774742\n@SQ\tSN:18\tLN:76117153\n@SQ\tSN:19\tLN:63811651\n@SQ\tSN:20\tLN:62435964\n@SQ\tSN:21\tLN:46944323\n@SQ\tSN:22\tLN:49691432\n@SQ\tSN:X\tLN:154913754\n@RG\tID:myID\tLB:library\tSM:sample\n@RG\tID:myID2\tSM:sample2\n@CO\tComment 1\n@CO\tComment 2\n");
// Add an HD tag.
SamHeaderHD* hd = new SamHeaderHD();
assert(hd->setTag("VN", "1.3") == true);
assert(samHeader.addHD(hd) == true);
assert(strcmp(samHeader.getHDTagValue("VN"), "1.3") == 0);
assert(samHeader.getHeaderString(headerString) == true);
assert(headerString == "@SQ\tSN:1\tLN:247249719\n@SQ\tSN:2\tLN:242951149\n@SQ\tSN:3\tLN:199501827\n@SQ\tSN:4\tLN:191273063\n@SQ\tSN:5\tLN:180857866\n@SQ\tSN:6\tLN:170899992\n@SQ\tSN:7\tLN:158821424\n@SQ\tSN:8\tLN:146274826\n@SQ\tSN:9\tLN:140273252\n@SQ\tSN:10\tLN:135374737\n@SQ\tSN:11\tLN:134452384\n@SQ\tSN:12\tLN:132349534\n@SQ\tSN:13\tLN:114142980\n@SQ\tSN:14\tLN:106368585\n@SQ\tSN:15\tLN:100338915\n@SQ\tSN:16\tLN:88827254\n@SQ\tSN:17\tLN:78774742\n@SQ\tSN:18\tLN:76117153\n@SQ\tSN:19\tLN:63811651\n@SQ\tSN:20\tLN:62435964\n@SQ\tSN:21\tLN:46944323\n@SQ\tSN:22\tLN:49691432\n@SQ\tSN:X\tLN:154913754\n@RG\tID:myID\tLB:library\tSM:sample\n@RG\tID:myID2\tSM:sample2\n@HD\tVN:1.3\n@CO\tComment 1\n@CO\tComment 2\n");
// Try adding another HD tag.
SamHeaderHD* hd2 = new SamHeaderHD();
assert(hd2->setTag("VN", "1.4") == true);
assert(samHeader.addHD(hd2) == false);
assert(strcmp(samHeader.getHDTagValue("VN"), "1.4") != 0);
assert(strcmp(samHeader.getHDTagValue("VN"), "1.3") == 0);
assert(samHeader.getHeaderString(headerString) == true);
assert(headerString == "@SQ\tSN:1\tLN:247249719\n@SQ\tSN:2\tLN:242951149\n@SQ\tSN:3\tLN:199501827\n@SQ\tSN:4\tLN:191273063\n@SQ\tSN:5\tLN:180857866\n@SQ\tSN:6\tLN:170899992\n@SQ\tSN:7\tLN:158821424\n@SQ\tSN:8\tLN:146274826\n@SQ\tSN:9\tLN:140273252\n@SQ\tSN:10\tLN:135374737\n@SQ\tSN:11\tLN:134452384\n@SQ\tSN:12\tLN:132349534\n@SQ\tSN:13\tLN:114142980\n@SQ\tSN:14\tLN:106368585\n@SQ\tSN:15\tLN:100338915\n@SQ\tSN:16\tLN:88827254\n@SQ\tSN:17\tLN:78774742\n@SQ\tSN:18\tLN:76117153\n@SQ\tSN:19\tLN:63811651\n@SQ\tSN:20\tLN:62435964\n@SQ\tSN:21\tLN:46944323\n@SQ\tSN:22\tLN:49691432\n@SQ\tSN:X\tLN:154913754\n@RG\tID:myID\tLB:library\tSM:sample\n@RG\tID:myID2\tSM:sample2\n@HD\tVN:1.3\n@CO\tComment 1\n@CO\tComment 2\n");
// Remove the entire HD Tag.
assert(samHeader.removeHD() == true);
assert(strcmp(samHeader.getHDTagValue("VN"), "") == 0);
assert(samHeader.getHeaderString(headerString) == true);
assert(headerString == "@SQ\tSN:1\tLN:247249719\n@SQ\tSN:2\tLN:242951149\n@SQ\tSN:3\tLN:199501827\n@SQ\tSN:4\tLN:191273063\n@SQ\tSN:5\tLN:180857866\n@SQ\tSN:6\tLN:170899992\n@SQ\tSN:7\tLN:158821424\n@SQ\tSN:8\tLN:146274826\n@SQ\tSN:9\tLN:140273252\n@SQ\tSN:10\tLN:135374737\n@SQ\tSN:11\tLN:134452384\n@SQ\tSN:12\tLN:132349534\n@SQ\tSN:13\tLN:114142980\n@SQ\tSN:14\tLN:106368585\n@SQ\tSN:15\tLN:100338915\n@SQ\tSN:16\tLN:88827254\n@SQ\tSN:17\tLN:78774742\n@SQ\tSN:18\tLN:76117153\n@SQ\tSN:19\tLN:63811651\n@SQ\tSN:20\tLN:62435964\n@SQ\tSN:21\tLN:46944323\n@SQ\tSN:22\tLN:49691432\n@SQ\tSN:X\tLN:154913754\n@RG\tID:myID\tLB:library\tSM:sample\n@RG\tID:myID2\tSM:sample2\n@CO\tComment 1\n@CO\tComment 2\n");
// Remove an entire SQ Tag.
assert(strcmp(samHeader.getSQTagValue("LN", "11"), "134452384") == 0);
assert(samHeader.removeSQ("11") == true);
assert(strcmp(samHeader.getSQTagValue("LN", "11"), "") == 0);
assert(samHeader.getHeaderString(headerString) == true);
assert(headerString == "@SQ\tSN:1\tLN:247249719\n@SQ\tSN:2\tLN:242951149\n@SQ\tSN:3\tLN:199501827\n@SQ\tSN:4\tLN:191273063\n@SQ\tSN:5\tLN:180857866\n@SQ\tSN:6\tLN:170899992\n@SQ\tSN:7\tLN:158821424\n@SQ\tSN:8\tLN:146274826\n@SQ\tSN:9\tLN:140273252\n@SQ\tSN:10\tLN:135374737\n@SQ\tSN:12\tLN:132349534\n@SQ\tSN:13\tLN:114142980\n@SQ\tSN:14\tLN:106368585\n@SQ\tSN:15\tLN:100338915\n@SQ\tSN:16\tLN:88827254\n@SQ\tSN:17\tLN:78774742\n@SQ\tSN:18\tLN:76117153\n@SQ\tSN:19\tLN:63811651\n@SQ\tSN:20\tLN:62435964\n@SQ\tSN:21\tLN:46944323\n@SQ\tSN:22\tLN:49691432\n@SQ\tSN:X\tLN:154913754\n@RG\tID:myID\tLB:library\tSM:sample\n@RG\tID:myID2\tSM:sample2\n@CO\tComment 1\n@CO\tComment 2\n");
// Try adding a null HD tag.
hd = NULL;
assert(samHeader.addHD(hd) == false);
assert(strcmp(samHeader.getHDTagValue("VN"), "") == 0);
assert(strcmp(samHeader.getHDTagValue("VN"), "1.4") != 0);
assert(strcmp(samHeader.getHDTagValue("VN"), "1.3") != 0);
assert(samHeader.getHeaderString(headerString) == true);
assert(headerString == "@SQ\tSN:1\tLN:247249719\n@SQ\tSN:2\tLN:242951149\n@SQ\tSN:3\tLN:199501827\n@SQ\tSN:4\tLN:191273063\n@SQ\tSN:5\tLN:180857866\n@SQ\tSN:6\tLN:170899992\n@SQ\tSN:7\tLN:158821424\n@SQ\tSN:8\tLN:146274826\n@SQ\tSN:9\tLN:140273252\n@SQ\tSN:10\tLN:135374737\n@SQ\tSN:12\tLN:132349534\n@SQ\tSN:13\tLN:114142980\n@SQ\tSN:14\tLN:106368585\n@SQ\tSN:15\tLN:100338915\n@SQ\tSN:16\tLN:88827254\n@SQ\tSN:17\tLN:78774742\n@SQ\tSN:18\tLN:76117153\n@SQ\tSN:19\tLN:63811651\n@SQ\tSN:20\tLN:62435964\n@SQ\tSN:21\tLN:46944323\n@SQ\tSN:22\tLN:49691432\n@SQ\tSN:X\tLN:154913754\n@RG\tID:myID\tLB:library\tSM:sample\n@RG\tID:myID2\tSM:sample2\n@CO\tComment 1\n@CO\tComment 2\n");
// Try adding a null SQ tag.
SamHeaderSQ* sq = NULL;
assert(samHeader.addSQ(sq) == false);
assert(samHeader.getHeaderString(headerString) == true);
assert(headerString == "@SQ\tSN:1\tLN:247249719\n@SQ\tSN:2\tLN:242951149\n@SQ\tSN:3\tLN:199501827\n@SQ\tSN:4\tLN:191273063\n@SQ\tSN:5\tLN:180857866\n@SQ\tSN:6\tLN:170899992\n@SQ\tSN:7\tLN:158821424\n@SQ\tSN:8\tLN:146274826\n@SQ\tSN:9\tLN:140273252\n@SQ\tSN:10\tLN:135374737\n@SQ\tSN:12\tLN:132349534\n@SQ\tSN:13\tLN:114142980\n@SQ\tSN:14\tLN:106368585\n@SQ\tSN:15\tLN:100338915\n@SQ\tSN:16\tLN:88827254\n@SQ\tSN:17\tLN:78774742\n@SQ\tSN:18\tLN:76117153\n@SQ\tSN:19\tLN:63811651\n@SQ\tSN:20\tLN:62435964\n@SQ\tSN:21\tLN:46944323\n@SQ\tSN:22\tLN:49691432\n@SQ\tSN:X\tLN:154913754\n@RG\tID:myID\tLB:library\tSM:sample\n@RG\tID:myID2\tSM:sample2\n@CO\tComment 1\n@CO\tComment 2\n");
// Try adding an HD tag again.
assert(samHeader.addHD(hd2) == true);
assert(strcmp(samHeader.getHDTagValue("VN"), "1.4") == 0);
assert(strcmp(samHeader.getHDTagValue("VN"), "1.3") != 0);
assert(samHeader.getHeaderString(headerString) == true);
assert(headerString == "@SQ\tSN:1\tLN:247249719\n@SQ\tSN:2\tLN:242951149\n@SQ\tSN:3\tLN:199501827\n@SQ\tSN:4\tLN:191273063\n@SQ\tSN:5\tLN:180857866\n@SQ\tSN:6\tLN:170899992\n@SQ\tSN:7\tLN:158821424\n@SQ\tSN:8\tLN:146274826\n@SQ\tSN:9\tLN:140273252\n@SQ\tSN:10\tLN:135374737\n@SQ\tSN:12\tLN:132349534\n@SQ\tSN:13\tLN:114142980\n@SQ\tSN:14\tLN:106368585\n@SQ\tSN:15\tLN:100338915\n@SQ\tSN:16\tLN:88827254\n@SQ\tSN:17\tLN:78774742\n@SQ\tSN:18\tLN:76117153\n@SQ\tSN:19\tLN:63811651\n@SQ\tSN:20\tLN:62435964\n@SQ\tSN:21\tLN:46944323\n@SQ\tSN:22\tLN:49691432\n@SQ\tSN:X\tLN:154913754\n@RG\tID:myID\tLB:library\tSM:sample\n@RG\tID:myID2\tSM:sample2\n@HD\tVN:1.4\n@CO\tComment 1\n@CO\tComment 2\n");
// TODO Get the comments.
}
void testFlagRead(const char* fileName)
{
SamFile inSam;
SamFileHeader samHeader;
SamRecord samRecord;
////////////////////////////////////////////////////////////
// Required flag 0x48 (only flag 73 matches)
// Exclude nothing
assert(inSam.OpenForRead(fileName));
assert(inSam.ReadHeader(samHeader));
validateHeader(samHeader);
inSam.SetReadFlags(0x48, 0x0);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead1(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == false);
inSam.Close();
////////////////////////////////////////////////////////////
// No required flags.
// Exclude 0x48. This leaves just the one read with flag 133.
assert(inSam.OpenForRead(fileName));
assert(inSam.ReadHeader(samHeader));
validateHeader(samHeader);
inSam.SetReadFlags(0x0, 0x48);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead2(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == false);
inSam.Close();
////////////////////////////////////////////////////////////
// Required flag 0x40
// Exclude 0x48.
// This will not find any records since the exclude and required conflict.
assert(inSam.OpenForRead(fileName));
assert(inSam.ReadHeader(samHeader));
validateHeader(samHeader);
inSam.SetReadFlags(0x40, 0x48);
assert(inSam.ReadRecord(samHeader, samRecord) == false);
inSam.Close();
////////////////////////////////////////////////////////////
// Required flag 0x4
// Exclude 0x8.
// Only finds flag 133.
assert(inSam.OpenForRead(fileName));
assert(inSam.ReadHeader(samHeader));
validateHeader(samHeader);
inSam.SetReadFlags(0x4, 0x8);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead2(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == false);
inSam.Close();
////////////////////////////////////////////////////////////
// Required flag 0x4
// Exclude nothing
// Finds flags 133 & 141.
assert(inSam.OpenForRead(fileName));
assert(inSam.ReadHeader(samHeader));
validateHeader(samHeader);
inSam.SetReadFlags(0x4, 0x0);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead2(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead8(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead10(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == false);
inSam.Close();
}
void testCopyHeader(SamFileHeader& samHeader)
{
// Copy the header.
SamFileHeader samHeader2;
SamHeaderRecord* recPtr = samHeader.getNextHeaderRecord();
while(recPtr != NULL)
{
samHeader2.addRecordCopy(*recPtr);
recPtr = samHeader.getNextHeaderRecord();
}
// Add the comments.
std::string nextComment = samHeader.getNextComment();
while(nextComment != SamFileHeader::EMPTY_RETURN)
{
samHeader2.addComment(nextComment.c_str());
nextComment = samHeader.getNextComment();
}
// Validate the header.
validateHeader(samHeader2);
}
SamFile::COORDINATE
file is sorted by coordinate.
Definition: SamFile.h:49
SamRecord::get0BasedPosition
int32_t get0BasedPosition()
Get the 0-based(BAM) leftmost position of the record.
Definition: SamRecord.cpp:1307
SamRecord::getReferenceName
const char * getReferenceName()
Get the reference sequence name (RNAME) of the record.
Definition: SamRecord.cpp:1286
SamRecord::get1BasedUnclippedStart
int32_t get1BasedUnclippedStart()
Returns the 1-based inclusive left-most position adjusted for clipped bases.
Definition: SamRecord.cpp:1507
SamFile::FLAG
SO flag from the header indicates the sort type.
Definition: SamFile.h:48
SamRecord::get0BasedAlignmentEnd
int32_t get0BasedAlignmentEnd()
Returns the 0-based inclusive rightmost position of the clipped sequence.
Definition: SamRecord.cpp:1455
SamRecord::getBin
uint16_t getBin()
Get the BAM bin for the record.
Definition: SamRecord.cpp:1335
SamFile::WriteRecord
bool WriteRecord(SamFileHeader &header, SamRecord &record)
Writes the specified record into the file.
Definition: SamFile.cpp:619
SamRecord::getMateReferenceID
int32_t getMateReferenceID()
Get the mate reference id of the record (BAM format: mate_rid/next_refID).
Definition: SamRecord.cpp:1426
SamRecord::getReferenceID
int32_t getReferenceID()
Get the reference sequence id of the record (BAM format rid).
Definition: SamRecord.cpp:1293
String
Definition: StringBasics.h:38
ErrorHandler::RETURN
just return failure on the error
Definition: ErrorHandler.h:31
SamFileHeader::getSQTagValue
const char * getSQTagValue(const char *tag, const char *name)
Get the value associated with the specified tag on the SQ line with the specified sequence name,...
Definition: SamFileHeader.cpp:696
GenomeSequence
Create/Access/Modify/Load Genome Sequences stored as binary mapped files.
Definition: GenomeSequence.h:99
SamRecord::getMapQuality
uint8_t getMapQuality()
Get the mapping quality (MAPQ) of the record.
Definition: SamRecord.cpp:1328
SamHeaderSQ
Definition: SamHeaderSQ.h:23
SamFileHeader::addSQ
bool addSQ(SamHeaderSQ *sq)
Add the SQ record to the header.
Definition: SamFileHeader.cpp:415
SamRecord::getCigarLength
uint16_t getCigarLength()
Get the length of the BAM formatted CIGAR.
Definition: SamRecord.cpp:1350
SamFile::ReadRecord
bool ReadRecord(SamFileHeader &header, SamRecord &record)
Reads the next record from the file & stores it in the passed in record.
Definition: SamFile.cpp:501
SamFileHeader::getNextComment
const char * getNextComment()
Returns the comment on the next comment line.
Definition: SamFileHeader.cpp:985
SamFile::QUERY_NAME
file is sorted by queryname.
Definition: SamFile.h:50
SamRecord::get0BasedUnclippedStart
int32_t get0BasedUnclippedStart()
Returns the 0-based inclusive left-most position adjusted for clipped bases.
Definition: SamRecord.cpp:1494
SamFileHeader::getHDTagValue
const char * getHDTagValue(const char *tag)
Returns the value associated with the specified HD tag, returning "" if the tag does not exist in the...
Definition: SamFileHeader.cpp:683
SamRecord::getFlag
uint16_t getFlag()
Get the flag (FLAG).
Definition: SamRecord.cpp:1372
SamRecord::getRecordBuffer
const void * getRecordBuffer()
Get a const pointer to the buffer that contains the BAM representation of the record.
Definition: SamRecord.cpp:1192
SamFileHeader::getHeaderString
bool getHeaderString(std::string &header) const
Set the passed in string to the entire header string, clearing its current contents.
Definition: SamFileHeader.cpp:131
SamFile::SetReadFlags
void SetReadFlags(uint16_t requiredFlags, uint16_t excludedFlags)
Specify which reads should be returned by ReadRecord.
Definition: SamFile.cpp:781
SamTags::isMDTagCorrect
static bool isMDTagCorrect(SamRecord &inputRec, GenomeSequence &genome)
Check to see if the MD tag in the record is accurate.
Definition: SamTags.cpp:126
SamRecord::getAlignmentLength
int32_t getAlignmentLength()
Returns the length of the clipped sequence, returning 0 if the cigar is '*'.
Definition: SamRecord.cpp:1481
SamRecord::get1BasedPosition
int32_t get1BasedPosition()
Get the 1-based(SAM) leftmost position (POS) of the record.
Definition: SamRecord.cpp:1300
SamFile::OpenForWrite
bool OpenForWrite(const char *filename, SamFileHeader *header=NULL)
Open a sam/bam file for writing with the specified filename, determining SAM/BAM from the extension (...
Definition: SamFile.cpp:223
SamRecord::get1BasedUnclippedEnd
int32_t get1BasedUnclippedEnd()
Returns the 1-based inclusive right-most position adjusted for clipped bases.
Definition: SamRecord.cpp:1523
SamRecord::resetTagIter
void resetTagIter()
Reset the tag iterator to the beginning of the tags.
Definition: SamRecord.cpp:2022
SamFileHeader::addHD
bool addHD(SamHeaderHD *hd)
Add the HD record to the header.
Definition: SamFileHeader.cpp:393
SamRecord::getQuality
const char * getQuality()
Returns the SAM formatted quality string (QUAL).
Definition: SamRecord.cpp:1626
SamFileHeader::addRecordCopy
bool addRecordCopy(const SamHeaderRecord &hdrRec)
Add a copy of the specified header record to the header.
Definition: SamFileHeader.cpp:526
SamFileHeader::removeSQ
bool removeSQ(const char *name)
Remove SQ record with the specified key.
Definition: SamFileHeader.cpp:573
SamRecord::get0BasedMatePosition
int32_t get0BasedMatePosition()
Get the 0-based(BAM) leftmost mate/next fragment's position.
Definition: SamRecord.cpp:1440
SamRecord::getReadName
const char * getReadName()
Returns the SAM formatted Read Name (QNAME).
Definition: SamRecord.cpp:1530
SamRecord::get0BasedUnclippedEnd
int32_t get0BasedUnclippedEnd()
Returns the 0-based inclusive right-most position adjusted for clipped bases.
Definition: SamRecord.cpp:1514
SamFileHeader::getNextHeaderRecord
SamHeaderRecord * getNextHeaderRecord(uint32_t &index, SamHeaderRecord::SamHeaderRecordType headerType)
Get the next header record of the specified type starting from the specified index and update the ind...
Definition: SamFileHeader.cpp:871
SamRecord::getSequence
const char * getSequence()
Returns the SAM formatted sequence string (SEQ), translating the base as specified by setSequenceTran...
Definition: SamRecord.cpp:1556
SamRecord::getReadLength
int32_t getReadLength()
Get the length of the read.
Definition: SamRecord.cpp:1379
SamFileHeader
This class allows a user to get/set the fields in a SAM/BAM Header.
Definition: SamFileHeader.h:34
SamRecord::getInsertSize
int32_t getInsertSize()
Get the inferred insert size of the read pair (ISIZE) or observed template length (TLEN).
Definition: SamRecord.cpp:1447
SamRecord::getCigar
const char * getCigar()
Returns the SAM formatted CIGAR string.
Definition: SamRecord.cpp:1543
SamRecord::getBlockSize
int32_t getBlockSize()
Get the block size of the record (BAM format).
Definition: SamRecord.cpp:1269
SamTags::createMDTag
static bool createMDTag(String &outputMDtag, SamRecord &inputRec, GenomeSequence &genome)
Create the MD tag for the specified input record and the genome.
Definition: SamTags.cpp:34
SamFile::setSortedValidation
void setSortedValidation(SortedType sortType)
Set the flag to validate that the file is sorted as it is read/written.
Definition: SamFile.cpp:669
SamRecord
Class providing an easy to use interface to get/set/operate on the fields in a SAM/BAM record.
Definition: SamRecord.h:51
SamRecord::get1BasedMatePosition
int32_t get1BasedMatePosition()
Get the 1-based(SAM) leftmost mate/next fragment's position (PNEXT).
Definition: SamRecord.cpp:1433
SamRecord::getReadNameLength
uint8_t getReadNameLength()
Get the length of the readname (QNAME) including the null.
Definition: SamRecord.cpp:1314
SamFile::OpenForRead
bool OpenForRead(const char *filename, SamFileHeader *header=NULL)
Open a sam/bam file for reading with the specified filename, determing the type of file and SAM/BAM b...
Definition: SamFile.cpp:93
SamFile::WriteHeader
bool WriteHeader(SamFileHeader &header)
Writes the specified header into the file.
Definition: SamFile.cpp:467
SamRecord::getMateReferenceNameOrEqual
const char * getMateReferenceNameOrEqual()
Get the mate/next fragment's reference sequence name (RNEXT), returning "=" if it is the same as the ...
Definition: SamRecord.cpp:1408
SamRecord::getNumOverlaps
uint32_t getNumOverlaps(int32_t start, int32_t end)
Return the number of bases in this read that overlap the passed in region.
Definition: SamRecord.cpp:1841
SamFile::ReadHeader
bool ReadHeader(SamFileHeader &header)
Reads the header section from the file and stores it in the passed in header.
Definition: SamFile.cpp:437
SamFile::Close
void Close()
Close the file if there is one open.
Definition: SamFile.cpp:400
SamFile
Allows the user to easily read/write a SAM/BAM file.
Definition: SamFile.h:35
SamRecord::get1BasedAlignmentEnd
int32_t get1BasedAlignmentEnd()
Returns the 1-based inclusive rightmost position of the clipped sequence.
Definition: SamRecord.cpp:1474
SamHeaderRecord
This class encapsulates the tag value pairs contained with a SAM Header line with accessors for getti...
Definition: SamHeaderRecord.h:27
SamHeaderRecord::setTag
bool setTag(const char *tag, const char *value)
Set the value of the specified tag to the specified value, deletes the tag when value is NULL.
Definition: SamHeaderRecord.cpp:119
SamHeaderHD
Definition: SamHeaderHD.h:23
SamRecord::getMateReferenceName
const char * getMateReferenceName()
Get the mate/next fragment's reference sequence name (RNEXT).
Definition: SamRecord.cpp:1398
bamRecordStruct
Structure of a BAM record.
Definition: SamRecord.h:33
SamRecord::setQuality
bool setQuality(const char *quality)
Sets the quality (QUAL) to the specified SAM formatted quality string.
Definition: SamRecord.cpp:357
SamRecord::getNextSamTag
bool getNextSamTag(char *tag, char &vtype, void **value)
Get the next tag from the record.
Definition: SamRecord.cpp:1950
SamFileHeader::setRGTag
bool setRGTag(const char *tag, const char *value, const char *id)
Set the specified tag to the specified value in the RG header with the specified id,...
Definition: SamFileHeader.cpp:311
SamFileHeader::removeHD
bool removeHD()
Remove the HD record.
Definition: SamFileHeader.cpp:554
SamFileHeader::addComment
bool addComment(const char *comment)
Add the specified comment to the header (do not include "@CO" or "\n").
Definition: SamFileHeader.cpp:213