本文整理汇总了C++中SamFileHeader::addHeaderLine方法的典型用法代码示例。如果您正苦于以下问题:C++ SamFileHeader::addHeaderLine方法的具体用法?C++ SamFileHeader::addHeaderLine怎么用?C++ SamFileHeader::addHeaderLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SamFileHeader
的用法示例。
在下文中一共展示了SamFileHeader::addHeaderLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testAddHeaderAndTagToFile
void testAddHeaderAndTagToFile(const char* inputName, const char* outputName)
{
SamFile inSam, outSam;
assert(inSam.OpenForRead(inputName));
assert(outSam.OpenForWrite(outputName));
// Read the SAM Header.
SamFileHeader samHeader;
assert(inSam.ReadHeader(samHeader));
// Add a header line.
assert(samHeader.addHeaderLine("@RG\tID:myID\tSM:mySM") == false);
assert(samHeader.addHeaderLine("@RG\tID:myID3\tSM:mySM") == true);
// Write Header
assert(outSam.WriteHeader(samHeader));
SamRecord samRecord;
assert(inSam.ReadRecord(samHeader, samRecord));
// validateRead1(samRecord);
// Add two tags.
assert(samRecord.addIntTag("XA", 123));
assert(samRecord.addIntTag("XA", 456));
assert(samRecord.addTag("RR", 'Z', "myID1"));
assert(samRecord.addTag("RR", 'Z', "myID2"));
// Write as Sam.
assert(outSam.WriteRecord(samHeader, samRecord));
// TODO, add test to verify it was written correctly.
// Read a couple of records to make sure it properly can read them even
// if they are bigger than the original.
assert(inSam.ReadRecord(samHeader, samRecord));
assert(inSam.ReadRecord(samHeader, samRecord));
// Check the MD tag, which requires the reference.
GenomeSequence reference("testFiles/chr1_partial.fa");
assert(SamTags::isMDTagCorrect(samRecord, reference) == false);
String newMDTag;
SamTags::createMDTag(newMDTag, samRecord, reference);
assert(newMDTag == "2T1N0");
assert(SamTags::updateMDTag(samRecord, reference));
// Write as Sam.
assert(outSam.WriteRecord(samHeader, samRecord));
}
示例2: main
//.........这里部分代码省略.........
// iterator over all @SQ objects
for(unsigned int i=0; i < numSQ; ++i) {
pSamHeaderRecord = samHeader.getSQ(fastaFile.vsSequenceNames[i].c_str());
if ( fastaFile.vsSequenceNames[i].compare(pSamHeaderRecord->getTagValue("SN")) != 0 ) {
gpLogger->error("SequenceName is not identical between fasta and input BAM file");
}
else if ( static_cast<int>(fastaFile.vnSequenceLengths[i]) != atoi(pSamHeaderRecord->getTagValue("LN")) ) {
gpLogger->error("SequenceLength is not identical between fasta and input BAM file");
}
else {
if ( !sAS.empty() )
samHeader.setSQTag("AS",sAS.c_str(),fastaFile.vsSequenceNames[i].c_str());
samHeader.setSQTag("M5",fastaFile.vsMD5sums[i].c_str(),fastaFile.vsSequenceNames[i].c_str());
if ( !sUR.empty() )
samHeader.setSQTag("UR",sUR.c_str(),fastaFile.vsSequenceNames[i].c_str());
if ( !sSP.empty() )
samHeader.setSQTag("SP",sSP.c_str(),fastaFile.vsSequenceNames[i].c_str());
}
}
gpLogger->write_log("Finished checking the consistency of SQ tags");
}
else {
gpLogger->write_log("Skipped checking the consistency of SQ tags");
}
// go over the headers again,
// assuming order of HD, SQ, RG, PG, and put proper tags at the end of the original tags
gpLogger->write_log("Creating the header of new output file");
//SamFileHeader outHeader;
samHeader.resetHeaderRecordIter();
for(unsigned int i=0; i < vsHDHeaders.size(); ++i) {
samHeader.addHeaderLine(vsHDHeaders[i].c_str());
}
/*
for(int i=0; i < fastaFile.vsSequenceNames.size(); ++i) {
std::string s("@SQ\tSN:");
char buf[1024];
s += fastaFile.vsSequenceNames[i];
sprintf(buf,"\tLN:%d",fastaFile.vnSequenceLengths[i]);
s += buf;
if ( !sAS.empty() ) {
sprintf(buf,"\tAS:%s",sAS.c_str());
s += buf;
}
if ( !sUR.empty() ) {
sprintf(buf,"\tUR:%s",sUR.c_str());
s += buf;
}
sprintf(buf,"\tM5:%s",fastaFile.vsMD5sums[i].c_str());
s += buf;
if ( !sSP.empty() ) {
sprintf(buf,"\tSP:%s",sSP.c_str());
s += buf;
}
outHeader.addHeaderLine(s.c_str());
}*/
for(unsigned int i=0; i < vsRGHeaders.size(); ++i) {
samHeader.addHeaderLine(vsRGHeaders[i].c_str());
}
for(unsigned int i=0; i < vsPGHeaders.size(); ++i) {
samHeader.addHeaderLine(vsPGHeaders[i].c_str());
示例3: addReadGroupToHeader
// add readgroup header line to the SamFileHeader
void addReadGroupToHeader(SamFileHeader& header, ReadGroup& rg) {
if ( !header.addHeaderLine(rg.s_header_line.c_str()) ) {
Logger::gLogger->error("Failed to add ID = %s, header line %s",rg.s_id.c_str(),rg.s_header_line.c_str());
}
}