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

Go to the SVN repository for this file.

1 /* $Id: add_feature_between_dlg.cpp 45437 2020-08-03 17:44:02Z 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: Igor Filippov
27  */
28 
29 
30 #include <ncbi_pch.hpp>
33 #include <objmgr/bioseq_ci.hpp>
34 #include <objmgr/feat_ci.hpp>
35 #include <objmgr/bioseq_handle.hpp>
36 
37 ////@begin includes
38 ////@end includes
50 #include <gui/objutils/utils.hpp>
51 
52 #include <wx/msgdlg.h>
53 
56 
57 ////@begin XPM images
58 ////@end XPM images
59 
61 
62 /*!
63  * CAddFeatureBetweenDlg type definition
64  */
65 
66 IMPLEMENT_DYNAMIC_CLASS( CAddFeatureBetweenDlg, CBulkCmdDlg )
67 
68 
69 /*!
70  * CAddFeatureBetweenDlg event table definition
71  */
72 
73 BEGIN_EVENT_TABLE( CAddFeatureBetweenDlg, CBulkCmdDlg )
74 
75 ////@begin CAddFeatureBetweenDlg event table entries
77 ////@end CAddFeatureBetweenDlg event table entries
78 
80 
81 
82 /*!
83  * CAddFeatureBetweenDlg constructors
84  */
85 
87 {
88  Init();
89 }
90 
91 CAddFeatureBetweenDlg::CAddFeatureBetweenDlg( wxWindow* parent, objects::CSeq_entry_Handle seh, IWorkbench* workbench,
92  wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
93  : m_TopSeqEntry(seh), m_Workbench(workbench)
94 {
95  Init();
96  Create(parent, id, caption, pos, size, style);
97 }
98 
99 
100 /*!
101  * CAddFeatureBetweenDlg creator
102  */
103 
104 bool CAddFeatureBetweenDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
105 {
106 ////@begin CAddFeatureBetweenDlg creation
107  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
108  CBulkCmdDlg::Create( parent, id, caption, pos, size, style );
109 
110  CreateControls();
111  if (GetSizer())
112  {
113  GetSizer()->SetSizeHints(this);
114  }
115  Centre();
116 ////@end CAddFeatureBetweenDlg creation
117 
118  return true;
119 }
120 
121 
122 /*!
123  * CAddFeatureBetweenDlg destructor
124  */
125 
127 {
128 ////@begin CAddFeatureBetweenDlg destruction
129 ////@end CAddFeatureBetweenDlg destruction
130 }
131 
132 
133 /*!
134  * Member initialisation
135  */
136 
138 {
139 ////@begin CAddFeatureBetweenDlg member initialisation
140  m_Notebook = NULL;
145 ////@end CAddFeatureBetweenDlg member initialisation
146  x_ListFeatures();
147 }
148 
149 
150 /*!
151  * Control creation for CAddFeatureBetweenDlg
152  */
153 
155 {
156 ////@begin CAddFeatureBetweenDlg content construction
157  // Generated by DialogBlocks, 10/06/2013 17:47:57 (unregistered)
158 
159  CAddFeatureBetweenDlg* itemCBulkCmdDlg1 = this;
160 
161  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
162  itemCBulkCmdDlg1->SetSizer(itemBoxSizer2);
163 
164  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
165  itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
166 
167  wxBoxSizer* LeftOptions = new wxBoxSizer(wxVERTICAL);
168  itemBoxSizer3->Add(LeftOptions, 0, wxALIGN_TOP|wxALL, 5);
169 
170  wxStaticText* itemStaticText5 = new wxStaticText( itemCBulkCmdDlg1, wxID_STATIC, _("Left Feature"), wxDefaultPosition, wxDefaultSize, 0 );
171  LeftOptions->Add(itemStaticText5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
172 
173  m_NoFeatPartialLeft = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("if selected feature is missing, extend to partial end"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
174  m_NoFeatPartialLeft->SetValue(true);
175  LeftOptions->Add(m_NoFeatPartialLeft, 0, wxALIGN_LEFT|wxALL, 5);
176 
177  m_NoFeatNoFeatLeft = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("if selected feature is missing, do not create feature"));
178  m_NoFeatNoFeatLeft->SetValue(false);
179  LeftOptions->Add(m_NoFeatNoFeatLeft, 0, wxALIGN_LEFT|wxALL, 5);
180 
181  m_ExtendCompleteLeft = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("extend to complete end"));
182  m_ExtendCompleteLeft->SetValue(false);
183  LeftOptions->Add(m_ExtendCompleteLeft, 0, wxALIGN_LEFT|wxALL, 5);
184 
185  m_ExtendPartialLeft = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("extend to partial end"));
186  m_ExtendPartialLeft->SetValue(false);
187  LeftOptions->Add(m_ExtendPartialLeft, 0, wxALIGN_LEFT|wxALL, 5);
188 
189  m_FeatureTypeLeft = new wxListBox( itemCBulkCmdDlg1, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_FeatureTypeStrings, wxLB_SINGLE );
190  LeftOptions->Add(m_FeatureTypeLeft, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
191  m_FeatureTypeLeft->Bind(wxEVT_LISTBOX, &CAddFeatureBetweenDlg::OnFeatLeftChanged, this);
192 
193  m_FeatLeftConstraint = new CFeatureFieldNamePanel(itemCBulkCmdDlg1, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
194  LeftOptions->Add(m_FeatLeftConstraint, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
196 
197  m_StringConstraintPanelLeft = new CStringConstraintPanel(itemCBulkCmdDlg1, false, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
198  LeftOptions->Add(m_StringConstraintPanelLeft, 0, wxALIGN_CENTER_HORIZONTAL|wxFIXED_MINSIZE|wxALL, 0);
199 
200  wxStaticLine *line1 = new wxStaticLine (itemCBulkCmdDlg1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL);
201  itemBoxSizer3->Add(line1, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxSHAPED, 5);
202 
203  wxBoxSizer* FeatureOptions = new wxBoxSizer(wxVERTICAL);
204  itemBoxSizer3->Add(FeatureOptions, 0, wxALIGN_TOP|wxALL, 5);
205 
206  wxStaticText* itemStaticText6 = new wxStaticText( itemCBulkCmdDlg1, wxID_STATIC, _("Feature To Add"), wxDefaultPosition, wxDefaultSize, 0 );
207  FeatureOptions->Add(itemStaticText6, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
208 
209  m_Notebook = new wxNotebook(itemCBulkCmdDlg1, wxID_ANY,wxDefaultPosition,wxDefaultSize);
210 
211  FeatureOptions->Add(m_Notebook, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
212 
213  CBulkRNAAddPanel *rnaPanel = new CBulkRNAAddPanel( m_Notebook, m_TopSeqEntry, false);
214  m_Notebook->AddPage(rnaPanel,_("RNA"));
215 
216  CBulkCDSAddPanel *cdsPanel = new CBulkCDSAddPanel( m_Notebook, m_TopSeqEntry, false);
217  m_Notebook->AddPage(cdsPanel,_("CDS"));
218 
219  CBulkOtherAddPanel *otherPanel = new CBulkOtherAddPanel( m_Notebook, m_TopSeqEntry, "", false);
220  m_Notebook->AddPage(otherPanel,_("Other"));
221 
222 
223  wxStaticLine *line2 = new wxStaticLine (itemCBulkCmdDlg1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL);
224  itemBoxSizer3->Add(line2, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxSHAPED, 5);
225 
226  wxBoxSizer* RightOptions = new wxBoxSizer(wxVERTICAL);
227  itemBoxSizer3->Add(RightOptions, 0, wxALIGN_TOP|wxALL, 5);
228 
229  wxStaticText* itemStaticText7 = new wxStaticText( itemCBulkCmdDlg1, wxID_STATIC, _("Right Feature"), wxDefaultPosition, wxDefaultSize, 0 );
230  RightOptions->Add(itemStaticText7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
231 
232  m_NoFeatPartialRight = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("if selected feature is missing, extend to partial end"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
233  m_NoFeatPartialRight->SetValue(true);
234  RightOptions->Add(m_NoFeatPartialRight, 0, wxALIGN_LEFT|wxALL, 5);
235 
236  m_NoFeatNoFeatRight = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("if selected feature is missing, do not create feature"));
237  m_NoFeatNoFeatRight->SetValue(false);
238  RightOptions->Add(m_NoFeatNoFeatRight, 0, wxALIGN_LEFT|wxALL, 5);
239 
240  m_ExtendCompleteRight = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("extend to complete end"));
241  m_ExtendCompleteRight->SetValue(false);
242  RightOptions->Add(m_ExtendCompleteRight, 0, wxALIGN_LEFT|wxALL, 5);
243 
244  m_ExtendPartialRight = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("extend to partial end"));
245  m_ExtendPartialRight->SetValue(false);
246  RightOptions->Add(m_ExtendPartialRight, 0, wxALIGN_LEFT|wxALL, 5);
247 
248  m_FeatureTypeRight = new wxListBox( itemCBulkCmdDlg1, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_FeatureTypeStrings, wxLB_SINGLE );
249  RightOptions->Add(m_FeatureTypeRight, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
251 
252  m_FeatRightConstraint = new CFeatureFieldNamePanel(itemCBulkCmdDlg1, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
253  RightOptions->Add(m_FeatRightConstraint, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
255 
256  m_StringConstraintPanelRight = new CStringConstraintPanel(itemCBulkCmdDlg1, false, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
257  RightOptions->Add(m_StringConstraintPanelRight, 0, wxALIGN_CENTER_HORIZONTAL|wxFIXED_MINSIZE|wxALL, 0);
258 
259  wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
260  itemBoxSizer2->Add(itemBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
261 
262  wxButton* itemButton6 = new wxButton( itemCBulkCmdDlg1, ID_APPLY_BUTTON, _("Accept"), wxDefaultPosition, wxDefaultSize, 0 );
263  itemBoxSizer5->Add(itemButton6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
264 
265  wxButton* itemButton7 = new wxButton( itemCBulkCmdDlg1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
266  itemBoxSizer5->Add(itemButton7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
267 
268  m_LeaveUp = new wxCheckBox (itemCBulkCmdDlg1, wxID_ANY, _("Leave dialog up"));
269  itemBoxSizer5->Add(m_LeaveUp, 0, wxALIGN_LEFT|wxALL, 5);
270 ////@end CAddFeatureBetweenDlg content construction
271 }
272 
274 {
275  if (!m_TopSeqEntry)
276  return;
277 
278  set<string> existing;
279  m_Subtype.clear();
280  m_FeatureTypeStrings.Clear();
281 
282  existing.insert("All");
283 
284  vector<const CFeatListItem *> featlist = GetSortedFeatList(m_TopSeqEntry);
285  ITERATE(vector<const CFeatListItem *>, feat_it, featlist) {
286  const CFeatListItem& item = **feat_it;
287  string desc = item.GetDescription();
288  int feat_type = item.GetType();
291  if (existing.find(desc) == existing.end()) {
292  existing.insert(desc);
293  m_Subtype.push_back(feat_subtype);
294  m_FeatureTypeStrings.Add(ToWxString(desc));
295  }
296  }
297  }
298 }
299 
301 {
302  locs.clear();
303  int s1 = m_FeatureTypeLeft->GetSelection();
304  int s2 = m_FeatureTypeRight->GetSelection();
305 
306  objects::CSeqFeatData::ESubtype subtype1 = objects::CSeqFeatData::eSubtype_bad;
307  if ( (m_NoFeatPartialLeft->GetValue() || m_NoFeatNoFeatLeft->GetValue())
308  && s1 != wxNOT_FOUND)
309  {
310  subtype1 = m_Subtype[s1];
311  }
312  objects::CSeqFeatData::ESubtype subtype2 = objects::CSeqFeatData::eSubtype_bad;
313  if ( (m_NoFeatPartialRight->GetValue() || m_NoFeatNoFeatRight->GetValue())
314  && s2 != wxNOT_FOUND)
315  {
316  subtype2 = m_Subtype[s2];
317  }
318 
319  CRef<CEditingActionConstraint> constraint_left;
321  {
322  string ncRNA_class1;
323  subtype1 = (CSeqFeatData::ESubtype)CorrectForncRNASubtypes(subtype1, ncRNA_class1);
324 
325  string leftconstr_ncRNA_class;
326  auto leftconstr_subtype = GetSubtype(m_FeatLeftConstraint, leftconstr_ncRNA_class);
327  constraint_left = CreateEditingActionConstraint( m_FeatureTypeLeft->GetStringSelection().ToStdString(),
329  subtype1, ncRNA_class1,
332  leftconstr_subtype, leftconstr_ncRNA_class,
334  }
335 
336  CRef<CEditingActionConstraint> constraint_right;
338  {
339  string ncRNA_class2;
340  subtype2 = (CSeqFeatData::ESubtype)CorrectForncRNASubtypes(subtype2, ncRNA_class2);
341 
342  string rightconstr_ncRNA_class;
343  auto rightconstr_subtype = GetSubtype(m_FeatRightConstraint, rightconstr_ncRNA_class);
344  constraint_right = CreateEditingActionConstraint( m_FeatureTypeRight->GetStringSelection().ToStdString(),
346  subtype2, ncRNA_class2,
349  rightconstr_subtype, rightconstr_ncRNA_class,
351  }
352 
353  for (CBioseq_CI bsi(m_TopSeqEntry, CSeq_inst::eMol_na); bsi; ++bsi)
354  {
355 
356  bool partial_left = true;
357  bool partial_right = true;
358  bool found = false;
359 
360  TSignedSeqPos length = bsi->GetBioseqLength();
361  if (length == 0)
362  continue;
363 
364  if (subtype1 != objects::CSeqFeatData::eSubtype_bad)
365  {
366  for (objects::CFeat_CI feat1(*bsi, objects::SAnnotSelector(subtype1)); feat1; ++feat1)
367  {
368  if (constraint_left && !constraint_left->Match(*feat1))
369  continue;
370  const CSeq_loc &loc1 = feat1->GetLocation();
371  TSignedSeqPos start1 = feat1->GetLocationTotalRange().GetFrom();
372  TSignedSeqPos stop1 = feat1->GetLocationTotalRange().GetTo();
373  partial_left = false;
374  TSignedSeqPos feat_left = stop1+1;
375  TSignedSeqPos feat_right = length - 1;
376 
377  if (subtype2 != objects::CSeqFeatData::eSubtype_bad)
378  for (objects::CFeat_CI feat2(*bsi, objects::SAnnotSelector(subtype2)); feat2 && feat_right == length-1; ++feat2)
379  {
380  if (constraint_right && !constraint_right->Match(*feat2))
381  continue;
382  const CSeq_loc &loc2 = feat2->GetLocation();
383  TSignedSeqPos start2 = feat2->GetLocationTotalRange().GetFrom();
384  TSignedSeqPos stop2 = feat2->GetLocationTotalRange().GetTo();
385  if (start2 >= feat_left)
386  {
387  partial_right = false;
388  feat_right = start2-1;
389  }
390  }
391 
392  if ( feat_right >= feat_left && (feat_right < length - 1 || !m_NoFeatNoFeatRight->GetValue()))
393  {
394  if (m_ExtendCompleteRight->GetValue())
395  partial_right = false;
396  AddOneFeatureBetween(locs,feat_left,feat_right,partial_left,partial_right,loc1.GetStrand(),loc1.GetId());
397  }
398  found = true;
399  }
400  if (!found && m_NoFeatPartialLeft->GetValue())
401  {
402  TSignedSeqPos feat_left = 0;
403  TSignedSeqPos feat_right = length - 1;
404  if (subtype2 != objects::CSeqFeatData::eSubtype_bad)
405  for (objects::CFeat_CI feat2(*bsi, objects::SAnnotSelector(subtype2)); feat2 && feat_right == length-1; ++feat2)
406  {
407  if (constraint_right && !constraint_right->Match(*feat2))
408  continue;
409  const CSeq_loc &loc2 = feat2->GetLocation();
410  TSignedSeqPos start2 = feat2->GetLocationTotalRange().GetFrom();
411  TSignedSeqPos stop2 = feat2->GetLocationTotalRange().GetTo();
412  if (start2 > feat_left)
413  {
414  partial_right = false;
415  feat_right = start2 - 1;
416  found = true;
417  AddOneFeatureBetween(locs,feat_left,feat_right,partial_left,partial_right,loc2.GetStrand(),loc2.GetId());
418  }
419  }
420 
421  if (!found && !m_NoFeatNoFeatRight->GetValue())
422  {
423  if (m_ExtendCompleteRight->GetValue())
424  partial_right = false;
425 
426  if (feat_right >= feat_left)
427  AddOneFeatureBetween (locs, feat_left, feat_right, partial_left, partial_right, objects::eNa_strand_plus, bsi->GetSeqId().GetPointer());
428 
429  }
430  }
431  }
432  else if (subtype2 != objects::CSeqFeatData::eSubtype_bad)
433  {
434  TSignedSeqPos feat_left = 0;
435  if (m_ExtendCompleteLeft->GetValue())
436  partial_left = false;
437  for (objects::CFeat_CI feat2(*bsi, objects::SAnnotSelector(subtype2)); feat2 && !found; ++feat2)
438  {
439  if (constraint_right && !constraint_right->Match(*feat2))
440  continue;
441  partial_right = false;
442  const CSeq_loc &loc2 = feat2->GetLocation();
443  TSignedSeqPos start2 = feat2->GetLocationTotalRange().GetFrom();
444  TSignedSeqPos stop2 = feat2->GetLocationTotalRange().GetTo();
445  TSignedSeqPos feat_right = start2 - 1;
446  if (feat_right >= feat_left)
447  AddOneFeatureBetween(locs,feat_left,feat_right,partial_left,partial_right,loc2.GetStrand(),loc2.GetId());
448  found = true;
449  }
450 
451  if (!found && !m_NoFeatNoFeatRight->GetValue())
452  AddOneFeatureBetween (locs, feat_left, length-1, partial_left, partial_right, objects::eNa_strand_plus, bsi->GetSeqId().GetPointer());
453  }
454  else
455  {
456  TSignedSeqPos feat_left = 0;
457  TSignedSeqPos feat_right = length - 1;
458  if (m_ExtendCompleteLeft->GetValue())
459  partial_left = false;
460  if (m_ExtendCompleteRight->GetValue())
461  partial_right = false;
462  if (feat_right >= feat_left)
463  AddOneFeatureBetween (locs, feat_left, feat_right, partial_left, partial_right, objects::eNa_strand_plus, bsi->GetSeqId().GetPointer());
464  }
465  }
466 }
467 
468 void CAddFeatureBetweenDlg::AddOneFeatureBetween(vector<CRef<objects::CSeq_loc> > &locs, TSignedSeqPos feat_left, TSignedSeqPos feat_right, bool partial_left, bool partial_right, objects::ENa_strand strand, const CSeq_id* id)
469 {
470  if (feat_left < 0 || feat_right < 0)
471  return;
473  loc->SetInt().SetId().Assign(*id);
474  loc->SetInt().SetFrom(feat_left);
475  loc->SetInt().SetTo(feat_right);
476  loc->SetStrand(strand);
477  loc->SetPartialStart(partial_left,eExtreme_Positional); // loc1.IsPartialStop(eExtreme_Positional)
478  loc->SetPartialStop(partial_right,eExtreme_Positional); // loc2.IsPartialStart(eExtreme_Positional)
479  locs.push_back(loc);
480 }
481 
482 /*!
483  * Should we show tooltips?
484  */
485 
487 {
488  return true;
489 }
490 
491 /*!
492  * Get bitmap resources
493  */
494 
495 wxBitmap CAddFeatureBetweenDlg::GetBitmapResource( const wxString& name )
496 {
497  // Bitmap retrieval
498 ////@begin CAddFeatureBetweenDlg bitmap retrieval
499  wxUnusedVar(name);
500  return wxNullBitmap;
501 ////@end CAddFeatureBetweenDlg bitmap retrieval
502 }
503 
504 /*!
505  * Get icon resources
506  */
507 
508 wxIcon CAddFeatureBetweenDlg::GetIconResource( const wxString& name )
509 {
510  // Icon retrieval
511 ////@begin CAddFeatureBetweenDlg icon retrieval
512  wxUnusedVar(name);
513  return wxNullIcon;
514 ////@end CAddFeatureBetweenDlg icon retrieval
515 }
516 
518 {
519  CRef<CCmdComposite> cmd(new CCmdComposite("Add Feature Between"));
520  vector<CRef<objects::CSeq_loc> > locs;
521  GetFeatureLocations(locs);
522  for (unsigned int i=0; i<locs.size(); i++)
523  {
524  if (locs[i] && locs[i]->IsInt() && locs[i]->GetInt().IsSetId())
525  {
526  CBioseq_Handle bsh = m_TopSeqEntry.GetScope().GetBioseqHandle(locs[i]->GetInt().GetId());
527  if (m_Notebook)
528  {
529  int sel = m_Notebook->GetSelection();
530  if (sel != wxNOT_FOUND)
531  {
532  wxWindow *win = m_Notebook->GetPage(sel);
533  CBulkCmdPanel * panel = dynamic_cast<CBulkCmdPanel*>(win);
534  if (panel)
535  {
536  panel->SetLoc(locs[i]);
537  panel->AddOneCommand(bsh, cmd);
538  }
539  }
540  }
541  }
542  }
543  return cmd;
544 }
545 
546 
548 {
549  if (m_Notebook)
550  {
551  int sel = m_Notebook->GetSelection();
552  if (sel != wxNOT_FOUND)
553  {
554  wxWindow *win = m_Notebook->GetPage(sel);
555  CBulkCmdPanel * panel = dynamic_cast<CBulkCmdPanel*>(win);
556  if (panel)
557  {
558  return panel->GetErrorMessage();
559  }
560  }
561  }
562  return kEmptyStr;
563 }
564 
565 void CAddFeatureBetweenDlg::OnApplyButton(wxCommandEvent& event )
566 {
567 
568  m_TopSeqEntry.Reset();
569  if (!m_Workbench) return;
570 
573  if (sel_srv)
574  {
575  sel_srv->GetActiveObjects(objects);
576  }
577  if (objects.empty())
578  {
580  }
581 
584  if (seh) {
585  m_TopSeqEntry = seh;
586  }
587  }
588 
589  if (objects.size() == 2)
590  {
591  const CObject* ptr = objects.front().object.GetPointer();
592  if (ptr)
593  {
594  const objects::CSeq_loc* loc = dynamic_cast<const objects::CSeq_loc*>(ptr);
595  if (loc)
596  {
597  CBioseq_Handle bsh = objects.front().scope->GetBioseqHandle(*loc);
598  if (bsh)
599  {
601  if (seh)
602  m_TopSeqEntry = seh;
603  }
604  }
605  }
606  }
607 
608  if (!m_TopSeqEntry)
609  return;
610  ICommandProccessor* cmdProcessor = NULL;
611 
613  if (srv)
614  {
615  CRef<CGBWorkspace> ws = srv->GetGBWorkspace();
616  if (!ws) return;
617 
618  CGBDocument* doc = dynamic_cast<CGBDocument*>(ws->GetProjectFromScope(m_TopSeqEntry.GetScope()));
619  if (doc)
620  cmdProcessor = &doc->GetUndoManager();
621  }
622  if (!cmdProcessor)
623  return;
624 
626  if (cmd)
627  cmdProcessor->Execute(cmd);
628  if (!m_LeaveUp->GetValue())
629  {
630  Close();
631  }
632 }
633 
634 void CAddFeatureBetweenDlg::OnFeatLeftChanged(wxCommandEvent& event)
635 {
636  string str = m_FeatureTypeLeft->GetStringSelection().ToStdString();
638  return;
640  bool allow_other = true;
641  vector<string> choices = m_FeatLeftConstraint->GetChoices(allow_other);
642  m_StringConstraintPanelLeft->SetChoices(choices, vector<string>());
643 }
644 
645 void CAddFeatureBetweenDlg::OnFeatRightChanged(wxCommandEvent& event)
646 {
647  string str = m_FeatureTypeRight->GetStringSelection().ToStdString();
649  return;
651  bool allow_other = true;
652  vector<string> choices = m_FeatRightConstraint->GetChoices(allow_other);
653  m_StringConstraintPanelRight->SetChoices(choices, vector<string>());
654 }
655 
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
#define ID_APPLY_BUTTON
static bool ShowToolTips()
Should we show tooltips?
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void OnApplyButton(wxCommandEvent &event)
CFeatureFieldNamePanel * m_FeatRightConstraint
virtual CRef< CCmdComposite > GetCommand()
bool Create(wxWindow *parent, wxWindowID id=10029, const wxString &caption=_("Add Features"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
void OnFeatRightChanged(wxCommandEvent &event)
void OnFeatLeftChanged(wxCommandEvent &event)
vector< objects::CSeqFeatData::ESubtype > m_Subtype
void Init()
Initialises member variables.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void CreateControls()
Creates the controls and sizers.
CStringConstraintPanel * m_StringConstraintPanelRight
void GetFeatureLocations(vector< CRef< objects::CSeq_loc > > &locs)
void AddOneFeatureBetween(vector< CRef< objects::CSeq_loc > > &locs, TSignedSeqPos feat_left, TSignedSeqPos feat_right, bool partial_left, bool partial_right, objects::ENa_strand strand, const CSeq_id *id)
CStringConstraintPanel * m_StringConstraintPanelLeft
CFeatureFieldNamePanel * m_FeatLeftConstraint
objects::CSeq_entry_Handle m_TopSeqEntry
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
bool Create(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxFrameNameStr)
virtual void AddOneCommand(const objects::CBioseq_Handle &bsh, CRef< CCmdComposite > cmd)
void SetLoc(CRef< objects::CSeq_loc > loc)
virtual string GetErrorMessage()=0
virtual bool Match(const string &value)
CFeatListItem - basic configuration data for one "feature" type.
int GetSubtype() const
string GetDescription() const
int GetType() const
virtual bool SetFieldName(const string &field)
virtual vector< string > GetChoices(bool &allow_other)
virtual string GetFieldName(const bool subfield=false)
Returns the name of the field as selected in the panel.
void ListPresentFeaturesFirst(objects::CSeq_entry_Handle seh, vector< const objects::CFeatListItem * > *featlist=nullptr)
static bool s_IsRarelyUsedOrDiscouragedFeatureType(int subtype)
CGBDocument.
Definition: document.hpp:113
CUndoManager & GetUndoManager()
Definition: document.hpp:158
CObject –.
Definition: ncbiobj.hpp:180
CProjectService - a service providing API for operations with Workspaces and Projects.
static bool IsRegulatory(ESubtype subtype)
CSeq_entry_Handle –.
CRef< edit::CStringConstraint > GetStringConstraint()
void SetChoices(const vector< string > &choices, const vector< string > &values)
Undo/Redo interface for editing operations.
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
#define _(proto)
Definition: ct_nlmzip_i.h:78
#define wxFIXED_MINSIZE
CRef< CEditingActionConstraint > CreateEditingActionConstraint(const string &field, CFieldNamePanel::EFieldType field_type, int subtype, const string &ncRNA_class, const string &const_field, CFieldNamePanel::EFieldType const_field_type, int const_subtype, string &const_ncRNA_class, CRef< CConstraintMatcher >constraint)
int CorrectForncRNASubtypes(CSeqFeatData::ESubtype subtype, string &ncRNA_class)
int GetSubtype(CFieldNamePanel *field_name_panel, string &ncRNA_class)
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static char line1[1024 *16]
Definition: t0016.c:98
static char line2[1024 *16]
Definition: t0016.c:99
static void Init(void)
Definition: cursor6.c:76
static const char * str(char *buf, int n)
Definition: stats.c:84
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
int TSignedSeqPos
Type for signed sequence position.
Definition: ncbimisc.hpp:887
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
Definition: service.hpp:91
objects::CSeq_entry_Handle GetTopSeqEntryFromScopedObject(SConstScopedObject &obj)
Definition: utils.cpp:2542
vector< const objects::CFeatListItem * > GetSortedFeatList(objects::CSeq_entry_Handle seh, size_t max=numeric_limits< size_t >::max())
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
ENa_strand GetStrand(void) const
Get the location's strand.
Definition: Seq_loc.cpp:882
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
Definition: Seq_loc.hpp:941
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,...
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
@ eMol_na
just a nucleic acid
Definition: Seq_inst_.hpp:113
END_EVENT_TABLE()
int i
void GetViewObjects(IWorkbench *workbench, TConstScopedObjects &objects)
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
Modified on Tue Apr 23 07:39:39 2024 by modify_doxy.py rev. 669887