本文整理汇总了C++中SamFile::setSortedValidation方法的典型用法代码示例。如果您正苦于以下问题:C++ SamFile::setSortedValidation方法的具体用法?C++ SamFile::setSortedValidation怎么用?C++ SamFile::setSortedValidation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SamFile
的用法示例。
在下文中一共展示了SamFile::setSortedValidation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
}
else
{
mySecondFile = ifopen(secondOut, "w", myCompression);
}
if(myUnpairedFile == NULL)
{
std::cerr << "Failed to open " << unpairedOut
<< " so can't convert bam2FastQ.\n";
return(-1);
}
if(myFirstFile == NULL)
{
std::cerr << "Failed to open " << firstOut
<< " so can't convert bam2FastQ.\n";
return(-1);
}
if(mySecondFile == NULL)
{
std::cerr << "Failed to open " << secondOut
<< " so can't convert bam2FastQ.\n";
return(-1);
}
}
if((readName) || (strcmp(mySamHeader.getSortOrder(), "queryname") == 0))
{
readName = true;
}
else
{
// defaulting to coordinate sorted.
samIn.setSortedValidation(SamFile::COORDINATE);
}
// Setup the '=' translation if the reference was specified.
if(!refFile.IsEmpty())
{
GenomeSequence* refPtr = new GenomeSequence(refFile);
samIn.SetReadSequenceTranslation(SamRecord::BASES);
samIn.SetReference(refPtr);
}
SamRecord* recordPtr;
int16_t samFlag;
SamStatus::Status returnStatus = SamStatus::SUCCESS;
while(returnStatus == SamStatus::SUCCESS)
{
recordPtr = myPool.getRecord();
if(recordPtr == NULL)
{
// Failed to allocate a new record.
throw(std::runtime_error("Failed to allocate a new SAM/BAM record"));
}
if(!samIn.ReadRecord(mySamHeader, *recordPtr))
{
// Failed to read a record.
returnStatus = samIn.GetStatus();
continue;
}
// Have a record. Check to see if it is a pair or unpaired read.
samFlag = recordPtr->getFlag();
if(SamFlag::isPaired(samFlag))
示例2: execute
//.........这里部分代码省略.........
}
if(logFile.IsEmpty())
{
logFile = outFile + ".log";
}
if(myDoRecab)
{
int status = myRecab.processRecabParam();
if(status != 0)
{
inputParameters.Status();
return(status);
}
}
if(params)
{
inputParameters.Status();
}
Logger::gLogger = new Logger(logFile.c_str(), verboseFlag);
/* -------------------------------------------------------------------
* The arguments are processed. Prepare the input BAM file,
* instantiate dedup_LowMem, and construct the read group library map
* ------------------------------------------------------------------*/
SamFile samIn;
samIn.OpenForRead(inFile.c_str());
// If the file isn't sorted it will throw an exception.
samIn.setSortedValidation(SamFile::COORDINATE);
SamFileHeader header;
samIn.ReadHeader(header);
buildReadGroupLibraryMap(header);
lastReference = -1;
lastCoordinate = -1;
// for keeping some basic statistics
uint32_t recordCount = 0;
uint32_t pairedCount = 0;
uint32_t properPairCount = 0;
uint32_t unmappedCount = 0;
uint32_t reverseCount = 0;
uint32_t qualCheckFailCount = 0;
uint32_t secondaryCount = 0;
uint32_t supplementaryCount = 0;
uint32_t excludedCount = 0;
// Now we start reading records
SamRecord* recordPtr;
SamStatus::Status returnStatus = SamStatus::SUCCESS;
while(returnStatus == SamStatus::SUCCESS)
{
recordPtr = mySamPool.getRecord();
if(recordPtr == NULL)
{
std::cerr << "Failed to allocate enough records\n";
return(-1);
}
if(!samIn.ReadRecord(header, *recordPtr))
示例3: testIndex
void testIndex(BamIndex& bamIndex)
{
assert(bamIndex.getNumMappedReads(1) == 2);
assert(bamIndex.getNumUnMappedReads(1) == 0);
assert(bamIndex.getNumMappedReads(0) == 4);
assert(bamIndex.getNumUnMappedReads(0) == 1);
assert(bamIndex.getNumMappedReads(23) == -1);
assert(bamIndex.getNumUnMappedReads(23) == -1);
assert(bamIndex.getNumMappedReads(-1) == 0);
assert(bamIndex.getNumUnMappedReads(-1) == 2);
assert(bamIndex.getNumMappedReads(-2) == -1);
assert(bamIndex.getNumUnMappedReads(-2) == -1);
assert(bamIndex.getNumMappedReads(22) == 0);
assert(bamIndex.getNumUnMappedReads(22) == 0);
// Get the chunks for reference id 1.
Chunk testChunk;
SortedChunkList chunkList;
assert(bamIndex.getChunksForRegion(1, -1, -1, chunkList) == true);
assert(!chunkList.empty());
testChunk = chunkList.pop();
assert(chunkList.empty());
assert(testChunk.chunk_beg == 0x4e7);
assert(testChunk.chunk_end == 0x599);
// Get the chunks for reference id 0.
assert(bamIndex.getChunksForRegion(0, -1, -1, chunkList) == true);
assert(!chunkList.empty());
testChunk = chunkList.pop();
assert(chunkList.empty());
assert(testChunk.chunk_beg == 0x360);
assert(testChunk.chunk_end == 0x4e7);
// Get the chunks for reference id 2.
assert(bamIndex.getChunksForRegion(2, -1, -1, chunkList) == true);
assert(!chunkList.empty());
testChunk = chunkList.pop();
assert(chunkList.empty());
assert(testChunk.chunk_beg == 0x599);
assert(testChunk.chunk_end == 0x5ea);
// Get the chunks for reference id 3.
// There isn't one for this ref id, but still successfully read the file,
// so it should return true, but the list should be empty.
assert(bamIndex.getChunksForRegion(3, -1, -1, chunkList) == true);
assert(chunkList.empty());
// Test reading an indexed bam file.
SamFile inFile;
assert(inFile.OpenForRead("testFiles/sortedBam.bam"));
inFile.setSortedValidation(SamFile::COORDINATE);
assert(inFile.ReadBamIndex("testFiles/sortedBam.bam.bai"));
SamFileHeader samHeader;
assert(inFile.ReadHeader(samHeader));
SamRecord samRecord;
// Test getting num mapped/unmapped reads.
assert(inFile.getNumMappedReadsFromIndex(1) == 2);
assert(inFile.getNumUnMappedReadsFromIndex(1) == 0);
assert(inFile.getNumMappedReadsFromIndex(0) == 4);
assert(inFile.getNumUnMappedReadsFromIndex(0) == 1);
assert(inFile.getNumMappedReadsFromIndex(23) == -1);
assert(inFile.getNumUnMappedReadsFromIndex(23) == -1);
assert(inFile.getNumMappedReadsFromIndex(-1) == 0);
assert(inFile.getNumUnMappedReadsFromIndex(-1) == 2);
assert(inFile.getNumMappedReadsFromIndex(-2) == -1);
assert(inFile.getNumUnMappedReadsFromIndex(-2) == -1);
assert(inFile.getNumMappedReadsFromIndex(22) == 0);
assert(inFile.getNumUnMappedReadsFromIndex(22) == 0);
assert(inFile.getNumMappedReadsFromIndex("2", samHeader) == 2);
assert(inFile.getNumUnMappedReadsFromIndex("2", samHeader) == 0);
assert(inFile.getNumMappedReadsFromIndex("1", samHeader) == 4);
assert(inFile.getNumUnMappedReadsFromIndex("1", samHeader) == 1);
assert(inFile.getNumMappedReadsFromIndex("22", samHeader) == 0);
assert(inFile.getNumUnMappedReadsFromIndex("22", samHeader) == 0);
assert(inFile.getNumMappedReadsFromIndex("", samHeader) == 0);
assert(inFile.getNumUnMappedReadsFromIndex("*", samHeader) == 2);
assert(inFile.getNumMappedReadsFromIndex("unknown", samHeader) == -1);
assert(inFile.getNumUnMappedReadsFromIndex("unknown", samHeader) == -1);
assert(inFile.getNumMappedReadsFromIndex("X", samHeader) == 0);
assert(inFile.getNumUnMappedReadsFromIndex("X", samHeader) == 0);
// Section -1 = Ref *: 2 records (8 & 10 from testSam.sam that is reflected
// in the validation.
assert(inFile.SetReadSection(-1));
assert(inFile.ReadRecord(samHeader, samRecord));
validateRead8(samRecord);
assert(inFile.ReadRecord(samHeader, samRecord));
validateRead10(samRecord);
assert(inFile.ReadRecord(samHeader, samRecord) == false);
// Section 2 = Ref 3: 1 records (9 from testSam.sam that is reflected
// in the validation.
assert(inFile.SetReadSection(2));
assert(inFile.ReadRecord(samHeader, samRecord));
validateRead9(samRecord);
assert(inFile.ReadRecord(samHeader, samRecord) == false);
//.........这里部分代码省略.........