本文整理汇总了C++中SamFileHeader::getReferenceID方法的典型用法代码示例。如果您正苦于以下问题:C++ SamFileHeader::getReferenceID方法的具体用法?C++ SamFileHeader::getReferenceID怎么用?C++ SamFileHeader::getReferenceID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SamFileHeader
的用法示例。
在下文中一共展示了SamFileHeader::getReferenceID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNumUnMappedReadsFromIndex
// Get the number of unmapped reads in the specified reference id.
// Returns -1 for out of range refIDs.
int32_t SamFile::getNumUnMappedReadsFromIndex(const char* refName,
SamFileHeader& header)
{
// The bam index must have already been read.
if(myBamIndex == NULL)
{
myStatus.setStatus(SamStatus::FAIL_ORDER,
"Cannot get num unmapped reads from the index until it has been read.");
return(false);
}
int32_t refID = BamIndex::REF_ID_UNMAPPED;
if((strcmp(refName, "") != 0) && (strcmp(refName, "*") != 0))
{
// Reference name specified, so read just the "-1" entries.
refID = header.getReferenceID(refName);
}
return(myBamIndex->getNumUnMappedReads(refID));
}
示例2: processNewSection
bool SamFile::processNewSection(SamFileHeader &header)
{
myNewSection = false;
// If there is no index file, return failure.
if(myBamIndex == NULL)
{
// No bam index has been read.
myStatus.setStatus(SamStatus::FAIL_ORDER,
"Cannot read section since there is no index file open");
throw(std::runtime_error("SOFTWARE BUG: trying to read a BAM record by section prior to opening the BAM Index file."));
return(false);
}
// If there is not a BAM file open for reading, return failure.
if(!myIsBamOpenForRead)
{
// There is not a BAM file open for reading.
myStatus.setStatus(SamStatus::FAIL_ORDER,
"Cannot read section since there is no bam file open");
throw(std::runtime_error("SOFTWARE BUG: trying to read a BAM record by section without opening a BAM file."));
return(false);
}
if(myHasHeader == false)
{
// The header has not yet been read.
myStatus.setStatus(SamStatus::FAIL_ORDER,
"Cannot read record since the header has not been read.");
throw(std::runtime_error("SOFTWARE BUG: trying to read a BAM record by section prior to opening the header."));
return(false);
}
// Indexed Bam open for read, so disable read buffering because iftell
// will be used.
// Needs to be done here after we already know that the header has been
// read.
myFilePtr->disableBuffering();
myChunksToRead.clear();
// Reset the end of the current chunk. We are resetting our read, so
// we no longer have a "current chunk" that we are reading.
myCurrentChunkEnd = 0;
// Check to see if the read section was set based on the reference name
// but not yet converted to reference id.
if(!myRefName.empty())
{
myRefID = header.getReferenceID(myRefName.c_str());
// Clear the myRefName length so this code is only executed once.
myRefName.clear();
// Check to see if a reference id was found.
if(myRefID == SamReferenceInfo::NO_REF_ID)
{
myStatus = SamStatus::NO_MORE_RECS;
return(false);
}
}
// Get the chunks associated with this reference region.
if(myBamIndex->getChunksForRegion(myRefID, myStartPos, myEndPos,
myChunksToRead) == true)
{
myStatus = SamStatus::SUCCESS;
}
else
{
String errorMsg = "Failed to get the specified region, refID = ";
errorMsg += myRefID;
errorMsg += "; startPos = ";
errorMsg += myStartPos;
errorMsg += "; endPos = ";
errorMsg += myEndPos;
myStatus.setStatus(SamStatus::FAIL_PARSE,
errorMsg);
}
return(true);
}
示例3: execute
//.........这里部分代码省略.........
else if(dbsnpListPtr == NULL)
{
std::cerr << "Failed to init the memory allocation for the dbsnpList.\n";
}
else
{
// Read the dbsnp file.
StringArray tokens;
String buffer;
int position = 0;
int refID = 0;
// Loop til the end of the file.
while (!ifeof(fdbSnp))
{
// Read the next line.
buffer.ReadLine(fdbSnp);
// If it does not have at least 2 columns,
// continue to the next line.
if (buffer.IsEmpty() || buffer[0] == '#') continue;
tokens.AddTokens(buffer);
if(tokens.Length() < 2) continue;
if(!tokens[1].AsInteger(position))
{
std::cerr << "Improperly formatted region line, start position "
<< "(2nd column) is not an integer: "
<< tokens[1]
<< "; Skipping to the next line.\n";
continue;
}
// Look up the reference name.
refID = samHeader.getReferenceID(tokens[0]);
if(refID != SamReferenceInfo::NO_REF_ID)
{
// Reference id was found, so add it to the dbsnp
dbsnpListPtr->addPosition(refID, position);
}
tokens.Clear();
buffer.Clear();
}
}
ifclose(fdbSnp);
}
// Read the sam records.
SamRecord samRecord;
int numReads = 0;
//////////////////////
// Setup in case doing a quality count.
// Quality histogram.
const int MAX_QUAL = 126;
const int START_QUAL = 33;
uint64_t qualCount[MAX_QUAL+1];
for(int i = 0; i <= MAX_QUAL; i++)
{
qualCount[i] = 0;
}
const int START_PHRED = 0;
const int PHRED_DIFF = START_QUAL - START_PHRED;
const int MAX_PHRED = MAX_QUAL - PHRED_DIFF;