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

Go to the SVN repository for this file.

1 /* $Id: edit_object_seq_feat.cpp 45995 2021-01-20 19:54:41Z grichenk $
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: Roman Katargin
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
35 
45 #include <gui/objutils/utils.hpp>
47 
48 
53 #include <objects/seq/Pubdesc.hpp>
55 
56 #include <objmgr/util/sequence.hpp>
57 #include <objmgr/feat_ci.hpp>
58 
61 
62 #include <wx/treebook.h>
63 #include <wx/panel.h>
64 //#include <wx/sizer.h>
65 //#include <wx/bitmap.h>
66 //#include <wx/icon.h>
67 //#include <wx/choice.h>
68 //#include <wx/textctrl.h>
69 //#include <wx/stattext.h>
70 //#include <wx/toplevel.h>
71 #include <wx/hyperlink.h>
72 #include <wx/toplevel.h>
73 
74 #include "generic_props_panel.hpp"
75 #include "comment_panel.hpp"
76 #include "location_panel.hpp"
77 #include "gene_panel.hpp"
78 #include "synonyms_panel.hpp"
79 #include "rna_panel.hpp"
80 #include "cds_exception_panel.hpp"
81 #include "cds_protein_panel.hpp"
83 #include "protein_panel.hpp"
84 #include "ec_numbers_panel.hpp"
86 #include "importfeature_panel.hpp"
88 #include "dbxref_panel.hpp"
89 #include "identifiers_panel.hpp"
90 #include "experiments_panel.hpp"
91 #include "inference_list_panel.hpp"
92 #include "citations_panel.hpp"
93 #include "loc_gcode_panel.hpp"
94 #include "biosourcepanel.hpp"
95 #include "srcmod_list_panel.hpp"
96 #include "src_other_pnl.hpp"
97 #include "featuregenepanel.hpp"
98 #include "region_panel.hpp"
99 #include "bond_panel.hpp"
100 #include "site_panel.hpp"
101 #include "experiment_list_panel.hpp"
102 #include "feat_comment.hpp"
103 #include "protein_properties.hpp"
105 
106 // publication editor includes
109 
110 #ifdef _DEBUG
111 #include <serial/objostr.hpp>
112 #include <serial/serial.hpp>
113 #endif
114 
117 
118 static const CBioseq* GetCDSProductSeq(const CSeq_feat* feat, CScope& scope)
119 {
120  const CBioseq* protein = NULL;
121 
122  if (feat->IsSetProduct() && feat->GetProduct().GetId()) {
123  CBioseq_Handle bsh = scope.GetBioseqHandle(*(feat->GetProduct().GetId()));
124  if (bsh) {
125  protein = bsh.GetCompleteBioseq().GetPointer();
126  }
127  }
128  return protein;
129 }
130 
131 
132 static const CSeq_feat* GetFeatureProtein(const CSeq_feat* feat, CScope& scope)
133 {
134  //const CProt_ref* protRef = feat->GetProtXref();
135  const CSeq_feat* protein = NULL;
136 
137  if (feat->IsSetProduct()) {
138  const CSeq_loc& product = feat->GetProduct();
139  int dist = numeric_limits<int>::max();
140  CFeat_CI it(scope, product, SAnnotSelector(CSeqFeatData::e_Prot));
141  for (; it; ++it) {
142  const CSeq_loc& loc = it->GetLocation();
143  sequence::ECompare comp = sequence::Compare(product, loc, &scope,
145  if (comp == sequence::eSame) {
146  protein = &it->GetOriginalFeature();
147  break;
148  }
149  else if (comp == sequence::eContains) {
150  int tmp = sequence::GetLength(product, &scope) -
151  sequence::GetLength(loc, &scope);
152  if (tmp < dist) {
153  dist = tmp;
154  protein = &it->GetOriginalFeature();
155  }
156  }
157  }
158  }
159 
160  return protein;
161 }
162 
163 
165 {
166  wxWindow* panel;
167 
168  panel = new CCDSProteinPanel(m_Window, prot, *m_Scope);
169  m_Window->AddPage(panel, wxT("Protein Name and Description"));
170 }
171 
172 
174 {
175  wxWindow* panel;
176 
177  panel = new CProteinPropertiesPanel(m_Window, prot, edited_protein);
178  m_Window->AddPage(panel, wxT("Protein Properties"));
179 }
180 
181 
183 {
185  string regulatory_class = CSeqFeatData::GetRegulatoryClass(feat.GetData().GetSubtype());
186  if (!NStr::IsBlank(regulatory_class)) {
187  feat.SetData().SetImp().SetKey("regulatory");
188  bool has_class = false;
190  if ((*it)->IsSetQual() && NStr::EqualNocase((*it)->GetQual(), "regulatory_class")) {
191  (*it)->SetVal(regulatory_class);
192  has_class = true;
193  break;
194  }
195  }
196  if (!has_class) {
197  CRef<CGb_qual> q(new CGb_qual());
198  q->SetQual("regulatory_class");
199  q->SetVal(regulatory_class);
200  feat.SetQual().push_back(q);
201  }
202  }
203  }
204 }
205 
206 
208 {
209  const CSeq_feat& seq_feat = dynamic_cast<const CSeq_feat&>(*m_Object);
210 
211  m_EditedFeature.Reset((CSerialObject*)CSeq_feat::GetTypeInfo()->Create());
212  m_EditedFeature->Assign(seq_feat);
213 
214  CSeq_feat& edited_seq_feat = dynamic_cast<CSeq_feat&>(*m_EditedFeature);
215  return edited_seq_feat;
216 }
217 
218 wxWindow* CEditObjectSeq_feat::CreateWindow(wxWindow* parent)
219 {
220  CSeq_feat& edited_seq_feat = x_GetSeqFeatCopy();
221  return CreateWindowImpl(parent,edited_seq_feat);
222 }
223 
224 wxWindow* CEditObjectSeq_feat::CreateWindowImpl(wxWindow* parent,CSeq_feat& edited_seq_feat)
225 {
226  if (m_Window) {
228  "CEditObjectSeq_feat::CreateWindow - Window already created!");
229  }
230  wxTopLevelWindow* gui_widget = dynamic_cast<wxTopLevelWindow*>(parent);
231  IHelpUrlClient* help_client = nullptr;
232  if (m_CreateMode)
233  help_client = dynamic_cast<IHelpUrlClient*>(parent);
234 
235  m_Window = new wxTreebook( parent, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize, wxBK_DEFAULT );
236  m_Window->Bind(wxEVT_TREEBOOK_PAGE_CHANGED, &CEditObjectSeq_feat::OnPageChange, this);
237 
238  CSeqFeatData& seq_feat_data = edited_seq_feat.SetData();
239  ConvertRegulatoryFeature(edited_seq_feat);
240 
241  string sub_type = seq_feat_data.GetKey();
242  if (sub_type.find("RNA") == sub_type.length()-3)
243  sub_type = "RNA";
244 
245  wxWindow* panel;
246  wxWindow* location = NULL;
247 
248  if (seq_feat_data.IsGene()) {
249  CGene_ref& gene_ref = seq_feat_data.SetGene();
250 
251  panel = new CGenePanel(m_Window, gene_ref, *m_Scope);
252  m_Window->AddPage(panel, wxT("Gene"));
253 
254  location = new CLocationPanel(m_Window, edited_seq_feat.SetLocation(), *m_Scope, true, false);
255  m_Window->AddPage(location, wxT("Location"));
256 
257  panel = new CSynonymsPanel(m_Window, gene_ref, *m_Scope);
258  m_Window->AddPage(panel, wxT("Synonyms"));
259  if (gui_widget)
260  gui_widget->SetTitle(_("Gene"));
261 
262  if (help_client)
263  help_client->SetHelpUrl(_("https://www.ncbi.nlm.nih.gov/tools/gbench/manual10/#gene"));
264  }
265  else if (seq_feat_data.IsRna()) {
266  panel = new CRNAPanel(m_Window, edited_seq_feat, *m_Scope);
267  m_Window->AddPage(panel, wxT("RNA"));
268 
269  location = new CLocationPanel(m_Window, edited_seq_feat.SetLocation(), *m_Scope, true, false);
270  m_Window->AddPage(location, wxT("Location"));
271  if (gui_widget)
272  gui_widget->SetTitle(_("RNA"));
273  if (help_client)
274  {
275  if (seq_feat_data.GetSubtype() == CSeqFeatData::eSubtype_rRNA)
276  help_client->SetHelpUrl(_("https://www.ncbi.nlm.nih.gov/tools/gbench/manual10/#rrna"));
277  if (seq_feat_data.GetSubtype() == CSeqFeatData::eSubtype_tRNA)
278  help_client->SetHelpUrl(_("https://www.ncbi.nlm.nih.gov/tools/gbench/manual10/#trna"));
279  if (seq_feat_data.GetSubtype() == CSeqFeatData::eSubtype_ncRNA)
280  help_client->SetHelpUrl(_("https://www.ncbi.nlm.nih.gov/tools/gbench/manual10/#ncrna"));
281  }
282 
283  }
284  else if (seq_feat_data.IsCdregion()) {
285  if (m_CreateMode && edited_seq_feat.IsSetLocation()) {
286  CBioseq_Handle bh = m_Scope->GetBioseqHandle(edited_seq_feat.GetLocation());
288  if (code) {
289  seq_feat_data.SetCdregion().SetCode(*code);
290  }
291  }
292  const CSeq_feat* protein = GetFeatureProtein(&edited_seq_feat, *m_Scope);
293  CRef<CProt_ref> prot_feat;
294  CSeq_feat* edited_protein = NULL;
295  if (protein && protein->GetData().IsProt()) {
297  static_cast<CSeq_feat*>(protein->GetThisTypeInfo()->Create()));
298  m_EditedProtein->Assign(*protein);
299 
300  edited_protein = dynamic_cast<CSeq_feat*>(m_EditedProtein.GetPointer());
301  prot_feat = &edited_protein->SetData().SetProt();
302  } else {
303  bool has_xref = false;
304  if (edited_seq_feat.IsSetXref()) {
305  NON_CONST_ITERATE (CSeq_feat::TXref, it, edited_seq_feat.SetXref()) {
306  if ((*it)->IsSetData() && (*it)->GetData().IsProt()) {
307  prot_feat = &((*it)->SetData().SetProt());
308  has_xref = true;
309  break;
310  }
311  }
312  }
313  if (!has_xref) {
314  CRef<CSeqFeatXref> xref(new CSeqFeatXref());
315  xref->SetData().SetProt();
316  edited_seq_feat.SetXref().push_back(xref);
317  prot_feat = &(xref->SetData().SetProt());
318  }
319  }
320  panel = new CCDSTranslationPanel (m_Window, edited_seq_feat, *m_Scope);
321  m_Window->AddPage(panel, wxT("Coding Region"));
323 
324  location = new CLocationPanel(m_Window, edited_seq_feat.SetLocation(), *m_Scope, true, false, true);
325  m_Window->AddPage(location, wxT("Location"));
326 
327  x_AddCodingRegionProteinPanels(*prot_feat, edited_protein);
328  panel = new CCDSExceptionPanel (m_Window, edited_seq_feat, *m_Scope);
329  m_Window->AddPage(panel, wxT("Translation Exceptions"));
330 
331  panel = new CFeatCommentPanel(m_Window, _("Non-functional CDS"));
332  m_Window->AddPage(panel, wxT("Misc"));
333 
334  if (gui_widget)
335  gui_widget->SetTitle(_("CDS"));
336  if (help_client)
337  help_client->SetHelpUrl(_("https://www.ncbi.nlm.nih.gov/tools/gbench/manual10/#cds"));
338  } else if (seq_feat_data.IsPub()) {
339  CRef<CPubdesc> pubdesc(&(seq_feat_data.SetPub()));
340  panel = new CPublicationTypePanel (m_Window, pubdesc, m_CreateMode);
341  m_Window->AddPage (panel, wxT("Publication"));
342 
343  location = new CLocationPanel(m_Window, edited_seq_feat.SetLocation(), *m_Scope, true, false);
344  m_Window->AddPage(location, wxT("Location"));
345  if (gui_widget)
346  gui_widget->SetTitle(_("Pub feature"));
347 
348  }
349  else if (seq_feat_data.IsImp()) {
350  panel = new CImportFeaturePanel(m_Window, edited_seq_feat);
351  m_Window->AddPage(panel, wxT("Import Feature"));
352 
353  location = new CLocationPanel(m_Window, edited_seq_feat.SetLocation(), *m_Scope, true, false);
354  m_Window->AddPage(location, wxT("Location"));
355  if (gui_widget)
356  {
357  if (seq_feat_data.GetImp().IsSetKey())
358  gui_widget->SetTitle(wxString(seq_feat_data.GetImp().GetKey()));
359  else
360  gui_widget->SetTitle(_("Imp Feature"));
361  }
362  if (help_client)
363  {
364  if (seq_feat_data.GetImp().IsSetKey() && seq_feat_data.GetImp().GetKey() == "misc_feature")
365  help_client->SetHelpUrl(_("https://www.ncbi.nlm.nih.gov/tools/gbench/manual10/#misc-feature"));
366  }
367 
368  }
369  else if (seq_feat_data.IsProt()) {
370  panel = new CProteinPanel(m_Window, edited_seq_feat.SetData().SetProt());
371  m_Window->AddPage(panel, wxT("Protein Name and Description"));
372  panel = new CECNumbersPanel(m_Window, edited_seq_feat.SetData().SetProt());
373  m_Window->AddPage(panel, wxT("Enzyme Commission Numbers"));
374  panel = new CProteinActivitiesPanel(m_Window, edited_seq_feat.SetData().SetProt());
375  m_Window->AddPage(panel, wxT("Activity"));
376  location = new CLocationPanel(m_Window, edited_seq_feat.SetLocation(), *m_Scope, false, true);
377  m_Window->AddPage(location, wxT("Location"));
378  if (gui_widget)
379  gui_widget->SetTitle(_("Protein"));
380  }
381  else if (seq_feat_data.IsBiosrc()) {
382  panel = new CBioSourcePanel(m_Window, edited_seq_feat.SetData().SetBiosrc());
383  m_Window->AddPage(panel, wxT("Source"));
384 
385  panel = new CLocAndGCodePanel(m_Window, edited_seq_feat.SetData().SetBiosrc());
386  m_Window->AddSubPage(panel, wxT("Genetic Code"));
387 
388 // panel = new CSrcModListPanel(m_Window, edited_seq_feat.SetData().SetBiosrc());
389 // m_Window->AddSubPage(panel, wxT("Source Modifiers"));
390 
391 // panel = new CDbxrefPanel(m_Window, edited_seq_feat.SetData().SetBiosrc().SetOrg());
392 // m_Window->AddSubPage(panel, wxT("Dbxrefs"));
393 
395  other->TransferFromOrgRef(edited_seq_feat.SetData().SetBiosrc().SetOrg());
396  m_Window->AddSubPage(other, wxT("Other"));
397 
398  location = new CLocationPanel(m_Window, edited_seq_feat.SetLocation(), *m_Scope, true, false);
399  m_Window->AddPage(location, wxT("Location"));
400  if (gui_widget)
401  gui_widget->SetTitle(_("BioSource"));
402  }
403  else if (seq_feat_data.IsRegion()) {
404  panel = new CRegionPanel(m_Window, edited_seq_feat.SetData().SetRegion());
405  m_Window->AddPage(panel, wxT("Region"));
406 
407  location = new CLocationPanel(m_Window, edited_seq_feat.SetLocation(), *m_Scope, true, false);
408  m_Window->AddPage(location, wxT("Location"));
409  if (gui_widget)
410  gui_widget->SetTitle(_("Region"));
411  }
412  else if (seq_feat_data.IsBond()) {
413  panel = new CBondPanel(m_Window, edited_seq_feat.SetData().SetBond());
414  m_Window->AddPage(panel, wxT("Bond"));
415 
416  //panel = new CLocationPanel(m_Window, edited_seq_feat.SetLocation(), *m_Scope, true, false); // TODO - location can't seem to handle bond seq-loc
417  //m_Window->AddPage(panel, wxT("Location"));
418  if (gui_widget)
419  gui_widget->SetTitle(_("Bond"));
420  }
421  else if (seq_feat_data.IsSite()) {
422  panel = new CSitePanel(m_Window, edited_seq_feat.SetData().SetSite());
423  m_Window->AddPage(panel, wxT("Site"));
424 
425  location = new CLocationPanel(m_Window, edited_seq_feat.SetLocation(), *m_Scope, true, false);
426  m_Window->AddPage(location, wxT("Location"));
427  if (gui_widget)
428  gui_widget->SetTitle(_("Site"));
429  }
430  else if (seq_feat_data.IsPsec_str()) {
432  sec_panel->SetSecondaryStructure(seq_feat_data.GetPsec_str());
433  m_Window->AddPage(sec_panel, wxT("Secondary Structure"));
434  if (gui_widget)
435  gui_widget->SetTitle(_("Secondary Structure"));
436  }
437  else if (seq_feat_data.IsComment()) {
438  panel = new CFeatCommentPanel(m_Window, _("Enter comment in Comment page"));
439  m_Window->AddPage(panel, wxT("Feature"));
440 
441  location = new CLocationPanel(m_Window, edited_seq_feat.SetLocation(), *m_Scope, true, false);
442  m_Window->AddPage(location, wxT("Location"));
443  if (gui_widget)
444  gui_widget->SetTitle(_("Comment"));
445  }
446  else {
447  location = new CLocationPanel(m_Window, edited_seq_feat.SetLocation(), *m_Scope);
448  m_Window->AddPage(location, wxT("Location"));
449  }
450 
451  if (!seq_feat_data.IsGene() && !seq_feat_data.IsComment()) {
452  panel = new CFeatureGenePanel(m_Window, edited_seq_feat, *m_Scope);
453  m_Window->AddPage(panel, wxT("Gene"));
454  }
455 
456  panel = new CCommentPanel(m_Window, edited_seq_feat);
457  m_Window->AddPage(panel, wxT("Comment"));
458 
459  if (CGBQualPanel::PanelNeeded(edited_seq_feat) || seq_feat_data.IsRna()) {
460  panel = new CGBQualPanel(m_Window, edited_seq_feat);
461  m_Window->AddPage (panel, wxT("GenBank Qualifiers"));
462 
463  if (seq_feat_data.IsRna()) {
464  CRNAPanel* rna_panel = 0;
465  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
466  if ((rna_panel = dynamic_cast<CRNAPanel*>(m_Window->GetPage(i))) != 0) {
467  break;
468  }
469  }
470 
471  rna_panel->SetGBQualPanel(dynamic_cast<CGBQualPanel*>(panel));
472  }
473  }
474 
475  panel = new CGenericPropsPanel(m_Window, edited_seq_feat, *m_Scope);
476  m_Window->AddPage(panel, wxT("General "));
477 
478  panel = new CDbxrefPanel (m_Window, edited_seq_feat);
479  m_Window->AddSubPage (panel, wxT("Dbxrefs"));
480 
481  panel = new CIdentifiersPanel (m_Window, edited_seq_feat, m_Scope);
482  m_Window->AddSubPage (panel, wxT("Feature Identifiers"));
483 
484 #if 1
485  panel = new CExperimentListPanel (m_Window, edited_seq_feat);
486 #else
487  panel = new CExperimentsPanel (m_Window, edited_seq_feat);
488 #endif
489  m_Window->AddSubPage (panel, wxT("Experiments"));
490 
491  panel = new CInferenceListPanel (m_Window, edited_seq_feat);
492  m_Window->AddSubPage (panel, wxT("Inferences"));
493 
494  panel = new CCitationsPanel (m_Window, edited_seq_feat, *m_Scope);
495  m_Window->AddSubPage (panel, wxT("Citations"));
496  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
497  m_Window->GetPage(i)->TransferDataToWindow();
498  }
499  return m_Window;
500 }
501 
502 
504 {
505  bool rval = false;
506  unsigned int partial_loc = sequence::SeqLocPartialCheck(loc, scope );
507  if (( partial_loc & sequence::eSeqlocPartial_Start )
508  || ( partial_loc & sequence::eSeqlocPartial_Stop )
509  || ( partial_loc & sequence::eSeqlocPartial_Internal )
510  || ( partial_loc & sequence::eSeqlocPartial_Other )
511  || ( partial_loc & sequence::eSeqlocPartial_Nostart )
512  || ( partial_loc & sequence::eSeqlocPartial_Nostop )
513  || ( partial_loc & sequence::eSeqlocPartial_Nointernal)) {
514  rval = true;
515  }
516  return rval;
517 }
518 
519 
520 bool s_ShouldSetGenePartialStart(const CSeq_loc& gene_loc, const CSeq_loc& cds_loc)
521 {
522  bool rval = false;
523  TSeqPos gene_start_pos = gene_loc.GetStart(eExtreme_Biological);
524  TSeqPos cds_start_pos = cds_loc.GetStart(eExtreme_Biological);
525  if (gene_start_pos == cds_start_pos) {
526  if (!gene_loc.IsPartialStart(eExtreme_Biological)
527  && cds_loc.IsPartialStart(eExtreme_Biological)) {
528  rval = true;
529  }
530  }
531  return rval;
532 }
533 
534 
535 bool s_ShouldSetGenePartialStop(const CSeq_loc& gene_loc, const CSeq_loc& cds_loc)
536 {
537  bool rval = false;
538  TSeqPos gene_stop_pos = gene_loc.GetStop(eExtreme_Biological);
539  TSeqPos cds_stop_pos = cds_loc.GetStop(eExtreme_Biological);
540  if (gene_stop_pos == cds_stop_pos) {
541  if (!gene_loc.IsPartialStop(eExtreme_Biological)
542  && cds_loc.IsPartialStop(eExtreme_Biological)) {
543  rval = true;
544  }
545  }
546  return rval;
547 }
548 
550 {
551  CBioseq_Handle bsh;
552  try
553  {
554  bsh = m_Scope->GetBioseqHandle(loc);
555  } catch (CObjMgrException&) {}
557  return true;
558  return false;
559 }
560 
562 {
563  CBioseq_Handle bsh;
564  try
565  {
566  bsh = m_Scope->GetBioseqHandle(new_loc);
567  } catch (CObjMgrException&) {}
568  if (!bsh)
569  return;
570  TSeqPos length = bsh.GetBioseqLength();
571  bool origin_start = false;
572  bool origin_stop = false;
573  set<pair<TSeqPos, TSeqPos> > intervals;
574  for (CSeq_loc_CI loc_iter(new_loc, CSeq_loc_CI::eEmpty_Skip); loc_iter; ++loc_iter)
575  {
576  CSeq_loc_CI::TRange range = loc_iter.GetRange();
577  TSeqPos start = range.GetFrom();
578  TSeqPos stop = range.GetTo();
579  if (start == 0)
580  origin_start = true;
581  else if (stop == length - 1)
582  origin_stop = true;
583 
584  if (start == 0)
585  {
586  start += length;
587  stop += length;
588  }
589  intervals.insert(make_pair(start, stop));
590  }
591  if (origin_start && origin_stop && !intervals.empty()) // crossing origin
592  {
593  TSeqPos int_start = intervals.begin()->first;
594  TSeqPos int_stop = intervals.rbegin()->second;
595  if (int_stop > length)
596  {
597  int_stop %= length;
598  int_start %= length;
599  CRef<CSeq_loc> before_origin(new CSeq_loc);
600  before_origin->SetInt().SetFrom(int_start);
601  before_origin->SetInt().SetTo(length - 1);
602  before_origin->SetInt().SetId().Assign(*new_loc.GetId());
603  CRef<CSeq_loc> after_origin(new CSeq_loc);
604  after_origin->SetInt().SetFrom(0);
605  after_origin->SetInt().SetTo(int_stop);
606  after_origin->SetInt().SetId().Assign(*new_loc.GetId());
607  adjusted_gene->SetLocation().SetMix().Set().clear();
608  adjusted_gene->SetLocation().SetMix().Set().push_back(before_origin);
609  adjusted_gene->SetLocation().SetMix().Set().push_back(after_origin);
610  }
611  else
612  {
613  int_start %= length;
614  adjusted_gene->SetLocation().SetInt().SetFrom(int_start);
615  adjusted_gene->SetLocation().SetInt().SetTo(int_stop);
616  adjusted_gene->SetLocation().SetInt().SetId().Assign(*new_loc.GetId());
617  }
618  }
619  else
620  {
621  set<ENa_strand> strands;
622  for (CSeq_loc_CI loc_iter(new_loc); loc_iter; ++loc_iter)
623  {
624  if (loc_iter.IsSetStrand())
625  strands.insert(loc_iter.GetStrand());
626  else
627  strands.insert(eNa_strand_plus);
628  }
629  if (strands.size() > 1)
630  {
631  adjusted_gene->SetLocation().Assign(new_loc);
632  }
633  else
634  {
635  adjusted_gene->SetLocation().SetInt().SetFrom(new_loc.GetStart(eExtreme_Positional));
636  adjusted_gene->SetLocation().SetInt().SetTo(new_loc.GetStop(eExtreme_Positional));
637  adjusted_gene->SetLocation().SetInt().SetId().Assign(*new_loc.GetId());
638  }
639  }
640 }
641 
643  const CSeq_loc& old_loc, const CSeq_loc& new_loc, CRef<CSeq_feat> updated_gene)
644 {
645  bool update_gene_span = true;
646 
647  CCDSTranslationPanel* cdsProductPanel = NULL;
648  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
649  cdsProductPanel = dynamic_cast<CCDSTranslationPanel*>(m_Window->GetPage(i));
650  if (cdsProductPanel) {
651  update_gene_span = cdsProductPanel->ShouldUpdateGeneLocation();
652  break;
653  }
654  }
655  if (!update_gene_span && updated_gene->Equals(old_gene))
656  return CIRef<IEditCommand>(NULL);
657  // may need to adjust location of overlapping gene
661 
662  CRef<CSeq_feat> adjusted_gene(new CSeq_feat());
663  adjusted_gene->Assign(*updated_gene);
664 
665  if ((!updated_gene->Equals(old_gene) && new_comp != sequence::eSame && new_comp != sequence::eContains) ||
666  ((before_comp != sequence::eNoOverlap) &&
667  ((before_comp == sequence::eSame && after_comp != sequence::eSame)
668  || (after_comp != sequence::eSame && after_comp != sequence::eContains)
669  || s_ShouldSetGenePartialStart(old_gene.GetLocation(), new_loc)
670  || s_ShouldSetGenePartialStop(old_gene.GetLocation(), new_loc)))) {
671 
672  if (x_IsCircular(old_gene.GetLocation()))
673  {
674  x_AdjustCircularGene(adjusted_gene, new_loc);
675  }
676  else
677  {
678  set<ENa_strand> strands;
679  set<CSeq_id_Handle> idhs;
680  for (CSeq_loc_CI loc_iter(new_loc); loc_iter; ++loc_iter)
681  {
682  if (loc_iter.IsSetStrand())
683  strands.insert(loc_iter.GetStrand());
684  else
685  strands.insert(eNa_strand_plus);
686  idhs.insert(loc_iter.GetSeq_id_Handle());
687  }
688  if (strands.size() > 1 || idhs.size() > 1)
689  {
690  adjusted_gene->SetLocation().Assign(new_loc);
691  }
692  else
693  {
694  const CSeq_id* id = new_loc.GetId();
695  if (!id)
696  return CIRef<IEditCommand>(NULL);
697  adjusted_gene->SetLocation().SetInt().SetFrom(new_loc.GetStart(eExtreme_Positional));
698  adjusted_gene->SetLocation().SetInt().SetTo(new_loc.GetStop(eExtreme_Positional));
699  adjusted_gene->SetLocation().SetInt().SetId().Assign(*id);
700  }
701  }
702  if (s_ShouldSetGenePartialStart(adjusted_gene->GetLocation(), new_loc)) {
703  adjusted_gene->SetLocation().SetPartialStart(true, eExtreme_Biological);
704  adjusted_gene->SetPartial(true);
705  }
706  if (s_ShouldSetGenePartialStop(adjusted_gene->GetLocation(), new_loc)) {
707  adjusted_gene->SetLocation().SetPartialStop(true, eExtreme_Biological);
708  adjusted_gene->SetPartial(true);
709  }
710  }
711 
712  if (!adjusted_gene->Equals(old_gene)) {
713  CSeq_feat_Handle fh = m_Scope->GetSeq_featHandle(old_gene);
714  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, *adjusted_gene));
715  return chgFeat;
716  }
717 
718  return CIRef<IEditCommand>(NULL);
719 }
720 
721 
722 const char* kTransSplicing = "trans-splicing";
723 
724 
726 {
727  CLocationPanel* locPanel = 0;
728  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
729  locPanel = dynamic_cast<CLocationPanel*>(m_Window->GetPage(i));
730  if (locPanel)
731  break;
732  }
733  if (locPanel) {
734  CRef<CSeq_loc> loc = locPanel->GetSeq_loc();
735  edited_seq_feat.SetLocation(*loc);
736  // note - fields from generic properties panel have already been set
737  // if feature was deliberately flagged as partial, will have already been set, otherwise will have been reset
738  if (s_ShouldSetFeaturePartial(*loc, m_Scope)) {
739  edited_seq_feat.SetPartial(true);
740  }
741  }
742 }
743 
745 {
746  CFeatCommentPanel* panel = 0;
747  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
748  panel = dynamic_cast<CFeatCommentPanel*>(m_Window->GetPage(i));
749  if (panel)
750  break;
751  }
752  if (panel && panel->GetConvertToMiscFeat() && edited_seq_feat.IsSetData())
753  {
754  if (edited_seq_feat.GetData().IsComment())
755  {
756  edited_seq_feat.ResetData();
757  edited_seq_feat.SetData().SetImp().SetKey("misc_feature");
758  }
759  }
760 }
761 
762 
764 {
765  // GenBank quals
766  CGBQualPanel* qualPanel = 0;
767  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
768  qualPanel = dynamic_cast<CGBQualPanel*>(m_Window->GetPage(i));
769  if (qualPanel)
770  break;
771  }
772  if (qualPanel) {
773  qualPanel->PopulateGBQuals(edited_seq_feat);
774  }
775 }
776 
777 
779 {
780  // Cross-refs
781  CDbxrefPanel* xrefPanel = 0;
782  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
783  xrefPanel = dynamic_cast<CDbxrefPanel*>(m_Window->GetPage(i));
784  if (xrefPanel) {
785  xrefPanel->PopulateDbxrefs(edited_seq_feat);
786  break;
787  }
788  }
789 }
790 
791 
793 {
794  // identifiers
795  CIdentifiersPanel* idPanel = nullptr;
796  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
797  idPanel = dynamic_cast<CIdentifiersPanel*>(m_Window->GetPage(i));
798  if (idPanel)
799  break;
800  }
801  if (idPanel) {
802  idPanel->PopulateIdentifiers(edited_seq_feat);
803  }
804 }
805 
806 
808 {
809 
810  // inferences
811  CInferenceListPanel* inferencePanel = 0;
812  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
813  inferencePanel = dynamic_cast<CInferenceListPanel*>(m_Window->GetPage(i));
814  if (inferencePanel)
815  break;
816  }
817  if (inferencePanel) {
818  inferencePanel->PopulateGBQuals(edited_seq_feat);
819  }
820 }
821 
822 
824 {
825 
826  // inferences
827  CExperimentListPanel* experimentsPanel = 0;
828  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
829  experimentsPanel = dynamic_cast<CExperimentListPanel*>(m_Window->GetPage(i));
830  if (experimentsPanel)
831  break;
832  }
833  if (experimentsPanel) {
834  experimentsPanel->PopulateGBQuals(edited_seq_feat);
835  }
836 }
837 
838 
840 {
841  // citations
842  CCitationsPanel* citationsPanel = 0;
843  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
844  citationsPanel = dynamic_cast<CCitationsPanel*>(m_Window->GetPage(i));
845  if (citationsPanel)
846  break;
847  }
848  if (citationsPanel) {
849  citationsPanel->SetCitations(edited_seq_feat);
850  }
851 }
852 
853 
854 CConstRef<CSeq_feat> s_GetmRNAForCDS(const CSeq_feat& cds, const CSeq_feat& orig_cds, CScope& scope)
855 {
856  // note - if the edited feature refers to an mRNA by feature ID, use that feature
857  bool has_xref = false;
859  if (cds.IsSetXref()) {
860  CBioseq_Handle bsh = scope.GetBioseqHandle(*(cds.GetLocation().GetId()));
861  CTSE_Handle tse = bsh.GetTSE_Handle();
863  if ((*it)->IsSetId() && (*it)->GetId().IsLocal() && (*it)->GetId().GetLocal().IsId()) {
864  CSeq_feat_Handle mrna_h = tse.GetFeatureWithId(CSeqFeatData::eSubtype_mRNA, (*it)->GetId().GetLocal().GetId());
865  if (mrna_h) {
866  mrna = mrna_h.GetSeq_feat();
867  }
868  has_xref = true;
869  }
870  }
871  }
872 
873  if (!has_xref) {
874  mrna = GetBestOverlappingFeat(
875  orig_cds.GetLocation(), // note - using original location to find mRNA
878  scope);
879  }
880  return mrna;
881 }
882 
883 
885 {
886  if (!cds.IsSetData() || !cds.GetData().IsCdregion() || !cds.IsSetLocation()) {
887  return CIRef<IEditCommand>(NULL);
888  }
889  // find original overlapping mRNA, if editing a coding region
890  bool update_mrna_span = false;
891  bool update_mrna_product = false;
892 
893  CCDSProteinPanel* cdsProteinPanel = 0;
894  CCDSTranslationPanel* cdsProductPanel = 0;
895  CLocationPanel *locPanel(NULL);
896  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
897  if (!cdsProteinPanel) {
898  cdsProteinPanel = dynamic_cast<CCDSProteinPanel*>(m_Window->GetPage(i));
899  }
900  if (!cdsProductPanel) {
901  cdsProductPanel = dynamic_cast<CCDSTranslationPanel*>(m_Window->GetPage(i));
902  }
903  if (!locPanel) {
904  locPanel = dynamic_cast<CLocationPanel*>(m_Window->GetPage(i));
905  }
906 
907  if (cdsProteinPanel && cdsProductPanel && locPanel) {
908  break;
909  }
910  }
911  if (cdsProteinPanel) {
912  update_mrna_product = cdsProteinPanel->ShouldUpdatemRNAProduct();
913  }
914  if (cdsProductPanel) {
915  update_mrna_span = cdsProductPanel->ShouldUpdatemRNALocation();
916  }
917  if (locPanel) {
918  update_mrna_span |= locPanel->ShouldUpdatemRNALocation();
919  }
920 
921  if (update_mrna_product || update_mrna_span) {
922  const CSeq_feat& orig_cds = dynamic_cast<const CSeq_feat&>(*m_Object);
923  CConstRef<CSeq_feat> mrna = s_GetmRNAForCDS(cds, orig_cds, *m_Scope);
924 
925  if ( mrna ) {
926  CRef<CSeq_feat> new_mrna(new CSeq_feat());
927  new_mrna->Assign(*mrna);
928  bool any_change = false;
929 
930  if (update_mrna_product) {
931  // update product
932  string new_prot_product = "";
933  if (m_EditedProtein) {
934  CSeq_feat& edited_protein = dynamic_cast<CSeq_feat&>(*m_EditedProtein);
935  if ( edited_protein.GetData().GetProt().IsSetName()
936  && edited_protein.GetData().GetProt().GetName().size() > 0) {
937  new_prot_product = edited_protein.GetData().GetProt().GetName().front();
938  }
939  }
940  string orig_mrna_product = "";
941  if (mrna->GetData().GetRna().IsSetExt() && mrna->GetData().GetRna().GetExt().IsName()) {
942  orig_mrna_product = mrna->GetData().GetRna().GetExt().GetName();
943  }
944  if (!NStr::Equal(new_prot_product, orig_mrna_product)
945  || !mrna->GetData().GetRna().IsSetExt()
946  || !mrna->GetData().GetRna().GetExt().IsName()) {
947  new_mrna->SetData().SetRna().SetExt().SetName(new_prot_product);
948  any_change = true;
949  }
950  }
951 
952  if (update_mrna_span) {
953  // adjust location
956  if (orig_comp == sequence::eSame || new_comp != sequence::eContained) {
957  new_mrna->SetLocation().Assign(cds.GetLocation());
958  bool make_partial = s_ShouldSetFeaturePartial(new_mrna->GetLocation(), m_Scope);
959  if (make_partial) {
960  new_mrna->SetPartial(true);
961  } else {
962  new_mrna->ResetPartial();
963  }
964  any_change = true;
965  }
966  }
967 
968  if (any_change) {
969  CSeq_feat_Handle fh = m_Scope->GetSeq_featHandle(*mrna);
970  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, *new_mrna));
971  return chgFeat;
972  }
973  }
974  }
975  return CIRef<IEditCommand>(NULL);
976 }
977 
978 
980 {
981  if (!cds.IsSetData() || !cds.GetData().IsCdregion()) {
982  return;
983  }
984 
985  CCDSExceptionPanel *transl_except_panel = 0;
986  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
987  transl_except_panel = dynamic_cast<CCDSExceptionPanel*>(m_Window->GetPage(i));
988  if (transl_except_panel)
989  break;
990  }
991  if (transl_except_panel) {
992  transl_except_panel->SetExceptions(cds.SetData().SetCdregion());
993  }
994 
995 }
996 
998 {
999  CRef<CCmdComposite> composite(new CCmdComposite("Handle CDS Product"));
1000  bool any_actions = false;
1001 
1002  const CBioseq * product_seq = GetCDSProductSeq(&cds, *m_Scope);
1003  const CSeq_feat* orig_protein = nullptr;
1004  if (product_seq) {
1005  orig_protein = GetFeatureProtein(&cds, *m_Scope);
1006  }
1007 
1008  CFeatCommentPanel* misc_panel = nullptr;
1009  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1010  misc_panel = dynamic_cast<CFeatCommentPanel*>(m_Window->GetPage(i));
1011  if (misc_panel)
1012  break;
1013  }
1014  if (misc_panel && misc_panel->GetConvertToMiscFeat())
1015  {
1016  cds.ResetProduct();
1017  cds.SetData().SetImp().SetKey("misc_feature");
1018  if (orig_protein)
1019  {
1020  CSeq_feat_Handle fh = m_Scope->GetSeq_featHandle(*orig_protein);
1021  CIRef<IEditCommand> delFeat(new CCmdDelSeq_feat(fh));
1022  composite->AddCommand(*delFeat);
1023  any_actions = true;
1024  }
1025  if (product_seq)
1026  {
1027  CBioseq_Handle bh = m_Scope->GetBioseqHandle(*product_seq);
1028  CIRef<IEditCommand> delInst(new CCmdDelBioseqInst(bh));
1029  composite->AddCommand(*delInst);
1030  any_actions = true;
1031  }
1032  if (!any_actions) {
1033  composite.Reset(NULL);
1034  }
1035  return composite;
1036  }
1037 
1038  CCDSTranslationPanel* transPanel = nullptr;
1039  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1040  transPanel = dynamic_cast<CCDSTranslationPanel*>(m_Window->GetPage(i));
1041  if (transPanel)
1042  break;
1043  }
1044 
1045  if (transPanel) {
1046  bool ShouldCreateNewProductSeq = transPanel->ShouldCreateNewProductSeq();
1047  if (transPanel->ShouldRetranslate()) {
1048  transPanel->Retranslate();
1049  }
1050 
1051  if (product_seq && !ShouldCreateNewProductSeq) {
1052  // adjust existing product
1053  CBioseq_Handle bh = m_Scope->GetBioseqHandle(*product_seq);
1054  CRef<CBioseq> edited_product(new CBioseq());
1055  edited_product->Assign(*product_seq);
1056  transPanel->SetProtein(*edited_product);
1057 
1058  if (edited_product->IsSetInst() && edited_product->GetInst().IsSetRepr()
1059  && edited_product->GetInst().GetRepr() != CSeq_inst::eRepr_not_set)
1060  {
1061  CIRef<IEditCommand> chgInst(new CCmdChangeBioseqInst(bh, edited_product->GetInst()));
1062  composite->AddCommand(*chgInst);
1064  if (chgPartials) {
1065  composite->AddCommand(*chgPartials);
1066  any_actions = true;
1067  }
1068  try
1069  {
1070  NRawToDeltaSeq::RemapOtherProtFeats(old_cds, cds, bh, composite, any_actions);
1071  } catch(const CUtilException&) {}
1072 
1073  if (orig_protein) {
1074  // adjust existing protein feature
1075  CSeq_feat& edited_protein = dynamic_cast<CSeq_feat&>(*m_EditedProtein);
1076  edited_protein.SetLocation().SetInt().SetId().Assign(*(edited_product->GetId().front()));
1077  edited_protein.SetLocation().SetInt().SetFrom(0);
1078  edited_protein.SetLocation().SetInt().SetTo(edited_product->GetLength() - 1);
1079  edit::AdjustProteinFeaturePartialsToMatchCDS(edited_protein, cds);
1080  CCleanup cleanup;
1081  cleanup.BasicCleanup(edited_protein);
1082 
1083  CSeq_feat_Handle fh = m_Scope->GetSeq_featHandle(*orig_protein);
1084  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, edited_protein));
1085  composite->AddCommand(*chgFeat);
1086  any_actions = true;
1087  } else {
1088  // create new protein feature
1089  bool cds_change = false;
1090  CRef<CCmdComposite> create_prot = CreateOrAdjustProteinFeature(bh, cds, cds_change);
1091  if (create_prot) {
1092  composite->AddCommand(*create_prot);
1093  any_actions = true;
1094  }
1095  }
1096  }
1097  else
1098  {
1099  // delete product
1100  if (orig_protein)
1101  {
1102  CSeq_feat_Handle fh = m_Scope->GetSeq_featHandle(*orig_protein);
1103  CIRef<IEditCommand> delFeat(new CCmdDelSeq_feat(fh));
1104  composite->AddCommand(*delFeat);
1105  }
1106  CIRef<IEditCommand> delInst(new CCmdDelBioseqInst(bh));
1107  composite->AddCommand(*delInst);
1108  // adjust or add prot-xref
1109  CSeq_feat& edited_protein = dynamic_cast<CSeq_feat&>(*m_EditedProtein);
1110  bool found_existing = false;
1111  if (cds.IsSetXref()) {
1113  if ((*it)->IsSetData() && (*it)->GetData().IsProt()) {
1114  (*it)->SetData().SetProt().Assign(edited_protein.GetData().GetProt());
1115  found_existing = true;
1116  break;
1117  }
1118  }
1119  }
1120  if (!found_existing) {
1121  CRef<CSeqFeatXref> prot_xref(new CSeqFeatXref());
1122  prot_xref->SetData().SetProt().Assign(edited_protein.GetData().GetProt());
1123  cds.SetXref().push_back(prot_xref);
1124  }
1125  any_actions = true;
1126  }
1127  } else if (ShouldCreateNewProductSeq) {
1128  // create new product sequence
1129  CRef<CBioseq> new_product(new CBioseq());
1130  transPanel->SetProtein(*new_product);
1131 
1132  if (new_product->IsSetInst() &&
1133  new_product->GetInst().IsSetRepr() &&
1134  new_product->GetInst().GetRepr() != CSeq_inst::eRepr_not_set) {
1135  CBioseq_Handle bsh;
1136  for (CSeq_loc_CI loc_iter(cds.GetLocation(), CSeq_loc_CI::eEmpty_Skip); loc_iter; ++loc_iter)
1137  {
1138  try {
1139  bsh = m_Scope->GetBioseqHandle(loc_iter.GetSeq_id());
1140  } catch (CObjMgrException&) {}
1141  if (bsh)
1142  break;
1143  }
1144 
1145  CRef<CSeq_id> product_id;
1146  if (!new_product->IsSetId() || new_product->GetId().empty()) {
1147  CSeq_entry_Handle seh = bsh.GetTopLevelEntry();
1148  product_id = transPanel->GetProductId();
1149  if (!product_id) {
1150  int offset = 1;
1151  string id_label;
1152  bool create_general_only = objects::edit::IsGeneralIdProtPresent(m_SEH.GetTopLevelEntry());
1153  product_id = edit::GetNewProtId(bsh, offset, id_label, create_general_only);
1154  }
1155  new_product->SetId().push_back(product_id);
1156  }
1157  else {
1158  product_id = new_product->SetId().front();
1159  }
1160 
1161  string label;
1162  product_id->GetLabel(&label, CSeq_id::eFasta);
1163  transPanel->SetProductId(label);
1164  transPanel->TransferDataFromWindow();
1165 
1166  CRef<CSeq_entry> prot_entry (new CSeq_entry());
1167  prot_entry->SetSeq(*new_product);
1168  bool partial5 = cds.GetLocation().IsPartialStart(eExtreme_Biological);
1169  bool partial3 = cds.GetLocation().IsPartialStop(eExtreme_Biological);
1170  SetMolinfoForProtein (prot_entry, partial5, partial3);
1171  CRef<CSeq_feat> prot = AddEmptyProteinFeatureToProtein(prot_entry, partial5, partial3);
1172  if (orig_protein) {
1173  CRef<CSeq_loc> keep_loc(new CSeq_loc());
1174  keep_loc->Assign(prot->GetLocation());
1175  prot->Assign(*orig_protein);
1176  prot->SetLocation().Assign(*keep_loc);
1177  if (partial5 || partial3) {
1178  prot->SetPartial(true);
1179  }
1180  } else if (cds.IsSetXref()) {
1182  if ((*it)->IsSetData() && (*it)->GetData().IsProt()) {
1183  prot->SetData().SetProt().Assign((*it)->GetData().GetProt());
1184  cds.SetXref().erase(it);
1185  break;
1186  }
1187  }
1188  if (cds.GetXref().empty()) {
1189  cds.ResetXref();
1190  }
1191  }
1192 
1193  CCleanup cleanup;
1194  cleanup.BasicCleanup(*prot);
1195 
1196  CRef<CCmdAddSeqEntry> subcmd(new CCmdAddSeqEntry(prot_entry, bsh.GetSeq_entry_Handle()));
1197  composite->AddCommand(*subcmd);
1198 
1199  if (product_seq) {
1200  CBioseq_Handle old_prot = m_Scope->GetBioseqHandle(*product_seq);
1201  CRef<CCmdDelBioseqInst> subcmd(new CCmdDelBioseqInst(old_prot));
1202  composite->AddCommand(*subcmd);
1203  }
1204 
1205  any_actions = true;
1206  }
1207  }
1208  transPanel->SetProduct(cds);
1209  }
1210 
1211 
1212  if (!any_actions) {
1213  composite.Reset(NULL);
1214  }
1215 
1216  return composite;
1217 }
1218 
1220  {
1221  //if (m_CreateMode)
1222  {
1223  CSeq_feat& edited_feat = dynamic_cast<CSeq_feat&>(*m_EditedFeature);
1225  set<CSeqFeatData::EQualifier> mandatory(mandatory_vec.begin(), mandatory_vec.end());
1226  if (edited_feat.IsSetQual())
1227  {
1228  for (CSeq_feat::TQual::iterator qual = edited_feat.SetQual().begin(); qual != edited_feat.SetQual().end(); ++qual)
1229  {
1230  if ((*qual)->IsSetQual() && !(*qual)->GetQual().empty() && (*qual)->IsSetVal() && !(*qual)->GetVal().empty())
1231  mandatory.erase(CSeqFeatData::GetQualifierType((*qual)->GetQual()));
1232  }
1233  }
1234 
1235  // some "qualifiers" are represented elsewhere
1236  if (edited_feat.GetData().IsRna() &&
1237  edited_feat.GetData().GetRna().IsSetExt() &&
1238  edited_feat.GetData().GetRna().GetExt().IsGen() &&
1239  edited_feat.GetData().GetRna().GetExt().GetGen().IsSetClass() &&
1240  !NStr::IsBlank(edited_feat.GetData().GetRna().GetExt().GetGen().GetClass())) {
1242  }
1243 
1244  if (!mandatory.empty())
1245  {
1246  vector<string> txt;
1247  for (auto q : mandatory)
1248  {
1249  txt.push_back("\"" + CSeqFeatData::GetQualifierAsString(q) + "\"");
1250  }
1251  wxString msg;
1252  msg << "This feature is missing mandatory qualifier";
1253  if (txt.size() > 1)
1254  msg << "s";
1255  msg << " ";
1256  if (txt.size() > 2)
1257  msg << NStr::Join(txt, ", ");
1258  else
1259  msg << NStr::Join(txt, " and ");
1260  msg << ". Would you like to continue?";
1261  int answer = wxMessageBox(msg, ToWxString("Warning"), wxYES_NO | wxICON_QUESTION);
1262  if (answer != wxYES)
1263  {
1264  if (m_Window)
1265  {
1266  m_Window->ChangeSelection(0);
1267  }
1268  return false;
1269  }
1270  }
1271  }
1272  return true;
1273  }
1274 
1276 {
1277  if (!m_Window)
1278  return 0;
1279 
1280  if (!m_EditAction) {
1281 
1283 
1284  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1285  if (!m_Window->GetPage(i)->TransferDataFromWindow()) {
1286  return 0;
1287  }
1288  }
1289  CRef<CCmdComposite> composite(new CCmdComposite("Edit Feature"));
1290 
1291  const CSeq_feat& seq_feat = dynamic_cast<const CSeq_feat&>(*m_Object);
1292  CSeq_feat& edited_seq_feat = dynamic_cast<CSeq_feat&>(*m_EditedFeature);
1293 
1294  x_AdjustLocation(edited_seq_feat);
1295  x_ConvertCommentToMiscFeat(edited_seq_feat);
1296 
1297  if (!m_CreateMode) {
1298  CSeq_feat_Handle fh;
1299  try {
1300  fh = m_Scope->GetSeq_featHandle(seq_feat);
1301  } catch (const CException&) {
1302  fh = GetSeqFeatHandleForBadLocFeature(seq_feat, *m_Scope);
1303  }
1304  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, edited_seq_feat));
1305  composite->AddCommand(*chgFeat);
1306  }
1307 
1308  // set data for publication feature
1309  CPublicationTypePanel* pubPanel = 0;
1310  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1311  pubPanel = dynamic_cast<CPublicationTypePanel*>(m_Window->GetPage(i));
1312  if (pubPanel)
1313  break;
1314  }
1315 
1316  if (pubPanel) {
1317  // copy to data
1318  CRef<CPubdesc> pub = pubPanel->GetPubdesc();
1319  edited_seq_feat.SetData().SetPub(*pub);
1320  }
1321 
1322  // import feature
1323  CImportFeaturePanel* impPanel = 0;
1324  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1325  impPanel = dynamic_cast<CImportFeaturePanel*>(m_Window->GetPage(i));
1326  if (impPanel)
1327  break;
1328  }
1329 
1330  if (impPanel) {
1331  impPanel->PopulateImpFeat (edited_seq_feat);
1332  }
1333  //biosource
1334  bool is_biosrc = false;
1335  CBioSourcePanel* biosource_panel = 0;
1336  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1337  biosource_panel = dynamic_cast<CBioSourcePanel*>(m_Window->GetPage(i));
1338  if (biosource_panel)
1339  break;
1340  }
1341  if (biosource_panel) {
1342  biosource_panel->PopulateBioSource(edited_seq_feat.SetData().SetBiosrc());
1343  is_biosrc = true;
1344  }
1345  if (is_biosrc) {
1346  CSourceOtherPanel* other_panel = 0;
1347  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1348  other_panel = dynamic_cast<CSourceOtherPanel*>(m_Window->GetPage(i));
1349  if (other_panel) {
1350  break;
1351  }
1352  }
1353  if (other_panel) {
1354  other_panel->TransferToOrgRef(edited_seq_feat.SetData().SetBiosrc().SetOrg());
1355  }
1356 
1357  CLocAndGCodePanel* loc_gc_panel = 0;
1358  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1359  loc_gc_panel = dynamic_cast<CLocAndGCodePanel*>(m_Window->GetPage(i));
1360  if (loc_gc_panel)
1361  break;
1362  }
1363  if (loc_gc_panel) {
1364  loc_gc_panel->PopulateLocAndGC(edited_seq_feat.SetData().SetBiosrc());
1365  }
1366  CCleanup cleanup;
1367  cleanup.BasicCleanup(edited_seq_feat.SetData().SetBiosrc());
1368  }
1369 
1370  x_SetGbQuals(edited_seq_feat);
1371  x_SetCrossRefs(edited_seq_feat);
1372  x_SetIdentifiers(edited_seq_feat);
1373  x_SetInferences(edited_seq_feat);
1374  x_SetExperiments(edited_seq_feat); // TODO restores gb-quals edited before
1375  x_SetCitations(edited_seq_feat);
1376 
1377  CRegionPanel* regionPanel = nullptr;
1378  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1379  regionPanel = dynamic_cast<CRegionPanel*>(m_Window->GetPage(i));
1380  if (regionPanel)
1381  break;
1382  }
1383 
1384  if (regionPanel) {
1385  // copy to data
1386  string region = regionPanel->GetRegion();
1387  if (regionPanel->GetConvertToMiscFeat())
1388  {
1389  edited_seq_feat.ResetData();
1390  edited_seq_feat.SetData().SetImp().SetKey("misc_feature");
1391  if (edited_seq_feat.IsSetComment())
1392  {
1393  if (!region.empty())
1394  region += "; ";
1395  region += edited_seq_feat.GetComment();
1396  }
1397  edited_seq_feat.SetComment(region);
1398  }
1399  else
1400  {
1401  edited_seq_feat.SetData().SetRegion(region);
1402  }
1403  }
1404 
1405  CBondPanel* bondPanel = nullptr;
1406  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1407  bondPanel = dynamic_cast<CBondPanel*>(m_Window->GetPage(i));
1408  if (bondPanel)
1409  break;
1410  }
1411 
1412  if (bondPanel) {
1413  // copy to data
1414  CSeqFeatData::EBond bond = bondPanel->GetBond();
1415  edited_seq_feat.SetData().SetBond(bond);
1416  }
1417 
1418  CSitePanel* sitePanel = nullptr;
1419  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1420  sitePanel = dynamic_cast<CSitePanel*>(m_Window->GetPage(i));
1421  if (sitePanel)
1422  break;
1423  }
1424 
1425  if (sitePanel) {
1426  // copy to data
1427  CSeqFeatData::ESite site = sitePanel->GetSite();
1428  edited_seq_feat.SetData().SetSite(site);
1429  }
1430 
1431  // Secondary Structure features
1432  CSecondaryStructurePanel* secondary_struc_panel = nullptr;
1433  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1434  secondary_struc_panel = dynamic_cast<CSecondaryStructurePanel*>(m_Window->GetPage(i));
1435  if (secondary_struc_panel)
1436  break;
1437  }
1438 
1439  if (secondary_struc_panel) {
1440  // copy to data
1441  CSeqFeatData::EPsec_str struc = secondary_struc_panel->GetSecondaryStructure();
1442  edited_seq_feat.SetData().SetPsec_str(struc);
1443  }
1444 
1445  CGenericPropsPanel* generic_props_panel = nullptr;
1446  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1447  generic_props_panel = dynamic_cast<CGenericPropsPanel*>(m_Window->GetPage(i));
1448  if (generic_props_panel)
1449  break;
1450  }
1451 
1452  bool modify_pseudo = false;
1453  string pseudo_choice;
1454  if (generic_props_panel && generic_props_panel->PseudoSelectionChanged()) {
1455  modify_pseudo = true;
1456  pseudo_choice = generic_props_panel->GetPseudoChoice();
1457  }
1458 
1459  // some generic cleanup
1460  if (edited_seq_feat.IsSetQual() && edited_seq_feat.GetQual().empty()) {
1461  edited_seq_feat.ResetQual();
1462  }
1463 
1464  CCleanup cleanup;
1465  cleanup.BasicCleanup(edited_seq_feat);
1466 
1467  // find original overlapping mRNA, if editing a coding region
1468  CIRef<IEditCommand> chgmRNA = x_UpdatemRNA(edited_seq_feat);
1469  if (chgmRNA) {
1470  composite->AddCommand(*chgmRNA);
1471  }
1472 
1473  CFeatureGenePanel* addedGenePanel = 0;
1474  CRef<CSeq_feat> new_gene;
1475  CConstRef<CSeq_feat> old_gene;
1476  CRef<CSeq_feat> updated_gene;
1477  for (size_t i = 0; i < m_Window->GetPageCount(); ++i) {
1478  addedGenePanel = dynamic_cast<CFeatureGenePanel*>(m_Window->GetPage(i));
1479  if (addedGenePanel) {
1480  addedGenePanel->SetModifyPseudo(modify_pseudo, pseudo_choice);
1481  new_gene = addedGenePanel->GetNewGene();
1482  old_gene = addedGenePanel->GetGeneToEdit();
1483  updated_gene = addedGenePanel->GetUpdatedGene();
1484  break;
1485  }
1486  }
1487 
1488  // copy trans-splicing exception from coding region to gene if present
1489  if (new_gene && edited_seq_feat.GetData().IsCdregion()
1490  && edited_seq_feat.IsSetExcept_text()
1491  && NStr::Find(edited_seq_feat.GetExcept_text(), kTransSplicing) != string::npos) {
1492  new_gene->SetExcept(true);
1493  new_gene->SetExcept_text(kTransSplicing);
1494  }
1495 
1496  try {
1497  if (!new_gene && !m_CreateMode && old_gene) {
1498  // may need to adjust location of overlapping gene
1499  CIRef<IEditCommand> change_gene = x_AdjustGene(*old_gene, seq_feat.GetLocation(), edited_seq_feat.GetLocation(), updated_gene);
1500  if (change_gene) {
1501  composite->AddCommand(*change_gene);
1502  }
1503  } else if (new_gene) {
1504  CBioseq_Handle bsh;
1505  for (CSeq_loc_CI loc_iter(new_gene->GetLocation(), CSeq_loc_CI::eEmpty_Skip); loc_iter; ++loc_iter)
1506  {
1507  try
1508  {
1509  bsh = m_SEH.GetScope().GetBioseqHandle(loc_iter.GetSeq_id());
1510  } catch (CObjMgrException&) {}
1511  if (bsh)
1512  break;
1513  }
1515  CIRef<IEditCommand> addFeat(new CCmdCreateFeat(seh, *new_gene));
1516  composite->AddCommand(*addFeat);
1517  }
1518 
1519  if (edited_seq_feat.IsSetData() && edited_seq_feat.GetData().IsCdregion()) {
1520  x_SetTranslExcept(edited_seq_feat);
1521  CRef<CCmdComposite> handle_product = x_HandleCdsProduct(seq_feat, edited_seq_feat);
1522  if (handle_product) {
1523  composite->AddCommand(*handle_product);
1524  }
1525  }
1526 
1527  if (m_CreateMode) {
1528  CIRef<IEditCommand> addFeat(new CCmdCreateFeat(m_SEH, edited_seq_feat));
1529  composite->AddCommand(*addFeat);
1530  }
1531 
1532  m_EditAction.Reset(composite);
1533  }
1534  catch (CException& e) {
1535  LOG_POST(Error << "CEditObjectSeq_feat::GetEditAction(): " << e.GetMsg());
1536  }
1537 
1538 
1539 
1540 #if 0
1541 #ifdef _DEBUG
1542  CNcbiOstrstream ostr;
1543  {{
1544  unique_ptr<CObjectOStream>
1546  *out << edited_seq_feat;
1547  }}
1548  _TRACE(string(CNcbiOstrstreamToString(ostr)));
1549  //LOG_POST(Info << string(CNcbiOstrstreamToString(ostr)));
1550 #endif
1551 #endif
1552 
1553  }
1554  return m_EditAction.GetPointer();
1555 }
1556 
1557 void CEditObjectSeq_feat::OnPageChange(wxBookCtrlEvent& event)
1558 {
1559  CImportExportContainer *parent = nullptr;
1560 
1561  wxPanel* panel_parent = dynamic_cast<wxPanel*>(m_Window->GetParent());
1562  if (panel_parent) {
1563  parent = dynamic_cast<CImportExportContainer*>(panel_parent->GetParent());
1564  }
1565  else {
1566  parent = dynamic_cast<CImportExportContainer*>(m_Window->GetParent());
1567  }
1568 
1569  _ASSERT(parent);
1570  CImportExportAccess *child = dynamic_cast<CImportExportAccess*>(m_Window->GetCurrentPage());
1571  bool enable_import = false;
1572  bool enable_export = false;
1573  if (child)
1574  {
1575  enable_import = child->IsImportEnabled();
1576  enable_export = child->IsExportEnabled();
1577  }
1578  parent->EnableImport(enable_import);
1579  parent->EnableExport(enable_export);
1580 }
1581 
1582 
User-defined methods of the data storage class.
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
@ eExtreme_Biological
5' and 3'
Definition: Na_strand.hpp:62
User-defined methods of the data storage class.
bool AdjustProteinFeaturePartialsToMatchCDS(CSeq_feat &new_prot, const CSeq_feat &cds)
AdjustProteinFeaturePartialsToMatchCDS A function to change an existing MolInfo to match a coding reg...
Definition: cds_fix.cpp:398
CRef< objects::CSeq_id > GetNewProtId(objects::CBioseq_Handle bsh, int &offset, string &id_label, bool general_only)
bool IsGeneralIdProtPresent(objects::CSeq_entry_Handle tse)
CRef< CGenetic_code > GetGeneticCodeForBioseq(CBioseq_Handle bh)
GetGeneticCodeForBioseq A function to construct the appropriate CGenetic_code object to use when cons...
Definition: cds_fix.cpp:707
void PopulateBioSource(objects::CBioSource &source)
CBioseq_Handle –.
TSeqPos GetLength(void) const
Definition: Bioseq.cpp:360
CSeqFeatData::EBond GetBond()
Definition: bond_panel.cpp:165
void SetExceptions(objects::CCdregion &cds)
virtual bool TransferDataFromWindow()
void SetProduct(objects::CSeq_feat &feat)
void SetProtein(objects::CBioseq &bioseq)
void SetProductId(const string &val)
CRef< objects::CSeq_id > GetProductId()
void SetCitations(objects::CSeq_feat &seq_feat)
void AddCommand(IEditCommand &command)
void PopulateDbxrefs(objects::CSeq_feat &seq_feat)
CRef< CCmdComposite > x_HandleCdsProduct(const objects::CSeq_feat &old_cds, objects::CSeq_feat &cds)
void x_SetGbQuals(objects::CSeq_feat &edited_feat)
void x_AdjustCircularGene(CRef< objects::CSeq_feat > adjusted_gene, const objects::CSeq_loc &new_loc)
void x_SetCitations(objects::CSeq_feat &edited_feat)
void x_SetTranslExcept(objects::CSeq_feat &cds)
void x_SetInferences(objects::CSeq_feat &edited_feat)
virtual IEditCommand * GetEditCommand()
After placing the window in the Edit Object Dialog ShowModal() method of the dialog is called.
objects::CSeq_feat & x_GetSeqFeatCopy()
void x_ConvertCommentToMiscFeat(objects::CSeq_feat &edited_seq_feat)
void x_AdjustLocation(objects::CSeq_feat &edited_feat)
void x_AddCodingRegionProteinNamePanel(objects::CProt_ref &prot)
CRef< CSerialObject > m_EditedFeature
bool x_IsCircular(const objects::CSeq_loc &loc)
void x_SetIdentifiers(objects::CSeq_feat &edited_feat)
virtual wxWindow * CreateWindow(wxWindow *parent)
creates a child (not top level) windows that can contain whatever controls/subwindows etc.
objects::CSeq_entry_Handle m_SEH
void x_SetExperiments(objects::CSeq_feat &edited_feat)
CRef< objects::CScope > m_Scope
CIRef< IEditCommand > m_EditAction
void x_AddCodingRegionProteinPanels(objects::CProt_ref &prot, objects::CSeq_feat *edited_protein)
CIRef< IEditCommand > x_AdjustGene(const objects::CSeq_feat &old_gene, const objects::CSeq_loc &old_loc, const objects::CSeq_loc &new_loc, CRef< objects::CSeq_feat > updated_gene)
CRef< CSerialObject > m_EditedProtein
void x_SetCrossRefs(objects::CSeq_feat &edited_feat)
void OnPageChange(wxBookCtrlEvent &event)
wxWindow * CreateWindowImpl(wxWindow *parent, objects::CSeq_feat &edited_seq_feat)
CIRef< IEditCommand > x_UpdatemRNA(const objects::CSeq_feat &cds)
void PopulateGBQuals(objects::CSeq_feat &seq_feat)
bool GetConvertToMiscFeat(void)
CFeat_CI –.
Definition: feat_ci.hpp:64
CConstRef< objects::CSeq_feat > GetGeneToEdit()
void SetModifyPseudo(bool modify_pseudo, const string &pseudo_choice)
CRef< objects::CSeq_feat > GetNewGene()
CRef< objects::CSeq_feat > GetUpdatedGene()
void PopulateGBQuals(objects::CSeq_feat &seq_feat)
static bool PanelNeeded(objects::CSeq_feat &seq_feat)
@Gb_qual.hpp User-defined methods of the data storage class.
Definition: Gb_qual.hpp:61
bool PseudoSelectionChanged() const
void PopulateIdentifiers(objects::CSeq_feat &seq_feat)
virtual bool IsImportEnabled(void)
virtual bool IsExportEnabled(void)
virtual void EnableImport(bool enable)=0
virtual void EnableExport(bool enable)=0
void PopulateImpFeat(objects::CSeq_feat &seq_feat)
void PopulateGBQuals(objects::CSeq_feat &seq_feat)
void PopulateLocAndGC(objects::CBioSource &source)
CRef< objects::CSeq_loc > GetSeq_loc() const
bool ShouldUpdatemRNALocation()
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
Base class for all object manager exceptions.
CRef< objects::CPubdesc > GetPubdesc() const
void SetGBQualPanel(CGBQualPanel *gbqual_panel)
Definition: rna_panel.cpp:257
string GetRegion()
bool GetConvertToMiscFeat(void)
CScope –.
Definition: scope.hpp:92
void SetSecondaryStructure(objects::CSeqFeatData::EPsec_str struc)
objects::CSeqFeatData::EPsec_str GetSecondaryStructure()
static const string & GetRegulatoryClass(ESubtype subtype)
void SetPub(TPub &v)
ESubtype GetSubtype(void) const
string GetKey(EVocabulary vocab=eVocabulary_full) const
const TQualifiers & GetMandatoryQualifiers(void) const
Get the list of all mandatory qualifiers for the feature.
void SetCdregion(TCdregion &v)
static EQualifier GetQualifierType(CTempString qual)
convert qual string to enumerated value
static CTempString GetQualifierAsString(EQualifier qual)
Convert a qualifier from an enumerated value to a string representation or empty if not found.
static bool IsRegulatory(ESubtype subtype)
void SetGene(TGene &v)
CSeqFeatXref –.
Definition: SeqFeatXref.hpp:66
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Seq-loc iterator class – iterates all intervals from a seq-loc in the correct order.
Definition: Seq_loc.hpp:453
Base class for all serializable objects.
Definition: serialbase.hpp:150
CSeqFeatData::ESite GetSite()
Definition: site_panel.cpp:165
void TransferToOrgRef(objects::COrg_ref &org)
void TransferFromOrgRef(const objects::COrg_ref &org)
CSeq_feat_Handle GetFeatureWithId(CSeqFeatData::E_Choice type, TFeatureIdInt id) const
Definition: tse_handle.cpp:635
Interface (functor) for object editing.
virtual void SetHelpUrl(const wxString &url)=0
constexpr const_iterator begin() const
constexpr const_iterator end() const
Definition: set.hpp:45
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator begin() const
Definition: set.hpp:135
size_type size() const
Definition: set.hpp:132
bool empty() const
Definition: set.hpp:133
void erase(iterator pos)
Definition: set.hpp:151
void SetMolinfoForProtein(CRef< objects::CSeq_entry > protein, bool partial5, bool partial3)
CRef< objects::CSeq_feat > AddEmptyProteinFeatureToProtein(CRef< objects::CSeq_entry > protein, bool partial5, bool partial3)
void RemapOtherProtFeats(const objects::CSeq_feat &old_cds, objects::CSeq_feat &cds, objects::CBioseq_Handle bh, CRef< CCmdComposite > composite, bool &any_actions)
#define _(proto)
Definition: ct_nlmzip_i.h:78
USING_SCOPE(objects)
bool s_ShouldSetFeaturePartial(const CSeq_loc &loc, CRef< CScope > scope)
bool s_ShouldSetGenePartialStart(const CSeq_loc &gene_loc, const CSeq_loc &cds_loc)
const char * kTransSplicing
void ConvertRegulatoryFeature(CSeq_feat &feat)
CConstRef< CSeq_feat > s_GetmRNAForCDS(const CSeq_feat &cds, const CSeq_feat &orig_cds, CScope &scope)
static const CBioseq * GetCDSProductSeq(const CSeq_feat *feat, CScope &scope)
bool s_ShouldSetGenePartialStop(const CSeq_loc &gene_loc, const CSeq_loc &cds_loc)
static const CSeq_feat * GetFeatureProtein(const CSeq_feat *feat, CScope &scope)
std::ofstream out("events_result.xml")
main entry point for tests
static void cleanup(void)
Definition: ct_dynamic.c:30
static char tmp[3200]
Definition: utf8.c:42
int offset
Definition: replacements.h:160
static const char location[]
Definition: config.c:97
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
#define _TRACE(message)
Definition: ncbidbg.hpp:122
#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
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
objects::CSeq_feat_Handle GetSeqFeatHandleForBadLocFeature(const objects::CSeq_feat &feat, objects::CScope &scope)
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
virtual const CTypeInfo * GetThisTypeInfo(void) const =0
virtual bool Equals(const CSerialObject &object, ESerialRecursionMode how=eRecursive) const
Check if both objects contain the same values.
@ eSerial_AsnText
ASN.1 text.
Definition: serialdef.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:2040
@ eFasta
Tagged ID in NCBI's traditional FASTA style.
Definition: Seq_id.hpp:607
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
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
Definition: Seq_loc.cpp:915
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
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
bool IsPartialStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:3251
TSeqPos GetStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:963
static CObjectOStream * Open(ESerialDataFormat format, CNcbiOstream &outStream, bool deleteOutStream)
Create serial object writer and attach it to an output stream.
Definition: objostr.cpp:126
CMappedFeat GetBestOverlappingFeat(const CMappedFeat &feat, CSeqFeatData::ESubtype need_subtype, sequence::EOverlapType overlap_type, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0)
Definition: feature.cpp:3653
TSeqPos GetLength(const CSeq_id &id, CScope *scope)
Get sequence length if scope not null, else return max possible TSeqPos.
int SeqLocPartialCheck(const CSeq_loc &loc, CScope *scope)
sequence::ECompare Compare(const CSeq_loc &loc1, const CSeq_loc &loc2, CScope *scope)
Returns the sequence::ECompare containment relationship between CSeq_locs.
ECompare
@ eSeqlocPartial_Nostart
@ eSeqlocPartial_Nostop
@ eSeqlocPartial_Internal
@ eSeqlocPartial_Nointernal
@ eSeqlocPartial_Other
@ eSeqlocPartial_Stop
@ eSeqlocPartial_Start
@ fCompareOverlapping
Check if seq-locs are overlapping.
@ eOverlap_CheckIntRev
1st is a subset of 2nd with matching boundaries
@ eContains
First CSeq_loc contains second.
@ eSame
CSeq_locs contain each other.
@ eContained
First CSeq_loc contained by second.
@ eNoOverlap
CSeq_locs do not overlap or abut.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
const CTSE_Handle & GetTSE_Handle(void) const
Get CTSE_Handle of containing TSE.
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
virtual CConstRef< CSeq_feat > GetSeq_feat(void) const
TSeqPos GetBioseqLength(void) const
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
TInst_Topology GetInst_Topology(void) const
bool IsSetInst_Topology(void) const
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
const CSeq_loc & GetLocation(void) const
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: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 bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
Definition: ncbistr.cpp:2891
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2697
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:5353
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
Definition: ncbistr.hpp:5384
TObjectPtr Create(CObjectMemoryPool *memoryPool=0) const
Create object of this type on heap (can be deleted by operator delete)
static const char label[]
const TName & GetName(void) const
Get the Name member data.
Definition: Prot_ref_.hpp:378
bool IsSetName(void) const
protein name Check if a value has been assigned to Name data member.
Definition: Prot_ref_.hpp:366
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 IsGen(void) const
Check if variant Gen is selected.
Definition: RNA_ref_.hpp:504
const TGen & GetGen(void) const
Get the variant data.
Definition: RNA_ref_.cpp:156
const TName & GetName(void) const
Get the variant data.
Definition: RNA_ref_.hpp:484
bool IsSetClass(void) const
for ncRNAs, the class of non-coding RNA: examples: antisense_RNA, guide_RNA, snRNA Check if a value h...
Definition: RNA_gen_.hpp:247
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 TClass & GetClass(void) const
Get the Class member data.
Definition: RNA_gen_.hpp:259
TXref & SetXref(void)
Assign a value to Xref data member.
Definition: Seq_feat_.hpp:1314
void SetQual(const TQual &value)
Assign a value to Qual data member.
Definition: Gb_qual_.hpp:221
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
void ResetPartial(void)
Reset Partial data member.
Definition: Seq_feat_.hpp:955
EPsec_str
protein secondary structure
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
Definition: Seq_feat_.hpp:913
bool IsSetQual(void) const
qualifiers Check if a value has been assigned to Qual data member.
Definition: Seq_feat_.hpp:1135
TPsec_str GetPsec_str(void) const
Get the variant data.
bool IsBond(void) const
Check if variant Bond is selected.
bool IsProt(void) const
Check if variant Prot is selected.
void SetLocation(TLocation &value)
Assign a value to Location data member.
Definition: Seq_feat_.cpp:131
bool IsCdregion(void) const
Check if variant Cdregion is selected.
bool IsImp(void) const
Check if variant Imp is selected.
void SetComment(const TComment &value)
Assign a value to Comment data member.
Definition: Seq_feat_.hpp:1058
void SetPartial(TPartial value)
Assign a value to Partial data member.
Definition: Seq_feat_.hpp:971
const TQual & GetQual(void) const
Get the Qual member data.
Definition: Seq_feat_.hpp:1147
bool IsSetKey(void) const
Check if a value has been assigned to Key data member.
Definition: Imp_feat_.hpp:247
bool IsSetXref(void) const
cite other relevant features Check if a value has been assigned to Xref data member.
Definition: Seq_feat_.hpp:1296
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
void SetExcept(TExcept value)
Assign a value to Except data member.
Definition: Seq_feat_.hpp:1018
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
const TExcept_text & GetExcept_text(void) const
Get the Except_text member data.
Definition: Seq_feat_.hpp:1405
bool IsPub(void) const
Check if variant Pub is selected.
void ResetData(void)
Reset Data data member.
Definition: Seq_feat_.cpp:85
bool IsSetExcept_text(void) const
explain if except=TRUE Check if a value has been assigned to Except_text data member.
Definition: Seq_feat_.hpp:1393
bool IsPsec_str(void) const
Check if variant Psec_str is selected.
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
const TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1096
const TComment & GetComment(void) const
Get the Comment member data.
Definition: Seq_feat_.hpp:1049
void SetVal(const TVal &value)
Assign a value to Val data member.
Definition: Gb_qual_.hpp:268
bool IsBiosrc(void) const
Check if variant Biosrc is selected.
void SetExcept_text(const TExcept_text &value)
Assign a value to Except_text data member.
Definition: Seq_feat_.hpp:1414
const TProt & GetProt(void) const
Get the variant data.
bool IsSite(void) const
Check if variant Site is selected.
const TXref & GetXref(void) const
Get the Xref member data.
Definition: Seq_feat_.hpp:1308
vector< CRef< CSeqFeatXref > > TXref
Definition: Seq_feat_.hpp:122
void ResetProduct(void)
Reset Product data member.
Definition: Seq_feat_.cpp:105
vector< CRef< CGb_qual > > TQual
Definition: Seq_feat_.hpp:117
bool IsComment(void) const
Check if variant Comment is selected.
void ResetXref(void)
Reset Xref data member.
Definition: Seq_feat_.cpp:182
const TRna & GetRna(void) const
Get the variant data.
TQual & SetQual(void)
Assign a value to Qual data member.
Definition: Seq_feat_.hpp:1153
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
Definition: Seq_feat_.hpp:1084
bool IsRna(void) const
Check if variant Rna is selected.
bool IsRegion(void) const
Check if variant Region is selected.
void ResetQual(void)
Reset Qual data member.
Definition: Seq_feat_.cpp:136
const TImp & GetImp(void) const
Get the variant data.
bool IsSetLocation(void) const
feature made from Check if a value has been assigned to Location data member.
Definition: Seq_feat_.hpp:1105
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
TSeq & SetSeq(void)
Select the variant.
Definition: Seq_entry_.cpp:108
TRepr GetRepr(void) const
Get the Repr member data.
Definition: Seq_inst_.hpp:565
TId & SetId(void)
Assign a value to Id data member.
Definition: Bioseq_.hpp:296
const TInst & GetInst(void) const
Get the Inst member data.
Definition: Bioseq_.hpp:336
bool IsSetRepr(void) const
Check if a value has been assigned to Repr data member.
Definition: Seq_inst_.hpp:546
const TId & GetId(void) const
Get the Id member data.
Definition: Bioseq_.hpp:290
bool IsSetInst(void) const
the sequence data Check if a value has been assigned to Inst data member.
Definition: Bioseq_.hpp:324
bool IsSetId(void) const
equivalent identifiers Check if a value has been assigned to Id data member.
Definition: Bioseq_.hpp:278
@ eRepr_not_set
empty
Definition: Seq_inst_.hpp:92
int i
#define wxT(x)
Definition: muParser.cpp:41
range(_Ty, _Ty) -> range< _Ty >
ESERV_Site site
T max(T x_, T y_)
void TestForNonAsciiText(wxWindow *win)
#define FOR_EACH_SEQFEATXREF_ON_SEQFEAT(Itr, Var)
FOR_EACH_SEQFEATXREF_ON_SEQFEAT EDIT_EACH_SEQFEATXREF_ON_SEQFEAT.
SAnnotSelector –.
Definition: inftrees.h:24
#define _ASSERT
CRef< CCmdComposite > GetSynchronizeProductMolInfoCommand(objects::CScope &scope, const objects::CSeq_feat &cds)
CRef< CCmdComposite > CreateOrAdjustProteinFeature(objects::CBioseq_Handle product, objects::CSeq_feat &cds, bool &cds_change)
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
Modified on Wed Jun 19 17:01:47 2024 by modify_doxy.py rev. 669887