本文整理汇总了C++中BamWriter::SetHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ BamWriter::SetHeader方法的具体用法?C++ BamWriter::SetHeader怎么用?C++ BamWriter::SetHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BamWriter
的用法示例。
在下文中一共展示了BamWriter::SetHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
default:
abort();
break;
}
}
if (!has_ref) {
cerr << "no FASTA reference provided, cannot realign" << endl;
exit(1);
}
BAMSINGLEREADER reader;
if (!reader.Open(STDIN)) {
cerr << "could not open stdin for reading" << endl;
exit(1);
}
#ifdef HAVE_BAMTOOLS
BamWriter writer;
if (isuncompressed) {
writer.SetCompressionMode(BamWriter::Uncompressed);
}
if (!suppress_output && !writer.Open("stdout", reader.GetHeaderText(), reader.GetReferenceData())) {
cerr << "could not open stdout for writing" << endl;
exit(1);
}
#else
SeqLib::BamWriter writer(isuncompressed ? SeqLib::SAM : SeqLib::BAM);
SeqLib::BamHeader hdr = reader.Header();
if (hdr.isEmpty()) {
cerr << "could not open header for input" << endl;
exit(1);
}
writer.SetHeader(hdr);
if (!suppress_output && !writer.Open("-")) {
cerr << "could not open stdout for writing" << endl;
exit(1);
}
#endif
// store the names of all the reference sequences in the BAM file
map<int, string> referenceIDToName;
REFVEC referenceSequences = reader.GETREFDATA;
int i = 0;
for (REFVEC::iterator r = referenceSequences.begin(); r != referenceSequences.end(); ++r) {
referenceIDToName[i] = r->REFNAME;
++i;
}
BAMALIGN alignment;
while (GETNEXT(reader, alignment)) {
DEBUG("--------------------------- read --------------------------" << endl);
DEBUG("| " << referenceIDToName[alignment.REFID] << ":" << alignment.POSITION << endl);
DEBUG("| " << alignment.QNAME << ":" << alignment.ENDPOSITION << endl);
DEBUG("| " << alignment.QNAME << ":" << (alignment.ISMAPPED ? " mapped" : " unmapped") << endl);
DEBUG("| " << alignment.QNAME << ":" << " cigar data size: " << alignment.GETCIGAR.size() << endl);
DEBUG("--------------------------- realigned --------------------------" << endl);
// skip unmapped alignments, as they cannot be left-realigned without CIGAR data
if (alignment.ISMAPPED) {
int endpos = alignment.ENDPOSITION;
int length = endpos - alignment.POSITION + 1;
if (alignment.POSITION >= 0 && length > 0) {
if (!stablyLeftAlign(alignment,
reference.getSubSequence(
referenceIDToName[alignment.REFID],
alignment.POSITION,
length),
maxiterations, debug)) {
cerr << "unstable realignment of " << alignment.QNAME
<< " at " << referenceIDToName[alignment.REFID] << ":" << alignment.POSITION << endl
<< alignment.QUERYBASES << endl;
}
}
}
DEBUG("----------------------------------------------------------------" << endl);
DEBUG(endl);
if (!suppress_output)
WRITEALIGNMENT(writer, alignment);
}
reader.Close();
if (!suppress_output)
writer.Close();
return 0;
}