本文整理汇总了C++中SamRecord::setSequenceTranslation方法的典型用法代码示例。如果您正苦于以下问题:C++ SamRecord::setSequenceTranslation方法的具体用法?C++ SamRecord::setSequenceTranslation怎么用?C++ SamRecord::setSequenceTranslation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SamRecord
的用法示例。
在下文中一共展示了SamRecord::setSequenceTranslation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNumOverlaps
// Returns the number of bases in the passed in read that overlap the
// region that is currently set.
uint32_t SamFile::GetNumOverlaps(SamRecord& samRecord)
{
if(myRefPtr != NULL)
{
samRecord.setReference(myRefPtr);
}
samRecord.setSequenceTranslation(myReadTranslation);
// Get the overlaps in the sam record for the region currently set
// for this file.
return(samRecord.getNumOverlaps(myStartPos, myEndPos));
}
示例2: ReadRecord
// Read a record from the currently opened file.
bool SamFile::ReadRecord(SamFileHeader& header,
SamRecord& record)
{
myStatus = SamStatus::SUCCESS;
if(myIsOpenForRead == false)
{
// File is not open for read
myStatus.setStatus(SamStatus::FAIL_ORDER,
"Cannot read record since the file is not open for reading");
throw(std::runtime_error("SOFTWARE BUG: trying to read a SAM/BAM record prior to opening the file."));
return(false);
}
if(myHasHeader == false)
{
// The header has not yet been read.
// TODO - maybe just read the header.
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 SAM/BAM record prior to reading the header."));
return(false);
}
// Check to see if a new region has been set. If so, determine the
// chunks for that region.
if(myNewSection)
{
if(!processNewSection(header))
{
// Failed processing a new section. Could be an
// order issue like the file not being open or the
// indexed file not having been read.
// processNewSection sets myStatus with the failure reason.
return(false);
}
}
// Read until a record is not successfully read or there are no more
// requested records.
while(myStatus == SamStatus::SUCCESS)
{
record.setReference(myRefPtr);
record.setSequenceTranslation(myReadTranslation);
// If reading by index, this method will setup to ensure it is in
// the correct position for the next record (if not already there).
// Sets myStatus if it could not move to a good section.
// Just returns true if it is not setup to read by index.
if(!ensureIndexedReadPosition())
{
// Either there are no more records in the section
// or it failed to move to the right section, so there
// is nothing more to read, stop looping.
break;
}
// File is open for reading and the header has been read, so read the
// next record.
myInterfacePtr->readRecord(myFilePtr, header, record, myStatus);
if(myStatus != SamStatus::SUCCESS)
{
// Failed to read the record, so break out of the loop.
break;
}
// Successfully read a record, so check if we should filter it.
// First check if it is out of the section. Returns true
// if not reading by sections, returns false if the record
// is outside of the section. Sets status to NO_MORE_RECS if
// there is nothing left ot read in the section.
if(!checkRecordInSection(record))
{
// The record is not in the section.
// The while loop will detect if NO_MORE_RECS was set.
continue;
}
// Check the flag for required/excluded flags.
uint16_t flag = record.getFlag();
if((flag & myRequiredFlags) != myRequiredFlags)
{
// The record does not conatain all required flags, so
// continue looking.
continue;
}
if((flag & myExcludedFlags) != 0)
{
// The record contains an excluded flag, so continue looking.
continue;
}
//increment the record count.
myRecordCount++;
if(myStatistics != NULL)
{
// Statistics should be updated.
myStatistics->updateStatistics(record);
//.........这里部分代码省略.........
示例3: validateSortOrder
// Validate that the record is sorted compared to the previously read record
// if there is one, according to the specified sort order.
// If the sort order is UNSORTED, true is returned.
bool SamFile::validateSortOrder(SamRecord& record, SamFileHeader& header)
{
if(myRefPtr != NULL)
{
record.setReference(myRefPtr);
}
record.setSequenceTranslation(myReadTranslation);
bool status = false;
if(mySortedType == UNSORTED)
{
// Unsorted, so nothing to validate, just return true.
status = true;
}
else
{
// Check to see if mySortedType is based on the header.
if(mySortedType == FLAG)
{
// Determine the sorted type from what was read out of the header.
mySortedType = getSortOrderFromHeader(header);
}
if(mySortedType == QUERY_NAME)
{
// Validate that it is sorted by query name.
// Get the query name from the record.
const char* readName = record.getReadName();
// Check if it is sorted either in samtools way or picard's way.
if((myPrevReadName.Compare(readName) > 0) &&
(strcmp(myPrevReadName.c_str(), readName) > 0))
{
// return false.
String errorMessage = "ERROR: File is not sorted by read name at record ";
errorMessage += myRecordCount;
errorMessage += "\n\tPrevious record was ";
errorMessage += myPrevReadName;
errorMessage += ", but this record is ";
errorMessage += readName;
myStatus.setStatus(SamStatus::INVALID_SORT,
errorMessage.c_str());
status = false;
}
else
{
myPrevReadName = readName;
status = true;
}
}
else
{
// Validate that it is sorted by COORDINATES.
// Get the leftmost coordinate and the reference index.
int32_t refID = record.getReferenceID();
int32_t coord = record.get0BasedPosition();
// The unmapped reference id is at the end of a sorted file.
if(refID == BamIndex::REF_ID_UNMAPPED)
{
// A new reference ID that is for the unmapped reads
// is always valid.
status = true;
myPrevRefID = refID;
myPrevCoord = coord;
}
else if(myPrevRefID == BamIndex::REF_ID_UNMAPPED)
{
// Previous reference ID was for unmapped reads, but the
// current one is not, so this is not sorted.
String errorMessage = "ERROR: File is not coordinate sorted at record ";
errorMessage += myRecordCount;
errorMessage += "\n\tPrevious record was unmapped, but this record is ";
errorMessage += header.getReferenceLabel(refID) + ":" + coord;
myStatus.setStatus(SamStatus::INVALID_SORT,
errorMessage.c_str());
status = false;
}
else if(refID < myPrevRefID)
{
// Current reference id is less than the previous one,
//meaning that it is not sorted.
String errorMessage = "ERROR: File is not coordinate sorted at record ";
errorMessage += myRecordCount;
errorMessage += "\n\tPrevious record was ";
errorMessage += header.getReferenceLabel(myPrevRefID) + ":" + myPrevCoord;
errorMessage += ", but this record is ";
errorMessage += header.getReferenceLabel(refID) + ":" + coord;
myStatus.setStatus(SamStatus::INVALID_SORT,
errorMessage.c_str());
status = false;
}
else
{
// The reference IDs are in the correct order.
if(refID > myPrevRefID)
{
// New reference id, so set the previous coordinate to -1
//.........这里部分代码省略.........