NCBI C++ ToolKit
denseg_graphic_ds.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: denseg_graphic_ds.cpp 47479 2023-05-02 13:24:02Z ucko $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors: Lianshou Wu
27 *
28 * File Description:
29 *
30 */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include <gui/objutils/utils.hpp>
38 
39 
42 #include <objects/seq/Bioseq.hpp>
43 
47 
48 
49 
52 
53 static const string kTracebacks = "Tracebacks";
54 static const string kCigar = "CIGAR";
55 static const string kMismatch = "MISMATCH";
56 
57 ///////////////////////////////////////////////////////////////////////////////
58 /// CDensegGraphicDataSource
59 
61  const objects::CSeq_align& align, objects::CScope& scope, TNumrow anchor)
62  : m_AnchorRow(anchor)
63  , m_Cigar(NULL)
64 {
65  m_Alignment.Reset(&align);
66  m_Scope.Reset(&scope);
67  x_InitCigar();
68 
69  // must be a non-empty pairwise dense-seg
70  _ASSERT(align.GetSegs().IsDenseg());
71  _ASSERT(align.CheckNumRows() == 2);
72  _ASSERT(align.GetSegs().GetDenseg().CheckNumSegs() > 0);
73  // Make sure it is not a genomic-to-protein alingment.
74  _ASSERT(!align.GetSegs().GetDenseg().IsSetWidths());
75 }
76 
77 
79 {
80  // do clean up
81  if (m_Cigar) {
82  delete m_Cigar;
83  }
84 }
85 
86 
88 {
89  const objects::CBioseq_Handle& bsh = GetBioseqHandle(m_AnchorRow);
90  if (bsh.IsProtein()) {
92  }
93 
94  return IAlnExplorer::fDNA;
95 }
96 
97 
100 {
101  return 2;
102 }
103 
104 
106 {
107  return m_Alignment->GetSeqStart(m_AnchorRow);
108 }
109 
110 
112 {
113  return m_Alignment->GetSeqStop(m_AnchorRow);
114 }
115 
116 
118 {
119  return m_Alignment->GetSeqStart(row);
120 }
121 
122 
124 {
125  return m_Alignment->GetSeqStop(row);
126 }
127 
128 
131 {
133 }
134 
135 
138 {
139  // use the same alignment range
140  return GetAlnRange();
141 }
142 
143 
145 {
146  if (row != m_AnchorRow) {
147  // for anchor row, we will never use CIGAR string
148 
149  if (IsCigarUnambiguous()) {
150  const TCigar& cigars = *GetCigar();
151  TSeqPos len = 0;
152  ITERATE (TCigar, iter, cigars) {
153  switch (iter->first) {
154  case eCigar_M:
155  case eCigar_Eq:
156  case eCigar_X:
157  case eCigar_I:
158  case eCigar_H:
159  case eCigar_S:
160  len += iter->second;
161  break;
162  default:
163  break;
164  }
165  }
166  return len;
167  }
168  }
169 
170  return GetBioseqHandle(row).GetBioseqLength();
171 }
172 
173 
175 {
176  // will be 1 always for either protein-to-protein alignments
177  // or genomic-to-genomic alignments
178  return 1;
179 }
180 
181 
184 {
185  return m_AnchorRow;
186 }
187 
188 
190 {
191  return m_Alignment->GetSeq_id(row);
192 }
193 
194 
195 const objects::CBioseq_Handle&
197 {
198  if (m_BioseqHandles.count(row) == 0) {
199  m_BioseqHandles[row] = m_Scope->GetBioseqHandle(m_Alignment->GetSeq_id(row));
200  }
201  return m_BioseqHandles[row];
202 }
203 
204 
206 {
207  return m_Alignment->GetSeqStrand(row) != eNa_strand_minus;
208 }
209 
210 
212 {
213  return m_Alignment->GetSeqStrand(row) == eNa_strand_minus;
214 }
215 
216 
220  bool try_reverse_dir) const
221 {
222  TSignedSeqPos seq_pos = (TSignedSeqPos)aln_pos;
223  if (row == m_AnchorRow) {
224  return seq_pos;
225  }
226 
227  CDenseg_CI curr_iter(*m_Alignment, row, m_AnchorRow,
230  CDenseg_CI pre_iter;
231 
232  while (curr_iter && seq_pos > curr_iter->GetAlnRange().GetTo()) {
233  pre_iter = curr_iter;
234  ++curr_iter;
235  }
236 
237  if (curr_iter) {
238  bool reversed = curr_iter->GetType() & IAlnSegment::fReversed;
239  if (curr_iter->GetAlnRange().GetFrom() > seq_pos) {
240  if (pre_iter) {
241  if (dir == IAlnExplorer::eRight ||
242  (!reversed && dir == IAlnExplorer::eForward) ||
243  (reversed && dir == IAlnExplorer::eBackwards)) {
244  seq_pos = reversed ? curr_iter->GetRange().GetTo() : curr_iter->GetRange().GetFrom();
245 
246  } else if (dir == IAlnExplorer::eLeft ||
247  (reversed && dir == IAlnExplorer::eForward) ||
248  (!reversed && dir == IAlnExplorer::eBackwards)) {
249  seq_pos = reversed ? pre_iter->GetRange().GetFrom() : pre_iter->GetRange().GetTo();
250  }
251 
252  } else {
253  if (try_reverse_dir ||
254  dir == IAlnExplorer::eRight ||
255  (!reversed && dir == IAlnExplorer::eForward) ||
256  (reversed && dir == IAlnExplorer::eBackwards)) {
257  seq_pos = reversed ? curr_iter->GetRange().GetTo() : curr_iter->GetRange().GetFrom();
258  }
259  }
260  } else {
261  TSignedSeqPos off = reversed ?
262  curr_iter->GetAlnRange().GetTo() - seq_pos : seq_pos - curr_iter->GetAlnRange().GetFrom();
263  seq_pos = curr_iter->GetRange().GetFrom() + off;
264  }
265  } else {
266  _ASSERT(pre_iter);
267  seq_pos = -1;
268  if (dir != IAlnExplorer::eNone) {
269  bool reversed = pre_iter->GetType() & IAlnSegment::fReversed;
270  if (try_reverse_dir ||
271  dir == IAlnExplorer::eLeft ||
272  (reversed && dir == IAlnExplorer::eForward) ||
273  (!reversed && dir == IAlnExplorer::eBackwards)) {
274  seq_pos = reversed ? pre_iter->GetRange().GetFrom() : pre_iter->GetRange().GetTo();
275  }
276  }
277  }
278 
279  return seq_pos;
280 }
281 
282 
283 
286  TSeqPos seq_pos,
288  bool try_reverse_dir) const
289 {
290  TSignedSeqPos aln_pos = (TSignedSeqPos)seq_pos;
291  if (row == m_AnchorRow) {
292  return aln_pos;
293  }
294 
295  CDenseg_CI curr_iter(*m_Alignment, row, m_AnchorRow,
298  CDenseg_CI pre_iter;
299 
300  bool reversed = IsPositiveStrand(row) != IsPositiveStrand(m_AnchorRow);
301 
302  while (curr_iter && ((reversed && aln_pos < curr_iter->GetRange().GetFrom()) ||
303  (!reversed && aln_pos > curr_iter->GetRange().GetTo()))) {
304  pre_iter = curr_iter;
305  ++curr_iter;
306  }
307 
308  if (curr_iter) {
309  bool reversed = curr_iter->GetType() & IAlnSegment::fReversed;
310  if ((reversed && aln_pos > curr_iter->GetRange().GetTo()) ||
311  (!reversed && aln_pos < curr_iter->GetRange().GetFrom())) {
312  if (pre_iter) {
313  if (dir == IAlnExplorer::eRight ||
314  (!reversed && dir == IAlnExplorer::eForward) ||
315  (reversed && dir == IAlnExplorer::eBackwards)) {
316  aln_pos = curr_iter->GetAlnRange().GetFrom();
317 
318  } else if (dir == IAlnExplorer::eLeft ||
319  (reversed && dir == IAlnExplorer::eForward) ||
320  (!reversed && dir == IAlnExplorer::eBackwards)) {
321  aln_pos = pre_iter->GetAlnRange().GetTo();
322  }
323 
324  } else {
325  if (try_reverse_dir ||
326  dir == IAlnExplorer::eRight ||
327  (!reversed && dir == IAlnExplorer::eForward) ||
328  (reversed && dir == IAlnExplorer::eBackwards)) {
329  aln_pos = curr_iter->GetAlnRange().GetFrom();
330  }
331  }
332  } else {
333  TSignedSeqPos off = reversed ?
334  curr_iter->GetRange().GetTo() - aln_pos : aln_pos - curr_iter->GetRange().GetFrom();
335  aln_pos = curr_iter->GetAlnRange().GetFrom() + off;
336  }
337  } else {
338  _ASSERT(pre_iter);
339  aln_pos = -1;
340  if (dir != IAlnExplorer::eNone) {
341  if (try_reverse_dir ||
342  dir == IAlnExplorer::eLeft ||
343  (reversed && dir == IAlnExplorer::eForward) ||
344  (!reversed && dir == IAlnExplorer::eBackwards)) {
345  aln_pos = pre_iter->GetAlnRange().GetTo();
346  }
347  }
348  }
349 
350  return aln_pos;
351 }
352 
353 
356  const TSignedRange& range,
357  IAlnSegmentIterator::EFlags flag) const
358 {
359  return new CDenseg_CI(*m_Alignment, row, m_AnchorRow, flag, range);
360 }
361 
362 
363 string&
365 {
366  buffer.clear();
367  const TCigar& cigars = *GetCigar();
368  size_t f = (size_t)GetSeqPosFromAlnPos(row, aln_range.GetFrom(), IAlnExplorer::eRight);
369  size_t t = (size_t)GetSeqPosFromAlnPos(row, aln_range.GetTo(), IAlnExplorer::eLeft);
370  bool reversed = IsPositiveStrand(row) != IsPositiveStrand(m_AnchorRow);
371  if (reversed) {
372  TSeqPos len_m1 = GetSeqLength(row) - 1;
373  t = len_m1 - t;
374  f = len_m1 - f;
375  }
376  t += 1;
377  _ASSERT(f < t);
378 
379  string mismatch_str = x_GetMismatchStr();
381  seq_vec.GetSeqData(aln_range.GetFrom(), aln_range.GetToOpen(), buffer);
382  size_t curr_p = 0;
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) {
389  case eCigar_H:
390  case eCigar_S:
391  case eCigar_X:
392  if (curr_p + span > f) {
393  size_t offset = f - curr_p;
394  size_t left_over = span - offset;
395  mis_str_idx += offset;
396  /*
397  if ( mis_str_idx >= mismatch_str.size()) {
398  cout << "\n -------------------- " << GetSeqId(row).GetSeqIdString(true) << "\n";
399  cout << "\n -------------- buffer:" << buffer << "\n";
400  cout << "\n -------- mismatch_str:" << mismatch_str << "\n";
401  cout << "\n -------- mis_str_idx:" << mis_str_idx << "\n";
402  throw runtime_error("Bad read!");
403  }
404  */
405  buffer.replace(curr_seq_idx, left_over, mismatch_str, mis_str_idx, left_over);
406  curr_p += span;
407  mis_str_idx += left_over;
408  curr_seq_idx += left_over;
409  f += left_over;
410  } else {
411  curr_p += span;
412  mis_str_idx += span;
413  }
414  break;
415  case eCigar_M:
416  case eCigar_Eq:
417  if (curr_p + span > f) {
418  curr_p += span;
419  size_t left_over = curr_p - f;
420  curr_seq_idx += left_over;
421  f += left_over;
422  } else {
423  curr_p += span;
424  }
425  break;
426  case eCigar_D:
427  case eCigar_N:
428  if (curr_p + span > f && curr_seq_idx > 0) {
429  buffer.replace(curr_seq_idx, span, span, '-');
430  curr_seq_idx += span;
431  }
432  break;
433  case eCigar_I:
434  mis_str_idx += span;
435  curr_p += span;
436  if (curr_p > f) {
437  f = curr_p;
438  }
439  break;
440  default:
441  break;
442  }
443  ++c_iter;
444  }
445  return buffer;
446 }
447 
448 string&
450  string &buffer,
451  const TSignedRange& aln_range) const
452 {
453  // assume the anchor row is the reference sequence row
454  if (row == m_AnchorRow) {
456  seq_vec.GetSeqData(aln_range.GetFrom(), aln_range.GetToOpen(), buffer);
457  return buffer;
458  }
459 
460  if (IsCigarUnambiguous()) {
461  try {
462  return x_GetAlnStringFromCigar(row, buffer, aln_range);
463  } catch (exception& e) {
464  ERR_POST(Error << e.what());
465  }
466  }
467 
468  buffer.clear();
469  bool reversed = IsPositiveStrand(row) != IsPositiveStrand(m_AnchorRow);
470  const CBioseq_Handle& bsh = GetBioseqHandle(row);
471  if (!bsh)
472  return buffer;
474  buffer.resize((size_t)aln_range.GetLength());
475  CDenseg_CI curr_iter(*m_Alignment, row, m_AnchorRow,
477  aln_range);
478  TSignedSeqPos f = aln_range.GetFrom();
479  TSignedSeqPos t = aln_range.GetToOpen();
480  size_t curr_seq_idx = 0;
481  while (curr_iter && f < t) {
482  if (curr_iter->GetAlnRange().NotEmpty()) {
483  TSignedSeqPos curr_f = curr_iter->GetAlnRange().GetFrom();
484  TSignedSeqPos span = curr_iter->GetAlnRange().GetLength();
485  if (f < curr_f) {
486  size_t off = curr_f - f;
487  buffer.replace(curr_seq_idx, off, off, '-');
488  f += off;
489  curr_seq_idx += off;
490  }
491  TSignedSeqPos offset = f - curr_f;
492  TSignedSeqPos left_over = span - offset;
493  if (t < curr_f + span) {
494  left_over = t - f;
495  }
496 
497  if (curr_iter->GetRange().Empty()) {
498  if (curr_seq_idx < buffer.length())
499  buffer.replace(curr_seq_idx, left_over, left_over, '-');
500  } else {
501  string tmp_str;
502  TSignedSeqPos row_f = curr_iter->GetRange().GetFrom();
503  TSignedSeqPos row_t = curr_iter->GetRange().GetTo();
504  if (reversed) {
505  row_t -= offset;
506  row_f = row_t - left_over + 1;
507  } else {
508  row_f += offset;
509  row_t = row_f + left_over - 1;
510  }
511  seq_vec.GetSeqData(row_f, row_t + 1, tmp_str);
512  if (reversed) {
513  string tmp_seq;
515  0, static_cast<TSeqPos>(tmp_str.length()), tmp_seq);
516  swap(tmp_str, tmp_seq);
517  }
518  if (curr_seq_idx < buffer.length())
519  buffer.replace(curr_seq_idx, left_over, tmp_str, 0, left_over);
520  }
521 
522  curr_seq_idx += left_over;
523  f += left_over;
524  }
525  ++curr_iter;
526  }
527 
528  return buffer;
529 }
530 
531 
532 string&
534  const TSignedRange& seq_rng,
535  const TSignedRange& aln_rng,
536  bool anchor_direct) const
537 {
538  if (row != m_AnchorRow && IsCigarUnambiguous()) {
539  const TCigar& cigars = *GetCigar();
540  bool reversed = IsPositiveStrand(row) != IsPositiveStrand(m_AnchorRow);
541  size_t f = (size_t)seq_rng.GetFrom();
542  size_t t = (size_t)seq_rng.GetTo();
543  if (reversed) {
544  TSeqPos len_m1 = GetSeqLength(row) - 1;
545  f = len_m1 - f;
546  t = len_m1 - t;
547  }
548  t += 1;
549  _ASSERT(f < t);
550 
551  buffer.clear();
552  string mismatch_str = x_GetMismatchStr();
553  string anchor_seq;
554 
556  seq_vec.GetSeqData(aln_rng.GetFrom(), aln_rng.GetToOpen(), anchor_seq);
557 
558  size_t curr_p = 0;
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) {
565  case eCigar_H:
566  case eCigar_S:
567  case eCigar_X:
568  if (curr_p + span > f) {
569  size_t offset = f - curr_p;
570  size_t left_over = span - offset;
571  mis_str_idx += offset;
572  buffer += mismatch_str.substr(mis_str_idx, left_over);
573  curr_p += span;
574  mis_str_idx += left_over;
575  curr_seq_idx += left_over;
576  f += left_over;
577  } else {
578  curr_p += span;
579  mis_str_idx += span;
580  }
581  break;
582  case eCigar_M:
583  case eCigar_Eq:
584  if (curr_p + span > f) {
585  curr_p += span;
586  size_t left_over = curr_p - f;
587  buffer += anchor_seq.substr(curr_seq_idx, left_over);
588  curr_seq_idx += left_over;
589  f += left_over;
590  } else {
591  curr_p += span;
592  }
593  break;
594  case eCigar_D:
595  case eCigar_N:
596  if (curr_p + span > f && curr_seq_idx > 0) {
597  curr_seq_idx += span;
598  }
599  break;
600  case eCigar_I:
601  if (curr_p + span > f) {
602  size_t offset = f - curr_p;
603  size_t left_over = span - offset;
604  mis_str_idx += offset;
605  buffer += mismatch_str.substr(mis_str_idx, left_over);
606  mis_str_idx += left_over;
607  f += left_over;
608  } else {
609  mis_str_idx += span;
610  }
611  curr_p += span;
612  break;
613  default:
614  break;
615  }
616  ++c_iter;
617  }
618 
619  if (!anchor_direct && reversed) {
620  // nucleotide sequence, get reverse and complement
621  string tmp_seq;
623  0, static_cast<TSeqPos>(buffer.length()), tmp_seq);
624  buffer = tmp_seq;
625  }
626 
627  } else {
628  IAlnGraphicDataSource::GetSeqString(buffer, row, seq_rng, aln_rng, anchor_direct);
629  }
630 
631  return buffer;
632 }
633 
634 
637  TNumrow row, TSeqPos seq_pos) const
638 {
639  if (row == m_AnchorRow) {
640  return GetSeqPosFromAlnPos(for_row, seq_pos);
641  }
642  return GetAlnPosFromSeqPos(row, seq_pos);
643 }
644 
645 
648 {
649  return ePolyA_Unknown;
650 }
651 
652 
654 {
655  if (m_AnchorRow != 0 || m_Cigar != NULL) {
656  // We assume the CIGAR is stored for BAM/cSRA files only,
657  // and the anchor row must be 0. Otherwise, the behaviour
658  // will be incorrect.
659  return;
660  }
661 
662  string cigar_str = x_GetCigarStr();
663  if ( !cigar_str.empty() ) {
664  m_IsCigarUnambiguous = true;
665  TCigar cigar;
666  // VDB CIGAR representation is different between BAM and SRA alignmnets
667  // SRA CIGAR == length/type pair [0-9][MIDNSHPX=]
668  // BAM CIGAR == type/length pair [MIDNSHPX=][0-9]
669  bool is_bam = !isdigit(cigar_str[0]);
670 
671  size_t i = 0;
672  const size_t c_len = cigar_str.length();
673  while (i < c_len) {
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] < '=') {
678  ++len_end;
679  }
680  if (is_bam) {
681  i = len_end;
682  } else {
683  type_index = len_end;
684  i = len_end + 1;
685  }
686  ECigarOp c_op = (ECigarOp)cigar_str[type_index];
687  if (c_op == 0)
688  continue;
689  if (is_bam && m_IsCigarUnambiguous && c_op == eCigar_M) {
690  m_IsCigarUnambiguous = false;
691  }
692  auto len = NStr::StringToSizet(cigar_str.substr(len_start, len_end - len_start));
693  cigar.emplace_back(c_op, len);
694  }
695 
696  if (!cigar.empty()) {
697  _ASSERT(m_Cigar == nullptr);
698  m_Cigar = new TCigar(move(cigar));
699  }
700  }
701 }
702 
703 
705 {
706  if (m_Alignment->CanGetExt()) {
707  ITERATE (CSeq_align::TExt, iter, m_Alignment->GetExt()) {
708  if ((*iter)->GetType().IsStr() &&
709  (*iter)->GetType().GetStr() == kTracebacks) {
710  CConstRef<CUser_field> cigar_field = (*iter)->GetFieldRef(kCigar);
711  if (cigar_field && cigar_field->GetData().IsStr()) {
712  return cigar_field->GetData().GetStr();
713  }
714  }
715  }
716  }
717 
718  return kEmptyStr;
719 }
720 
721 
723 {
724  if (m_Alignment->CanGetExt()) {
725  ITERATE (CSeq_align::TExt, iter, m_Alignment->GetExt()) {
726  if ((*iter)->GetType().IsStr() &&
727  (*iter)->GetType().GetStr() == kTracebacks) {
728  CConstRef<CUser_field> mismatch_field = (*iter)->GetFieldRef(kMismatch);
729  if (mismatch_field && mismatch_field->GetData().IsStr()) {
730  return mismatch_field->GetData().GetStr();
731  }
732  }
733  }
734  }
735 
736  return kEmptyStr;
737 }
738 
739 
CBioseq_Handle –.
virtual TNumrow GetNumRows(void) const
number of rows in alignment
virtual const objects::CSeq_id & GetSeqId(TNumrow row) 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
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 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.
Definition: denseg_ci.hpp:81
static SIZE_TYPE ReverseComplement(const string &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst)
@ e_Iupacna
Definition: sequtil.hpp:47
CSeqVector –.
Definition: seq_vector.hpp:65
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...
Definition: User_field.cpp:226
ESearchDirection
Position search options.
@ eNone
No search.
@ 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.
EFlags
Iterator options.
@ 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
int offset
Definition: replacements.h:160
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
int TSignedSeqPos
Type for signed sequence position.
Definition: ncbimisc.hpp:887
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
Definition: ncbimisc.hpp:1508
#define NULL
Definition: ncbistd.hpp:225
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
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).
Definition: seq_vector.cpp:304
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
position_type GetLength(void) const
Definition: range.hpp:158
bool NotEmpty(void) const
Definition: range.hpp:152
position_type GetToOpen(void) const
Definition: range.hpp:138
bool Empty(void) const
Definition: range.hpp:148
static TThisType GetWhole(void)
Definition: range.hpp:272
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
static size_t StringToSizet(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to size_t.
Definition: ncbistr.cpp:1769
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
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
Definition: Seq_align_.hpp:402
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
int i
int len
range(_Ty, _Ty) -> range< _Ty >
EIPRangeType t
Definition: ncbi_localip.c:101
int isdigit(Uchar c)
Definition: ncbictype.hpp:64
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
static pcre_uint8 * buffer
Definition: pcretest.c:1051
#define row(bind, expected)
Definition: string_bind.c:73
#define _ASSERT
Modified on Mon Jun 24 05:22:46 2024 by modify_doxy.py rev. 669887