本文整理汇总了C++中BamAlignment::SetIsMapped方法的典型用法代码示例。如果您正苦于以下问题:C++ BamAlignment::SetIsMapped方法的具体用法?C++ BamAlignment::SetIsMapped怎么用?C++ BamAlignment::SetIsMapped使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BamAlignment
的用法示例。
在下文中一共展示了BamAlignment::SetIsMapped方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: realign_bam
//.........这里部分代码省略.........
//
gssw_graph_mapping_destroy(gm);
if (params.dry_run) {
if (strand == "-" && !alignment.IsMapped()) {
read = reverseComplement(read);
}
cout << read << endl;
cout << graph_mapping_to_string(gm) << endl;
cout << score << " " << strand << " "
<< position << " "
<< flat_cigar << endl;
} else {
/*
if (strand == "-") {
read = reverseComplement(trace_report.read);
}
*/
// TODO the qualities are not on the right side of the read
if (strand == "-" && alignment.IsMapped()) {
// if we're realigning, this is always true unless we swapped strands
alignment.SetIsReverseStrand(true);
//reverse(alignment.Qualities.begin(), alignment.Qualities.end()); // reverse qualities
}
//alignment.QueryBases = reverseComplement(trace_report.read);
alignment.QueryBases = read;
alignment.Qualities = qualities;
alignment.Position = position;// + 1;// + 1;//(trace_report.node->position - 1) + trace_report.x;
alignment.SetIsMapped(true);
if (!alignment.MapQuality) {
alignment.MapQuality = 20; // horrible hack... at least approximate with alignment mismatches against graph
}
// check if somehow we've ended up with an indel at the ends
// if so, grab the reference sequence right beyond it and add
// a single match to the cigar, allowing variant detection methods
// to run on the results without internal modification
Cigar& cigar = flat_cigar;
//cerr << flat_cigar << " " << flat_cigar.readLen() << " " << flat_cigar.refLen() << endl;
int flankSize = params.flatten_flank;
if (cigar.front().isIndel() ||
(cigar.front().isSoftclip() && cigar.at(1).isIndel())) {
alignment.Position -= flankSize;
string refBase = reference.getSubSequence(seqname, alignment.Position, flankSize);
if (cigar.front().isSoftclip()) {
alignment.QueryBases.erase(alignment.QueryBases.begin(),
alignment.QueryBases.begin()+cigar.front().length);
alignment.Qualities.erase(alignment.Qualities.begin(),
alignment.Qualities.begin()+cigar.front().length);
cigar.erase(cigar.begin());
}
alignment.QueryBases.insert(0, refBase);
alignment.Qualities.insert(0, string(flankSize, shortInt2QualityChar(30)));
Cigar newCigar; newCigar.push_back(CigarElement(flankSize, 'M'));
newCigar.append(flat_cigar);
flat_cigar = newCigar;
}
if (cigar.back().isIndel() ||
(cigar.back().isSoftclip() && cigar.at(cigar.size()-2).isIndel())) {
string refBase = reference.getSubSequence(seqname,
alignment.Position