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

Go to the SVN repository for this file.

1 /* $Id: cds_from_gene_mrna_exon.cpp 42183 2019-01-09 17:19:23Z filippov $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Igor Filippov
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 ////@begin includes
33 ////@end includes
34 
35 #include <wx/stattext.h>
36 #include <wx/msgdlg.h>
37 #include <wx/statbox.h>
38 
42 #include <objmgr/seq_vector.hpp>
43 #include <objmgr/util/sequence.hpp>
51 
52 ////@begin XPM images
53 ////@end XPM images
54 
56 
58 
59 /*!
60  * CCdsFromGeneMrnaExon type definition
61  */
62 
63 IMPLEMENT_DYNAMIC_CLASS( CCdsFromGeneMrnaExon, CBulkCmdDlg )
64 
65 
66 /*!
67  * CCdsFromGeneMrnaExon event table definition
68  */
69 
70 BEGIN_EVENT_TABLE( CCdsFromGeneMrnaExon, CBulkCmdDlg )
71 
72 ////@begin CCdsFromGeneMrnaExon event table entries
73 
74 ////@end CCdsFromGeneMrnaExon event table entries
77 
78 
79 /*!
80  * CCdsFromGeneMrnaExon constructors
81  */
82 
84 {
85  Init();
86 }
87 
88 CCdsFromGeneMrnaExon::CCdsFromGeneMrnaExon( wxWindow* parent, IWorkbench* wb, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
89  : CBulkCmdDlg(wb)
90 {
91  Init();
92  Create(parent, id, caption, pos, size, style);
93 }
94 
95 
96 /*!
97  * CCdsFromGeneMrnaExon creator
98  */
99 
100 bool CCdsFromGeneMrnaExon::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
101 {
102 ////@begin CCdsFromGeneMrnaExon creation
103  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
104  CBulkCmdDlg::Create( parent, id, caption, pos, size, style );
105 
106  CreateControls();
107  if (GetSizer())
108  {
109  GetSizer()->SetSizeHints(this);
110  }
111  Centre();
112 ////@end CCdsFromGeneMrnaExon creation
113  return true;
114 }
115 
116 
117 /*!
118  * CCdsFromGeneMrnaExon destructor
119  */
120 
122 {
123 ////@begin CCdsFromGeneMrnaExon destruction
124 ////@end CCdsFromGeneMrnaExon destruction
125 }
126 
127 
128 /*!
129  * Member initialisation
130  */
131 
133 {
134 ////@begin CCdsFromGeneMrnaExon member initialisation
136  m_OkCancel = NULL;
137 ////@end CCdsFromGeneMrnaExon member initialisation
138  m_ErrorMessage = "";
141 }
142 
143 
144 /*!
145  * Control creation for CCdsFromGeneMrnaExon
146  */
147 
149 {
150 ////@begin CCdsFromGeneMrnaExon content construction
151  CCdsFromGeneMrnaExon* itemCBulkCmdDlg1 = this;
152 
153  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
154  itemCBulkCmdDlg1->SetSizer(itemBoxSizer2);
155 
156 
158 
159  wxArrayString feat_strings;
160  feat_strings.Add(_("Gene"));
161  feat_strings.Add(_("mRNA"));
162  feat_strings.Add(_("exon"));
163  m_FeatureType = new wxChoice( itemCBulkCmdDlg1, wxID_ANY, wxDefaultPosition, wxDefaultSize, feat_strings, 0 );
164  m_FeatureType->SetSelection(0);
165  itemBoxSizer2->Add(m_FeatureType, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
166  m_FeatureType->Bind(wxEVT_CHOICE, &CCdsFromGeneMrnaExon::OnSelectFeature, this);
167 
168  wxStaticBox* itemStaticBoxSizer7Static = new wxStaticBox(itemCBulkCmdDlg1, wxID_ANY, _("Source for new CDS protein name"));
169  wxStaticBoxSizer* itemBoxSizer7 = new wxStaticBoxSizer(itemStaticBoxSizer7Static, wxVERTICAL);
170  itemBoxSizer2->Add(itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
171 
172  wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
173  itemBoxSizer7->Add(itemBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
174 
175  wxStaticText* stattext2 = new wxStaticText( this, wxID_STATIC, _("1st Choice"), wxDefaultPosition, wxDefaultSize, 0 );
176  itemBoxSizer8->Add(stattext2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
177  wxArrayString choice_strings;
178  choice_strings.Add(_("None"));
179  choice_strings.Add(_("locus"));
180  choice_strings.Add(_("description"));
181  choice_strings.Add(_("comment"));
182  choice_strings.Add(_("allele"));
183  choice_strings.Add(_("maploc"));
184  choice_strings.Add(_("locus_tag"));
185  choice_strings.Add(_("synonym"));
186  choice_strings.Add(_("old_locus_tag"));
187 
188 
189  m_FeatQual = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choice_strings, 0 );
190  m_FeatQual->SetSelection(0);
191  itemBoxSizer8->Add(m_FeatQual, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
192  m_FeatQual->Bind(wxEVT_CHOICE, &CCdsFromGeneMrnaExon::OnSelectFeatQual, this);
193  m_Remove = new wxCheckBox( itemCBulkCmdDlg1, wxID_ANY, _("Remove if used"), wxDefaultPosition, wxDefaultSize, 0 );
194  m_Remove->SetValue(false);
195  itemBoxSizer8->Add(m_Remove, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
196 
197 
198  wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxHORIZONTAL);
199  itemBoxSizer7->Add(itemBoxSizer9, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
200  m_2ndChoice = new wxStaticText( this, wxID_STATIC, _("2nd Choice"), wxDefaultPosition, wxDefaultSize, 0 );
201  itemBoxSizer9->Add(m_2ndChoice, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
202  m_FeatQual2 = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choice_strings, 0 );
203  m_FeatQual2->SetSelection(0);
204  itemBoxSizer9->Add(m_FeatQual2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
205  m_FeatQual2->Bind(wxEVT_CHOICE, &CCdsFromGeneMrnaExon::OnSelectFeatQual, this);
206  m_FeatQual2->Disable();
207  m_Remove2 = new wxCheckBox( itemCBulkCmdDlg1, wxID_ANY, _("Remove if used"), wxDefaultPosition, wxDefaultSize, 0 );
208  m_Remove2->SetValue(false);
209  itemBoxSizer9->Add(m_Remove2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
210  m_Remove2->Disable();
211 
212  wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
213  itemBoxSizer7->Add(itemBoxSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
214  m_3rdChoice = new wxStaticText( this, wxID_STATIC, _("3rd Choice"), wxDefaultPosition, wxDefaultSize, 0 );
215  itemBoxSizer10->Add(m_3rdChoice, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
216  m_FeatQual3 = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choice_strings, 0 );
217  m_FeatQual3->SetSelection(0);
218  itemBoxSizer10->Add(m_FeatQual3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
219  m_FeatQual3->Disable();
220  m_Remove3 = new wxCheckBox( itemCBulkCmdDlg1, wxID_ANY, _("Remove if used"), wxDefaultPosition, wxDefaultSize, 0 );
221  m_Remove3->SetValue(false);
222  itemBoxSizer10->Add(m_Remove3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
223  m_Remove3->Disable();
224 
225  m_CapChangeOptions = new CCapChangePanel( itemCBulkCmdDlg1, wxID_ANY, wxDefaultPosition, wxSize(100, 100), wxSIMPLE_BORDER );
226  itemBoxSizer2->Add(m_CapChangeOptions, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
227 
228  wxStaticText* stattext4 = new wxStaticText( this, wxID_STATIC, _("Append text to name"), wxDefaultPosition, wxDefaultSize, 0 );
229  itemBoxSizer2->Add(stattext4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
230  m_StrQual = new wxTextCtrl( itemCBulkCmdDlg1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(100, -1), 0 );
231  itemBoxSizer2->Add(m_StrQual, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5);
232 
233 
234  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
235  itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
236 
237  m_SingleInterval = new wxCheckBox( itemCBulkCmdDlg1, wxID_ANY, _("Fuse multiple intervals for new CDS"), wxDefaultPosition, wxDefaultSize, 0 );
238  m_SingleInterval->SetValue(false);
239  itemBoxSizer4->Add(m_SingleInterval, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
240 
241 
242  m_FeatureConstraint = new CFeatureFieldNamePanel(itemCBulkCmdDlg1, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
243  itemBoxSizer2->Add(m_FeatureConstraint, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
245 
246  m_StringConstraintPanel = new CStringConstraintPanel( itemCBulkCmdDlg1, false, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
247  itemBoxSizer2->Add(m_StringConstraintPanel, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxFIXED_MINSIZE, 0);
248 
249  m_OkCancel = new COkCancelPanel( itemCBulkCmdDlg1, wxID_ANY, wxDefaultPosition, wxSize(100, 100), 0 );
250  itemBoxSizer2->Add(m_OkCancel, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
251 
252  m_CapChangeOptions->Disable();
253 ////@end CCdsFromGeneMrnaExon content construction
254 }
255 
256 
257 /*!
258  * Should we show tooltips?
259  */
260 
262 {
263  return true;
264 }
265 
266 /*!
267  * Get bitmap resources
268  */
269 
270 wxBitmap CCdsFromGeneMrnaExon::GetBitmapResource( const wxString& name )
271 {
272  // Bitmap retrieval
273 ////@begin CCdsFromGeneMrnaExon bitmap retrieval
274  wxUnusedVar(name);
275  return wxNullBitmap;
276 ////@end CCdsFromGeneMrnaExon bitmap retrieval
277 }
278 
279 /*!
280  * Get icon resources
281  */
282 
283 wxIcon CCdsFromGeneMrnaExon::GetIconResource( const wxString& name )
284 {
285  // Icon retrieval
286 ////@begin CCdsFromGeneMrnaExon icon retrieval
287  wxUnusedVar(name);
288  return wxNullIcon;
289 ////@end CCdsFromGeneMrnaExon icon retrieval
290 }
291 
292 
293 
295 {
296  return m_ErrorMessage;
297 }
298 
299 
301 {
303 
304  string feat_type;
305  int sel_feat = m_FeatureType->GetSelection();
306  if (sel_feat != wxNOT_FOUND)
307  {
308  feat_type = m_FeatureType->GetString(sel_feat).ToStdString();
309  }
310 
311  string field_name;
312  if (NStr::IsBlank(feat_type)) {
313  field_name = kPartialStart;
314  } else {
315  field_name = feat_type + " " + kPartialStart;
316  }
317 
318  CRef<CMiscSeqTableColumn> col(new CMiscSeqTableColumn(field_name));
319 
321  string constraint_field = m_FeatureConstraint->GetFieldName(false);
322 
323 
324  vector<CConstRef<CObject> > objs;
325  objs = col->GetObjects(m_TopSeqEntry, constraint_field, string_constraint);
326 
327  if (objs.size() == 0) {
328  wxMessageBox(wxT("No features found!"), wxT("Error"),
329  wxOK | wxICON_ERROR, NULL);
330  return cmd;
331  }
332 
333  bool any_change = false;
334  CScope &scope = m_TopSeqEntry.GetScope();
335  bool create_general_only = objects::edit::IsGeneralIdProtPresent(m_TopSeqEntry);
336 
337  bool single_interval = m_SingleInterval->GetValue();
338 
340  cmd.Reset(new CCmdComposite("CDS from Gene, mRNA, exon"));
341  ITERATE(vector<CConstRef<CObject> >, it, objs)
342  {
343  const CSeq_feat* f = dynamic_cast<const CSeq_feat* >((*it).GetPointer());
344  if (f)
345  {
346  CBioseq_Handle bsh = scope.GetBioseqHandle(f->GetLocation());
347  features[bsh].push_back(f);
348  }
349  }
350  for (auto &bsh_pair : features)
351  {
352  CBioseq_Handle bsh = bsh_pair.first;
353  for (size_t i = 0; i < bsh_pair.second.size(); i++)
354  {
355  const CSeq_feat* f = bsh_pair.second[i];
356  CRef<CSeq_loc> loc(new CSeq_loc());
357  loc->Assign(f->GetLocation());
358 
359  CRef<CSeq_feat> new_feat(new CSeq_feat());
360  new_feat->SetData().SetCdregion();
361  new_feat->SetLocation(*loc);
362  if (single_interval)
363  {
364  CRef<CSeq_loc> new_loc(new CSeq_loc);
365  new_loc->Assign(new_feat->GetLocation());
366  bool partial_start = new_loc->IsPartialStart(eExtreme_Positional);
367  bool partial_stop = new_loc->IsPartialStop(eExtreme_Positional);
368  new_loc->SetPartialStart(false,eExtreme_Positional);
369  new_loc->SetPartialStop(false,eExtreme_Positional);
370  for (size_t j = 1; j < bsh_pair.second.size(); j++)
371  {
372  const CSeq_feat* f2 = bsh_pair.second[j];
373  CRef<CSeq_loc> add_loc(new CSeq_loc);
374  add_loc->Assign(f2->GetLocation());
375  partial_stop = add_loc->IsPartialStop(eExtreme_Positional);
376  add_loc->SetPartialStart(false,eExtreme_Positional);
377  add_loc->SetPartialStop(false,eExtreme_Positional);
378  new_loc->Assign(*(sequence::Seq_loc_Add(*new_loc, *add_loc, CSeq_loc::fMerge_All|CSeq_loc::fSort, &scope)));
379  }
380  new_loc->SetPartialStart(partial_start,eExtreme_Positional);
381  new_loc->SetPartialStop(partial_stop,eExtreme_Positional);
382  new_feat->SetLocation(*new_loc);
383  new_feat->SetPartial(partial_start || partial_stop);
384  }
386  CRef<objects::CSeq_feat> prot_feat(new CSeq_feat);
387  m_modified = false;
388  CRef<CSeq_feat> mod_feat(new CSeq_feat());
389  mod_feat->Assign(*f);
390  string prot_name = GetSuggestedName(*mod_feat, seh);
391  if (m_modified)
392  {
393  CSeq_feat_Handle fh = scope.GetSeq_featHandle(*f);
394  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(fh,*mod_feat)));
395  }
396  prot_feat->SetData().SetProt();
397  if (!prot_name.empty())
398  {
399  prot_feat->SetData().SetProt().SetName().push_back(prot_name);
400  }
401  new_feat->SetData().SetCdregion().SetFrame(objects::CSeqTranslator::FindBestFrame(*new_feat,scope));
402  cmd->AddCommand(*CRef<CCmdAddCDS>(new CCmdAddCDS(seh, *new_feat,prot_feat, create_general_only)));
403  any_change = true;
404  if (single_interval)
405  break;
406  }
407  }
408 
409 
410 
411  if (!any_change) {
412  wxMessageBox(wxT("No effect!"), wxT("Error"),
413  wxOK | wxICON_ERROR, NULL);
414  cmd.Reset(NULL);
415  }
416 
417  return cmd;
418 }
419 
420 
421 void CCdsFromGeneMrnaExon::OnSelectFeature(wxCommandEvent& event)
422 {
423  string feat_type;
424  int sel_feat = m_FeatureType->GetSelection();
425  if (sel_feat != wxNOT_FOUND)
426  {
427  feat_type = m_FeatureType->GetString(sel_feat).ToStdString();
428  }
429  if (feat_type.empty())
430  return;
431 
432  wxArrayString choice_strings;
433  m_FeatQual->Clear();
434  m_FeatQual2->Clear();
435  m_FeatQual3->Clear();
436 
437  if ( feat_type == "mRNA" )
438  {
439  choice_strings.Add(_("None"));
440  choice_strings.Add(_("Comment"));
441  choice_strings.Add(_("Product"));
442  m_FeatQual->Append(choice_strings);
443  m_FeatQual2->Append(choice_strings);
444  m_FeatQual3->Append(choice_strings);
445  }
446  else if (feat_type == "Gene")
447  {
448  choice_strings.Add(_("None"));
449  choice_strings.Add(_("locus"));
450  choice_strings.Add(_("description"));
451  choice_strings.Add(_("comment"));
452  choice_strings.Add(_("allele"));
453  choice_strings.Add(_("maploc"));
454  choice_strings.Add(_("locus_tag"));
455  choice_strings.Add(_("synonym"));
456  choice_strings.Add(_("old_locus_tag"));
457  m_FeatQual->Append(choice_strings);
458  m_FeatQual2->Append(choice_strings);
459  m_FeatQual3->Append(choice_strings);
460  }
461  else if (feat_type == "exon")
462  {
463  choice_strings.Add(_("None"));
464  choice_strings.Add(_("allele"));
465  choice_strings.Add(_("comment"));
466  choice_strings.Add(_("EC_number"));
467  choice_strings.Add(_("function"));
468  choice_strings.Add(_("old_locus_tag"));
469  choice_strings.Add(_("number"));
470  choice_strings.Add(_("product"));
471  m_FeatQual->Append(choice_strings);
472  m_FeatQual2->Append(choice_strings);
473  m_FeatQual3->Append(choice_strings);
474  }
475  m_FeatQual->SetSelection(0);
476  m_FeatQual->Refresh();
477  m_FeatQual2->SetSelection(0);
478  m_FeatQual2->Disable();
479  m_FeatQual2->Refresh();
480  m_FeatQual3->SetSelection(0);
481  m_FeatQual3->Disable();
482  m_FeatQual3->Refresh();
483 
484 }
485 
486 
487 void CCdsFromGeneMrnaExon::OnSelectFeatQual(wxCommandEvent& event)
488 {
489  int sel1 = m_FeatQual->GetSelection();
490  if (sel1 != wxNOT_FOUND && sel1 != 0)
491  {
492  m_FeatQual2->Enable();
493  m_Remove2->Enable();
494  m_CapChangeOptions->Enable();
495  }
496  else
497  {
498  m_FeatQual2->Disable();
499  m_Remove2->Disable();
500  m_CapChangeOptions->Disable();
501  }
502 
503  int sel2 = m_FeatQual2->GetSelection();
504  if (sel2 != wxNOT_FOUND && sel2 != 0)
505  {
506  m_FeatQual3->Enable();
507  m_Remove3->Enable();
508  }
509  else
510  {
511  m_FeatQual3->Disable();
512  m_Remove3->Disable();
513  }
514 }
515 
517 {
518  string name;
519  string feat_type;
520  int sel_feat = m_FeatureType->GetSelection();
521  if (sel_feat != wxNOT_FOUND)
522  {
523  feat_type = m_FeatureType->GetString(sel_feat).ToStdString();
524  }
525  if (feat_type == "Gene" && feat.IsSetData() && feat.GetData().IsGene())
526  {
527  if (m_FeatQual->GetSelection() != wxNOT_FOUND)
528  name = GetNameFromGene(feat, m_FeatQual->GetString(m_FeatQual->GetSelection()), m_Remove->GetValue());
529 
530  if (name.empty() && m_FeatQual2->IsEnabled() && m_FeatQual2->GetSelection() != wxNOT_FOUND)
531  name = GetNameFromGene(feat, m_FeatQual2->GetString(m_FeatQual2->GetSelection()), m_Remove2->GetValue());
532 
533  if (name.empty() && m_FeatQual3->IsEnabled() && m_FeatQual3->GetSelection() != wxNOT_FOUND)
534  name = GetNameFromGene(feat, m_FeatQual3->GetString(m_FeatQual3->GetSelection()), m_Remove3->GetValue());
535 
536  }
537  if (feat_type == "mRNA" && feat.IsSetData() && feat.GetData().IsRna() && feat.GetData().GetRna().IsSetType() && feat.GetData().GetRna().GetType() == CRNA_ref::eType_mRNA)
538  {
539  if (m_FeatQual->GetSelection() != wxNOT_FOUND)
540  name = GetNameFromMRNA(feat, m_FeatQual->GetString(m_FeatQual->GetSelection()),seh, m_Remove->GetValue());
541 
542  if (name.empty() && m_FeatQual2->IsEnabled() && m_FeatQual2->GetSelection() != wxNOT_FOUND)
543  name = GetNameFromMRNA(feat, m_FeatQual2->GetString(m_FeatQual2->GetSelection()),seh, m_Remove2->GetValue());
544 
545  if (name.empty() && m_FeatQual3->IsEnabled() && m_FeatQual3->GetSelection() != wxNOT_FOUND)
546  name = GetNameFromMRNA(feat, m_FeatQual3->GetString(m_FeatQual3->GetSelection()),seh, m_Remove3->GetValue());
547 
548  }
549  if (feat_type == "exon" && feat.IsSetData() && feat.GetData().IsImp() && feat.GetData().GetImp().IsSetKey() &&
550  feat.GetData().GetImp().GetKey() == "exon" )
551  {
552  if (m_FeatQual->GetSelection() != wxNOT_FOUND)
553  name = GetNameFromExon(feat, m_FeatQual->GetString(m_FeatQual->GetSelection()), m_Remove->GetValue());
554 
555  if (name.empty() && m_FeatQual2->IsEnabled() && m_FeatQual2->GetSelection() != wxNOT_FOUND)
556  name = GetNameFromExon(feat, m_FeatQual2->GetString(m_FeatQual2->GetSelection()), m_Remove2->GetValue());
557 
558  if (name.empty() && m_FeatQual3->IsEnabled() && m_FeatQual3->GetSelection() != wxNOT_FOUND)
559  name = GetNameFromExon(feat, m_FeatQual3->GetString(m_FeatQual3->GetSelection()), m_Remove3->GetValue());
560  }
561 
562 
563  name += m_StrQual->GetValue().ToStdString();
564  if (m_CapChangeOptions->IsEnabled())
565  {
567  FixCapitalizationInString(seh, name, cap_change);
568  }
569  return name;
570 }
571 
572 string CCdsFromGeneMrnaExon::GetNameFromGene(CSeq_feat& gene, const wxString& sel_str, bool remove)
573 {
574  string str;
575  if (sel_str == _("locus") && gene.GetData().GetGene().IsSetLocus())
576  {
577  str = gene.GetData().GetGene().GetLocus();
578  if (remove)
579  {
580  gene.SetData().SetGene().ResetLocus();
581  m_modified = true;
582  }
583  }
584 
585  if (sel_str == _("comment") && gene.IsSetComment())
586  {
587  str = gene.GetComment();
588  if (remove)
589  {
590  gene.ResetComment();
591  m_modified = true;
592  }
593  }
594 
595  if (sel_str == _("locus_tag") && gene.GetData().GetGene().IsSetLocus_tag())
596  {
597  str = gene.GetData().GetGene().GetLocus_tag();
598  if (remove)
599  {
600  gene.SetData().SetGene().ResetLocus_tag();
601  m_modified = true;
602  }
603  }
604 
605  if (sel_str == _("allele") && gene.GetData().GetGene().IsSetAllele())
606  {
607  str = gene.GetData().GetGene().GetAllele();
608  if (remove)
609  {
610  gene.SetData().SetGene().ResetAllele();
611  m_modified = true;
612  }
613  }
614 
615  if (sel_str == _("description") && gene.GetData().GetGene().IsSetDesc())
616  {
617  str = gene.GetData().GetGene().GetDesc();
618  if (remove)
619  {
620  gene.SetData().SetGene().ResetDesc();
621  m_modified = true;
622  }
623  }
624 
625  if (sel_str == _("maploc") && gene.GetData().GetGene().IsSetMaploc())
626  {
627  str = gene.GetData().GetGene().GetMaploc();
628  if (remove)
629  {
630  gene.SetData().SetGene().ResetMaploc();
631  m_modified = true;
632  }
633  }
634 
635  if (sel_str == _("synonym") && gene.GetData().GetGene().IsSetSyn() && !gene.GetData().GetGene().GetSyn().empty())
636  {
637  str = gene.GetData().GetGene().GetSyn().front();
638  if (remove)
639  {
640  gene.SetData().SetGene().SetSyn().erase(gene.SetData().SetGene().SetSyn().begin());
641  if (gene.GetData().GetGene().GetSyn().empty())
642  gene.SetData().SetGene().ResetSyn();
643  m_modified = true;
644  }
645  }
646 
647  if (sel_str == _("old_locus_tag"))
648  {
649  str = gene.GetNamedQual("old_locus_tag");
650  if (remove)
651  {
652  gene.RemoveQualifier("old_locus_tag");
653  m_modified = true;
654  }
655  }
656 
657  return str;
658 }
659 
660 string CCdsFromGeneMrnaExon::GetNameFromMRNA(CSeq_feat& feat, const wxString& sel_str, CSeq_entry_Handle seh, bool remove)
661 {
662  string str;
663  if (sel_str == _("Comment") && feat.IsSetComment() && !feat.GetComment().empty())
664  {
665  str = feat.GetComment();
666  if (remove)
667  {
668  feat.ResetComment();
669  m_modified = true;
670  }
671  }
672 
673  if (sel_str == _("Product") && feat.GetData().GetRna().IsSetExt() && feat.GetData().GetRna().GetExt().IsName())
674  {
675  str = feat.GetData().GetRna().GetExt().GetName();
676  if (remove)
677  {
678  feat.SetData().SetRna().ResetExt();
679  m_modified = true;
680  }
681  }
682  return str;
683 }
684 
685 
686 string CCdsFromGeneMrnaExon::GetNameFromExon(CSeq_feat& feat, const wxString& sel_str, bool remove)
687 {
688  if (sel_str == _("None"))
689  {
690  return kEmptyStr;
691  }
692  string str;
693  if (sel_str == _("comment") && feat.IsSetComment() && !feat.GetComment().empty())
694  {
695  str = feat.GetComment();
696  if (remove)
697  {
698  feat.ResetComment();
699  m_modified = true;
700  }
701  }
702 
703  if (!sel_str.IsEmpty())
704  {
705  str = feat.GetNamedQual(sel_str.ToStdString());
706  if (remove)
707  {
708  feat.RemoveQualifier(sel_str.ToStdString());
709  m_modified = true;
710  }
711  }
712 
713  return str;
714 }
715 
716 void CCdsFromGeneMrnaExon::ProcessUpdateFeatEvent( wxCommandEvent& event )
717 {
718  UpdateChildrenFeaturePanels(this->GetSizer());
719 }
720 
722 {
723  wxSizerItemList& slist = sizer->GetChildren();
724  int n =0;
725  for (wxSizerItemList::iterator iter = slist.begin(); iter != slist.end(); ++iter, ++n) {
726  if ((*iter)->IsSizer()) {
727  UpdateChildrenFeaturePanels((*iter)->GetSizer());
728  } else if ((*iter)->IsWindow()) {
729  wxWindow* child = (*iter)->GetWindow();
730  if (child) {
731  CFeatureTypePanel* panel = dynamic_cast<CFeatureTypePanel*>(child);
732  if (panel) {
734  } else {
735  wxSizer* subsizer = child->GetSizer();
736  if (subsizer) {
737  UpdateChildrenFeaturePanels(subsizer);
738  }
739  }
740  }
741  }
742  }
743 }
744 
746 
747 
748 
749 
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
bool IsGeneralIdProtPresent(objects::CSeq_entry_Handle tse)
USING_SCOPE(ncbi::objects)
CBioseq_Handle –.
objects::CSeq_entry_Handle m_TopSeqEntry
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)
bool GetTopLevelSeqEntryAndProcessor()
objects::ECapChange GetCapitalizationRequest()
void CreateControls()
Creates the controls and sizers.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void UpdateChildrenFeaturePanels(wxSizer *sizer)
string GetNameFromExon(CSeq_feat &feat, const wxString &sel_str, bool remove)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
string GetNameFromMRNA(CSeq_feat &feat, const wxString &sel_str, CSeq_entry_Handle seh, bool remove)
void Init()
Initialises member variables.
void ProcessUpdateFeatEvent(wxCommandEvent &event)
bool Create(wxWindow *parent, wxWindowID id=10468, const wxString &caption=_("CDS From Gene, mRNA, exon"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(900, 500), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
virtual CRef< CCmdComposite > GetCommand()
static bool ShowToolTips()
Should we show tooltips?
CCapChangePanel * m_CapChangeOptions
void OnSelectFeature(wxCommandEvent &event)
void OnSelectFeatQual(wxCommandEvent &event)
string GetNameFromGene(CSeq_feat &gene, const wxString &sel_str, bool remove)
string GetSuggestedName(CSeq_feat &feat, CSeq_entry_Handle seh)
CStringConstraintPanel * m_StringConstraintPanel
CFeatureFieldNamePanel * m_FeatureConstraint
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)
vector< CConstRef< CObject > > GetObjects(objects::CBioseq_Handle bsh)
CScope –.
Definition: scope.hpp:92
CSeq_entry_Handle –.
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
const string & GetNamedQual(const CTempString &qual_name) const
Return a named qualifier.
Definition: Seq_feat.cpp:429
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
CRef< edit::CStringConstraint > GetStringConstraint()
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
Definition: map.hpp:338
#define _(proto)
Definition: ct_nlmzip_i.h:78
#define wxFIXED_MINSIZE
static auto & FixCapitalizationInString
const string kPartialStart
#define EVT_UPDATE_FEATURE_LIST(id, fn)
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static void DLIST_NAME() remove(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
Definition: dlist.tmpl.h:90
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
#define NULL
Definition: ncbistd.hpp:225
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
bool IsPartialStart(ESeqLocExtremes ext) const
check start or stop of location for e_Lim fuzz
Definition: Seq_loc.cpp:3222
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Override Assign() to incorporate cache invalidation.
Definition: Seq_loc.cpp:337
void SetPartialStart(bool val, ESeqLocExtremes ext)
set / remove e_Lim fuzz on start or stop (lt/gt - indicating partial interval)
Definition: Seq_loc.cpp:3280
void SetPartialStop(bool val, ESeqLocExtremes ext)
Definition: Seq_loc.cpp:3313
bool IsPartialStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:3251
@ fMerge_All
Definition: Seq_loc.hpp:331
CRef< CSeq_loc > Seq_loc_Add(const CSeq_loc &loc1, const CSeq_loc &loc2, CSeq_loc::TOpFlags flags, CScope *scope)
Add two seq-locs.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CSeq_feat_Handle GetSeq_featHandle(const CSeq_feat &feat, EMissing action=eMissing_Default)
Definition: scope.cpp:200
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
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
bool IsSetSyn(void) const
synonyms for locus Check if a value has been assigned to Syn data member.
Definition: Gene_ref_.hpp:756
const TSyn & GetSyn(void) const
Get the Syn member data.
Definition: Gene_ref_.hpp:768
const TDesc & GetDesc(void) const
Get the Desc member data.
Definition: Gene_ref_.hpp:599
bool IsSetLocus_tag(void) const
systematic gene name (e.g., MI0001, ORF0069) Check if a value has been assigned to Locus_tag data mem...
Definition: Gene_ref_.hpp:781
bool IsSetLocus(void) const
Official gene symbol Check if a value has been assigned to Locus data member.
Definition: Gene_ref_.hpp:493
bool IsSetDesc(void) const
descriptive name Check if a value has been assigned to Desc data member.
Definition: Gene_ref_.hpp:587
bool IsSetAllele(void) const
Official allele designation Check if a value has been assigned to Allele data member.
Definition: Gene_ref_.hpp:540
bool IsSetMaploc(void) const
descriptive map location Check if a value has been assigned to Maploc data member.
Definition: Gene_ref_.hpp:634
const TLocus_tag & GetLocus_tag(void) const
Get the Locus_tag member data.
Definition: Gene_ref_.hpp:793
const TLocus & GetLocus(void) const
Get the Locus member data.
Definition: Gene_ref_.hpp:505
const TAllele & GetAllele(void) const
Get the Allele member data.
Definition: Gene_ref_.hpp:552
const TMaploc & GetMaploc(void) const
Get the Maploc member data.
Definition: Gene_ref_.hpp:646
TType GetType(void) const
Get the Type member data.
Definition: RNA_ref_.hpp:529
bool IsSetExt(void) const
generic fields for ncRNA, tmRNA, miscRNA Check if a value has been assigned to Ext data member.
Definition: RNA_ref_.hpp:604
bool IsSetType(void) const
Check if a value has been assigned to Type data member.
Definition: RNA_ref_.hpp:510
const TName & GetName(void) const
Get the variant data.
Definition: RNA_ref_.hpp:484
const TExt & GetExt(void) const
Get the Ext member data.
Definition: RNA_ref_.hpp:616
bool IsName(void) const
Check if variant Name is selected.
Definition: RNA_ref_.hpp:478
const TKey & GetKey(void) const
Get the Key member data.
Definition: Imp_feat_.hpp:259
bool IsSetComment(void) const
Check if a value has been assigned to Comment data member.
Definition: Seq_feat_.hpp:1037
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
Definition: Seq_feat_.hpp:913
void SetLocation(TLocation &value)
Assign a value to Location data member.
Definition: Seq_feat_.cpp:131
bool IsImp(void) const
Check if variant Imp is selected.
void SetPartial(TPartial value)
Assign a value to Partial data member.
Definition: Seq_feat_.hpp:971
bool IsSetKey(void) const
Check if a value has been assigned to Key data member.
Definition: Imp_feat_.hpp:247
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
bool IsGene(void) const
Check if variant Gene is selected.
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 TGene & GetGene(void) const
Get the variant data.
const TRna & GetRna(void) const
Get the variant data.
bool IsRna(void) const
Check if variant Rna is selected.
const TImp & GetImp(void) const
Get the variant data.
END_EVENT_TABLE()
int i
yy_size_t n
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
static static static wxID_ANY
static const char *const features[]
Modified on Mon Apr 22 04:07:32 2024 by modify_doxy.py rev. 669887