54 static const string kCigar =
"CIGAR";
61 const objects::CSeq_align& align, objects::CScope& scope,
TNumrow anchor)
70 _ASSERT(align.GetSegs().IsDenseg());
71 _ASSERT(align.CheckNumRows() == 2);
72 _ASSERT(align.GetSegs().GetDenseg().CheckNumSegs() > 0);
74 _ASSERT(!align.GetSegs().GetDenseg().IsSetWidths());
90 if (bsh.IsProtein()) {
153 switch (iter->first) {
195 const objects::CBioseq_Handle&
220 bool try_reverse_dir)
const
233 pre_iter = curr_iter;
253 if (try_reverse_dir ||
270 if (try_reverse_dir ||
288 bool try_reverse_dir)
const
302 while (curr_iter && ((reversed && aln_pos < curr_iter->GetRange().GetFrom()) ||
304 pre_iter = curr_iter;
311 (!reversed && aln_pos < curr_iter->GetRange().GetFrom())) {
325 if (try_reverse_dir ||
341 if (try_reverse_dir ||
383 size_t mis_str_idx = 0;
384 size_t curr_seq_idx = 0;
385 TCigar::const_iterator c_iter = cigars.begin();
386 while (
f <
t && c_iter != cigars.end()) {
387 size_t span = c_iter->second;
388 switch (c_iter->first) {
392 if (curr_p + span >
f) {
394 size_t left_over = span -
offset;
405 buffer.replace(curr_seq_idx, left_over, mismatch_str, mis_str_idx, left_over);
407 mis_str_idx += left_over;
408 curr_seq_idx += left_over;
417 if (curr_p + span >
f) {
419 size_t left_over = curr_p -
f;
420 curr_seq_idx += left_over;
428 if (curr_p + span >
f && curr_seq_idx > 0) {
429 buffer.replace(curr_seq_idx, span, span,
'-');
430 curr_seq_idx += span;
463 }
catch (exception& e) {
480 size_t curr_seq_idx = 0;
481 while (curr_iter &&
f <
t) {
486 size_t off = curr_f -
f;
487 buffer.replace(curr_seq_idx, off, off,
'-');
493 if (
t < curr_f + span) {
498 if (curr_seq_idx <
buffer.length())
499 buffer.replace(curr_seq_idx, left_over, left_over,
'-');
506 row_f = row_t - left_over + 1;
509 row_t = row_f + left_over - 1;
511 seq_vec.
GetSeqData(row_f, row_t + 1, tmp_str);
515 0,
static_cast<TSeqPos>(tmp_str.length()), tmp_seq);
516 swap(tmp_str, tmp_seq);
518 if (curr_seq_idx <
buffer.length())
519 buffer.replace(curr_seq_idx, left_over, tmp_str, 0, left_over);
522 curr_seq_idx += left_over;
536 bool anchor_direct)
const
541 size_t f = (size_t)seq_rng.
GetFrom();
542 size_t t = (size_t)seq_rng.
GetTo();
559 size_t mis_str_idx = 0;
560 size_t curr_seq_idx = 0;
561 TCigar::const_iterator c_iter = cigars.begin();
562 while (
f <
t && c_iter != cigars.end()) {
563 size_t span = c_iter->second;
564 switch (c_iter->first) {
568 if (curr_p + span >
f) {
570 size_t left_over = span -
offset;
572 buffer += mismatch_str.substr(mis_str_idx, left_over);
574 mis_str_idx += left_over;
575 curr_seq_idx += left_over;
584 if (curr_p + span >
f) {
586 size_t left_over = curr_p -
f;
587 buffer += anchor_seq.substr(curr_seq_idx, left_over);
588 curr_seq_idx += left_over;
596 if (curr_p + span >
f && curr_seq_idx > 0) {
597 curr_seq_idx += span;
601 if (curr_p + span >
f) {
603 size_t left_over = span -
offset;
605 buffer += mismatch_str.substr(mis_str_idx, left_over);
606 mis_str_idx += left_over;
619 if (!anchor_direct && reversed) {
663 if ( !cigar_str.empty() ) {
669 bool is_bam = !
isdigit(cigar_str[0]);
672 const size_t c_len = cigar_str.length();
674 size_t len_start = is_bam ?
i + 1 :
i;
675 size_t len_end = len_start;
676 size_t type_index =
i;
677 while (len_end < c_len && cigar_str[len_end] <
'=') {
683 type_index = len_end;
693 cigar.emplace_back(c_op,
len);
696 if (!cigar.empty()) {
708 if ((*iter)->GetType().IsStr() &&
726 if ((*iter)->GetType().IsStr() &&
729 if (mismatch_field && mismatch_field->
GetData().
IsStr()) {
virtual TNumrow GetNumRows(void) const
number of rows in alignment
virtual const objects::CSeq_id & GetSeqId(TNumrow row) const
bool m_IsCigarUnambiguous
string x_GetMismatchStr() const
virtual const TCigar * GetCigar() const
Get CIGAR vector.
virtual bool IsCigarUnambiguous() const
Check if cigar doesn't have ambiguous M's.
virtual IAlnSegmentIterator * CreateSegmentIterator(TNumrow row, const TSignedRange &range, IAlnSegmentIterator::EFlags flag) const
virtual const objects::CBioseq_Handle & GetBioseqHandle(TNumrow row) const
virtual TSignedSeqPos GetAlnPosFromSeqPos(TNumrow row, TSeqPos seq_pos, IAlnExplorer::ESearchDirection dir=IAlnExplorer::eNone, bool try_reverse_dir=true) const
virtual TSignedSeqPos GetSeqPosFromSeqPos(TNumrow for_row, TNumrow row, TSeqPos seq_pos) const
virtual TNumrow GetAnchor(void) const
virtual TSeqPos GetAlnStart(void) const
CRef< objects::CScope > m_Scope
string x_GetCigarStr() const
virtual TSignedSeqPos GetSeqPosFromAlnPos(TNumrow for_row, TSeqPos aln_pos, IAlnExplorer::ESearchDirection dir=IAlnExplorer::eNone, bool try_reverse_dir=true) const
map< TNumrow, objects::CBioseq_Handle > m_BioseqHandles
IAlnExplorer::TNumrow TNumrow
virtual TSignedRange GetAlnRange(void) const
virtual TSeqPos GetAlnStop(void) const
virtual TSeqPos GetSeqLength(TNumrow row) const
CConstRef< objects::CSeq_align > m_Alignment
virtual string & GetAlnSeqString(TNumrow row, string &buffer, const TSignedRange &aln_rng) const
virtual bool IsPositiveStrand(TNumrow row) const
virtual bool IsNegativeStrand(TNumrow row) const
virtual TSignedRange GetSeqAlnRange(TNumrow row) const
virtual TSeqPos GetSeqStop(TNumrow row) const
CDensegGraphicDataSource(const objects::CSeq_align &align, objects::CScope &scope, TNumrow anchor)
CDensegGraphicDataSource.
virtual TSeqPos GetBaseWidth(TNumrow row) const
virtual string & GetSeqString(string &buffer, TNumrow row, const TSignedRange &seq_rng, const TSignedRange &aln_rng, bool anchor_direct) const
Get sequence string for a given row in sequence range.
string & x_GetAlnStringFromCigar(TNumrow row, string &buffer, const TSignedRange &aln_range) const
virtual ~CDensegGraphicDataSource()
virtual EPolyATail HasPolyATail() const
Check if there is any unaligned polyA tail.
virtual TSeqPos GetSeqStart(TNumrow row) const
virtual IAlnExplorer::EAlignType GetAlignType() const
Implementation of IAlnSegmentIterator for CDense_seg.
static SIZE_TYPE ReverseComplement(const string &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst)
CConstRef< CUser_field > GetFieldRef(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Return a field reference representing the tokenized key, or a NULL reference if the key doesn't exist...
ESearchDirection
Position search options.
@ eRight
Towards higher aln coord (always to the right)
@ eLeft
Towards lower aln coord (always to the left)
@ eBackwards
Towards lower seq coord (to the left if plus strand, right if minus)
@ eForward
Towards higher seq coord (to the right if plus strand, left if minus)
vector< TCigarPair > TCigar
IAlnExplorer::TSignedRange TSignedRange
IAlnExplorer::TNumrow TNumrow
EPolyATail
Cetantiy of having unaligned polyA tail.
virtual string & GetSeqString(string &buffer, TNumrow row, const TSignedRange &seq_rng, const TSignedRange &aln_rng, bool anchor_direct) const
Get sequence string for a given row in sequence range.
Alignment segment iterator interface.
@ eAllSegments
Iterate all segments.
@ eSkipGaps
Skip gap segments (show only aligned ranges)
virtual const TSignedRange & GetRange(void) const =0
Get the selected row range.
@ fReversed
The selected row is reversed (relative to the anchor).
virtual TSegTypeFlags GetType(void) const =0
Get current segment type.
virtual const TSignedRange & GetAlnRange(void) const =0
Get alignment range for the segment.
static const string kMismatch
USING_SCOPE(ncbi::objects)
static const string kCigar
static const string kTracebacks
unsigned int TSeqPos
Type for sequence locations and lengths.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
int TSignedSeqPos
Type for signed sequence position.
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
void Error(CExceptionArgs_Base &args)
CSeqVector GetSeqVector(EVectorCoding coding, ENa_strand strand=eNa_strand_plus) const
Get sequence: Iupacna or Iupacaa if use_iupac_coding is true.
@ eCoding_Iupac
Set coding to printable coding (Iupacna or Iupacaa)
void GetSeqData(TSeqPos start, TSeqPos stop, string &buffer) const
Fill the buffer string with the sequence data for the interval [start, stop).
void Reset(void)
Reset reference object.
void Reset(void)
Reset reference object.
position_type GetLength(void) const
bool NotEmpty(void) const
position_type GetToOpen(void) const
static TThisType GetWhole(void)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static size_t StringToSizet(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to size_t.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
const TStr & GetStr(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
bool IsStr(void) const
Check if variant Str is selected.
list< CRef< CUser_object > > TExt
range(_Ty, _Ty) -> range< _Ty >
double f(double x_, const double &y_)
static pcre_uint8 * buffer