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

Go to the SVN repository for this file.

1  /* $Id: paint_alignment.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: Igor Filippov
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 #include <wx/graphics.h>
33 #include <wx/settings.h>
34 #include <wx/msgdlg.h>
38 #include <objmgr/util/sequence.hpp>
39 #include <objmgr/seq_vector.hpp>
43 
44 #include <wx/textfile.h>
45 
47 
48 IMPLEMENT_DYNAMIC_CLASS( CPaintAlignment, wxVScrolledWindow )
49 
50 
51 BEGIN_EVENT_TABLE(CPaintAlignment, wxVScrolledWindow)
52  EVT_PAINT(CPaintAlignment::OnPaint)
53  EVT_ERASE_BACKGROUND(CPaintAlignment::OnEraseBackground)
55  EVT_KEY_DOWN(CPaintAlignment::OnKeyDown)
57  EVT_LEFT_DOWN(CPaintAlignment::OnMouseDown)
59 
60 
61 CPaintAlignment::CPaintAlignment(wxWindow *parent, CSeq_align_Handle ah, const vector< vector<vector<pair<TSeqPos,TSeqPos> > > > &feat_ranges,
62  const vector< vector<pair<string,objects::CSeqFeatData::ESubtype> > > &feat_types,
63  const vector< vector<objects::CBioseq_Handle::EVectorStrand> > &feat_strand,
64  wxWindowID id, const wxPoint &pos, const wxSize &size)
65 : wxVScrolledWindow(parent,id, pos, size, wxFULL_REPAINT_ON_RESIZE|wxWANTS_CHARS), m_Alignment(ah), m_FeatRanges(feat_ranges), m_FeatTypes(feat_types), m_FeatStrand(feat_strand),
66  m_EnableFeatures(false), m_EnableSubstitute(true)
67 {
68 //m_Alignment.GetScope().AddDataLoader(CWGSDataLoader::GetLoaderNameFromArgs());
69  SetBackgroundStyle(wxBG_STYLE_PAINT);
70  SetBackgroundColour(*wxWHITE);
71  m_Font = wxFont(10, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
72  m_FontHeight = 10;
73  m_FontWidth = 10;
74  m_NumRows = 1;
75  m_NumCols = 1;
76  m_LastRowLength = 0;
77  GetSegments();
78  GetFeatWholeRange();
79  if (m_TotalLength > 0)
80  {
81  wxGraphicsContext *gc = wxGraphicsContext::Create();
82  gc->SetFont(m_Font, *wxBLACK);
83  CalculateFontWidthAndHeight(gc);
84  m_NumCols = CalculateNumCols();
85  m_NumRows = static_cast<int>(m_NumAlignRows * (m_TotalLength / m_NumCols));
86  m_LastRowLength = m_TotalLength % m_NumCols;
87  if (m_LastRowLength > 0)
88  m_NumRows += m_NumAlignRows;
89  }
90  m_CursorCol = 0;
91  m_CursorRow = 0;
92  m_CursorSeq = -1;
93  m_CursorAlign = -1;
94  m_DragMin = -1;
95  m_DragMax = -1;
96  m_SelAlignRow = -1;
97  SetRowCount(m_NumRows);
98  m_Parent = NULL;
99  wxWindow *win = GetParent();
100  while (win)
101  {
102  CAlignmentAssistant *base = dynamic_cast<CAlignmentAssistant *>(win);
103  if (base)
104  m_Parent = base;
105  win = win->GetParent();
106  }
107 }
108 
109 
111 {
112  string accession;
113  string local;
114  string label;
115  for (CBioseq_Handle::TId::const_iterator it = bsh.GetId().begin(); it != bsh.GetId().end(); ++it)
116  {
117  const CSeq_id &id = *(it->GetSeqId());
118  if (id.IsGenbank() && id.GetGenbank().IsSetAccession())
119  accession = id.GetGenbank().GetAccession();
120  if (id.IsLocal() && id.GetLocal().IsStr())
121  local = id.GetLocal().GetStr();
122  }
123  if (!accession.empty())
124  return accession;
125  if (!local.empty())
126  return local;
127 
129  return label;
130 }
131 
133 {
134  m_Alignment = ah;
135  GetSegments();
136 }
137 
139 {
140  m_Seqs.clear();
141  m_Labels.clear();
142  m_TotalLength = 0;
144  {
145  const CDense_seg& denseg = m_Alignment.GetSegs().GetDenseg();
146  if ( denseg.CanGetDim() && denseg.CanGetNumseg() &&
147  denseg.CanGetIds() && denseg.CanGetStarts() &&
148  denseg.CanGetLens())
149  {
150  CDense_seg::TDim num_rows = denseg.GetDim();
151  CDense_seg::TNumseg num_segs = denseg.GetNumseg();
152  for (CDense_seg::TDim row = 0; row < num_rows; ++row)
153  {
154  const CSeq_id& id = denseg.GetSeq_id(row);
156  if (!bsh)
157  continue;
158  string label = GetSeqTitle(bsh);
159  int length = bsh.GetBioseqLength();
161  string seq_plus;
162  vec_plus.GetSeqData(0, length, seq_plus);
163  string seq_minus;
164  if (bsh.IsNucleotide())
165  CSeqManip::ReverseComplement(seq_plus, CSeqUtil::e_Iupacna, 0, static_cast<TSeqPos>(seq_plus.size()), seq_minus);
166  else
167  CSeqManip::ReverseComplement(seq_plus, CSeqUtil::e_Iupacaa, 0, static_cast<TSeqPos>(seq_plus.size()), seq_minus);
168  string seq;
169  for (CDense_seg::TNumseg seg = 0; seg < num_segs; ++seg)
170  {
171  TSignedSeqPos start = denseg.GetStarts()[seg * num_rows + row];
172  TSignedSeqPos len = denseg.GetLens()[seg];
173  ENa_strand strand = eNa_strand_plus;
174  if (denseg.IsSetStrands())
175  strand = denseg.GetStrands()[seg * num_rows + row];
176  if (start >= 0)
177  {
178  if (strand != eNa_strand_minus)
179  {
180  if (start < seq_plus.size())
181  {
182  seq += seq_plus.substr(start, len);
183  }
184  }
185  else
186  {
187  TSignedSeqPos real_start = length - start - len;
188  if (real_start >= 0 && real_start < seq_minus.size())
189  {
190  seq += seq_minus.substr(real_start, len);
191  }
192  }
193  }
194  else
195  {
196  seq += string(len, '-');
197  }
198  }
199  m_Seqs.push_back(seq);
200  m_Labels.push_back(label);
201  m_visible_to_row.push_back(row);
202  }
203  }
204  }
205  if (m_Seqs.empty() || m_Seqs.front().empty())
206  NCBI_THROW( CException, eUnknown, "Cannot parse Seq-align" );
207  m_TotalLength = m_Seqs.front().length();
208  m_NumAlignRows = m_Seqs.size();
209 }
210 
211 wxCoord CPaintAlignment::OnGetRowHeight( size_t row ) const
212 {
213  int r = 0;
214  int align_row = static_cast<int>(row % m_NumAlignRows);
215  vector<unsigned int> feats_in_row = GetFeaturesInRow(static_cast<int>(row), align_row);
216  map<unsigned int, vector<unsigned int> > feats_with_exons = GetFeatsWithExons(static_cast<int>(row), align_row, feats_in_row);
217  DrawLabelCell(0, 0, r, static_cast<int>(row), align_row, feats_in_row, feats_with_exons, NULL);
218  return r;
219 }
220 
221 int CPaintAlignment::AlignPosToSeqPos(int pos, int row, bool left) const
222 {
223  int res = -1;
224  const CDense_seg& denseg = m_Alignment.GetSegs().GetDenseg();
225  const CSeq_id& id = denseg.GetSeq_id(m_visible_to_row[row]);
227  if (!bsh)
228  return -1;
229  int length = bsh.GetBioseqLength();
230  CDense_seg::TNumseg num_segs = denseg.GetNumseg();
231  CDense_seg::TDim num_rows = denseg.GetDim();
232  CDense_seg::TNumseg seg = 0;
233  TSignedSeqPos total_len = 0;
234  int found_seg = -1;
235  while ( seg < num_segs )
236  {
237  TSignedSeqPos start = denseg.GetStarts()[seg * num_rows + m_visible_to_row[row]];
238  TSignedSeqPos len = denseg.GetLens()[seg];
239  ENa_strand strand = eNa_strand_plus;
240  if (denseg.IsSetStrands())
241  strand = denseg.GetStrands()[seg * num_rows + m_visible_to_row[row]];
242 
243  total_len += len;
244  if ((total_len > pos && total_len - len <= pos && strand != eNa_strand_minus) ||
245  (total_len - 1>= pos && total_len -1 - len < pos && strand == eNa_strand_minus))
246  {
247  if (start >= 0)
248  {
249  res = start + (pos - (total_len - len));
250  if (strand == eNa_strand_minus)
251  {
252  res = start + total_len - 1 - pos;
253  }
254  break;
255  }
256  else
257  {
258  found_seg = seg;
259  break;
260  }
261  }
262  ++seg;
263  }
264  if (found_seg >= 0)
265  {
266  seg = found_seg;
267  if (left)
268  {
269  ++seg;
270  while ( seg < num_segs )
271  {
272  TSignedSeqPos start = denseg.GetStarts()[seg * num_rows + m_visible_to_row[row]];
273  TSignedSeqPos len = denseg.GetLens()[seg];
274  ENa_strand strand = eNa_strand_plus;
275  if (denseg.IsSetStrands())
276  strand = denseg.GetStrands()[seg * num_rows + m_visible_to_row[row]];
277  if (start >= 0)
278  {
279  res = start;
280  if (strand == eNa_strand_minus)
281  res = start + len - 1;
282  break;
283  }
284  ++seg;
285  }
286  }
287  else
288  {
289  while (seg > 0)
290  {
291  --seg;
292  TSignedSeqPos start = denseg.GetStarts()[seg * num_rows + m_visible_to_row[row]];
293  TSignedSeqPos len = denseg.GetLens()[seg];
294  ENa_strand strand = eNa_strand_plus;
295  if (denseg.IsSetStrands())
296  strand = denseg.GetStrands()[seg * num_rows + m_visible_to_row[row]];
297  if (start >= 0)
298  {
299  res = start + len - 1;
300  if (strand == eNa_strand_minus)
301  res = start;
302  break;
303  }
304  }
305  }
306  }
307  return res;
308 }
309 
310 int CPaintAlignment::SeqPosToAlignPos(int pos, int row, bool left)
311 {
312  int res = 0;
313  const CDense_seg& denseg = m_Alignment.GetSegs().GetDenseg();
314  const CSeq_id& id = denseg.GetSeq_id(m_visible_to_row[row]);
316  if (!bsh)
317  return 0;
318  int length = bsh.GetBioseqLength();
319  CDense_seg::TNumseg num_segs = denseg.GetNumseg();
320  CDense_seg::TDim num_rows = denseg.GetDim();
321  CDense_seg::TNumseg seg = 0;
322  TSignedSeqPos total_len = 0;
323  int found_len = 0;
324  bool found = false;
325  while ( seg < num_segs )
326  {
327  TSignedSeqPos start = denseg.GetStarts()[seg * num_rows + m_visible_to_row[row]];
328  TSignedSeqPos len = denseg.GetLens()[seg];
329  ENa_strand strand = eNa_strand_plus;
330  int pos2 = pos;
331  if (denseg.IsSetStrands())
332  strand = denseg.GetStrands()[seg * num_rows + m_visible_to_row[row]];
333  if (strand == eNa_strand_minus && start >= 0)
334  {
335  start = length - start - len;
336  pos2 = length - pos - 1;
337  }
338  if (start >= 0 && pos2 >= start && pos2 < start + len)
339  {
340  res = total_len + pos2 - start;
341  found = true;
342  break;
343  }
344  if (start >= 0 && start > pos2 && left)
345  {
346  res = total_len;
347  found = true;
348  break;
349  }
350  if (start >= 0 && start + len - 1 < pos2 && !left)
351  {
352  found_len = total_len + len - 1;
353  }
354  total_len += len;
355  ++seg;
356  }
357  if (!found)
358  res = found_len;
359 
360  return res;
361 }
362 
364 {
365 }
366 
367 void CPaintAlignment::UpdateFeatures(const vector< vector<vector<pair<TSeqPos,TSeqPos> > > > &feat_ranges,
368  const vector< vector<pair<string,objects::CSeqFeatData::ESubtype> > > &feat_types,
369  const vector< vector<objects::CBioseq_Handle::EVectorStrand> > &feat_strand)
370 {
371  m_FeatRanges = feat_ranges;
372  m_FeatTypes = feat_types;
373  m_FeatStrand = feat_strand;
375 }
376 
378 {
379  SeqPosToColRow();
382  Refresh();
383 }
384 
386 {
387  m_EnableFeatures = enable;
389 }
390 
392 {
393  m_EnableSubstitute = enable;
395 }
396 
398 {
399  if (m_CursorRow < GetVisibleRowsBegin() || m_CursorRow > GetVisibleRowsEnd() - 1)
400  ScrollToRow(m_CursorRow);
401 }
402 
403 
404 void CPaintAlignment::OnKeyDown(wxKeyEvent& event)
405 {
406  wxSize sz = GetClientSize();
407  int num_rows = static_cast<int>(GetVisibleRowsEnd() - GetVisibleRowsBegin());
408 
409  int uc = event.GetKeyCode();
410  switch ( uc )
411  {
412  case WXK_LEFT : m_CursorCol--; m_CursorSeq = -1; m_CursorAlign = -1; break;
413  case WXK_RIGHT : m_CursorCol++; m_CursorSeq = -1; m_CursorAlign = -1; break;
414  case WXK_UP : m_CursorRow--; m_CursorSeq = -1; m_CursorAlign = -1; break;
415  case WXK_DOWN : m_CursorRow++; m_CursorSeq = -1; m_CursorAlign = -1; break;
416  case WXK_END : m_CursorSeq = static_cast<int>(m_TotalLength - 1); SeqPosToColRow(); break;
417  case WXK_HOME : m_CursorSeq = 0; SeqPosToColRow(); break;
418  case WXK_PAGEUP : m_CursorRow = static_cast<int>(GetVisibleRowsBegin() - num_rows); m_CursorSeq = -1; m_CursorAlign = -1; break;
419  case WXK_PAGEDOWN : m_CursorRow = static_cast<int>(GetVisibleRowsBegin() + num_rows); m_CursorSeq = -1; m_CursorAlign = -1; break;
420  case WXK_INSERT :
421  if (m_CursorSeq >= 0 && m_CursorSeq < m_TotalLength && m_CursorAlign >= 0 && m_CursorAlign < m_NumAlignRows)
422  {
423  if (m_DragMin < 0)
424  {
427  }
428  else if (m_DragMax < 0 && m_CursorAlign == m_SelAlignRow)
430  else if (m_CursorAlign == m_SelAlignRow)
431  {
434  else
436  }
437  else
438  {
439  wxMessageBox (_("Selection should be confined to the same bioseq"), _("Warning"), wxOK);
440  }
441  }
442  break;
443  case WXK_SPACE:
444  event.Skip();
445  break;
446  case WXK_DELETE:
447  case WXK_BACK :
448  if (m_Parent)
449  {
451  m_DragMin = -1;
452  m_DragMax = -1;
453  m_SelAlignRow = -1;
454  m_CursorSeq = -1;
455  m_CursorAlign = -1;
456  }
457  break;
458  default:
459  event.Skip();
460  return;
461  break;
462  }
463 
466  Refresh();
467 }
468 
470 {
471  if (m_CursorCol < 0)
472  m_CursorCol = 0;
473  if (m_CursorCol >= m_NumCols)
475  if (m_CursorRow < 0)
476  m_CursorRow = 0;
477  if (m_CursorRow >= m_NumRows)
481  if (m_CursorAlign < 0)
482  m_CursorAlign = 0;
484  m_CursorAlign = static_cast<int>(m_NumAlignRows - 1);
485  if (m_SelAlignRow < 0)
486  m_SelAlignRow = 0;
488  m_SelAlignRow = static_cast<int>(m_NumAlignRows - 1);
489 }
490 
492 {
493  return (5 + 15 * m_FontWidth + 5); // leaving 10 spaces for feature labels
494 }
495 
496 int CPaintAlignment::FindRowByCoord(int y, int &y_row)
497 {
498  y_row = TopMarginHeight();
499  if (y <= 0)
500  return 0;
501  int row = static_cast<int>(GetVisibleRowsBegin());
502  int row_height = OnGetRowHeight(row);
503  while ( y_row < y && row <= GetVisibleRowsEnd()+1 )
504  {
505  y_row += row_height;
506  row++;
507  row_height = OnGetRowHeight(row);
508  }
509  row--;
510  y_row -= OnGetRowHeight(row);
511  return row;
512 }
513 
514 bool CPaintAlignment::MouseToSeqPos(wxPoint p, int &row, int &y_row)
515 {
516  bool found = false;
517  row = FindRowByCoord(p.y, y_row);
518  int col = (p.x - LeftMarginWidth()) / m_FontWidth;
519  int num_groups = col / 12; // 2 spaces between groups
520  int pos_in_group = col % 12;
521  if (pos_in_group != 10 && pos_in_group != 11)
522  {
523  m_CursorCol = num_groups * 10 + pos_in_group;
524  m_CursorRow = row;
525  ColRowToSeqPos();
526  found = true;
527  }
528 
529  return found;
530 }
531 
532 void CPaintAlignment::OnMouseDrag(wxMouseEvent& evt)
533 {
534  if (evt.Dragging())
535  {
536  int row = 0, y_row;
537  bool found = MouseToSeqPos(evt.GetPosition(), row, y_row);
538  int align_row = row % m_NumAlignRows;
539  if (found && (align_row == m_SelAlignRow || m_SelAlignRow < 0))
540  {
541  if ( m_DragMin < 0)
543  else
545  m_SelAlignRow = align_row;
546  if (m_DragMin >= 0 && m_DragMin > m_TotalLength - 1)
547  m_DragMin = static_cast<int>(m_TotalLength) - 1;
548  if (m_DragMax >= 0 && m_DragMax > m_TotalLength - 1)
549  m_DragMax = static_cast<int>(m_TotalLength) - 1;
550 
551  Refresh();
552  }
553  }
554  evt.Skip();
555 }
556 
557 void CPaintAlignment::OnMouseDown(wxMouseEvent& evt)
558 {
559  int row, y_row;
560  bool found = MouseToSeqPos(evt.GetPosition(), row, y_row);
561 
562  if (evt.GetModifiers() == wxMOD_SHIFT)
563  {
564  if (m_CursorSeq >= 0 && m_CursorSeq < m_TotalLength && m_CursorAlign >= 0 && m_CursorAlign < m_NumAlignRows)
565  {
566  if (m_DragMin < 0)
567  {
570  }
571  else if (m_DragMax < 0 && m_CursorAlign == m_SelAlignRow)
573  else if (m_CursorAlign == m_SelAlignRow)
574  {
577  else
579  }
580  else
581  {
582  wxMessageBox (_("Selection should be confined to the same bioseq"), _("Warning"), wxOK);
583  }
584  }
587  Refresh();
588  return;
589  }
590  if (m_DragMin >= 0 && m_DragMax >= 0)
591  {
592  m_DragMin = -1;
593  m_DragMax = -1;
594  m_SelAlignRow = -1;
595  found = true;
596  }
597 
598  if (found)
599  {
600  Refresh();
601  }
602  evt.Skip();
603 }
604 
606 {
611 }
612 
614 {
617 }
618 
620 {
621  m_CursorSeq = pos - 1;
622  if (m_CursorSeq < 0)
623  m_CursorSeq = 0;
624  if (m_CursorSeq >= m_TotalLength)
625  m_CursorSeq = static_cast<int>(m_TotalLength) - 1;
626  SeqPosToColRow();
628  Refresh();
629 }
630 
632 {
633  if (pos < 1)
634  return;
635  m_CursorSeq = SeqPosToAlignPos(pos - 1, m_CursorAlign, true);
636  if (m_CursorSeq < 0)
637  m_CursorSeq = 0;
638  if (m_CursorSeq >= m_TotalLength)
639  m_CursorSeq = static_cast<int>(m_TotalLength) - 1;
640  SeqPosToColRow();
642  Refresh();
643 }
644 
646 {
647  if (row < 0 || row >= m_NumAlignRows)
648  return;
649  m_CursorAlign = row;
650  SeqPosToColRow();
652  Refresh();
653 }
654 
655 
656 /// Painting
657 void CPaintAlignment::OnPaint(wxPaintEvent& event)
658 {
659  wxAutoBufferedPaintDC dc(this);
660  wxGraphicsContext *gc = wxGraphicsContext::Create( dc );
661  if (gc && m_TotalLength > 0)
662  {
663  ClearScreen(gc);
664  gc->SetFont(m_Font, *wxBLACK);
666  m_NumRows = static_cast<int>(m_NumAlignRows * (m_TotalLength / m_NumCols));
668  if (m_LastRowLength > 0)
670  SetRowCount(m_NumRows);
671  if (m_CursorSeq >= 0)
672  SeqPosToColRow();
673  else
674  ColRowToSeqPos();
675  int hidden_rows = static_cast<int>(GetVisibleRowsBegin());
676  unsigned int start= (hidden_rows / m_NumAlignRows) * m_NumCols;
677  unsigned int row = hidden_rows;
678  unsigned int start_align_row = hidden_rows % m_NumAlignRows;
679  int client_y = GetClientSize().y;
680  int y = TopMarginHeight();
681  while (start < m_TotalLength)
682  {
683  for (size_t align_row = start_align_row; align_row < m_NumAlignRows; ++align_row)
684  {
685  unsigned int seq_pos = start;
686  DrawTextLine(start, y, row, static_cast<int>(align_row), gc, seq_pos);
687  if (y > client_y)
688  break;
689  row++;
690  }
691  if (y > client_y)
692  break;
693  start += m_NumCols;
694  start_align_row = 0;
695  }
696  delete gc;
697  }
698 
699  if (m_Parent)
700  {
701  int pos1 = m_DragMin;
702  int pos2 = m_DragMax;
703  if (pos1 > pos2)
704  swap(pos1, pos2);
705  string label;
706  if (IsSelection())
707  {
708  pos1 = AlignPosToSeqPos(pos1, m_SelAlignRow, true);
709  pos2 = AlignPosToSeqPos(pos2, m_SelAlignRow, false);
711  }
712  if ( m_CursorSeq >=0 )
713  {
714  int pos = AlignPosToSeqPos(m_CursorSeq, m_CursorAlign, false);
716  }
717  m_Parent->ReportRange(pos1+1, pos2+1, label);
718  }
719 }
720 
721 
722 
723 // Empty implementation, to prevent flicker
724 void CPaintAlignment::OnEraseBackground(wxEraseEvent& event)
725 {
726 }
727 
728 ////////////////////////////////////////////////////////////
729 /// Notification for the derived class that moment is good
730 /// for doing its update and drawing stuff
731 ////////////////////////////////////////////////////////////
733 {
734 
735 }
736 
737 void CPaintAlignment::OnResize(wxSizeEvent& event)
738 {
739 
740 }
741 
742 void CPaintAlignment::ClearScreen(wxGraphicsContext *gc)
743 {
744  wxColour backgroundColour = GetBackgroundColour();
745  if (!backgroundColour.Ok())
746  backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
747  wxSize sz = GetClientSize();
748  wxRect windowRect(wxPoint(0,0), sz);
749  gc->SetBrush(wxBrush(backgroundColour));
750  gc->SetPen(wxPen(backgroundColour, 1));
751  gc->DrawRectangle(windowRect.GetX(),windowRect.GetY(),windowRect.GetWidth(),windowRect.GetHeight());
752 }
753 
755 {
756  wxDouble width;
757  wxDouble height;
758  wxDouble descent;
759  wxDouble externalLeading;
760  if (m_TotalLength > 1000)
761  {
762  gc->GetTextExtent(wxString(m_Seqs.front().substr(0,1000)), &width, &height, &descent, &externalLeading);
763  width /= 1000;
764  }
765  else
766  {
767  gc->GetTextExtent(wxString(m_Seqs.front()), &width, &height, &descent, &externalLeading);
768  width /= m_TotalLength;
769  }
770  width = ceil(1+width);
771  height = ceil(2+height);
772  m_FontHeight = height;
773  m_FontWidth = width;
774 }
775 
777 {
778  int width = int(GetClientSize().x);
779  width -= LeftMarginWidth();
780  int line_length = width / m_FontWidth;
781  int num_groups = line_length / 12; // leaving 2 spaces for breaks between each 10
782  if (num_groups == 0)
783  num_groups = 1;
784  if (num_groups > 1 && width - 12*num_groups*m_FontWidth < 8*m_FontWidth)
785  num_groups--;
786  line_length = 10*num_groups;
787  return line_length;
788 }
789 
790 void CPaintAlignment::DrawTextLine(const unsigned int start, int &y_label, int row, int align_row, wxGraphicsContext *gc, unsigned int &seq_pos)
791 {
792  int x = 5;
793  m_ContinueFeatures = false;
794  unsigned int orig_pos = seq_pos;
795  int orig_y = y_label;
796  vector<unsigned int> feats_in_row = GetFeaturesInRow(row, align_row);
797  map<unsigned int, vector<unsigned int> > feats_with_exons = GetFeatsWithExons(row, align_row, feats_in_row);
798  DrawLabelCell(orig_pos,x,y_label,row, align_row, feats_in_row, feats_with_exons, gc);
799  x += LeftMarginWidth() - 5;
800  for (unsigned int i=0; i<m_NumCols; i++)
801  {
802  int y = orig_y;
803  DrawTextCell(start, i, row, align_row, seq_pos, x, y, feats_in_row, feats_with_exons, gc);
804  seq_pos++;
805  x += m_FontWidth;
806  if (i % 10 == 9)
807  {
808  x += 2*m_FontWidth; // skipping two spaces after each 10
809  m_ContinueFeatures = true;
810  }
811  else
812  {
813  m_ContinueFeatures = false;
814  }
815  }
816  x = LeftMarginWidth() + (m_NumCols / 10)* 12 * m_FontWidth;
817 }
818 
819 void CPaintAlignment::DrawLabelCell(unsigned int pos, int x, int &y, int row, int align_row, const vector<unsigned int> &feats_in_row, const map<unsigned int, vector<unsigned int> > &feats_with_exons, wxGraphicsContext *gc) const
820 {
821  DrawTopLineNumbers(align_row, 0, 0, x, y, NULL);
822  DrawLineNumber(align_row, pos, x, y, gc);
823  DrawFeatureLabels(row, align_row, x, y, feats_in_row, feats_with_exons, gc);
824  y += 5;
825 }
826 
827 void CPaintAlignment::DrawTopLineNumbers(int align_row, unsigned int seq_pos, int col, int x, int &y, wxGraphicsContext *gc) const
828 {
829  if (align_row != 0)
830  return;
831  if (gc)
832  {
833  wxString label;
834  label << seq_pos + 1 + (10 - ((col + 1) % 10));
835  if ((col + label.Length()) % 10 == 0 )
836  {
837  gc->SetFont(m_Font, wxColour(255,0,255));
838  gc->DrawText(label,x,y);
839  gc->SetFont(m_Font,*wxBLACK);
840  }
841  }
842  y += m_FontHeight;
843  if (gc)
844  {
845  gc->SetPen(wxPen(wxColour(255,0,255)));
846  if ( (col +1) % 10 == 0)
847  gc->StrokeLine(x+m_FontWidth/2, y, x+m_FontWidth/2, y+16);
848  else if ( (col +1) % 10 == 5)
849  gc->StrokeLine(x+m_FontWidth/2, y+8, x+m_FontWidth/2, y+16);
850  }
851  y += 16;
852 }
853 
854 void CPaintAlignment::DrawTextCell(const unsigned int start, int col, int row, int align_row, unsigned int seq_pos, int x, int &y, const vector<unsigned int> &feats_in_row,
855  const map<unsigned int, vector<unsigned int> > &feats_with_exons, wxGraphicsContext *gc) const
856 {
857  DrawTopLineNumbers(align_row, seq_pos, col, x, y, gc);
858  if (gc && start + col < m_TotalLength)
859  {
860  gc->SetFont(m_Font,*wxBLACK);
861  char substr = '\0';
862  if (seq_pos < m_Seqs[align_row].size())
863  substr = m_Seqs[align_row][seq_pos];
864  if (m_EnableSubstitute && substr != '-' && seq_pos < m_Seqs[m_CursorAlign].size() && substr == m_Seqs[m_CursorAlign][seq_pos] && align_row != m_CursorAlign)
865  substr = '.';
866  if (substr != '\0')
867  {
868  int pos1 = m_DragMin;
869  int pos2 = m_DragMax;
870  if (pos1 > pos2)
871  swap(pos1, pos2);
872  if (pos1 >= 0 && pos2 >= 0 && seq_pos >= pos1 && seq_pos <= pos2 && align_row == m_SelAlignRow)
873  gc->DrawText(wxString(substr),x,y, gc->CreateBrush(*wxLIGHT_GREY_BRUSH));
874  else
875  gc->DrawText(wxString(substr),x,y);
876  }
877  }
878  y += m_FontHeight;
879  DrawCursor(col,row,x,y,gc);
880  DrawFeatures(row,align_row,seq_pos,x,y,feats_in_row,feats_with_exons,gc);
881  y += 5;
882 }
883 
884 void CPaintAlignment::DrawCursor(int col, int row, int x, int &y, wxGraphicsContext *gc) const
885 {
886  if (col == m_CursorCol && row == m_CursorRow && gc)
887  {
888  gc->SetPen( *wxRED_PEN);
889  gc->StrokeLine(x,y,x+m_FontWidth,y);
890  }
891  //y += 1;
892 }
893 
894 
895 const wxPen* CPaintAlignment::GetColorForFeature(objects::CSeqFeatData::ESubtype subtype) const
896 {
897  const wxPen* pen = wxBLACK_PEN;
898  switch(subtype)
899  {
900  case CSeqFeatData::eSubtype_cdregion : pen = wxBLUE_PEN; break;
901  default : pen = wxBLACK_PEN; break;
902  }
903  return pen;
904 }
905 
906 void CPaintAlignment::DrawLineNumber(int align_row, unsigned int seq_pos, int x, int &y, wxGraphicsContext *gc) const
907 {
908  int allowed = LeftMarginWidth() / m_FontWidth;
909  wxString pos_label;
910  int pos = AlignPosToSeqPos(seq_pos, align_row, false);
911  if (pos < 0)
912  pos = 0;
913  pos_label << pos+1;
914  wxString id_label(m_Labels[align_row]);
915  if (allowed > pos_label.Length() && allowed < pos_label.Length() + id_label.Length())
916  id_label = id_label.Left(allowed - pos_label.Length());
917  int len = static_cast<int>(allowed - pos_label.Length() - id_label.Length());
918  if (len <= 0)
919  id_label = wxString(m_Labels[align_row]).Left(allowed);
920 
921  if (gc)
922  {
923  if (align_row == m_CursorAlign)
924  gc->SetFont(m_Font,*wxRED);
925  else
926  gc->SetFont(m_Font,*wxBLACK);
927  gc->DrawText(id_label, x, y);
928 
929  if (len > 0)
930  {
931  wxDouble width;
932  wxDouble height;
933  wxDouble descent;
934  wxDouble externalLeading;
935  gc->GetTextExtent(id_label + wxString('N',len), &width, &height, &descent, &externalLeading);
936  x += width;
937  gc->SetFont(m_Font,wxColour(255,0,255));
938  gc->DrawText(pos_label, x, y);
939  }
940  gc->SetFont(m_Font,*wxBLACK);
941  }
942  y += m_FontHeight;
943 }
944 
945 
946 void CPaintAlignment::DrawFeatureLabels(int row, int align_row, int x, int &y, const vector<unsigned int> &feats_in_row, const map<unsigned int, vector<unsigned int> > &feats_with_exons, wxGraphicsContext *gc) const
947 {
948  for (unsigned int k = 0; k < feats_in_row.size(); k++)
949  {
950  unsigned int i = feats_in_row[k];
951  if (m_EnableFeatures)
952  {
953  string label = m_FeatTypes[align_row][i].first.substr(0,10); // only take first 10 characters of the label
954  if (gc)
955  gc->DrawText(wxString(label),x,y);
956  y += m_FontHeight;
957  }
958  }
959 }
960 
961 vector<unsigned int> CPaintAlignment::GetFeaturesInRow(int row, int align_row) const
962 {
963  vector<unsigned int> feats_in_row;
964 
965  for (size_t i = 0; i < m_FeatWholeRange[align_row].size(); i++)
966  {
967  TSeqPos start = m_FeatWholeRange[align_row][i].first;
968  TSeqPos stop = m_FeatWholeRange[align_row][i].second;
969  int row_start = (row / m_NumAlignRows) * m_NumCols;
970  int row_end = row_start + m_NumCols - 1;
971  if ( (row_start >= start && row_end <= stop) ||
972  (start >= row_start && start <= row_end) ||
973  (stop >= row_start && stop <= row_end) )
974  {
975  feats_in_row.push_back(static_cast<int>(i));
976  }
977 
978  }
979  return feats_in_row;
980 }
981 
982 
983 void CPaintAlignment::DrawFeatures(int row, int align_row, unsigned int seq_pos, int x, int &y, const vector<unsigned int> &feats_in_row, const map<unsigned int, vector<unsigned int> > &feats_with_exons, wxGraphicsContext *gc) const
984 {
985  for (unsigned int k = 0; k < feats_in_row.size(); k++)
986  {
987  unsigned int i = feats_in_row[k];
988  map<unsigned int, vector<unsigned int> >::const_iterator f = feats_with_exons.find(i);
989 
990  if (m_EnableFeatures)
991  {
992  bool found = false;
993  bool startpoint = false;
994  bool endpoint = false;
995 
996  if (f != feats_with_exons.end())
997  {
998  for (unsigned int m = 0; m < f->second.size(); m++)
999  {
1000  unsigned int j = f->second[m];
1001  TSeqPos start = m_FeatRanges[align_row][i][j].first;
1002  TSeqPos stop = m_FeatRanges[align_row][i][j].second;
1003  if (seq_pos >= start && seq_pos <= stop)
1004  {
1005  found = true;
1006  if (seq_pos == start)
1007  startpoint = true;
1008  if (seq_pos == stop)
1009  endpoint = true;
1010  break;
1011  }
1012  }
1013  }
1014 
1015 
1016  if (gc && seq_pos >= m_FeatWholeRange[align_row][i].first && seq_pos <= m_FeatWholeRange[align_row][i].second)
1017  {
1018  gc->SetPen( *GetColorForFeature(m_FeatTypes[align_row][i].second));
1019  gc->SetBrush(*wxBLACK_BRUSH);
1020  gc->StrokeLine(x, y+m_FontHeight/2, x+m_FontWidth, y+m_FontHeight/2);
1021  if (found)
1022  gc->StrokeLine(x, y+m_FontHeight/2+1, x+m_FontWidth, y+m_FontHeight/2+1);
1023  if (m_ContinueFeatures && !startpoint)
1024  {
1025  gc->StrokeLine(x-2*m_FontWidth, y+m_FontHeight/2, x ,y+m_FontHeight/2);
1026  if (found)
1027  gc->StrokeLine(x-2*m_FontWidth, y+m_FontHeight/2+1, x ,y+m_FontHeight/2+1);
1028  }
1029  if (m_FeatStrand[align_row][i] == objects::CBioseq_Handle::eStrand_Plus)
1030  {
1031  if (startpoint)
1032  gc->DrawRectangle(x, y+m_FontHeight/2-3, 6, 6);
1033  if (endpoint)
1034  {
1035  wxPoint2DDouble lines[] = {wxPoint2DDouble(x+m_FontWidth-4, y-4+m_FontHeight/2), wxPoint2DDouble(x+m_FontWidth-4, y+4+m_FontHeight/2), wxPoint2DDouble(x+m_FontWidth,y+m_FontHeight/2)};
1036  gc->DrawLines(3,lines);
1037  }
1038  }
1039  else
1040  {
1041  if (startpoint)
1042  {
1043  wxPoint2DDouble lines[] = {wxPoint2DDouble(x+4, y-4+m_FontHeight/2), wxPoint2DDouble(x+4, y+4+m_FontHeight/2), wxPoint2DDouble(x,y+m_FontHeight/2)};
1044  gc->DrawLines(3,lines);
1045  }
1046  if (endpoint)
1047  gc->DrawRectangle(x+m_FontWidth-6, y+m_FontHeight/2-3, 6, 6);
1048  }
1049  }
1050  y += m_FontHeight;
1051  }
1052 
1053  }
1054 }
1055 
1056 
1058 {
1059  bool found = false;
1060  if (m_DragMin >= 0 && m_DragMax >= 0 && m_SelAlignRow >= 0)
1061  found = true;
1062  return found;
1063 }
1064 
1066 {
1067  if (IsSelection())
1068  {
1069  int pos1 = m_DragMin;
1070  int pos2 = m_DragMax;
1071  if (pos1 > pos2)
1072  swap(pos1, pos2);
1073 
1074  pos1 = AlignPosToSeqPos(pos1, row, true);
1075  pos2 = AlignPosToSeqPos(pos2, row, false);
1076  return pair<int,int>(pos1, pos2);
1077  }
1078  return pair<int,int>(-1, -1);
1079 }
1080 
1082 {
1083  if (IsSelection())
1084  {
1085  int pos1 = m_DragMin;
1086  int pos2 = m_DragMax;
1087  if (pos1 > pos2)
1088  swap(pos1, pos2);
1089  return pair<int,int>(pos1, pos2);
1090  }
1091  return pair<int,int>(0, m_TotalLength - 1);
1092 }
1093 
1095 {
1096  for (size_t row = 0; row < m_NumAlignRows; row++)
1097  for (size_t i = 0; i < m_FeatRanges[row].size(); i++)
1098  for (size_t j = 0; j < m_FeatRanges[row][i].size(); j++)
1099  {
1100  TSeqPos start = m_FeatRanges[row][i][j].first;
1101  TSeqPos stop = m_FeatRanges[row][i][j].second;
1102 
1103  m_FeatRanges[row][i][j].first = SeqPosToAlignPos(start, static_cast<int>(row), true);
1104  m_FeatRanges[row][i][j].second = SeqPosToAlignPos(stop, static_cast<int>(row), false);
1105  if (m_FeatRanges[row][i][j].first > m_FeatRanges[row][i][j].second)
1106  swap(m_FeatRanges[row][i][j].first, m_FeatRanges[row][i][j].second);
1107  }
1108 
1109 
1110  m_FeatWholeRange.clear();
1111  m_FeatLengthBefore.clear();
1112  m_FeatTotalLength.clear();
1113  for (size_t row = 0; row < m_NumAlignRows; row++)
1114  {
1115  vector<pair<TSeqPos,TSeqPos> > feat_whole_range;
1116  vector< vector<TSeqPos> > feat_length_before;
1117  vector<TSeqPos> feat_total_length;
1118  for (size_t i = 0; i < m_FeatRanges[row].size(); i++)
1119  {
1120  TSeqPos start = INT_MAX;
1121  TSeqPos stop = 0;
1122  TSeqPos length = 0;
1123  vector<TSeqPos> length_before;
1124  for (size_t j = 0; j < m_FeatRanges[row][i].size(); j++)
1125  {
1126  if (m_FeatRanges[row][i][j].first < start)
1127  start = m_FeatRanges[row][i][j].first;
1128  if (m_FeatRanges[row][i][j].second > stop)
1129  stop = m_FeatRanges[row][i][j].second;
1130  length_before.push_back(length);
1131  length += m_FeatRanges[row][i][j].second - m_FeatRanges[row][i][j].first + 1;
1132  }
1133  feat_whole_range.push_back(pair<TSeqPos,TSeqPos>(start,stop));
1134  feat_total_length.push_back(length);
1135  feat_length_before.push_back(length_before);
1136  }
1137  m_FeatWholeRange.push_back(feat_whole_range);
1138  m_FeatTotalLength.push_back(feat_total_length);
1139  m_FeatLengthBefore.push_back(feat_length_before);
1140  }
1141 }
1142 
1143 vector<unsigned int> CPaintAlignment::IsExonPresent(int i, int row, int align_row) const
1144 {
1145  vector<unsigned int> ranges;
1146  for (unsigned int j=0; j<m_FeatRanges[align_row][i].size(); j++)
1147  {
1148  TSeqPos start = m_FeatRanges[align_row][i][j].first;
1149  TSeqPos stop = m_FeatRanges[align_row][i][j].second;
1150  int row_start = (row / m_NumAlignRows) * m_NumCols;
1151  int row_end = row_start + m_NumCols - 1;
1152  if ( (row_start >= start && row_end <= stop) ||
1153  (start >= row_start && start <= row_end) ||
1154  (stop >= row_start && stop <= row_end) )
1155  {
1156  ranges.push_back(j);
1157  }
1158  }
1159 
1160  return ranges;
1161 }
1162 
1163 map<unsigned int, vector<unsigned int> > CPaintAlignment::GetFeatsWithExons(int row, int align_row, const vector<unsigned int> &feats_in_row) const
1164 {
1165  map<unsigned int, vector<unsigned int> > feats_with_exons;
1166  for (unsigned int k = 0; k < feats_in_row.size(); k++)
1167  {
1168  unsigned int i = feats_in_row[k];
1169  vector<unsigned int> ranges = IsExonPresent(i, row, align_row);
1170  if (!ranges.empty())
1171  feats_with_exons[i] = ranges;
1172  }
1173  return feats_with_exons;
1174 }
1175 
1177 {
1178  string str;
1179  string lb(wxString(wxTextFile::GetEOL()).ToStdString());
1180  size_t pos = 0;
1181  while (pos < m_TotalLength)
1182  {
1183  for (size_t i = 0; i < m_Labels.size(); i++)
1184  {
1185  str += m_Labels[i] + " ";
1186  if (pos < m_Seqs[i].size())
1187  str += m_Seqs[i].substr(pos, m_NumCols);
1188  str += lb;
1189  }
1190  str += lb;
1191  pos += m_NumCols;
1192  }
1193  return str;
1194 }
1195 
1197 {
1198  string str;
1199  string lb(wxString(wxTextFile::GetEOL()).ToStdString());
1200  for (size_t i = 0; i < m_Labels.size(); i++)
1201  {
1202  str += ">" + m_Labels[i] + lb;
1203  size_t pos = 0;
1204  while (pos < m_TotalLength)
1205  {
1206  if (pos < m_Seqs[i].size())
1207  str += m_Seqs[i].substr(pos, m_NumCols) + lb;
1208  pos += m_NumCols;
1209  }
1210  str += lb;
1211  }
1212  return str;
1213 }
1214 
void ReportPos(int pos, const string &label)
void ReportRange(int pos1, int pos2, const string &label)
CBioseq_Handle –.
@ eContent
Definition: Bioseq.hpp:103
void GetLabel(string *label, ELabelType type, bool worst=false) const
Definition: Bioseq.cpp:202
const CSeq_id & GetSeq_id(TDim row) const
Definition: Dense_seg.cpp:154
vector< vector< TSeqPos > > m_FeatTotalLength
void CalculateFontWidthAndHeight(wxGraphicsContext *gc)
vector< vector< vector< TSeqPos > > > m_FeatLengthBefore
virtual void OnUpdate()
Notification for the derived class that moment is good for doing its update and drawing stuff.
CAlignmentAssistant * m_Parent
void SetPos(int pos)
int AlignPosToSeqPos(int pos, int row, bool left) const
int FindRowByCoord(int y, int &y_row)
void DrawLabelCell(unsigned int pos, int x, int &y, int row, int align_row, const vector< unsigned int > &feats_in_row, const map< unsigned int, vector< unsigned int > > &feats_with_exons, wxGraphicsContext *gc) const
vector< CDense_seg::TDim > m_visible_to_row
static string GetSeqTitle(CBioseq_Handle bsh)
virtual void OnEraseBackground(wxEraseEvent &event)
vector< unsigned int > IsExonPresent(int i, int row, int align_row) const
void OnMouseDown(wxMouseEvent &evt)
CSeq_align_Handle m_Alignment
vector< vector< vector< pair< TSeqPos, TSeqPos > > > > m_FeatRanges
void DrawTextLine(const unsigned int start, int &y_label, int row, int align_row, wxGraphicsContext *gc, unsigned int &seq_pos)
vector< vector< pair< string, CSeqFeatData::ESubtype > > > m_FeatTypes
pair< int, int > GetSelection(int row)
void OnMouseDrag(wxMouseEvent &evt)
void SetAlign(CSeq_align_Handle ah)
void SetTarget(int row)
void DrawFeatureLabels(int row, int align_row, int x, int &y, const vector< unsigned int > &feats_in_row, const map< unsigned int, vector< unsigned int > > &feats_with_exons, wxGraphicsContext *gc) const
vector< string > m_Labels
void EnableSubstitute(bool enable)
virtual ~CPaintAlignment()
const wxPen * GetColorForFeature(objects::CSeqFeatData::ESubtype subtype) const
void ClearScreen(wxGraphicsContext *gc)
void DrawTopLineNumbers(int align_row, unsigned int seq_pos, int col, int x, int &y, wxGraphicsContext *gc) const
bool MouseToSeqPos(wxPoint p, int &row, int &y_row)
int SeqPosToAlignPos(int pos, int row, bool left)
void DrawCursor(int col, int row, int x, int &y, wxGraphicsContext *gc) const
void DrawFeatures(int row, int align_row, unsigned int seq_pos, int x, int &y, const vector< unsigned int > &feats_in_row, const map< unsigned int, vector< unsigned int > > &feats_with_exons, wxGraphicsContext *gc) const
int LeftMarginWidth() const
map< unsigned int, vector< unsigned int > > GetFeatsWithExons(int row, int align_row, const vector< unsigned int > &feats_in_row) const
void EnableFeatures(bool enable)
pair< int, int > GetAlignSelection(void)
void OnResize(wxSizeEvent &)
virtual void OnPaint(wxPaintEvent &event)
Painting.
void SetPosSeq(int pos)
vector< unsigned int > GetFeaturesInRow(int row, int align_row) const
vector< string > m_Seqs
void UpdateFeatures(const vector< vector< vector< pair< TSeqPos, TSeqPos > > > > &feat_ranges, const vector< vector< pair< string, objects::CSeqFeatData::ESubtype > > > &feat_types, const vector< vector< objects::CBioseq_Handle::EVectorStrand > > &feat_strand)
vector< vector< CBioseq_Handle::EVectorStrand > > m_FeatStrand
vector< vector< pair< TSeqPos, TSeqPos > > > m_FeatWholeRange
void OnKeyDown(wxKeyEvent &event)
void DrawLineNumber(int align_row, unsigned int seq_pos, int x, int &y, wxGraphicsContext *gc) const
virtual wxCoord OnGetRowHeight(size_t row) const
void DrawTextCell(const unsigned int start, int col, int row, int align_row, unsigned int seq_pos, int x, int &y, const vector< unsigned int > &feats_in_row, const map< unsigned int, vector< unsigned int > > &feats_with_exons, wxGraphicsContext *gc) const
static SIZE_TYPE ReverseComplement(const string &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst)
@ e_Iupacna
Definition: sequtil.hpp:47
@ e_Iupacaa
Definition: sequtil.hpp:55
CSeqVector –.
Definition: seq_vector.hpp:65
Definition: map.hpp:338
#define _(proto)
Definition: ct_nlmzip_i.h:78
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
static const char * str(char *buf, int n)
Definition: stats.c:84
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
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
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
bool IsNucleotide(void) const
TBioseqCore GetBioseqCore(void) const
Get bioseq core structure.
CScope & GetScope(void) const
Get scope this handle belongs to.
TSeqPos GetBioseqLength(void) const
const CSeq_align::TSegs & GetSegs(void) const
const TId & GetId(void) const
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
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static const char label[]
bool CanGetDim(void) const
Check if it is safe to call GetDim method.
Definition: Dense_seg_.hpp:402
const TDenseg & GetDenseg(void) const
Get the variant data.
Definition: Seq_align_.cpp:153
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_align_.hpp:691
bool IsSetStrands(void) const
Check if a value has been assigned to Strands data member.
Definition: Dense_seg_.hpp:568
const TStarts & GetStarts(void) const
Get the Starts member data.
Definition: Dense_seg_.hpp:530
const TLens & GetLens(void) const
Get the Lens member data.
Definition: Dense_seg_.hpp:555
bool CanGetNumseg(void) const
Check if it is safe to call GetNumseg method.
Definition: Dense_seg_.hpp:452
bool CanGetIds(void) const
Check if it is safe to call GetIds method.
Definition: Dense_seg_.hpp:499
TDim GetDim(void) const
Get the Dim member data.
Definition: Dense_seg_.hpp:421
bool CanGetStarts(void) const
Check if it is safe to call GetStarts method.
Definition: Dense_seg_.hpp:524
TNumseg GetNumseg(void) const
Get the Numseg member data.
Definition: Dense_seg_.hpp:465
const TStrands & GetStrands(void) const
Get the Strands member data.
Definition: Dense_seg_.hpp:580
bool CanGetLens(void) const
Check if it is safe to call GetLens method.
Definition: Dense_seg_.hpp:549
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
END_EVENT_TABLE()
int i
int len
const struct ncbi::grid::netcache::search::fields::SIZE size
#define abs(a)
Definition: ncbi_heapmgr.c:130
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
#define row(bind, expected)
Definition: string_bind.c:73
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
#define const
Definition: zconf.h:232
#define local
Definition: zutil.h:33
Modified on Wed Apr 24 14:17:37 2024 by modify_doxy.py rev. 669887