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

Go to the SVN repository for this file.

1 /* $Id: update_seq_panel.cpp 44435 2019-12-18 17:13:05Z asztalos $
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: Andrea Asztalos
27  */
28 
29 
30 // Generated by DialogBlocks (unregistered), 26/01/2015 09:02:45
31 
32 #include <ncbi_pch.hpp>
33 #include <objmgr/util/sequence.hpp>
40 #include "update_seq_panel.hpp"
43 
44 #include <wx/msgdlg.h>
45 #include <wx/toolbar.h>
46 #include <wx/sizer.h>
47 #include <wx/statbox.h>
48 #include <wx/stattext.h>
49 #include <wx/radiobut.h>
50 #include <wx/checkbox.h>
51 #include <wx/button.h>
52 #include <wx/wupdlock.h>
53 #include <wx/dcclient.h>
54 #include <wx/valgen.h>
55 #include <wx/wupdlock.h>
56 
59 
62  &CUpdateSeqAlignWidget::x_OnAlnWidgetSelChanged)
64 
65 
66 void CUpdateSeqAlignWidget::CreateColumns()
67 {
68  CAlnMultiRenderer &renderer = m_AlignPane->GetRenderer();
69  renderer.SetColumnVisible(renderer.GetColumnIndexByType(IAlignRow::eIcons), false);
71  renderer.SetColumnVisible(renderer.GetColumnIndexByType(IAlignRow::eStart), false);
73  renderer.SetColumnVisible(renderer.GetColumnIndexByType(IAlignRow::eEnd), false);
74  renderer.SetColumnVisible(renderer.GetColumnIndexByType(IAlignRow::eSeqEnd), false);
76 
77  renderer.UpdateColumns();
78 }
79 
81 {
82  if (!m_Model)
83  return;
84 
86  UpdateView();
87 }
88 
90 {
91  if (!m_Model)
92  return;
93 
95  if (m_Model->GetNumRows() > 0) {
96  try {
97  align_type = m_DataSource->GetAlignType();
98  }
99  catch (...) {
100  }
101  }
102  m_Model->GetDisplayStyle()->SaveSettings(view, align_type);
103 }
104 
106 {
107  switch (update.GetType()) {
111  break;
113  if (!CDCN_GetMessage(update).empty())
115  CDCN_GetMessage(update)
116  );
117  break;
119  m_Model->SetDataSource(nullptr);
120  if (m_DataSource && !m_DataSource->IsEmpty()) {
121  bool set_master(false);
122  TNumrow master_row = x_FindAnchorRow();
123  if (master_row != -1 && m_DataSource->CanChangeAnchor()) {
124  m_DataSource->SetAnchor(master_row);
125  set_master = true;
126  }
127 
128  if (!set_master) {
129  NCBI_THROW(CSeqUpdateException, eInternal,
130  "Can not select the master sequence. Alignment can not be used.");
131  }
132 
134 
135  string kDefaultScoringMethod("Show Differences");
137  }
140  break;
141  default:
142  _ASSERT(false); //unexpected
143  }
144 }
145 
146 
148 {
149  _ASSERT(m_Model);
150  _ASSERT(m_OldSeq);
151 
152  TNumrow master_row = -1;
153  if (m_DataSource && m_DataSource->GetNumRows() == 2) {
154  for (IAlnMultiDataSource::TNumrow row = 0; row < m_DataSource->GetNumRows(); row++) {
155  const CSeq_id& row_id = m_DataSource->GetSeqId(row);
156  if (m_OldSeq.IsSynonym(row_id)) {
157  master_row = row;
158  break;
159  }
160  }
161  }
162  return master_row;
163 }
164 
166 {
167  ZoomToSelection();
168 }
169 
170 
171 BEGIN_EVENT_TABLE(CDrawingPanel, wxPanel)
172  EVT_PAINT(CDrawingPanel::PaintEvent)
174 
175 CDrawingPanel::CDrawingPanel(wxWindow* parent, const wxSize& size, const CUpdateSeqPanel::SDrawingParams& params)
176  : wxPanel(parent, wxID_ANY, wxDefaultPosition, size, wxSIMPLE_BORDER),
177  m_Params(params), m_Lambda(0.0), m_Border(10), m_Start(0), m_Lone(0), m_Lold(0), m_Lupd(0)
178 {
179 }
180 
181 void CDrawingPanel::PaintEvent( wxPaintEvent& event)
182 {
183  wxPaintDC dc(this);
184  Render(dc);
185 }
186 
187 void CDrawingPanel::Render(wxDC& dc)
188 {
189  if (m_Params.IsEmpty())
190  return;
191 
192  x_SetScalingFactor(dc);
193  if (m_Lambda <= 0) {
194  LOG_POST(Error << "Wrong scaling factor: " << m_Lambda);
195  return;
196  }
197 
198  int Aln_old = m_Params.aln_stop_old - m_Params.aln_start_old + 1;
199  int Aln_upd = m_Params.aln_stop_upd - m_Params.aln_start_upd + 1;
200  int Aln = (Aln_old > Aln_upd) ? Aln_old : Aln_upd;
201 
202  int Laln = (int) floor((double)Aln/m_Lambda); // length of the alignment
203 
204  /* obtaining the drawing coordinates:
205  old sequence: start -> y1, end -> y2
206  upd sequence: start -> z1, end -> z2
207  alignment: start -> x0, end -> x1
208  */
209  int y1 = m_Start;
210  int z1 = m_Start;
211  int x0 = m_Start;
212 
213  int Left_old = x_GetLeft_OldSeq();
214  int Left_upd = x_GetLeft_UpdSeq();
215 
216  if (Left_old > Left_upd) { // old sequence is longer on the left of the alignment
217  z1 += (int)floor((double)(Left_old - Left_upd) / m_Lambda);
218  x0 += (int)floor((double)(Left_old) / m_Lambda);
219  } else {
220  y1 += (int)floor((double)(Left_upd - Left_old) / m_Lambda);
221  x0 += (int)floor((double)(Left_upd) / m_Lambda);
222  }
223 
224  int x1 = x0 + Laln;
225 
226  int Right_old = x_GetRight_OldSeq();
227  int Right_upd = x_GetRight_UpdSeq();
228 
229  int y2 = x1 + (int) floor((double)(Right_old)/m_Lambda);
230  int z2 = x1 + (int) floor((double)(Right_upd)/m_Lambda);
231 
232  // the actual drawing
233  int rect_height = 15;
234  int offset = 20;
235  int coord_Y = 25;
236 
237  // drawing the old sequence:
238 
239  string str_left("1"), str_right("1");
241  str_left.assign(NStr::IntToString(m_Params.Lold));
242  } else {
243  str_right.assign(NStr::IntToString(m_Params.Lold));
244  }
245 
246  int LOLD = (m_Params.strand_old == eNa_strand_minus) ? m_Lold : m_Lone;
247  dc.DrawText(ToWxString(str_left), y1 - m_Border - LOLD, coord_Y);
248  dc.DrawText(ToWxString(str_right), y2 + m_Border, coord_Y);
249 
250  dc.SetBrush(*wxTRANSPARENT_BRUSH);
251  dc.SetPen(*wxBLACK_PEN);
252 
253  dc.DrawRectangle(y1, coord_Y, x1 - y1, rect_height);
254  dc.DrawRectangle(x0, coord_Y, y2 - x0, rect_height);
255  wxRegion rg_old1(y1 , coord_Y, x1 - y1, rect_height);
256  wxRegion rg_old2(x0, coord_Y, y2 - x0, rect_height);
257 
258  rg_old1.Intersect(rg_old2);
259  wxRect old_aln_rg = rg_old1.GetBox();
260  dc.SetDeviceClippingRegion(rg_old1);
261  dc.SetBrush(*wxGREEN_BRUSH);
262  dc.DrawRectangle(old_aln_rg);
263  dc.DestroyClippingRegion();
264 
265  // draw the length of alignment on top of the alignment region
266  int mid_align = x0 + (x1 - x0) / 2 - 4; // shift the text towards left by 4 units from the midpoint
267  dc.DrawText(ToWxString(NStr::IntToString(Aln_old)),mid_align, coord_Y - offset);
268 
269 
270  // drawing the update sequence:
271  str_left.assign("1"); str_right.assign("1");
273  str_left.assign(NStr::IntToString(m_Params.Lupd));
274  } else {
275  str_right.assign(NStr::IntToString(m_Params.Lupd));
276  }
277 
278  int LUPD = (m_Params.strand_upd == eNa_strand_minus) ? m_Lupd : m_Lone;
279  dc.DrawText(ToWxString(str_left), z1 - m_Border - LUPD, coord_Y + offset);
280  dc.DrawText(ToWxString(str_right), z2 + m_Border, coord_Y + offset);
281 
282  dc.SetBrush(*wxTRANSPARENT_BRUSH);
283  dc.SetPen(*wxBLACK_PEN);
284 
285  dc.DrawRectangle(z1 , coord_Y + offset, x1 - z1 , rect_height);
286  dc.DrawRectangle(x0, coord_Y + offset, z2 - x0, rect_height);
287  wxRegion rg_upd1(z1, coord_Y + offset, x1 - z1, rect_height);
288  wxRegion rg_upd2(x0, coord_Y + offset, z2 - x0, rect_height);
289 
290  rg_upd1.Intersect(rg_upd2);
291  wxRect upd_aln_rg = rg_upd1.GetBox();
292  dc.SetDeviceClippingRegion(rg_upd1);
293  dc.SetBrush(*wxGREEN_BRUSH);
294  dc.DrawRectangle(upd_aln_rg);
295  dc.DestroyClippingRegion();
296 
297  // draw the length of alignment below of the alignment region
298  dc.DrawText(ToWxString(NStr::IntToString(Aln_upd)), mid_align, coord_Y + 2*offset);
299 
300 }
301 
303 {
304  int Aln_old = m_Params.aln_stop_old - m_Params.aln_start_old + 1;
305  int Aln_upd = m_Params.aln_stop_upd - m_Params.aln_start_upd + 1;
306  int Aln = (Aln_old > Aln_upd) ? Aln_old : Aln_upd;
307 
308  int Left_old = x_GetLeft_OldSeq();
309  int Left_upd = x_GetLeft_UpdSeq();
310  int Left_max = (Left_old > Left_upd) ? Left_old : Left_upd;
311 
312  int Right_old = x_GetRight_OldSeq();
313  int Right_upd = x_GetRight_UpdSeq();
314  int Right_max = (Right_old > Right_upd) ? Right_old : Right_upd;
315 
316  int width = x_FindWidthDrawingArea(dc);
317  if (width != 0) {
318  m_Lambda = (double)(Left_max + Aln + Right_max) / (double)width;
319  }
320 }
321 
323 {
324  // Reset drawing coordinates
325  wxCoord height_txt;
326  dc.GetTextExtent(wxT("1"), &m_Lone, &height_txt);
327  dc.GetTextExtent(ToWxString(NStr::IntToString(m_Params.Lold)), &m_Lold, &height_txt);
328  dc.GetTextExtent(ToWxString(NStr::IntToString(m_Params.Lupd)), &m_Lupd, &height_txt);
329 
330  int Left_old = (m_Params.strand_old == eNa_strand_minus) ? m_Lold : m_Lone;
331  int Left_upd = (m_Params.strand_upd == eNa_strand_minus) ? m_Lupd : m_Lone;
332  int LeftMax = (Left_old >= Left_upd) ? Left_old : Left_upd;
333 
334  int Right_old = (m_Params.strand_old == eNa_strand_minus) ? m_Lone : m_Lold;
335  int Right_upd = (m_Params.strand_upd == eNa_strand_minus) ? m_Lone : m_Lupd;
336  int RightMax = (Right_old >= Right_upd) ? Right_old : Right_upd;
337 
338  m_Start = 2 * m_Border + LeftMax;
339  int End = 2 * m_Border + RightMax;
340  int width = GetClientRect().GetWidth() - m_Start - End;
341  if (width < 0) return 0;
342  return width;
343 }
344 
346 {
347  int left_old = m_Params.aln_start_old;
349  left_old = m_Params.Lold - 1 - m_Params.aln_stop_old;
350  }
351  return left_old;
352 }
354 {
355  int left_upd = m_Params.aln_start_upd;
357  left_upd = m_Params.Lupd - 1 - m_Params.aln_stop_upd;
358  }
359  return left_upd;
360 }
361 
363 {
364  int right_old = m_Params.Lold - 1 - m_Params.aln_stop_old;
366  right_old = m_Params.aln_start_old;
367  }
368  return right_old;
369 }
370 
372 {
373  int right_upd = m_Params.Lupd - 1 - m_Params.aln_stop_upd;
375  right_upd = m_Params.aln_start_upd;
376  }
377  return right_upd;
378 }
379 
380 
381 /*
382  * CUpdateSeqPanel type definition
383  */
384 
385 IMPLEMENT_DYNAMIC_CLASS( CUpdateSeqPanel, wxPanel )
386 
387 
388 /*
389  * CUpdateSeqPanel event table definition
390  */
391 
392 BEGIN_EVENT_TABLE( CUpdateSeqPanel, wxPanel )
393 
394 ////@begin CUpdateSeqPanel event table entries
395  EVT_RADIOBUTTON( ID_SEQUPD_BTN1, CUpdateSeqPanel::OnNoChangeBtnSelected )
396 
397  EVT_RADIOBUTTON( ID_SEQUPD_BTN2, CUpdateSeqPanel::OnReplaceBtnSelected )
398 
399  EVT_RADIOBUTTON( ID_SEQUPD_BTN3, CUpdateSeqPanel::OnPatchBtnSelected )
400 
401  EVT_RADIOBUTTON( ID_SEQUPD_BTN4, CUpdateSeqPanel::OnExtend5BtnSelected )
402 
403  EVT_RADIOBUTTON( ID_SEQUPD_BTN5, CUpdateSeqPanel::OnExtend3BtnSelected )
404 
406 
408 
410 
412 
413 ////@end CUpdateSeqPanel event table entries
414 
420 
422 
423 /*
424 * CUpdateSeqPanel constructors
425 */
426 
428  : m_Scope(0), m_UpdSeqInput(0)
429 {
430  Init();
431 }
432 
433 CUpdateSeqPanel::CUpdateSeqPanel(wxWindow* parent, const CUpdateSeq_Input* updseq_in,
434  wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
435  : m_Scope(0), m_UpdSeqInput(updseq_in)
436 {
437  if (m_UpdSeqInput) {
438  m_Scope.Reset(&(m_UpdSeqInput->GetOldBioseq().GetScope()));
439  }
440 
441  Init();
442  Create(parent, id, pos, size, style);
443 }
444 
445 
446 /*
447 * CUpdateSeqPanel creator
448 */
449 
450 bool CUpdateSeqPanel::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
451 {
452 ////@begin CUpdateSeqPanel creation
453 #ifdef __WXOSX_COCOA__
454  SetBackgroundStyle(wxBG_STYLE_COLOUR);
455  SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK));
456 #endif
457 
458  wxPanel::Create( parent, id, pos, size, style );
459 
460  CreateControls();
461  if (GetSizer())
462  {
463  GetSizer()->SetSizeHints(this);
464  }
465  Centre();
466 ////@end CUpdateSeqPanel creation
467  return true;
468 }
469 
470 
471 /*
472 * CUpdateSeqPanel destructor
473 */
474 
476 {
477 }
478 
479 
480 /*
481 * Member initialisation
482 */
483 
485 {
486 ////@begin CUpdateSeqPanel member initialisation
487  m_MainSizer = NULL;
489  m_OldSeqName = NULL;
490  m_NewSeqName = NULL;
492  m_Toolbar = NULL;
494  m_NoChange = NULL;
495  m_Replace = NULL;
496  m_Patch = NULL;
497  m_Extend5 = NULL;
498  m_Extend3 = NULL;
500  m_FeatType = NULL;
503 ////@end CUpdateSeqPanel member initialisation
504 
505  m_AlnWidget = nullptr;
506  m_DrawPanel = nullptr;
507  m_DeltaSeqText = nullptr;
508 }
509 
510 /*
511 * Control creation for CUpdateSeqPanel
512 */
513 
514 static const string kRegPath = "Dialogs.UpdateSequencePanel";
515 
517 {
518 ////@begin CUpdateSeqPanel content construction
519  CUpdateSeqPanel* itemPanel1 = this;
520 
521  m_MainSizer = new wxBoxSizer(wxVERTICAL);
522  itemPanel1->SetSizer(m_MainSizer);
523 
524  wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemPanel1, wxID_ANY, _("Alignment"));
525  m_AlignStaticBoxSizer = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL);
526  m_MainSizer->Add(m_AlignStaticBoxSizer, 1, wxGROW|wxALL, 5);
527 
528  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
529  m_AlignStaticBoxSizer->Add(itemBoxSizer4, 0, wxGROW|wxALL, 0);
530 
531  wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
532  itemBoxSizer4->Add(itemBoxSizer5, 0, wxALIGN_CENTER_VERTICAL, 2);
533 
534  m_OldSeqName = new wxStaticText( m_AlignStaticBoxSizer->GetStaticBox(), wxID_STATIC, _("Old sequence:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT );
535  itemBoxSizer5->Add(m_OldSeqName, 0, wxALIGN_LEFT|wxALL, 5);
536 
537  m_NewSeqName = new wxStaticText( m_AlignStaticBoxSizer->GetStaticBox(), wxID_STATIC, _("Update sequence:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT );
538  itemBoxSizer5->Add(m_NewSeqName, 0, wxALIGN_LEFT|wxALL, 5);
539 
540  m_NoAlignmentText = new wxStaticText( m_AlignStaticBoxSizer->GetStaticBox(), wxID_STATIC, _("Could not form alignment between old and update sequence"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT );
541  m_NoAlignmentText->Show(false);
542  itemBoxSizer5->Add(m_NoAlignmentText, 0, wxALIGN_LEFT|wxALL, 5);
543 
544  itemBoxSizer4->Add(0, 0, 1, wxALIGN_TOP, 0);
545 
546  m_Toolbar = new wxToolBar(m_AlignStaticBoxSizer->GetStaticBox(), ID_SEQUPD_TOOLBAR, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL | wxTB_NODIVIDER);
547 
549  cmd_reg.AppendTool(*m_Toolbar, eCmdZoomIn);
550  cmd_reg.AppendTool(*m_Toolbar, eCmdZoomOut);
551  cmd_reg.AppendTool(*m_Toolbar, eCmdZoomAll);
552  cmd_reg.AppendTool(*m_Toolbar, eCmdZoomSeq);
553  cmd_reg.AppendTool(*m_Toolbar, eCmdZoomSel);
554 
555  m_Toolbar->Show(false);
556 #ifdef __WXMSW__
557  m_Toolbar->SetToolBitmapSize(wxSize(16, 16));
558 #else
559  m_Toolbar->SetToolBitmapSize(wxSize(35, 35));
560 #endif
561  m_Toolbar->Realize();
562  itemBoxSizer4->Add(m_Toolbar, 0, wxALIGN_BOTTOM | wxRIGHT, 5);
563 
564  m_ProgressSizer = new wxBoxSizer(wxHORIZONTAL);
565  m_AlignStaticBoxSizer->Add(m_ProgressSizer, 1, wxGROW, 0);
566 
567  wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
568  m_ProgressSizer->Add(itemBoxSizer12, 1, wxALIGN_TOP, 5);
569 
570  wxStaticText* itemStaticText13 = new wxStaticText( m_AlignStaticBoxSizer->GetStaticBox(), ID_SEQUPD_LOADTEXT, _("Generating alignment ..."), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT );
571  itemStaticText13->SetForegroundColour(wxColour(0, 0, 0));
572  itemStaticText13->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(), wxNORMAL_FONT->GetFamily(), wxNORMAL_FONT->GetStyle(), wxFONTWEIGHT_BOLD, wxNORMAL_FONT->GetUnderlined(), wxNORMAL_FONT->GetFaceName()));
573  itemBoxSizer12->Add(itemStaticText13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
574 
575  CIndProgressBar* itemWindow14 = new CIndProgressBar( m_AlignStaticBoxSizer->GetStaticBox(), ID_SEQUPD_PROGRESSBAR, wxDefaultPosition, 100 );
576  itemBoxSizer12->Add(itemWindow14, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
577 
578  wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxHORIZONTAL);
579  m_MainSizer->Add(itemBoxSizer15, 0, wxALIGN_LEFT|wxALL, 0);
580 
581  wxStaticBox* itemStaticBoxSizer16Static = new wxStaticBox(itemPanel1, wxID_ANY, _("Sequence Update"));
582  wxStaticBoxSizer* itemStaticBoxSizer16 = new wxStaticBoxSizer(itemStaticBoxSizer16Static, wxVERTICAL);
583  itemBoxSizer15->Add(itemStaticBoxSizer16, 0, wxALIGN_TOP|wxALL, 5);
584 
585  wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL);
586  itemStaticBoxSizer16->Add(itemBoxSizer17, 0, wxALIGN_LEFT|wxALL, 0);
587 
588  m_NoChange = new wxRadioButton( itemStaticBoxSizer16->GetStaticBox(), ID_SEQUPD_BTN1, _("No change"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
589  m_NoChange->SetValue(false);
590  itemBoxSizer17->Add(m_NoChange, 0, wxALIGN_LEFT|wxALL, 5);
591 
592  m_Replace = new wxRadioButton( itemStaticBoxSizer16->GetStaticBox(), ID_SEQUPD_BTN2, _("Replace"), wxDefaultPosition, wxDefaultSize, 0 );
593  m_Replace->SetValue(false);
594  itemBoxSizer17->Add(m_Replace, 0, wxALIGN_LEFT|wxALL, 5);
595 
596  m_Patch = new wxRadioButton( itemStaticBoxSizer16->GetStaticBox(), ID_SEQUPD_BTN3,
597  RunningInsideNCBI() ? _("Patch") : _("Patch aligned region"), wxDefaultPosition, wxDefaultSize, 0 );
598  m_Patch->SetValue(false);
599  itemBoxSizer17->Add(m_Patch, 0, wxALIGN_LEFT|wxALL, 5);
600 
601  m_Extend5 = new wxRadioButton( itemStaticBoxSizer16->GetStaticBox(), ID_SEQUPD_BTN4, _("Extend 5'"), wxDefaultPosition, wxDefaultSize, 0 );
602  m_Extend5->SetValue(false);
603  itemBoxSizer17->Add(m_Extend5, 0, wxALIGN_LEFT|wxALL, 5);
604 
605  m_Extend3 = new wxRadioButton( itemStaticBoxSizer16->GetStaticBox(), ID_SEQUPD_BTN5, _("Extend 3'"), wxDefaultPosition, wxDefaultSize, 0 );
606  m_Extend3->SetValue(false);
607  itemBoxSizer17->Add(m_Extend3, 0, wxALIGN_LEFT|wxALL, 5);
608 
609  itemBoxSizer17->Add(7, 8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
610 
611  m_IgnoreAlignChk = new wxCheckBox( itemStaticBoxSizer16->GetStaticBox(), ID_SEQUPD_IALN_CHK, _("Ignore alignment"), wxDefaultPosition, wxDefaultSize, 0 );
612  m_IgnoreAlignChk->SetValue(false);
613  if (!RunningInsideNCBI()) {
614  m_IgnoreAlignChk->SetToolTip(wxT("When checked, the update sequence is attached to the old sequence with no overlap. "
615  "Existing and imported features are shifted accordingly."));
616  }
617  itemBoxSizer17->Add(m_IgnoreAlignChk, 0, wxALIGN_LEFT|wxALL, 5);
618 
619  wxStaticBox* itemStaticBoxSizer25Static = new wxStaticBox(itemPanel1, wxID_ANY, _("Existing Features"));
620  wxStaticBoxSizer* itemStaticBoxSizer25 = new wxStaticBoxSizer(itemStaticBoxSizer25Static, wxVERTICAL);
621  itemBoxSizer15->Add(itemStaticBoxSizer25, 0, wxALIGN_TOP|wxALL, 5);
622 
623  wxRadioButton* itemRadioButton26 = new wxRadioButton( itemStaticBoxSizer25->GetStaticBox(), ID_SEQUPD_DELFEAT_BTN1, _("Do not remove"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
624  itemRadioButton26->SetValue(true);
625  itemStaticBoxSizer25->Add(itemRadioButton26, 0, wxALIGN_LEFT|wxALL, 5);
626 
627  wxRadioButton* itemRadioButton27 = new wxRadioButton( itemStaticBoxSizer25->GetStaticBox(), ID_SEQUPD_DELFEAT_BTN2, _("Remove in aligned area"), wxDefaultPosition, wxDefaultSize, 0 );
628  itemRadioButton27->SetValue(false);
629  itemStaticBoxSizer25->Add(itemRadioButton27, 0, wxALIGN_LEFT|wxALL, 5);
630 
631  wxRadioButton* itemRadioButton28 = new wxRadioButton( itemStaticBoxSizer25->GetStaticBox(), ID_SEQUPD_DELFEAT_BTN3, _("Remove outside aligned area"), wxDefaultPosition, wxDefaultSize, 0 );
632  itemRadioButton28->SetValue(false);
633  itemStaticBoxSizer25->Add(itemRadioButton28, 0, wxALIGN_LEFT|wxALL, 5);
634 
635  wxRadioButton* itemRadioButton29 = new wxRadioButton( itemStaticBoxSizer25->GetStaticBox(), ID_SEQUPD_DELFEAT_BTN4, _("Remove all"), wxDefaultPosition, wxDefaultSize, 0 );
636  itemRadioButton29->SetValue(false);
637  itemStaticBoxSizer25->Add(itemRadioButton29, 0, wxALIGN_LEFT|wxALL, 5);
638 
639  if (RunningInsideNCBI()) {
640  wxStaticBox* itemStaticBoxSizer30Static = new wxStaticBox(itemPanel1, wxID_ANY, _("Import Features"));
641  wxStaticBoxSizer* itemStaticBoxSizer30 = new wxStaticBoxSizer(itemStaticBoxSizer30Static, wxHORIZONTAL);
642  itemBoxSizer15->Add(itemStaticBoxSizer30, 0, wxALIGN_TOP | wxALL, 5);
643 
644  wxBoxSizer* itemBoxSizer31 = new wxBoxSizer(wxVERTICAL);
645  itemStaticBoxSizer30->Add(itemBoxSizer31, 0, wxALIGN_TOP | wxALL, 0);
646 
647  m_FeatType = new CFeatureTypePanel(itemStaticBoxSizer30->GetStaticBox(), ID_SEQUPD_FEATPNL, wxDefaultPosition, itemStaticBoxSizer30->GetStaticBox()->ConvertDialogToPixels(wxSize(100, 85)), wxSIMPLE_BORDER);
648  itemBoxSizer31->Add(m_FeatType, 0, wxALIGN_LEFT | wxALL, 5);
649 
650  wxBoxSizer* itemBoxSizer33 = new wxBoxSizer(wxVERTICAL);
651  itemStaticBoxSizer30->Add(itemBoxSizer33, 0, wxALIGN_TOP | wxALL, 0);
652 
653  m_ImportFeature = new wxCheckBox(itemStaticBoxSizer30->GetStaticBox(), ID_SEQUPD_IMPCHK, _("Import"), wxDefaultPosition, wxDefaultSize, 0);
654  m_ImportFeature->SetValue(false);
655  itemBoxSizer33->Add(m_ImportFeature, 0, wxALIGN_LEFT | wxALL, 5);
656 
657  itemBoxSizer33->Add(7, 8, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
658 
659  wxRadioButton* itemRadioButton36 = new wxRadioButton(itemStaticBoxSizer30->GetStaticBox(), ID_SEQUPD_IMPFEATUPD_BTN1, _("Except duplicates"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
660  itemRadioButton36->SetValue(false);
661  itemBoxSizer33->Add(itemRadioButton36, 0, wxALIGN_LEFT | wxALL, 5);
662 
663  wxRadioButton* itemRadioButton37 = new wxRadioButton(itemStaticBoxSizer30->GetStaticBox(), ID_SEQUPD_IMPFEATUPD_BTN2, _("Merge duplicates"), wxDefaultPosition, wxDefaultSize, 0);
664  itemRadioButton37->SetValue(false);
665  itemBoxSizer33->Add(itemRadioButton37, 0, wxALIGN_LEFT | wxALL, 5);
666 
667  wxRadioButton* itemRadioButton38 = new wxRadioButton(itemStaticBoxSizer30->GetStaticBox(), ID_SEQUPD_IMPFEATUPD_BTN3, _("Replace duplicates"), wxDefaultPosition, wxDefaultSize, 0);
668  itemRadioButton38->SetValue(false);
669  itemBoxSizer33->Add(itemRadioButton38, 0, wxALIGN_LEFT | wxALL, 5);
670 
671  wxRadioButton* itemRadioButton39 = new wxRadioButton(itemStaticBoxSizer30->GetStaticBox(), ID_SEQUPD_IMPFEATUPD_BTN4, _("Including duplicates"), wxDefaultPosition, wxDefaultSize, 0);
672  itemRadioButton39->SetValue(false);
673  itemBoxSizer33->Add(itemRadioButton39, 0, wxALIGN_LEFT | wxALL, 5);
674 
675  wxStaticBox* itemStaticBoxSizer40Static = new wxStaticBox(itemPanel1, wxID_ANY, _("Options"));
676  wxStaticBoxSizer* itemStaticBoxSizer40 = new wxStaticBoxSizer(itemStaticBoxSizer40Static, wxVERTICAL);
677  itemBoxSizer15->Add(itemStaticBoxSizer40, 0, wxALIGN_TOP | wxALL, 5);
678 
679  m_KeepProteinIdBox = new wxCheckBox(itemStaticBoxSizer40->GetStaticBox(), ID_SEQUPD_KEEPPROTID, _("Keep protein ID"), wxDefaultPosition, wxDefaultSize, 0);
680  m_KeepProteinIdBox->SetValue(false);
681  itemStaticBoxSizer40->Add(m_KeepProteinIdBox, 0, wxALIGN_LEFT | wxALL, 5);
682 
683  wxCheckBox* itemCheckBox42 = new wxCheckBox(itemStaticBoxSizer40->GetStaticBox(), ID_SEQUPD_ADDCITSUB, _("Add cit-sub to updated sequence"), wxDefaultPosition, wxDefaultSize, 0);
684  itemCheckBox42->SetValue(false);
685  itemStaticBoxSizer40->Add(itemCheckBox42, 0, wxALIGN_LEFT | wxALL, 5);
686 
687  wxCheckBox* itemCheckBox43 = new wxCheckBox(itemStaticBoxSizer40->GetStaticBox(), ID_SEQUPD_UPDPROTEIN, _("Update proteins for updated sequence"), wxDefaultPosition, wxDefaultSize, 0);
688  itemCheckBox43->SetValue(false);
689  itemStaticBoxSizer40->Add(itemCheckBox43, 0, wxALIGN_LEFT | wxALL, 5);
690 
691  // set validators
692  itemRadioButton36->SetValidator(wxGenericValidator(&m_ImportFeatureType[0]));
693  itemRadioButton37->SetValidator(wxGenericValidator(&m_ImportFeatureType[1]));
694  itemRadioButton38->SetValidator(wxGenericValidator(&m_ImportFeatureType[2]));
695  itemRadioButton39->SetValidator(wxGenericValidator(&m_ImportFeatureType[3]));
696 
697  itemCheckBox42->SetValidator(wxGenericValidator(&m_AddCitSub));
698  itemCheckBox43->SetValidator(wxGenericValidator(&m_UpdateProtein));
699  }
700  else {
701  wxStaticBox* itemStaticBoxSizer40Static = new wxStaticBox(itemPanel1, wxID_ANY, _("Options"));
702  wxStaticBoxSizer* itemStaticBoxSizer40 = new wxStaticBoxSizer(itemStaticBoxSizer40Static, wxVERTICAL);
703  itemBoxSizer15->Add(itemStaticBoxSizer40, 0, wxALIGN_TOP | wxALL, 5);
704 
705  m_ImportFeature = new wxCheckBox(itemStaticBoxSizer40->GetStaticBox(), ID_SEQUPD_IMPCHK, _("Import all features from update sequence"), wxDefaultPosition, wxDefaultSize, 0);
706  m_ImportFeature->SetValue(false);
707  itemStaticBoxSizer40->Add(m_ImportFeature, 0, wxALIGN_LEFT | wxALL, 5);
708 
709  m_KeepProteinIdBox = new wxCheckBox(itemStaticBoxSizer40->GetStaticBox(), ID_SEQUPD_KEEPPROTID,
710  _("Annotation is copied from an earlier version \nof the same nucleotide accession"), wxDefaultPosition, wxDefaultSize, 0);
711  m_KeepProteinIdBox->SetValue(false);
712  itemStaticBoxSizer40->Add(m_KeepProteinIdBox, 0, wxALIGN_LEFT | wxALL, 5);
713  }
714 
715  // Set validators
716  m_NoChange->SetValidator( wxGenericValidator(& m_SequenceUpdateType[0]) );
717  m_Replace->SetValidator( wxGenericValidator(& m_SequenceUpdateType[1]) );
718  m_Patch->SetValidator( wxGenericValidator(& m_SequenceUpdateType[2]) );
719  m_Extend5->SetValidator( wxGenericValidator(& m_SequenceUpdateType[3]) );
720  m_Extend3->SetValidator( wxGenericValidator(& m_SequenceUpdateType[4]) );
721  m_IgnoreAlignChk->SetValidator( wxGenericValidator(& m_IgnoreAlignState) );
722  itemRadioButton26->SetValidator( wxGenericValidator(& m_RemoveFeatureType[0]) );
723  itemRadioButton27->SetValidator( wxGenericValidator(& m_RemoveFeatureType[1]) );
724  itemRadioButton28->SetValidator( wxGenericValidator(& m_RemoveFeatureType[2]) );
725  itemRadioButton29->SetValidator( wxGenericValidator(& m_RemoveFeatureType[3]) );
726 
727  m_ImportFeature->SetValidator( wxGenericValidator(& m_ImportFeatsState) );
728  m_KeepProteinIdBox->SetValidator( wxGenericValidator(& m_KeepProteinId) );
729 ////@end CUpdateSeqPanel content construction
730 
731  wxStaticBox* staticBox = m_AlignStaticBoxSizer->GetStaticBox();
732  m_AlnWidget = new CUpdateSeqAlignWidget( staticBox, wxID_ANY, wxDefaultPosition, staticBox->ConvertDialogToPixels(wxSize(325, 60)), wxSIMPLE_BORDER );
733  m_AlignStaticBoxSizer->Add(m_AlnWidget, wxSizerFlags().Border().Expand().ReserveSpaceEvenIfHidden().Proportion(1));
735 
736  m_DrawPanel = new CDrawingPanel( staticBox, staticBox->ConvertDialogToPixels(wxSize(325, 50)), m_DrawParams );
737  m_AlignStaticBoxSizer->Add(m_DrawPanel, wxSizerFlags().Border().Expand().ReserveSpaceEvenIfHidden());
738 
739  m_DeltaSeqText = new wxStaticText( itemPanel1, wxID_STATIC, _("The old sequence is delta sequence, if updated, it will be converted to raw."), wxDefaultPosition, wxDefaultSize, 0 );
740  m_DeltaSeqText->Show(false);
741  m_MainSizer->Add(m_DeltaSeqText, wxSizerFlags().DoubleBorder().Left().ReserveSpaceEvenIfHidden());
742 
743  if (m_UpdSeqInput && RunningInsideNCBI()) {
745  CSeq_entry_Handle seh = upd_bsh.GetSeq_entry_Handle();
748  }
749 
750 
751  if (m_UpdSeqInput) {
753  if (RunningInsideNCBI()) {
754  m_ImportFeature->GetParent()->Disable();
755  }
756  else {
757  m_ImportFeature->Disable();
758  m_KeepProteinIdBox->Disable();
759  }
760  }
761 
763  FindWindow(ID_SEQUPD_DELFEAT_BTN1)->GetParent()->Disable();
764  }
765  }
766 
768  x_ShowProgressBar(false);
769  }
770 
771 
772 
774 
776 }
777 
779 {
781 }
782 
784 {
785  if (!m_UpdSeqInput) {
786  return;
787  }
789  if (!align) {
790  return;
791  }
792  const CBioseq_Handle& oldbsh = m_UpdSeqInput->GetOldBioseq();
793  const CBioseq_Handle& updbsh = m_UpdSeqInput->GetUpdateBioseq();
795  && updbsh.IsSetInst_Repr() && (updbsh.GetInst_Repr() == objects::CSeq_inst::eRepr_raw)) {
796  m_DeltaSeqText->Show(true);
797  }
798  const CSeq_align::TDim oldseqRow = CSequenceUpdater::FindRowInAlignment(oldbsh, *align);
799  const CSeq_align::TDim updseqRow = CSequenceUpdater::FindRowInAlignment(updbsh, *align);
800  _ASSERT(oldseqRow != updseqRow);
801  _ASSERT(oldseqRow > -1);
802  _ASSERT(updseqRow > -1);
803 
804  const TSeqPos aln_start = align->GetSeqStart(oldseqRow);
805  const TSeqPos aln_stop = align->GetSeqStop(oldseqRow);
806  const TSeqPos old3end = m_UpdSeqInput->GetOldBioseq().GetBioseqLength() - 1 - aln_stop;
807 
808  const TSeqPos aln_start_upd = align->GetSeqStart(updseqRow);
809  const TSeqPos aln_stop_upd = align->GetSeqStop(updseqRow);
810  const TSeqPos new3end = m_UpdSeqInput->GetUpdateBioseq().GetBioseqLength() - 1 - aln_stop_upd;
811 
812  if (oldbsh.IsAa()) {
813  m_NoChange->Enable();
814  m_Replace->Enable();
815  m_Patch->Disable();
816  m_Extend5->Disable();
817  m_Extend3->Disable();
818  } else {
819  // extend 5'
820  if (aln_start_upd > aln_start && new3end < old3end) {
821  m_Extend5->Enable();
822  m_Extend3->Disable();
823  }
824  // extend 3'
825  else if (aln_start_upd < aln_start && new3end > old3end) {
826  m_Extend3->Enable();
827  m_Extend5->Disable();
828  }
829  // replace
830  else {
831  m_Replace->Enable();
832  m_Extend5->Disable();
833  m_Extend3->Disable();
834  }
835 
838  m_Patch->Disable();
839  m_Extend5->Disable();
840  m_Extend3->Disable();
841  m_NoChange->Enable();
842  m_NoChange->SetValue(true);
843  m_Replace->Disable();
844  m_DeltaSeqText->SetLabel("Either the old or the update sequence is a delta sequence with far pointers.");
845  m_DeltaSeqText->Show(true);
846  }
847  }
848 }
849 
851 {
852  if (!m_UpdSeqInput)
853  return;
854 
856  if (!align.IsNull()) {
858  if (m_AlnWidget) {
859 
860  // update the drawingPanel
863  m_DrawPanel->Show(true);
864  m_DrawPanel->Layout();
865  m_DrawPanel->Refresh();
866 
867  m_Patch->Enable(true);
868  m_NoChange->Enable(true);
869  m_Replace->Enable(true);
870  bool enable = RunningInsideNCBI() ? true : false;
871  m_IgnoreAlignChk->Enable(enable);
872 
873  m_Toolbar->Show(true);
874  m_AlnWidget->Show(true);
875 
876  if (!m_AlnWidget->GetModel()) {
878  m_AlnWidget->LoadSettingsV(CGuiRegistry::GetInstance().GetReadView(kRegPath + ".Widget"));
879  }
880 
883 
884 
885  m_NoAlignmentText->Show(false);
886  }
887  }
888  else {
889  // if no alignment, disable the Patch button and the Ignore Alignment checkbox
890  m_NoChange->Disable();
891  m_Patch->Disable();
892  m_IgnoreAlignChk->Disable();
893  m_Extend3->Enable();
894  m_Extend5->Enable();
895 
896  m_Toolbar->Show(false);
897  m_AlnWidget->Show(false);
898  m_DrawPanel->Show(false);
899  if (!create) {
900  m_NoAlignmentText->Show(true);
901  }
902  }
903 
905 }
906 
908 {
910 
911  // setup display styles
916 }
917 
919 {
921  m_Builder.PreCreateDataSource(false); // false - for not having a sparse or spliced alignment
923  m_DataSource->SetListener(m_AlnWidget);
924 
926 }
927 
929 {
931  string name;
932  best_idh.GetSeqId()->GetLabel(&name, CSeq_id::eContent);
933  label.append(name);
934  label.append(" Length: ");
935  label.append(NStr::IntToString(bsh.GetBioseqLength()));
936 }
937 
939 {
942  return;
943  }
944  m_DrawParams.Lold = m_UpdSeqInput->GetOldBioseq().GetBioseqLength();
945  m_DrawParams.Lupd = m_UpdSeqInput->GetUpdateBioseq().GetBioseqLength();
946  const CSeq_align& align = *(m_UpdSeqInput->GetAlignment());
947 
948  if (align.GetSegs().IsDenseg()) {
949  const CDense_seg& denseg = align.GetSegs().GetDenseg();
952 
953  m_DrawParams.aln_start_old = denseg.GetSeqStart(old_row);
954  m_DrawParams.aln_stop_old = denseg.GetSeqStop(old_row);
955  m_DrawParams.strand_old = denseg.GetSeqStrand(old_row);
956 
957  m_DrawParams.aln_start_upd = denseg.GetSeqStart(upd_row);
958  m_DrawParams.aln_stop_upd = denseg.GetSeqStop(upd_row);
959  m_DrawParams.strand_upd = denseg.GetSeqStrand(upd_row);
960  }
961 }
962 
963 
965 {
966  string label("Update sequence: ");
967  if (m_UpdSeqInput) {
969  m_NewSeqName->SetLabel(ToWxString(label));
970  }
971 
972  label.assign("Old sequence: ");
973  if (m_UpdSeqInput) {
975  m_OldSeqName->SetLabel(ToWxString(label));
976  }
977 
978 
979  std::fill(begin(m_SequenceUpdateType), end(m_SequenceUpdateType), false);
980  std::fill(begin(m_RemoveFeatureType), end(m_RemoveFeatureType), false);
981  std::fill(begin(m_ImportFeatureType), end(m_ImportFeatureType), false);
982 
983  m_SequenceUpdateType[(short)params.m_SeqUpdateOption] = true;
984  m_RemoveFeatureType[(short)params.m_FeatRemoveOption] = true;
988  if (RunningInsideNCBI()) {
989  m_AddCitSub = params.m_AddCitSub;
990  m_UpdateProtein = (params.m_UpdateProteins) ? true : false;
991  m_ImportFeatureType[(short)params.m_FeatImportOption] = true;
992  } else {
993  m_AddCitSub = false;
994  m_UpdateProtein = true;
996  }
997 }
998 
1000 {
1001  SUpdateSeqParams params;
1002  if (!Validate() || !TransferDataFromWindow()) {
1003  return params;
1004  }
1005 
1006  for (size_t i = 0; i < SUpdateSeqParams::CountSeqUpdateType; ++i){
1007  if (m_SequenceUpdateType[i]){
1009  break;
1010  }
1011  }
1012  for (size_t i = 0; i < SUpdateSeqParams::CountFeatRemoveType; ++i) {
1013  if (m_RemoveFeatureType[i]) {
1015  break;
1016  }
1017  }
1020  if (RunningInsideNCBI()) {
1021  string sel_feat = m_FeatType->GetFieldName();
1022  if (!NStr::EqualNocase(sel_feat, "any")) {
1024  }
1025  for (size_t i = 0; i < SUpdateSeqParams::CountFeatUpdateType; ++i) {
1026  if (m_ImportFeatureType[i]) {
1028  break;
1029  }
1030  }
1031  }
1032 
1033  // for updating protein IDs
1035  if (RunningInsideNCBI()) {
1036  // for updating proteins on the updated sequence
1038  // for adding cit-sub to the updated sequence
1039  params.m_AddCitSub = m_AddCitSub;
1040  } else {
1041  // for external users, always update proteins and never add cit-subs
1042  params.m_UpdateProteins = true;
1043  params.m_AddCitSub = false;
1045  }
1046 
1047  return params;
1048 }
1049 
1050 void CUpdateSeqPanel::UpdatePanel(bool running, const CUpdateSeq_Input* updseq_in)
1051 {
1052  x_ShowProgressBar(running);
1053 
1054  if (updseq_in) {
1055  m_UpdSeqInput.Reset(updseq_in);
1056  m_Scope.Reset(&(m_UpdSeqInput->GetOldBioseq().GetScope()));
1057 
1058  string label("Update sequence: ");
1060  m_NewSeqName->SetLabel(ToWxString(label));
1061 
1062  label.assign("Old sequence: ");
1064  m_OldSeqName->SetLabel(ToWxString(label));
1065 
1067  if (RunningInsideNCBI()) {
1068  m_ImportFeature->GetParent()->Disable();
1069  }
1070  else {
1071  m_ImportFeature->Disable();
1072  m_KeepProteinIdBox->Disable();
1073  }
1074  }
1075 
1076  if (!m_UpdSeqInput->OldSeqHasFeatures()) {
1077  FindWindow(ID_SEQUPD_DELFEAT_BTN1)->GetParent()->Disable();
1078  }
1079  if (RunningInsideNCBI()) {
1081  CSeq_entry_Handle seh = upd_bsh.GetSeq_entry_Handle();
1084  }
1085  }
1086 
1087  if (running) {
1088  m_Toolbar->Show(false);
1089  m_AlnWidget->Show(false);
1090  m_DrawPanel->Show(false);
1091  m_NoAlignmentText->Show(false);
1092  }
1093  else {
1095  }
1096 
1097  Layout();
1098 }
1099 
1101 {
1102  wxWindow* win = FindWindowById(ID_SEQUPD_UPDPROTEIN);
1103  if (win) {
1104  wxCheckBox* box = dynamic_cast<wxCheckBox*>(win);
1105  if (box)
1106  box->SetValue(value);
1107  }
1108 }
1109 
1111 {
1112  wxWindow* win = FindWindowById(ID_SEQUPD_UPDPROTEIN);
1113  if (win) {
1114  wxCheckBox* box = dynamic_cast<wxCheckBox*>(win);
1115  if (box)
1116  return box->GetValue();
1117  }
1118  return false;
1119 }
1120 
1122 {
1123 }
1124 
1126 {
1127  if (!m_AlnWidget)
1128  return;
1129 
1130  if (m_AlnWidget && m_AlnWidget->GetModel())
1131  m_AlnWidget->SaveSettingsV(CGuiRegistry::GetInstance().GetWriteView(kRegPath + ".Widget"));
1132 }
1133 
1134 
1135 /*!
1136  * Should we show tooltips?
1137  */
1138 
1140 {
1141  return true;
1142 }
1143 
1144 /*!
1145  * Get bitmap resources
1146  */
1147 
1148 wxBitmap CUpdateSeqPanel::GetBitmapResource(const wxString& name)
1149 {
1150  // Bitmap retrieval
1151 ////@begin CUpdateSeq_Dlg bitmap retrieval
1152  wxUnusedVar(name);
1153  return wxNullBitmap;
1154 ////@end CUpdateSeq_Dlg bitmap retrieval
1155 }
1156 
1157 /*!
1158  * Get icon resources
1159  */
1160 
1161 wxIcon CUpdateSeqPanel::GetIconResource(const wxString& name)
1162 {
1163  // Icon retrieval
1164 ////@begin CUpdateSeq_Dlg icon retrieval
1165  wxUnusedVar(name);
1166  return wxNullIcon;
1167 ////@end CUpdateSeq_Dlg icon retrieval
1168 }
1169 
1171 {
1172  event.Enable(false);
1174  event.Enable(true);
1175 }
1176 
1177 void CUpdateSeqPanel::OnNoChangeBtnSelected(wxCommandEvent& event)
1178 {
1179  m_Replace->Enable();
1180 
1181  m_Patch->Disable();
1182  m_Extend5->Disable();
1183  m_Extend3->Disable();
1184  m_IgnoreAlignChk->Disable();
1185 }
1186 
1187 void CUpdateSeqPanel::OnReplaceBtnSelected(wxCommandEvent& event)
1188 {
1190  if (align) {
1191  m_NoChange->Enable();
1192  m_Patch->Enable();
1193  bool enable = RunningInsideNCBI() ? true : false;
1194  m_IgnoreAlignChk->Enable(enable);
1195 
1196  m_Extend5->Disable();
1197  m_Extend3->Disable();
1198  }
1199 }
1200 
1201 void CUpdateSeqPanel::OnPatchBtnSelected(wxCommandEvent& event)
1202 {
1203  m_NoChange->Enable();
1204  m_Replace->Enable();
1205 
1206  m_Extend5->Disable();
1207  m_Extend3->Disable();
1208  m_IgnoreAlignChk->Disable();
1209 }
1210 
1211 void CUpdateSeqPanel::OnExtend5BtnSelected(wxCommandEvent& event)
1212 {
1214  if (align) {
1215  m_Replace->Enable();
1216  m_Extend3->Enable();
1217  m_IgnoreAlignChk->Enable();
1218 
1219  m_NoChange->Disable();
1220  m_Patch->Disable();
1221  }
1222  else {
1223  m_Replace->Enable();
1224  m_Extend3->Enable();
1225  m_IgnoreAlignChk->SetValue(true);
1226  }
1227 }
1228 
1229 void CUpdateSeqPanel::OnExtend3BtnSelected(wxCommandEvent& event)
1230 {
1232  if (align) {
1233  m_Replace->Enable();
1234  m_Extend5->Enable();
1235  m_IgnoreAlignChk->Enable();
1236 
1237  m_NoChange->Disable();
1238  m_Patch->Disable();
1239  }
1240  else {
1241  m_Replace->Enable();
1242  m_Extend5->Enable();
1243  m_IgnoreAlignChk->SetValue(true);
1244  }
1245 }
1246 
1247 void CUpdateSeqPanel::OnIgnoreAlignmentClick(wxCommandEvent& event)
1248 {
1249  if (RunningInsideNCBI()) {
1250  m_Replace->Enable();
1251  if (m_IgnoreAlignChk->IsChecked()) {
1252  m_Extend5->Enable();
1253  m_Extend3->Enable();
1254 
1255  m_NoChange->Disable();
1256  m_Patch->Disable();
1257  }
1258  else {
1259  m_Extend5->Disable();
1260  m_Extend3->Disable();
1261 
1262  m_NoChange->Enable();
1263  m_Patch->Enable();
1264  }
1265  }
1266 }
1267 
1268 void CUpdateSeqPanel::OnImportChecked(wxCommandEvent& event)
1269 {
1270  if (RunningInsideNCBI()) {
1271  if (m_ImportFeature->IsEnabled() && m_ImportFeature->IsChecked()) {
1272  m_FeatType->SetFieldName("Any");
1273  }
1274  }
1275 
1276 }
1277 void CUpdateSeqPanel::OnZoomIn(wxCommandEvent& event)
1278 {
1279  m_AlnWidget->OnZoomInX(event);
1280 }
1281 
1282 void CUpdateSeqPanel::OnZoomOut(wxCommandEvent& event)
1283 {
1284  m_AlnWidget->OnZoomOutX(event);
1285 }
1286 
1287 void CUpdateSeqPanel::OnZoomAll(wxCommandEvent& event)
1288 {
1289  m_AlnWidget->OnZoomAll(event);
1290 }
1291 
1292 void CUpdateSeqPanel::OnZoomToSequence(wxCommandEvent& event)
1293 {
1294  m_AlnWidget->OnZoomSequence(event);
1295 }
1296 
1297 void CUpdateSeqPanel::OnZoomToSelection(wxCommandEvent& event)
1298 {
1299  m_AlnWidget->OnZoomSelection(event);
1300 }
1301 
static CRef< CScope > m_Scope
EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX, CAdjustFeaturesForGaps::OnKnownUnknownSelected) EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX1
static const char * kDefaultScoringMethod
EVT_UPDATE_UI(eCmdAlnShowMethodsDlg, CAlnMultiWidget::OnUpdateShowMethodDlg) EVT_UPDATE_UI(eCmdMethodProperties
#define true
Definition: bool.h:35
void Init(objects::CScope &scope, const objects::CSeq_align &align)
initial data set from which an alignment will be build
CRef< IAlnMultiDataSource > CreateDataSource()
void PreCreateDataSource(bool sparse)
virtual CWidgetDisplayStyle * GetDisplayStyle()
const size_t GetNumRows() const
Get number of rows registered in model.
virtual void SetDataSource(IAlnMultiDataSource *p_ds)
class CAlnMultiPane
void HideProgressPanel()
void ShowProgressPanel(float progress, const string &msg)
class CAlnMultiRenderer - renders multiple alignment represented by IAlnMultiRendererContext (the Mod...
int GetColumnIndexByType(TColumnType type) const
void SetColumnVisible(int index, bool b_visible)
class CAlnMultiWidget
CAlnMultiPane * m_AlignPane
representation of alignment data
IAlnMultiDataSource * m_DataSource
virtual void SetDataSource(IAlnMultiDataSource *p_ds, objects::CScope *scope)
virtual void x_SetScoringMethod(const string &method_name, bool save)
virtual void x_UpdateOnDataChanged(bool b_reset=true)
Update handlers.
virtual void SetStyleCatalog(const CRowStyleCatalog *catalog)
void OnZoomSequence(wxCommandEvent &event)
CAlnMultiModel * m_Model
source of alignment data
virtual const CWidgetDisplayStyle * GetDisplayStyle() const
virtual CAlnMultiModel * GetModel()
void OnZoomSelection(wxCommandEvent &event)
virtual void CreateWidget(CAlnMultiModel *model=NULL)
performs initialization, creates Model and Controls.
CBioseq_Handle –.
CUpdate - notification send by CUIDataSource to the listener.
ENa_strand GetSeqStrand(TDim row) const
Definition: Dense_seg.cpp:241
TSeqPos GetSeqStop(TDim row) const
Definition: Dense_seg.cpp:203
TSeqPos GetSeqStart(TDim row) const
Definition: Dense_seg.cpp:165
int x_GetLeft_UpdSeq() const
int x_GetRight_OldSeq() const
int x_FindWidthDrawingArea(wxDC &dc)
void SetParams(const CUpdateSeqPanel::SDrawingParams &params)
void Render(wxDC &dc)
void PaintEvent(wxPaintEvent &event)
int x_GetRight_UpdSeq() const
int x_GetLeft_OldSeq() const
void x_SetScalingFactor(wxDC &dc)
CUpdateSeqPanel::SDrawingParams m_Params
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
virtual bool SetFieldName(const string &field)
virtual string GetFieldName(const bool subfield=false)
Returns the name of the field as selected in the panel.
void ListPresentFeaturesFirst(const objects::CSeq_entry_Handle &entry, vector< const objects::CFeatListItem * > *featlist=nullptr)
void OnZoomOutX(wxCommandEvent &event)
virtual void SetRegistryPath(const string &reg_path)
void OnZoomAll(wxCommandEvent &event)
void OnZoomInX(wxCommandEvent &event)
static CGuiRegistry & GetInstance()
access the application-wide singleton
Definition: registry.cpp:400
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
CRowDisplayStyle is a base class representing a display style for IAlignRow.
void SetDefaultStyle(CRowDisplayStyle *style)
assumes ownership
void SetWidgetStyle(const CWidgetDisplayStyle *style)
static ESubtype SubtypeNameToValue(CTempString sName)
Turn a string into its ESubtype which is NOT necessarily related to the identifier of the enum.
Sequence update exception class.
TSeqPos GetSeqStop(TDim row) const
Definition: Seq_align.cpp:273
TSeqPos GetSeqStart(TDim row) const
Definition: Seq_align.cpp:252
CSeq_entry_Handle –.
static objects::CSeq_align::TDim FindRowInAlignment(const objects::CBioseq_Handle &bsh, const objects::CSeq_align &align)
Definition: update_seq.cpp:611
CUICommandRegistry is a centralized registry where all application commands should be registered.
Definition: ui_command.hpp:146
static CUICommandRegistry & GetInstance()
the main instance associated with the application
Definition: ui_command.cpp:176
void AppendTool(wxToolBar &tool_bar, TCmdID cmd_id)
Definition: ui_command.cpp:448
void SetNewBioseq(const CBioseq_Handle &bsh)
objects::CBioseq_Handle m_OldSeq
void LoadSettingsV(const CRegistryReadView &view)
virtual void OnDSChanged(CDataChangeNotifier::CUpdate &update)
void SaveSettingsV(CRegistryWriteView view) const
void x_OnAlnWidgetSelChanged(CEvent *evt)
IAlnMultiDataSource::TNumrow TNumrow
void OnZoomAll(wxCommandEvent &event)
void OnNoChangeBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_SEQUPD_BTN1
wxCheckBox * m_IgnoreAlignChk
void x_InitAlnMultiWidgetAndUpdateTypes(bool create=false)
void OnRemoveAlignedFeaturesUpdated(wxUpdateUIEvent &event)
wxEVT_UPDATE_UI event handler for ID_SEQUPD_DELFEAT_BTN2
static bool ShowToolTips()
Should we show tooltips?
SUpdateSeqParams GetData()
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
CIRef< IAlnMultiDataSource > m_DataSource
wxStaticText * m_NewSeqName
void LoadSettings(const CRegistryReadView &view)
void x_SetUpdateTypes(void)
bool GetUpdateProteins() const
void CreateControls()
Creates the controls and sizers.
void OnExtend3BtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_SEQUPD_BTN5
wxStaticText * m_OldSeqName
void SaveSettings(CRegistryWriteView view) const
CRef< CScope > m_Scope
wxBoxSizer * m_MainSizer
void x_GetNameAndLength(const objects::CBioseq_Handle &bsh, string &label)
bool Create(wxWindow *parent, wxWindowID id=wxTAB_TRAVERSAL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
void x_ShowProgressBar(bool show)
bool m_ImportFeatureType[SUpdateSeqParams::CountFeatUpdateType]
wxRadioButton * m_Replace
wxRadioButton * m_Extend3
CUpdateSeqPanel()
Constructors.
wxBoxSizer * m_ProgressSizer
void OnIgnoreAlignmentClick(wxCommandEvent &event)
wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_SEQUPD_IALN_CHK
void Init()
Initialises member variables.
void OnImportChecked(wxCommandEvent &event)
wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_SEQUPD_IMPCHK
SDrawingParams m_DrawParams
bool m_RemoveFeatureType[SUpdateSeqParams::CountFeatRemoveType]
CRowStyleCatalog m_StyleCatalog
wxRadioButton * m_Patch
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
wxStaticText * m_DeltaSeqText
wxCheckBox * m_ImportFeature
wxStaticText * m_NoAlignmentText
wxRadioButton * m_Extend5
bool m_SequenceUpdateType[SUpdateSeqParams::CountSeqUpdateType]
wxStaticBoxSizer * m_AlignStaticBoxSizer
void UpdatePanel(bool running, const CUpdateSeq_Input *updseq_in=nullptr)
Function updates the panel with new (old, update) sequence pair.
wxRadioButton * m_NoChange
void OnZoomOut(wxCommandEvent &event)
void OnExtend5BtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_SEQUPD_BTN4
CUpdateSeqAlignWidget * m_AlnWidget
CFeatureTypePanel * m_FeatType
void OnZoomToSelection(wxCommandEvent &event)
void OnPatchBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_SEQUPD_BTN3
~CUpdateSeqPanel()
Destructor.
CAlnMultiDSBuilder m_Builder
void SetUpdateProteins(bool value)
CConstRef< CUpdateSeq_Input > m_UpdSeqInput
void SetData(const SUpdateSeqParams &params)
void OnZoomIn(wxCommandEvent &event)
CDrawingPanel * m_DrawPanel
void OnZoomToSequence(wxCommandEvent &event)
void OnReplaceBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_SEQUPD_BTN2
wxCheckBox * m_KeepProteinIdBox
Sets up the old and the update sequences, and generates the alignment between them.
CConstRef< objects::CSeq_align > GetAlignment(void) const
bool UpdateSeqHasFeatures(void) const
static bool s_IsDeltaWithFarPointers(const objects::CBioseq &bseq)
const objects::CBioseq_Handle & GetUpdateBioseq(void) const
const objects::CBioseq_Handle & GetOldBioseq(void) const
bool OldSeqHasFeatures(void) const
static bool s_IsDeltaWithNoGaps(const objects::CBioseq &bseq)
void SaveSettings(CRegistryWriteView view, IAlnExplorer::EAlignType type)
void LoadSettings(const CRegistryReadView &view)
@ eIcons
Strand + Expand icons.
Definition: ialign_row.hpp:77
virtual IAlnExplorer::EAlignType GetAlignType() const =0
virtual bool CanChangeAnchor(void) const =0
IAlnExplorer::TNumrow TNumrow
virtual TNumrow GetNumRows(void) const =0
number of rows in alignment
virtual bool SetAnchor(TNumrow anchor)=0
virtual const objects::CSeq_id & GetSeqId(TNumrow row) const =0
virtual bool IsEmpty() const =0
IAlnMultiDataSource::TNumrow TNumrow
Stores parameters regarding the type of sequence update, on how to handle existing features and on ho...
EFeatUpdateType m_FeatImportOption
ESequenceUpdateType m_SeqUpdateOption
TProtUpdFlags m_UpdateProteins
objects::CSeqFeatData::ESubtype m_FeatImportType
Defines the imported feature subtype.
bool m_AddCitSub
flag to attach a citation with the current date (false)
EFeatRemoveType m_FeatRemoveOption
bool m_ImportFeatures
Flag to indicate that features from the update sequence will be imported.
bool m_KeepProteinId
flag to update protein IDs, default is to update (false) - relevant only to imported protein IDs
@ eProtUpdate
retranslate coding regions and update the proteins
@ CountSeqUpdateType
extend the 3' end of old sequence with the update
char value[7]
Definition: config.c:431
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define NULL
Definition: ncbistd.hpp:225
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
#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
EDialogReturnValue NcbiMessageBox(const string &message, TDialogType type=eDialog_Ok, EDialogIcon icon=eIcon_Exclamation, const string &title="Error", EDialogTextMode text_mode=eRaw)
Definition: message_box.cpp:48
#define END_EVENT_MAP()
Ends definition of Command Map.
#define BEGIN_EVENT_MAP(thisClass, baseClass)
Begins definition of Command Map for CEventHandler-derived class.
@ eCmdZoomIn
empty command
Definition: command.hpp:68
@ eCmdZoomOut
Definition: command.hpp:69
@ eCmdZoomSeq
Zoom to Selection.
Definition: command.hpp:74
@ eCmdZoomAll
Definition: command.hpp:70
@ eCmdZoomSel
Definition: command.hpp:73
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
Definition: Seq_id.cpp:2039
CConstRef< CSeq_id > GetSeqId(void) const
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:573
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
@ eGetId_Best
return the "best" gi (uses FindBestScore(), with CSeq_id::CalculateScore() as the score function
Definition: sequence.hpp:101
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
TSeqPos GetBioseqLength(void) const
bool IsAa(void) const
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
bool IsSetInst_Repr(void) const
TInst_Repr GetInst_Repr(void) const
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:1401
TObjectType * GetNCPointer(void) const THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:1174
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#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 string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5083
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5352
static const char label[]
const TDenseg & GetDenseg(void) const
Get the variant data.
Definition: Seq_align_.cpp:153
const TSegs & GetSegs(void) const
Get the Segs member data.
Definition: Seq_align_.hpp:921
bool IsDenseg(void) const
Check if variant Denseg is selected.
Definition: Seq_align_.hpp:740
@ 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
@ eIcon_Stop
Definition: types.hpp:66
@ eWrap
Definition: types.hpp:82
@ eDialog_Ok
Definition: types.hpp:47
END_EVENT_TABLE()
int i
#define wxT(x)
Definition: muParser.cpp:41
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::SIZE size
int offset
Definition: replacements.h:160
static static static wxID_ANY
#define _ASSERT
const string & CDCN_GetMessage(const CDataChangeNotifier::CUpdate &update)
USING_SCOPE(objects)
static const string kRegPath
ON_EVENT(CAlnMultiPane::CEvent, CAlnMultiPane::eLinearSelChanged, &CUpdateSeqAlignWidget::x_OnAlnWidgetSelChanged) void CUpdateSeqAlignWidget
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
bool RunningInsideNCBI()
Definition: wx_utils.cpp:1335
#define const
Definition: zconf.h:230
Modified on Sat Sep 23 22:43:39 2023 by modify_doxy.py rev. 669887