本文整理汇总了C++中BamAlignment::SetIsDuplicate方法的典型用法代码示例。如果您正苦于以下问题:C++ BamAlignment::SetIsDuplicate方法的具体用法?C++ BamAlignment::SetIsDuplicate怎么用?C++ BamAlignment::SetIsDuplicate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BamAlignment
的用法示例。
在下文中一共展示了BamAlignment::SetIsDuplicate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runInternal
/**
* Main work method. Reads the BAM file once and collects sorted information about
* the 5' ends of both ends of each read (or just one end in the case of pairs).
* Then makes a pass through those determining duplicates before re-reading the
* input file and writing it out with duplication flags set correctly.
*/
int MarkDuplicates::runInternal() {
ogeNameThread("am_MarkDuplicates");
if(verbose)
cerr << "Reading input file and constructing read end information." << endl;
buildSortedReadEndLists();
generateDuplicateIndexes();
if(verbose)
cerr << "Marking " << numDuplicateIndices << " records as duplicates." << endl;
BamReader in;
in.Open(getBufferFileName());
// Now copy over the file while marking all the necessary indexes as duplicates
long recordInFileIndex = 0;
long written = 0;
while (true) {
BamAlignment * prec = in.GetNextAlignment();
if(!prec)
break;
if (prec->IsPrimaryAlignment()) {
if (duplicateIndexes.count(recordInFileIndex) == 1)
prec->SetIsDuplicate(true);
else
prec->SetIsDuplicate(false);
}
recordInFileIndex++;
if (removeDuplicates && prec->IsDuplicate()) {
// do nothing
}
else {
putOutputAlignment(prec);
if (verbose && read_count && ++written % 100000 == 0) {
cerr << "\rWritten " << written << " records (" << written * 100 / read_count <<"%)." << std::flush;
}
}
}
if (verbose && read_count)
cerr << "\rWritten " << written << " records (" << written * 100 / read_count <<"%)." << endl;
in.Close();
remove(getBufferFileName().c_str());
return 0;
}
示例2:
// reverts a BAM alignment
// default behavior (for now) is : replace Qualities with OQ, clear IsDuplicate flag
// can override default behavior using command line options
void RevertTool::RevertToolPrivate::RevertAlignment(BamAlignment& al) {
// replace Qualities with OQ, if requested
if ( !m_settings->IsKeepQualities ) {
string originalQualities;
if ( al.GetTag(m_OQ, originalQualities) ) {
al.Qualities = originalQualities;
al.RemoveTag(m_OQ);
}
}
// clear duplicate flag, if requested
if ( !m_settings->IsKeepDuplicateFlag )
al.SetIsDuplicate(false);
}
示例3: main
//.........这里部分代码省略.........
while ( reader.GetNextAlignment(al) ) {
if(al.IsMapped() || al.HasTag("NM") || al.HasTag("MD") ){
if(!allowAligned){
cerr << "Reads should not be aligned" << endl;
return 1;
}else{
//should we remove tags ?
}
}
if(al.IsPaired() &&
al2Null ){
al2=al;
al2Null=false;
continue;
}else{
if(al.IsPaired() &&
!al2Null){
bool result = mtr.processPair(al,al2);
if( result ){//was merged
BamAlignment orig;
BamAlignment orig2;
if(keepOrig){
orig2 = al2;
orig = al;
}
writer.SaveAlignment(al);
if(keepOrig){
orig.SetIsDuplicate(true);
orig2.SetIsDuplicate(true);
writer.SaveAlignment(orig2);
writer.SaveAlignment(orig);
}
//the second record is empty
}else{
//keep the sequences as pairs
writer.SaveAlignment(al2);
writer.SaveAlignment(al);
}
//
// SINGLE END
//
}else{
BamAlignment orig;
if(keepOrig){
orig =al;
}
mtr.processSingle(al);
if(keepOrig){
//write duplicate
if(orig.QueryBases.length() != al.QueryBases.length()){
orig.SetIsDuplicate(true);
writer.SaveAlignment(orig);
}
}
writer.SaveAlignment(al);
} //end single end
al2Null=true;
}//second pair
} //while al
reader.Close();
writer.Close();
} //else BAM
cerr <<mtr.reportSingleLine()<<endl;
if(printLog){
ofstream fileLog;
fileLog.open(logFileName.c_str());
if (fileLog.is_open()){
fileLog <<mtr.reportMultipleLines() <<endl;
}else{
cerr << "Unable to print to file "<<logFileName<<endl;
}
fileLog.close();
}
return 0;
}