本文整理汇总了C++中SamFileHeader::getErrorMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ SamFileHeader::getErrorMessage方法的具体用法?C++ SamFileHeader::getErrorMessage怎么用?C++ SamFileHeader::getErrorMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SamFileHeader
的用法示例。
在下文中一共展示了SamFileHeader::getErrorMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readHeader
// Read a BAM file's header.
bool BamInterface::readHeader(IFILE filePtr, SamFileHeader& header,
SamStatus& status)
{
if(filePtr == NULL)
{
// File is not open, return false.
status.setStatus(SamStatus::FAIL_ORDER,
"Cannot read header since the file pointer is null");
return(false);
}
if(filePtr->isOpen() == false)
{
status.setStatus(SamStatus::FAIL_ORDER,
"Cannot read header since the file is not open");
return(false);
}
// Clear the passed in header.
header.resetHeader();
int32_t headerLength;
int readSize = ifread(filePtr, &headerLength, sizeof(headerLength));
if(readSize != sizeof(headerLength))
{
String errMsg = "Failed to read the BAM header length, read ";
errMsg += readSize;
errMsg += " bytes instead of ";
errMsg += (unsigned int)sizeof(headerLength);
status.setStatus(SamStatus::FAIL_IO, errMsg.c_str());
return(false);
}
String headerStr;
if(headerLength > 0)
{
// Read the header.
readSize =
ifread(filePtr, headerStr.LockBuffer(headerLength + 1), headerLength);
headerStr[headerLength] = 0;
headerStr.UnlockBuffer();
if(readSize != headerLength)
{
// Failed to read the header.
status.setStatus(SamStatus::FAIL_IO, "Failed to read the BAM header.");
return(false);
}
}
// Parse the header that was read.
if(!header.addHeader(headerStr))
{
// Status is set in the method on failure.
status.setStatus(SamStatus::FAIL_PARSE, header.getErrorMessage());
return(false);
}
int referenceCount;
// Read the number of references sequences.
ifread(filePtr, &referenceCount, sizeof(int));
// Get and clear the reference info so it can be set
// from the bam reference table.
SamReferenceInfo& refInfo =
header.getReferenceInfoForBamInterface();
refInfo.clear();
CharBuffer refName;
// Read each reference sequence
for (int i = 0; i < referenceCount; i++)
{
int nameLength;
int rc;
// Read the length of the reference name.
rc = ifread(filePtr, &nameLength, sizeof(int));
if(rc != sizeof(int))
{
status.setStatus(SamStatus::FAIL_IO,
"Failed to read the BAM reference dictionary.");
return(false);
}
// Read the name.
refName.readFromFile(filePtr, nameLength);
// Read the length of the reference sequence.
int32_t refLen;
rc = ifread(filePtr, &refLen, sizeof(int));
if(rc != sizeof(int)) {
status.setStatus(SamStatus::FAIL_IO,
"Failed to read the BAM reference dictionary.");
return(false);
}
refInfo.add(refName.c_str(), refLen);
}
//.........这里部分代码省略.........