本文整理汇总了C++中SamRecord::setQuality方法的典型用法代码示例。如果您正苦于以下问题:C++ SamRecord::setQuality方法的具体用法?C++ SamRecord::setQuality怎么用?C++ SamRecord::setQuality使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SamRecord
的用法示例。
在下文中一共展示了SamRecord::setQuality方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testRead
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);
}
示例2: updateQual
bool Revert::updateQual(SamRecord& samRecord)
{
// Get the OQ tag, which is a string.
const String* oldQual = samRecord.getStringTag(SamTags::ORIG_QUAL_TAG);
bool status = true;
if(oldQual != NULL)
{
// The old quality was found, so set it in the record.
status &= samRecord.setQuality((*oldQual).c_str());
if(!myKeepTags)
{
// Remove the tag.
samRecord.rmTag(SamTags::ORIG_QUAL_TAG, SamTags::ORIG_QUAL_TAG_TYPE);
}
}
return(status);
}
示例3: processReadApplyTable
//.........这里部分代码省略.........
// Check if there is an old quality.
const String* oldQPtr =
samRecord.getStringTag(myQField.c_str());
if((oldQPtr != NULL) && (oldQPtr->Length() == seqLen))
{
// There is an old quality, so use that.
myQualityStrings.oldq = oldQPtr->c_str();
}
else
{
myQualityStrings.oldq = samRecord.getQuality();
}
}
else
{
myQualityStrings.oldq = samRecord.getQuality();
}
if(myQualityStrings.oldq.length() != (unsigned int)seqLen)
{
Logger::gLogger->warning("Quality is not the correct length, so skipping recalibration on that record.");
return(false);
}
myQualityStrings.newq.resize(seqLen);
////////////////
////// iterate sequence
////////////////
int32_t seqPos = 0;
int seqIncr = 1;
bool reverse;
if(SamFlag::isReverse(flag))
{
reverse = true;
seqPos = seqLen - 1;
seqIncr = -1;
}
else
reverse = false;
// Check which read - this will be the same for all positions, so
// do this outside of the smaller loop.
if(!SamFlag::isPaired(flag) || SamFlag::isFirstFragment(flag))
// Mark as first if it is not paired or if it is the
// first in the pair.
data.read = 0;
else
data.read = 1;
// Set unsetbase for curBase.
// This will be used for the prebase of cycle 0.
data.curBase = 'K';
for (data.cycle = 0; data.cycle < seqLen; data.cycle++, seqPos += seqIncr)
{
// Set the preBase to the previous cycle's current base.
// For cycle 0, curBase was set to a default value.
data.preBase = data.curBase;
// Get the current base.
data.curBase = samRecord.getSequence(seqPos);
if(reverse)
{
// Complement the current base.
data.curBase =
BaseAsciiMap::base2complement[(unsigned int)(data.curBase)];
}
// Get quality
data.qual =
BaseUtilities::getPhredBaseQuality(myQualityStrings.oldq[seqPos]);
// skip bases with quality below the minimum set.
if(data.qual < myMinBaseQual)
{
myQualityStrings.newq[seqPos] = myQualityStrings.oldq[seqPos];
continue;
}
// Update quality score
uint8_t qemp = hasherrormodel.getQemp(data);
qemp = mySqueeze.getQualCharFromQemp(qemp);
if(qemp > myMaxBaseQualChar)
{
qemp = myMaxBaseQualChar;
}
myQualityStrings.newq[seqPos] = qemp;
}
if(!myStoreQualTag.IsEmpty())
{
samRecord.addTag(myStoreQualTag, 'Z', myQualityStrings.oldq.c_str());
}
samRecord.setQuality(myQualityStrings.newq.c_str());
return true;
}
示例4: execute
//.........这里部分代码省略.........
// Keep reading records until ReadRecord returns false.
while(samIn.ReadRecord(samHeader, samRecord)) {
// Successfully read a record from the file, so write it.
strcpy(seq,samRecord.getSequence());
strcpy(qual,samRecord.getQuality());
// Number of bases to trim from the left/right,
// set based on ignoreStrand flag and strand info.
int trimLeft = numTrimBaseL;
int trimRight = numTrimBaseR;
if(!ignoreStrand)
{
if(SamFlag::isReverse(samRecord.getFlag()))
{
// We are reversing the reverse reads,
// so swap the left & right trim counts.
trimRight = numTrimBaseL;
trimLeft = numTrimBaseR;
}
}
len = strlen(seq);
// Do not trim if sequence is '*'
if ( strcmp(seq, "*") != 0 ) {
bool qualValue = true;
if(strcmp(qual, "*") == 0)
{
qualValue = false;
}
int qualLen = strlen(qual);
if ( (qualLen != len) && qualValue ) {
fprintf(stderr,"ERROR: Sequence and Quality have different length\n");
return(-1);
}
if ( len < (trimLeft + trimRight) ) {
// Read Length is less than the total number of bases to trim,
// so trim the entire read.
for(i=0; i < len; ++i) {
seq[i] = 'N';
if ( qualValue ) {
qual[i] = '!';
}
}
}
else
{
// Read Length is larger than the total number of bases to trim,
// so trim from the left, then from the right.
for(i=0; i < trimLeft; ++i)
{
// Trim the bases from the left.
seq[i] = 'N';
if ( qualValue )
{
qual[i] = '!';
}
}
for(i = 0; i < trimRight; i++)
{
seq[len-i-1] = 'N';
if(qualValue)
{
qual[len-i-1] = '!';
}
}
}
samRecord.setSequence(seq);
samRecord.setQuality(qual);
}
if(!samOut.WriteRecord(samHeader, samRecord)) {
// Failed to write a record.
fprintf(stderr, "Failure in writing record %s\n", samOut.GetStatusMessage());
return(-1);
}
}
if(samIn.GetStatus() != SamStatus::NO_MORE_RECS)
{
// Failed to read a record.
fprintf(stderr, "%s\n", samIn.GetStatusMessage());
}
std::cerr << std::endl << "Number of records read = " <<
samIn.GetCurrentRecordCount() << std::endl;
std::cerr << "Number of records written = " <<
samOut.GetCurrentRecordCount() << std::endl;
if(samIn.GetStatus() != SamStatus::NO_MORE_RECS)
{
// Failed reading a record.
return(samIn.GetStatus());
}
// Since the reads were successful, return the status based
samIn.Close();
samOut.Close();
return 0;
}