本文整理汇总了C++中BamAlignment::RemoveTag方法的典型用法代码示例。如果您正苦于以下问题:C++ BamAlignment::RemoveTag方法的具体用法?C++ BamAlignment::RemoveTag怎么用?C++ BamAlignment::RemoveTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BamAlignment
的用法示例。
在下文中一共展示了BamAlignment::RemoveTag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// 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);
}
示例2: test_ParseRead
void ReadContainerTest::test_ParseRead() {
map<pair<string,int>, string> ref_ext_nucleotides;
BamAlignment aln;
std::string rg = "test";
std::string repseq = "AC";
AlignedRead aligned_read;
float copynum = 10;
include_flank = false;
// Test valid allele length
aln.Name = "test";
aln.QueryBases = "NNNNN";
aln.Qualities = "NNNNN";
aln.SetIsReverseStrand(true);
aln.Position = 0;
aln.SetIsSecondMate(false);
aln.AddTag("RG","Z",rg);
aln.AddTag("XS","i",0);
aln.AddTag("XE","i",20);
aln.AddTag("XR", "Z", repseq);
aln.AddTag("XC", "f", copynum);
aln.RefID = 0;
// No XD
aln.RemoveTag("XD");
CPPUNIT_ASSERT(!(_read_container->ParseRead(aln, &aligned_read, ref_ext_nucleotides)));
// Test more valid allele lengths
aln.AddTag("XD","i",20);
CPPUNIT_ASSERT(_read_container->ParseRead(aln, &aligned_read, ref_ext_nucleotides));
aln.RemoveTag("XD");
aln.AddTag("XD","i",-19);
CPPUNIT_ASSERT(_read_container->ParseRead(aln, &aligned_read, ref_ext_nucleotides));
// Test invalid allele length
aln.RemoveTag("XD");
aln.AddTag("XD","i",-31);
CPPUNIT_ASSERT(!(_read_container->ParseRead(aln, &aligned_read, ref_ext_nucleotides)));
// Exceed max_diff_ref
aln.RemoveTag("XD");
aln.AddTag("XD","i",100);
CPPUNIT_ASSERT(!(_read_container->ParseRead(aln, &aligned_read, ref_ext_nucleotides)));
aln.RemoveTag("XD");
aln.AddTag("XD","i",0);
// Exceed max mate dist
aln.AddTag("XM","i",1000000);
CPPUNIT_ASSERT(!(_read_container->ParseRead(aln, &aligned_read, ref_ext_nucleotides)));
aln.RemoveTag("XM");
// Exceed max mapq
aln.AddTag("XQ","i",10000);
CPPUNIT_ASSERT(!(_read_container->ParseRead(aln, &aligned_read, ref_ext_nucleotides)));
aln.RemoveTag("XQ");
// Read is mate
aln.SetIsSecondMate(true);
CPPUNIT_ASSERT(!(_read_container->ParseRead(aln, &aligned_read, ref_ext_nucleotides)));
aln.SetIsSecondMate(false);
// Read is partial
aln.AddTag("XP","i",1);
CPPUNIT_ASSERT(!(_read_container->ParseRead(aln, &aligned_read, ref_ext_nucleotides)));
aln.RemoveTag("XP");
// Non-unit
unit = true;
aln.RemoveTag("XD");
aln.AddTag("XD","i",5);
CPPUNIT_ASSERT(!(_read_container->ParseRead(aln, &aligned_read, ref_ext_nucleotides)));
unit = false;
}
示例3: test_GetBamTags
void ReadContainerTest::test_GetBamTags() {
// TODO
BamAlignment aln;
string str_result;
float float_result;
string rg = "test";
float xc = 12.0;
aln.AddTag("RG","Z",rg);
aln.AddTag("XD","i",0);
aln.AddTag("XC","f",xc);
// GetStringBamTag
CPPUNIT_ASSERT(_read_container->GetStringBamTag(aln, "RG", &str_result));
CPPUNIT_ASSERT(str_result == "test");
CPPUNIT_ASSERT(!_read_container->GetStringBamTag(aln, "XX", &str_result));
// GetFloatBamTag
CPPUNIT_ASSERT(_read_container->GetFloatBamTag(aln, "XC", &float_result));
CPPUNIT_ASSERT(float_result == 12.0);
CPPUNIT_ASSERT(!_read_container->GetFloatBamTag(aln, "XX", &float_result));
// GetIntBamTag
int int_result;
int d = 0;
aln.AddTag("XA","i",d);
CPPUNIT_ASSERT(_read_container->GetIntBamTag(aln, "XA", &int_result));
CPPUNIT_ASSERT_EQUAL(int_result, 0);
aln.RemoveTag("XA");
int8_t d8 = 10;
aln.AddTag("XA","c", d8);
CPPUNIT_ASSERT(_read_container->GetIntBamTag(aln, "XA", &int_result));
CPPUNIT_ASSERT_EQUAL(int_result, 10);
aln.RemoveTag("XA");
aln.AddTag("XA","c",rg);
CPPUNIT_ASSERT(!_read_container->GetFloatBamTag(aln, "XA", &float_result));
aln.RemoveTag("XA");
uint8_t ud8 = 9;
aln.AddTag("XA","C", ud8);
CPPUNIT_ASSERT(_read_container->GetIntBamTag(aln, "XA", &int_result));
CPPUNIT_ASSERT_EQUAL(int_result, 9);
aln.RemoveTag("XA");
aln.AddTag("XA","C",rg);
CPPUNIT_ASSERT(!_read_container->GetFloatBamTag(aln, "XA", &float_result));
aln.RemoveTag("XA");
int16_t d16 = 8;
aln.AddTag("XA","s",d16);
CPPUNIT_ASSERT(_read_container->GetIntBamTag(aln, "XA", &int_result));
CPPUNIT_ASSERT_EQUAL(int_result, 8);
aln.RemoveTag("XA");
aln.AddTag("XA","s",rg);
CPPUNIT_ASSERT(!_read_container->GetFloatBamTag(aln, "XA", &float_result));
aln.RemoveTag("XA");
uint16_t ud16 = 7;
aln.AddTag("XA","S",ud16);
CPPUNIT_ASSERT(_read_container->GetIntBamTag(aln, "XA", &int_result));
CPPUNIT_ASSERT_EQUAL(int_result, 7);
aln.RemoveTag("XA");
aln.AddTag("XA","S",rg);
CPPUNIT_ASSERT(!_read_container->GetFloatBamTag(aln, "XA", &float_result));
aln.RemoveTag("XA");
uint32_t ud32 = 6;
aln.AddTag("XA","I",ud32);
CPPUNIT_ASSERT(_read_container->GetIntBamTag(aln, "XA", &int_result));
CPPUNIT_ASSERT_EQUAL(int_result, 6);
aln.RemoveTag("XA");
aln.AddTag("XA","I",rg);
CPPUNIT_ASSERT(!_read_container->GetFloatBamTag(aln, "XA", &float_result));
aln.RemoveTag("XA");
}
示例4: setMateInfo
void setMateInfo( BamAlignment & rec1, BamAlignment & rec2, SamHeader & header) {
const int NO_ALIGNMENT_REFERENCE_INDEX = -1;
const int NO_ALIGNMENT_START = -1;
// If neither read is unmapped just set their mate info
if (rec1.IsMapped() && rec2.IsMapped()) {
rec1.MateRefID = rec2.MateRefID;
rec1.MatePosition = rec2.Position;
rec1.SetIsReverseStrand(rec2.IsReverseStrand());
rec1.SetIsMapped(true);
rec1.AddTag("MQ", "i", rec2.MapQuality);
rec2.MateRefID = rec1.RefID;
rec2.MatePosition = rec1.Position;
rec2.SetIsReverseStrand( rec1.IsReverseStrand() );
rec2.SetIsMapped(true);
rec2.AddTag("MQ", "i", rec1.MapQuality);
}
// Else if they're both unmapped set that straight
else if (!rec1.IsMapped() && !rec2.IsMapped()) {
rec1.RefID = NO_ALIGNMENT_REFERENCE_INDEX;
rec1.Position = NO_ALIGNMENT_START;
rec1.MateRefID = NO_ALIGNMENT_REFERENCE_INDEX;
rec1.MatePosition = NO_ALIGNMENT_START;
rec1.SetIsReverseStrand(rec2.IsReverseStrand());
rec1.SetIsMapped(false);
rec2.RemoveTag("MQ");
rec1.Length = 0;
rec2.RefID = NO_ALIGNMENT_REFERENCE_INDEX;
rec2.Position = NO_ALIGNMENT_START;
rec2.MateRefID = NO_ALIGNMENT_REFERENCE_INDEX;
rec2.MatePosition = NO_ALIGNMENT_START;
rec2.SetIsReverseStrand(rec1.IsReverseStrand());
rec2.SetIsMapped(false);
rec2.RemoveTag("MQ");
rec2.Length = 0;
}
// And if only one is mapped copy it's coordinate information to the mate
else {
BamAlignment & mapped = rec1.IsMapped() ? rec1 : rec2;
BamAlignment & unmapped = rec1.IsMapped() ? rec2 : rec1;
unmapped.RefID = mapped.RefID;
unmapped.Position = mapped.Position;
mapped.MateRefID = unmapped.RefID;
mapped.MatePosition = unmapped.Position;
mapped.SetIsMateReverseStrand(unmapped.IsReverseStrand());
mapped.SetIsMateMapped(false);
mapped.Length = 0;
unmapped.MateRefID = mapped.RefID;
unmapped.MatePosition = mapped.Position;
unmapped.SetIsMateReverseStrand(mapped.IsReverseStrand());
unmapped.SetIsMateMapped(true);
unmapped.Length = 0;
}
const int insertSize = computeInsertSize(rec1, rec2);
rec1.Length = insertSize;
rec2.Length = -insertSize;
}