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

Go to the SVN repository for this file.

1 /* $Id: bulk_cds_edit.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 #include <ncbi_pch.hpp>
31 #include <objmgr/feat_ci.hpp>
32 #include <objmgr/util/sequence.hpp>
41 
45 
46 #include <wx/msgdlg.h>
47 
50 
51 
52 
53 IMPLEMENT_DYNAMIC_CLASS( CBulkCDS, wxDialog )
54 
55 BEGIN_EVENT_TABLE( CBulkCDS, wxDialog )
56 
57  EVT_BUTTON( wxID_OK, CBulkCDS::OnClickOk )
58 
59  EVT_BUTTON( wxID_CANCEL, CBulkCDS::OnClickCancel )
60 
61 
63 
65 {
66  Init();
67 }
68 
69 CBulkCDS::CBulkCDS( wxWindow* parent, objects::CSeq_entry_Handle seh, IWorkbench* workbench, CConstRef<objects::CSeq_submit> seqSubmit,
70  wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
71 {
72  this->m_Workbench = workbench;
73  this->m_SeqSubmit = seqSubmit;
74 
76  for ( ; fi ; ++fi )
77  {
78  m_FeatHandles.push_back(fi->GetSeq_feat_Handle());
79  }
80  Init();
81  Create(parent, id, caption, pos, size, style);
82 }
83 
84 CBulkCDS::CBulkCDS( wxWindow* parent, const vector<CSeq_feat_Handle> &feat_handles, IWorkbench* workbench,
85  wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
86  : m_FeatHandles(feat_handles)
87 {
88  this->m_Workbench = workbench;
89  Init();
90  Create(parent, id, caption, pos, size, style);
91 }
92 
93 
94 bool CBulkCDS::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
95 {
96  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
97  SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED);
98  wxDialog::Create( parent, id, caption, pos, size, style );
99 
100  CreateControls();
101  if (GetSizer())
102  {
103  GetSizer()->SetSizeHints(this);
104  }
105  Centre();
106  return true;
107 }
108 
109 
111 {
112 }
113 
114 
115 /*!
116  * Member initialisation
117  */
118 
120 {
121  m_Grid=NULL;
122 }
123 
124 
126 {
127  CBulkCDS* itemDialog1 = this;
128 
129  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
130  itemDialog1->SetSizer(itemBoxSizer2);
131 
132  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
133  itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
134 
135  wxArrayString itemChoiceStrings, itemChoiceStringsWritable;
136 
137  if (m_FeatHandles.empty())
138  {
139  wxMessageBox(wxT("No CDS records found"), wxT("Error"), wxOK | wxICON_ERROR);
140  NCBI_THROW( CException, eUnknown, "No CDS records found" );
141  }
142 
144  if (values_table->GetNum_rows() < 1)
145  {
146  wxMessageBox(wxT("No CDS records found"), wxT("Error"), wxOK | wxICON_ERROR);
147  NCBI_THROW( CException, eUnknown, "No CDS records found" );
148  }
149  CRef<CSeq_table> choices = GetChoices(values_table);
150  int glyph_col = GetCollapsible();
151  m_GridPanel = new CSeqTableGridPanel(this, values_table, choices, glyph_col);
152  itemBoxSizer3->Add(m_GridPanel, 0, wxALIGN_TOP|wxALL, 5);
154  CSeqTableGrid *gridAdapter = new CSeqTableGrid(values_table);
155  m_Grid->SetTable(gridAdapter, true);
156  m_Grid->AutoSizeColumns();
157  int l_height = m_Grid->GetColLabelSize();
158  m_Grid->SetColLabelSize( 2 * l_height );
159 
160  int pos = 0;
161  ITERATE (CSeq_table::TColumns, it, values_table->GetColumns())
162  {
163  if (pos > 0)
164  {
165  if ((*it)->IsSetHeader() && (*it)->GetHeader().IsSetTitle() )
166  {
167  string title = (*it)->GetHeader().GetTitle();
168  if (!title.empty())
169  {
170  itemChoiceStrings.Add(wxString(title));
171  if (!IsReadOnlyColumn(title))
172  itemChoiceStringsWritable.Add(wxString(title));
173  }
174  if (IsReadOnlyColumn(title))
175  m_GridPanel->MakeColumnReadOnly(pos - 1, true);
176  }
177  }
178  pos++;
179  }
180 
181  if (glyph_col >= 0 && glyph_col+1 < m_Grid->GetNumberCols())
182  {
183  m_GridPanel->InitColumnCollapse(glyph_col+1);
184  }
185 
186 
187  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
188  itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
189 
190  m_StringConstraintPanel = new CStringConstraintSelect( itemDialog1, m_GridPanel, itemChoiceStrings, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
191  itemBoxSizer4->Add(m_StringConstraintPanel, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxFIXED_MINSIZE, 0);
192 
193  wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
194  itemBoxSizer2->Add(itemBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
195 
196  m_AecrPanel = new CApplyEditconvertPanel( itemDialog1, m_GridPanel, itemChoiceStringsWritable, 0, true, wxID_ANY, wxDefaultPosition, wxSize(1128, 219));
197  itemBoxSizer5->Add(m_AecrPanel, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxFIXED_MINSIZE, 1);
198 
199  m_CopyProtNameToComment = new wxCheckBox( itemDialog1, wxID_ANY, _("Save old protein name in CDS comment"), wxDefaultPosition, wxDefaultSize, 0 );
200  itemBoxSizer2->Add(m_CopyProtNameToComment, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
201  m_CopyProtNameToComment->SetValue(false);
202 
203  wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL);
204  itemBoxSizer2->Add(itemBoxSizer13, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
205 
206  wxButton* itemButton14 = new wxButton( itemDialog1, wxID_OK, _("Accept"), wxDefaultPosition, wxDefaultSize, 0 );
207  itemBoxSizer13->Add(itemButton14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
208 
209  wxButton* itemButton15 = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
210  itemBoxSizer13->Add(itemButton15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
211 }
212 
214 {
215 
216  CRef<objects::CSeqTable_column> id_col(new objects::CSeqTable_column());
217  id_col->SetHeader().SetField_id(objects::CSeqTable_column_info::eField_id_location_id);
218  id_col->SetHeader().SetTitle(kSequenceIdColLabel);
219 
220  CRef<objects::CSeqTable_column> expand_col(new objects::CSeqTable_column());
221  expand_col->SetHeader().SetTitle("");
222  expand_col->SetHeader().SetField_name("expand");
223  expand_col->SetData().SetString();
224 
225  CRef<objects::CSeqTable_column> name_col(new objects::CSeqTable_column());
226  name_col->SetHeader().SetTitle("protein name");
227  name_col->SetHeader().SetField_name("protein_name");
228  name_col->SetData().SetString();
229 
230  CRef<objects::CSeqTable_column> desc_col(new objects::CSeqTable_column());
231  desc_col->SetHeader().SetTitle("protein description");
232  desc_col->SetHeader().SetField_name("protein_description");
233  desc_col->SetData().SetString();
234 
235  CRef<objects::CSeqTable_column> loc_col(new objects::CSeqTable_column());
236  loc_col->SetHeader().SetTitle("location");
237  loc_col->SetHeader().SetField_name("location");
238  loc_col->SetData().SetString();
239 
240  CRef<objects::CSeqTable_column> comment_col(new objects::CSeqTable_column());
241  comment_col->SetHeader().SetTitle("comment");
242  comment_col->SetHeader().SetField_name("comment");
243  comment_col->SetData().SetString();
244 
245  CRef<objects::CSeqTable_column> ec_number_col(new objects::CSeqTable_column());
246  ec_number_col->SetHeader().SetTitle("ec number");
247  ec_number_col->SetHeader().SetField_name("ec_number");
248  ec_number_col->SetData().SetString();
249 
250  CRef<objects::CSeqTable_column> activity_col(new objects::CSeqTable_column());
251  activity_col->SetHeader().SetTitle("activity");
252  activity_col->SetHeader().SetField_name("activity");
253  activity_col->SetData().SetString();
254 
255  // bogus column to include last, otherwise deletion of the previous column will not work
256  CRef<objects::CSeqTable_column> bogus_col(new objects::CSeqTable_column());
257  bogus_col->SetHeader().SetTitle("");
258  bogus_col->SetHeader().SetField_name("");
259  bogus_col->SetData().SetString();
260 
261  CRef<objects::CSeq_table> table(new objects::CSeq_table());
262  table->SetColumns().push_back(id_col);
263  table->SetColumns().push_back(expand_col);
264  table->SetColumns().push_back(name_col);
265  table->SetColumns().push_back(desc_col);
266  table->SetColumns().push_back(loc_col);
267 
270  partial_start_col->SetHeader().SetField_name(kPartialStart);
271 
274  partial_stop_col->SetHeader().SetField_name(kPartialStop);
275 
276  table->SetColumns().push_back(comment_col);
277  table->SetColumns().push_back(ec_number_col);
278  table->SetColumns().push_back(activity_col);
279  table->SetColumns().push_back(bogus_col);
280 
281  size_t row = 0;
282 
283  CSeq_entry_Handle seh;
285  IEditingActionFeat* ec_feat_action = dynamic_cast<IEditingActionFeat*>(ec_action.GetPointer());
287  IEditingActionFeat* act_feat_action = dynamic_cast<IEditingActionFeat*>(act_action.GetPointer());
288 
289  for ( vector<CSeq_feat_Handle>::iterator fi = m_FeatHandles.begin(); fi != m_FeatHandles.end() ; ++fi )
290  {
291  // Use Cdregion.Product to get handle to protein bioseq
292  if (!fi->IsSetProduct()) continue;
293  CBioseq_Handle prot_bsh = fi->GetScope().GetBioseqHandle(fi->GetProduct());
294  // Should be a protein!
295  if (!prot_bsh || !prot_bsh.IsProtein()) continue;
296 
297  CRef<objects::CSeq_id> id(new objects::CSeq_id());
298  id->SetLocal().SetId(static_cast<CObject_id::TId>(row));
299  //id->Assign (*(prot_bsh.GetSeqId()));
300  string name,desc,loc,comment;
301 
303  CFeat_CI prot_feat_ci(prot_bsh, sel);
304  if (prot_feat_ci)
305  {
306  const CSeq_feat &feat = prot_feat_ci->GetOriginalFeature();
307  const CProt_ref &prot = feat.GetData().GetProt();
308  if (prot.IsSetName())
309  name = prot.GetName().front();
310  if (prot.IsSetDesc())
311  desc = prot.GetDesc();
312  // if ( feat.IsSetLocation() )
313  // feat.GetLocation().GetLabel(&loc);
314 
315  }
316 
317  if ( fi->GetOriginalSeq_feat()->IsSetLocation() )
318  fi->GetOriginalSeq_feat()->GetLocation().GetLabel(&loc);
319 
320  if (fi->GetOriginalSeq_feat()->IsSetComment())
321  comment = fi->GetOriginalSeq_feat()->GetComment();
322 
323  seh = fi->GetScope().GetBioseqHandle(fi->GetLocation()).GetSeq_entry_Handle();
324  ec_feat_action->SetTopSeqEntry(seh);
325  ec_feat_action->SetFeat(*fi);
326  const vector<string>& ec_values = ec_feat_action->GetValues();
327  string ec_number = NStr::Join(ec_values, "|");
328 
329  act_feat_action->SetTopSeqEntry(seh);
330  act_feat_action->SetFeat(*fi);
331  const vector<string>& act_values = act_feat_action->GetValues();
332  string activity = NStr::Join(act_values, "|");
333 
334  id_col->SetData().SetId().push_back(id);
335  expand_col->SetData().SetString().push_back("");
336  name_col->SetData().SetString().push_back(name);
337  desc_col->SetData().SetString().push_back(desc);
338  loc_col->SetData().SetString().push_back(loc);
339  AddValueToColumn(partial_start_col, partial_start_feat_col->GetFromFeat(*fi->GetOriginalSeq_feat()), row);
340  AddValueToColumn(partial_stop_col, partial_stop_feat_col->GetFromFeat(*fi->GetOriginalSeq_feat()), row);
341  comment_col->SetData().SetString().push_back(comment);
342  ec_number_col->SetData().SetString().push_back(ec_number);
343  activity_col->SetData().SetString().push_back(activity);
344  bogus_col->SetData().SetString().push_back("");
345  row++;
346  }
347 
348 
349  table->SetNum_rows(static_cast<CSeq_table::TNum_rows>(row));
350 
351  return table;
352 }
353 
354 
356 {
357  CRef<CCmdComposite> cmd(new CCmdComposite("Bulk CDS Edit"));
358 
359  CSeq_entry_Handle seh;
361  IEditingActionFeat* ec_feat_action = dynamic_cast<IEditingActionFeat*>(ec_action.GetPointer());
363  IEditingActionFeat* act_feat_action = dynamic_cast<IEditingActionFeat*>(act_action.GetPointer());
364 
367  m_Modified = false;
368  size_t row = 0;
370  bool not_asked = true;
371  for ( vector<CSeq_feat_Handle>::iterator fi = m_FeatHandles.begin(); fi != m_FeatHandles.end() ; ++fi )
372  {
373  if (!fi->IsSetProduct()) continue;
374  CBioseq_Handle prot_bsh = fi->GetScope().GetBioseqHandle(fi->GetProduct());
375  // Should be a protein!
376  if (!prot_bsh || !prot_bsh.IsProtein()) continue;
377 
378  CRef<CSeq_feat> new_cds(new CSeq_feat());
379  new_cds->Assign(*fi->GetOriginalSeq_feat());
380 
381  string name,desc,loc;
382  string save_old_name;
383 
385  CFeat_CI prot_feat_ci(prot_bsh, sel);
386  if (prot_feat_ci)
387  {
388  const CSeq_feat &feat = prot_feat_ci->GetOriginalFeature();
389  const CProt_ref &prot = feat.GetData().GetProt();
390  CRef<CSeq_feat> new_feat(new CSeq_feat());
391  new_feat->Assign(feat);
392  bool modified = false;
393 
394  if (prot.IsSetName())
395  name = prot.GetName().front();
396  if (prot.IsSetDesc())
397  desc = prot.GetDesc();
398  //if ( feat.IsSetLocation() )
399  // feat.GetLocation().GetLabel(&loc);
400 
401  string new_name;
402  try
403  {
404  if (row < values_table->GetColumn("protein_name").GetData().GetString().size())
405  new_name = values_table->GetColumn("protein_name").GetData().GetString()[row];
406  } catch(CSeqTableException& ) {}
407 
408  if (new_name != name)
409  {
410  if (new_name.empty())
411  new_feat->SetData().SetProt().ResetName();
412  else
413  {
414  if (new_feat->SetData().SetProt().SetName().empty())
415  new_feat->SetData().SetProt().SetName().push_back(new_name);
416  else
417  new_feat->SetData().SetProt().SetName().front() = new_name;
418  }
419  GetUpdateMRNAProductNameCmd(new_cds, fi->GetScope(), new_name, cmd);
420  modified = true;
421 
422  if (m_CopyProtNameToComment->GetValue())
423  save_old_name = name;
424  }
425 
426 
427  string new_desc;
428  try
429  {
430  if (row < values_table->GetColumn("protein_description").GetData().GetString().size())
431  new_desc = values_table->GetColumn("protein_description").GetData().GetString()[row];
432  } catch(CSeqTableException&) {}
433 
434  if (new_desc != desc)
435  {
436  if (new_desc.empty())
437  new_feat->SetData().SetProt().ResetDesc();
438  else
439  new_feat->SetData().SetProt().SetDesc() = new_desc;
440  modified = true;
441  }
442 
443  seh = fi->GetScope().GetBioseqHandle(fi->GetLocation()).GetSeq_entry_Handle();
444  ec_feat_action->SetTopSeqEntry(seh);
445  ec_feat_action->SetFeat(*fi);
446  const vector<string>& ec_values = ec_feat_action->GetValues();
447  string old_ec_number = NStr::Join(ec_values, "|");
448  string new_ec_number;
449  try
450  {
451  if (row < values_table->GetColumn("ec_number").GetData().GetString().size())
452  new_ec_number = values_table->GetColumn("ec_number").GetData().GetString()[row];
453  } catch(CSeqTableException&) {}
454  if (new_ec_number != old_ec_number)
455  {
456  if (new_cds->GetProtXref() != NULL)
457  {
458  new_cds->SetProtXref().ResetEc();
459  }
460  new_cds->RemoveQualifier("EC_number");
461  new_feat->RemoveQualifier("EC_number");
462  new_feat->SetData().SetProt().ResetEc();
463  vector<string> new_values;
464  NStr::Split(new_ec_number, "|", new_values);
465  for (const auto& val : new_values)
466  {
467  if (!val.empty())
468  {
469  new_feat->SetData().SetProt().SetEc().push_back(val);
470  }
471  }
472  modified = true;
473  }
474 
475  act_feat_action->SetTopSeqEntry(seh);
476  act_feat_action->SetFeat(*fi);
477  const vector<string>& act_values = act_feat_action->GetValues();
478  string old_activity = NStr::Join(act_values, "|");
479  string new_activity;
480  try
481  {
482  if (row < values_table->GetColumn("activity").GetData().GetString().size())
483  new_activity = values_table->GetColumn("activity").GetData().GetString()[row];
484  } catch(CSeqTableException&) {}
485  if (new_activity != old_activity)
486  {
487  new_cds->RemoveQualifier("activity");
488  new_feat->SetData().SetProt().ResetActivity();
489  vector<string> new_values;
490  NStr::Split(new_activity, "|", new_values);
491  for (const auto& val : new_values)
492  {
493  if (!val.empty())
494  {
495  new_feat->SetData().SetProt().SetActivity().push_back(val);
496  }
497  }
498  modified = true;
499  }
500 
501 
502  if (modified)
503  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(*prot_feat_ci,*new_feat)));
504  m_Modified |= modified;
505  }
506 
507  if ( fi->GetOriginalSeq_feat()->IsSetLocation() )
508  fi->GetOriginalSeq_feat()->GetLocation().GetLabel(&loc);
509 
510  bool changed_feat = false;
511 
512  string comment;
513  if (new_cds->IsSetComment())
514  comment = new_cds->GetComment();
515 
516  string new_comment;
517  try
518  {
519  if (row < values_table->GetColumn("comment").GetData().GetString().size())
520  new_comment = values_table->GetColumn("comment").GetData().GetString()[row];
521  } catch(CSeqTableException&) {}
522 
523  if (!save_old_name.empty())
524  {
525  if (new_comment.empty())
526  new_comment = save_old_name;
527  else
528  {
529  if (not_asked)
530  {
531  string msg = "Do you want to overwrite existing comment values?";
532  int answer = wxMessageBox(ToWxString(msg), wxT("Existing Text"), wxYES_NO | wxCANCEL | wxICON_QUESTION, this);
533  if (answer == wxCANCEL)
534  {
535  existing_text = objects::edit::eExistingText_cancel;
536  }
537  else if (answer == wxYES)
538  {
540  }
541  else
542  {
543  CExistingTextDlg dlg(this);
544  dlg.AllowAdditionalQual(false);
545  if (dlg.ShowModal() == wxID_OK) {
546  existing_text = dlg.GetExistingTextHandler();
547  } else {
548  existing_text = objects::edit::eExistingText_cancel;
549  }
550  }
551  not_asked = false;
552  }
553  AddValueToString(new_comment, save_old_name, existing_text);
554  //new_comment += "; " + save_old_name;
555  }
556  }
557 
558  if (new_comment != comment)
559  {
560  if (new_comment.empty())
561  new_cds->ResetComment();
562  else
563  new_cds->SetComment() = new_comment;
564  changed_feat = true;
565  }
566 
567 
568  string partial_start_val = partial_start_feat_col->GetFromFeat(*fi->GetOriginalSeq_feat());
569  string new_partial_start_val;
570  try
571  {
572  if (row < values_table->GetColumn(kPartialStart).GetData().GetString().size())
573  new_partial_start_val = values_table->GetColumn(kPartialStart).GetData().GetString()[row];
574  } catch(CSeqTableException&) {}
575 
576  if (new_partial_start_val != partial_start_val)
577  {
578  if (new_partial_start_val.empty())
579  partial_start_feat_col->ClearInFeature(*new_cds);
580  else
581  partial_start_feat_col->AddToFeature(*new_cds, new_partial_start_val, edit::eExistingText_replace_old);
582  changed_feat = true;
583  }
584 
585  string partial_stop_val = partial_stop_feat_col->GetFromFeat(*fi->GetOriginalSeq_feat());
586  string new_partial_stop_val;
587  try
588  {
589  if (row < values_table->GetColumn(kPartialStop).GetData().GetString().size())
590  new_partial_stop_val = values_table->GetColumn(kPartialStop).GetData().GetString()[row];
591  } catch(CSeqTableException&) {}
592 
593  if (new_partial_stop_val != partial_stop_val)
594  {
595  if (new_partial_stop_val.empty())
596  partial_stop_feat_col->ClearInFeature(*new_cds);
597  else
598  partial_stop_feat_col->AddToFeature(*new_cds, new_partial_stop_val, edit::eExistingText_replace_old);
599  changed_feat = true;
600  }
601 
602  if (changed_feat)
603  {
604  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(*fi,*new_cds)));
605  }
606  m_Modified |= changed_feat;
607 
608  row++;
609  }
610 
611  return cmd;
612 }
613 
614 void CBulkCDS::GetUpdateMRNAProductNameCmd(CRef<CSeq_feat> cds, CScope& scope, const string& prot_name, CRef<CCmdComposite> composite)
615 {
617  CConstRef<CSeq_feat> orig_mrna;
618 
619  if (cds)
620  {
621  orig_mrna.Reset(sequence::GetmRNAforCDS(*cds, scope));
622  }
623 
624  if (orig_mrna)
625  {
626  CRef<CSeq_feat> new_mrna(new CSeq_feat());
627  new_mrna->Assign(*orig_mrna);
628  string remainder;
629  new_mrna->SetData().SetRna().SetRnaProductName(prot_name, remainder);
630  CSeq_feat_Handle mrna_fh = scope.GetSeq_featHandle(*orig_mrna);
631  cmd.Reset(new CCmdChangeSeq_feat(mrna_fh, *new_mrna));
632  }
633 
634  if (cmd)
635  composite->AddCommand(*cmd);
636 }
637 
639 {
640  CRef<CSeq_table> values_table = m_GridPanel->GetValuesTable();
642  return cmd;
643 }
644 
646 {
647  return "Invalid operation in Bulk CDS Edit";
648 }
649 
650 
651 /*!
652  * Should we show tooltips?
653  */
654 
656 {
657  return true;
658 }
659 
660 /*!
661  * Get bitmap resources
662  */
663 
664 wxBitmap CBulkCDS::GetBitmapResource( const wxString& name )
665 {
666  // Bitmap retrieval
667 ////@begin CBulkCDS bitmap retrieval
668  wxUnusedVar(name);
669  return wxNullBitmap;
670 ////@end CBulkCDS bitmap retrieval
671 }
672 
673 /*!
674  * Get icon resources
675  */
676 
677 wxIcon CBulkCDS::GetIconResource( const wxString& name )
678 {
679  // Icon retrieval
680 ////@begin CBulkCDS icon retrieval
681  wxUnusedVar(name);
682  return wxNullIcon;
683 ////@end CBulkCDS icon retrieval
684 }
685 
686 /*!
687  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON
688  */
689 
690 void CBulkCDS::OnClickOk( wxCommandEvent& event )
691 {
692 ////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON in CBulkCDS.
693  // Before editing this code, remove the block markers.
694  event.Skip();
695 ////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON in CBulkCDS.
696 }
697 
698 /*!
699  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1
700  */
701 
702 void CBulkCDS::OnClickCancel( wxCommandEvent& event )
703 {
704  bool modified = m_GridPanel->GetModified() | m_AecrPanel->GetModified();
705  if (modified)
706  {
707  wxMessageDialog dlg(this,_("Discard modifications?"), _("Attention"),wxOK|wxCANCEL|wxCENTRE);
708  if (dlg.ShowModal() == wxID_OK)
709  {
710  event.Skip();
711  }
712  }
713  else
714  event.Skip();
715 
716 }
717 
719 {
720  objects.clear();
721  const CObject* obj = NULL;
722 
723  if (row < m_FeatHandles.size() )
724  {
725  if ( m_FeatHandles[row].GetOriginalSeq_feat()->IsSetLocation() )
726  {
727  bsh = m_FeatHandles[row].GetScope().GetBioseqHandle(m_FeatHandles[row].GetOriginalSeq_feat()->GetLocation()); // CBioseq_Handle GetBioseqHandle(const CSeq_loc& loc);
728  if (bsh)
729  {
730  if (m_SeqSubmit)
731  objects.push_back(SConstScopedObject(m_SeqSubmit,&bsh.GetScope()));
732  else
734  obj = bsh.GetBioseqCore().GetPointer();
735  }
736  }
737  }
738  return obj;
739 }
740 
USING_SCOPE(ncbi::objects)
CBioseq_Handle –.
CBulkCDS()
Constructors.
vector< CSeq_feat_Handle > m_FeatHandles
static bool ShowToolTips()
Should we show tooltips?
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=_("CDS Editing"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
void CreateControls()
Creates the controls and sizers.
CRef< CCmdComposite > GetCommandFromValuesTable(CRef< objects::CSeq_table >)
void OnClickCancel(wxCommandEvent &event)
CSeqTableGridPanel * m_GridPanel
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void GetUpdateMRNAProductNameCmd(CRef< CSeq_feat > cds, CScope &scope, const string &prot_name, CRef< CCmdComposite > composite)
wxGrid * m_Grid
~CBulkCDS()
Destructor.
void Init()
Initialises member variables.
wxCheckBox * m_CopyProtNameToComment
string GetErrorMessage()
virtual const CObject * RowToScopedObjects(int row, TConstScopedObjects &objects, CBioseq_Handle &bsh)
CRef< objects::CSeq_table > GetChoices(CRef< objects::CSeq_table > values_table)
CRef< CCmdComposite > GetCommand()
int GetCollapsible()
CApplyEditconvertPanel * m_AecrPanel
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
CRef< objects::CSeq_table > GetValuesTableFromSeqEntry()
CStringConstraintSelect * m_StringConstraintPanel
void OnClickOk(wxCommandEvent &event)
bool IsReadOnlyColumn(string column_name)
void AddCommand(IEditCommand &command)
objects::edit::EExistingText GetExistingTextHandler()
void AllowAdditionalQual(bool val)
CFeat_CI –.
Definition: feat_ci.hpp:64
static CRef< CFeatureSeqTableColumnBase > Create(const string &sTitle, objects::CSeqFeatData::ESubtype subtype=objects::CSeqFeatData::eSubtype_any)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
CObject –.
Definition: ncbiobj.hpp:180
CScope –.
Definition: scope.hpp:92
CConstRef< objects::CSeq_submit > m_SeqSubmit
Seq-loc and seq-align mapper exceptions.
void MakeColumnReadOnly(int pos, bool val=true)
wxGrid * GetGrid(void)
void InitColumnCollapse(int col)
CRef< objects::CSeq_table > GetValuesTable()
CSeq_entry_Handle –.
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
const CProt_ref * GetProtXref(void) const
get protein (if present) from Seq-feat.xref list
Definition: Seq_feat.cpp:222
void RemoveQualifier(const string &qual_name)
Remove all qualifiers with the given name; do nothing if no such qualifier exists.
Definition: Seq_feat.cpp:315
void SetProtXref(CProt_ref &value)
Definition: Seq_feat.cpp:233
const CSeqTable_column & GetColumn(CTempString column_name) const
Definition: Seq_table.cpp:65
virtual void SetFeat(CSeq_feat_Handle fh)
void SetTopSeqEntry(CSeq_entry_Handle seh)
const vector< string > & GetValues(void)
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
#define _(proto)
Definition: ct_nlmzip_i.h:78
#define wxFIXED_MINSIZE
CIRef< IEditingAction > CreateAction(CSeq_entry_Handle seh, const string &field, CFieldNamePanel::EFieldType field_type, int subtype, const string &ncRNA_class=kEmptyStr, CConstRef< objects::CSeq_submit > submit=CConstRef< objects::CSeq_submit >(NULL))
const string kPartialStart
const string kPartialStop
const char * kSequenceIdColLabel
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static void Init(void)
Definition: cursor6.c:76
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#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
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
CConstRef< CSeq_feat > GetmRNAforCDS(const CSeq_feat &cds, CScope &scope)
GetmRNAforCDS A function to find a CSeq_feat representing the appropriate mRNA for a given CDS.
Definition: sequence.cpp:1261
CSeq_feat_Handle GetSeq_featHandle(const CSeq_feat &feat, EMissing action=eMissing_Default)
Definition: scope.cpp:200
TBioseqCore GetBioseqCore(void) const
Get bioseq core structure.
bool IsProtein(void) const
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
CScope & GetScope(void) const
Get scope this handle belongs to.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:1684
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
#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 list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3461
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2697
void SetHeader(THeader &value)
Assign a value to Header data member.
vector< CRef< CSeqTable_column > > TColumns
Definition: Seq_table_.hpp:92
const TString & GetString(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
bool IsSetComment(void) const
Check if a value has been assigned to Comment data member.
Definition: Seq_feat_.hpp:1037
void SetComment(const TComment &value)
Assign a value to Comment data member.
Definition: Seq_feat_.hpp:1058
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
void ResetComment(void)
Reset Comment data member.
Definition: Seq_feat_.cpp:99
const TComment & GetComment(void) const
Get the Comment member data.
Definition: Seq_feat_.hpp:1049
const TProt & GetProt(void) const
Get the variant data.
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
END_EVENT_TABLE()
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
#define fi
static static static wxID_ANY
CRef< CSeqTable_column > AddStringColumnToTable(CRef< CSeq_table > table, string label)
void AddValueToColumn(CRef< CSeqTable_column > column, string value, size_t row, edit::EExistingText existing_text=edit::eExistingText_replace_old)
#define row(bind, expected)
Definition: string_bind.c:73
EExistingText
@ eExistingText_cancel
@ eExistingText_replace_old
bool AddValueToString(string &str, const string &value, EExistingText existing_text)
Add text to an existing string, using the "existing_text" directive to combine new text with existing...
SAnnotSelector –.
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
Modified on Mon Apr 22 04:07:25 2024 by modify_doxy.py rev. 669887