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

Go to the SVN repository for this file.

1 /* $Id: cds_to_mat_peptide.cpp 42167 2019-01-08 17:17:20Z 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 
45 #include <objmgr/seq_vector.hpp>
46 #include <objmgr/util/sequence.hpp>
61 ////@begin XPM images
62 ////@end XPM images
63 
65 
67 
68 /*!
69  * CCdsToMatPeptide type definition
70  */
71 
72 IMPLEMENT_DYNAMIC_CLASS( CCdsToMatPeptide, CBulkCmdDlg )
73 
74 
75 /*!
76  * CCdsToMatPeptide event table definition
77  */
78 
79 BEGIN_EVENT_TABLE( CCdsToMatPeptide, CBulkCmdDlg )
80 
81 ////@begin CCdsToMatPeptide event table entries
84 ////@end CCdsToMatPeptide event table entries
85 
87 
88 
89 /*!
90  * CCdsToMatPeptide constructors
91  */
92 
94 {
95  Init();
96 }
97 
98 CCdsToMatPeptide::CCdsToMatPeptide( wxWindow* parent, IWorkbench* wb, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
99  : CBulkCmdDlg(wb)
100 {
101  Init();
102  Create(parent, id, caption, pos, size, style);
103 }
104 
105 
106 /*!
107  * CCdsToMatPeptide creator
108  */
109 
110 bool CCdsToMatPeptide::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
111 {
112 ////@begin CCdsToMatPeptide creation
113  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
114  CBulkCmdDlg::Create( parent, id, caption, pos, size, style );
115 
116  CreateControls();
117  if (GetSizer())
118  {
119  GetSizer()->SetSizeHints(this);
120  }
121  Centre();
122 ////@end CCdsToMatPeptide creation
123  return true;
124 }
125 
126 
127 /*!
128  * CCdsToMatPeptide destructor
129  */
130 
132 {
133 ////@begin CCdsToMatPeptide destruction
134 ////@end CCdsToMatPeptide destruction
135 }
136 
137 
138 /*!
139  * Member initialisation
140  */
141 
143 {
144 ////@begin CCdsToMatPeptide member initialisation
145  m_OkCancel = NULL;
146 ////@end CCdsToMatPeptide member initialisation
147  m_ErrorMessage = "";
149  string field_name = "CDS " + kPartialStart;
150  m_col.Reset(new CMiscSeqTableColumn(field_name));
151 }
152 
153 
154 /*!
155  * Control creation for CCdsToMatPeptide
156  */
157 
159 {
160 ////@begin CCdsToMatPeptide content construction
161  CCdsToMatPeptide* itemCBulkCmdDlg1 = this;
162 
163  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
164  itemCBulkCmdDlg1->SetSizer(itemBoxSizer2);
165 
166 
168 
169  m_Inner = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("Convert inner CDSs to mat_peptides"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
170  m_Inner->SetValue(true);
171  itemBoxSizer2->Add(m_Inner, 0, wxALIGN_LEFT|wxALL, 5);
172 
173  m_Merge = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("Merge multiple CDSs to one CDS and convert inner CDSs to mat_peptides"), wxDefaultPosition, wxDefaultSize, 0 );
174  m_Merge->SetValue(false);
175  itemBoxSizer2->Add(m_Merge, 0, wxALIGN_LEFT|wxALL, 5);
176 
177  m_Each = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("Create mat_peptide from protein on each CDS"), wxDefaultPosition, wxDefaultSize, 0 );
178  m_Each->SetValue(false);
179  itemBoxSizer2->Add(m_Each, 0, wxALIGN_LEFT|wxALL, 5);
180 
181  m_EntireRange = new wxCheckBox( itemCBulkCmdDlg1, wxID_ANY, _("New CDS should cover the entire sequence"), wxDefaultPosition, wxDefaultSize, 0 );
182  itemBoxSizer2->Add(m_EntireRange, 0, wxALIGN_LEFT|wxALL, 5);
183 
184  m_ProductFirst = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("Use product name from first CDS"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
185  m_ProductFirst->SetValue(true);
186  itemBoxSizer2->Add(m_ProductFirst, 0, wxALIGN_LEFT|wxALL, 5);
187 
188  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
189  itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_LEFT, 0);
190  m_ProductThis = new wxRadioButton( itemCBulkCmdDlg1, wxID_ANY, _("Use this product name"), wxDefaultPosition, wxDefaultSize, 0 );
191  m_ProductThis->SetValue(false);
192  itemBoxSizer3->Add(m_ProductThis, 0, wxALIGN_LEFT|wxALL, 5);
193  m_ProductName = new wxTextCtrl( itemCBulkCmdDlg1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
194  itemBoxSizer3->Add(m_ProductName, 0, wxALIGN_LEFT|wxALL, 5);
195 
196  m_FeatureConstraint = new CFeatureFieldNamePanel(itemCBulkCmdDlg1, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
197  itemBoxSizer2->Add(m_FeatureConstraint, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
199 
200  m_StringConstraintPanel = new CStringConstraintPanel( itemCBulkCmdDlg1, false, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
201  itemBoxSizer2->Add(m_StringConstraintPanel, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxFIXED_MINSIZE, 0);
202 
203  m_OkCancel = new COkCancelPanel( itemCBulkCmdDlg1, wxID_ANY, wxDefaultPosition, wxSize(100, 100), 0 );
204  itemBoxSizer2->Add(m_OkCancel, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
205 
206 ////@end CCdsToMatPeptide content construction
207  m_EntireRange->Disable();
208  m_ProductFirst->Disable();
209  m_ProductThis->Disable();
210  m_ProductName->Disable();
211  m_StringConstraintPanel->Disable();
212  m_FeatureConstraint->Disable();
213 }
214 
215 
216 /*!
217  * Should we show tooltips?
218  */
219 
221 {
222  return true;
223 }
224 
225 /*!
226  * Get bitmap resources
227  */
228 
229 wxBitmap CCdsToMatPeptide::GetBitmapResource( const wxString& name )
230 {
231  // Bitmap retrieval
232 ////@begin CCdsToMatPeptide bitmap retrieval
233  wxUnusedVar(name);
234  return wxNullBitmap;
235 ////@end CCdsToMatPeptide bitmap retrieval
236 }
237 
238 /*!
239  * Get icon resources
240  */
241 
242 wxIcon CCdsToMatPeptide::GetIconResource( const wxString& name )
243 {
244  // Icon retrieval
245 ////@begin CCdsToMatPeptide icon retrieval
246  wxUnusedVar(name);
247  return wxNullIcon;
248 ////@end CCdsToMatPeptide icon retrieval
249 }
250 
251 
252 
254 {
255  return m_ErrorMessage;
256 }
257 
258 
260 {
261 
262  CRef<CCmdComposite> cmd(new CCmdComposite("Convert Features"));
263 
264  if (m_Each->GetValue())
265  {
266  ConvertEach(cmd);
267  }
268  else if (m_Merge->GetValue())
269  {
270  MergeConvert(cmd);
271  }
272  else if (m_Inner->GetValue())
273  {
274  ConvertInner(cmd);
275  }
276 
277  return cmd;
278 }
279 
281 {
282  CRef<edit::CStringConstraint> string_constraint(NULL);
283  vector<CConstRef<CObject> > objs;
284  objs = m_col->GetObjects(m_TopSeqEntry, kEmptyStr, string_constraint);
285 
286  bool leave_original = true;
287  ITERATE(vector<CConstRef<CObject> >, it, objs) {
288  const CSeq_feat* f = dynamic_cast<const CSeq_feat* >((*it).GetPointer());
289  CRef<CCmdComposite> subcmd = m_converter->Convert(*f, leave_original, m_TopSeqEntry.GetScope());
290  if (subcmd) {
291  cmd->AddCommand(*subcmd);
292  }
293  }
294 }
295 
297 {
298  CScope &scope = m_TopSeqEntry.GetScope();
300  string constraint_field = m_FeatureConstraint->GetFieldName(false);
301  bool create_general_only = objects::edit::IsGeneralIdProtPresent(m_TopSeqEntry);
302  for (CBioseq_CI bi(m_TopSeqEntry, objects::CSeq_inst::eMol_na); bi; ++bi)
303  {
304  CBioseq_Handle bsh = *bi;
306  if (!seh.IsSet())
307  {
309  if (bss)
310  seh = bss.GetParentEntry();
311  }
312  vector<CConstRef<CObject> > objs;
313  objs = m_col->GetObjects(seh, constraint_field, string_constraint);
314  if (objs.empty())
315  continue;
316  CRef<objects::CSeq_id> prot_id(new objects::CSeq_id());
317  int offset = 1;
318  string id_label;
319  prot_id->Assign(*objects::edit::GetNewProtId(bsh, offset, id_label, create_general_only));
320 
321  CRef<CSeq_feat> new_cds(new CSeq_feat);
322  CRef<CSeq_loc> new_loc(new CSeq_loc);
323  CRef<CSeq_annot> annot;
324  CRef<CSeq_entry> new_entry(new CSeq_entry);
325  new_entry->Assign(*seh.GetCompleteSeq_entry());
326  string new_product;
327  vector<string> products;
328  bool first = true;
329  ITERATE(vector<CConstRef<CObject> >, it, objs)
330  {
331  const CSeq_feat* f = dynamic_cast<const CSeq_feat* >((*it).GetPointer());
332  string product = m_converter->x_GetCDSProduct(*f, scope);
333  products.push_back(product);
334  if (first)
335  {
336  new_cds->Assign(*f);
337  new_loc->Assign(f->GetLocation());
338  new_product = product;
339  FindAnnot(new_entry, f, annot);
340  first = false;
341  }
342  else
343  {
344  CRef<CSeq_loc> add_loc(new CSeq_loc);
345  add_loc->Assign(f->GetLocation());
346  new_loc->Assign(*(sequence::Seq_loc_Add(*new_loc, *add_loc, CSeq_loc::fMerge_All|CSeq_loc::fSort, &scope)));
347  }
348 
349  }
350 
351  if (m_EntireRange->GetValue())
352  {
353  new_loc = bsh.GetRangeSeq_loc(0,0);
354  }
355  new_cds->SetLocation(*new_loc);
356  new_cds->SetProduct().SetWhole().Assign(*prot_id);
357  annot->SetData().SetFtable().push_back(new_cds);
358 
359  CRef<CSeq_annot> prot_annot(new CSeq_annot);
360  CRef<objects::CBioseq> protein = CSeqTranslator::TranslateToProtein (*new_cds, scope);
361  protein->SetId().push_back(prot_id);
362  CRef<objects::CSeqdesc> pdesc(new objects::CSeqdesc());
363  pdesc->SetMolinfo().SetBiomol(objects::CMolInfo::eBiomol_peptide);
364  pdesc->SetMolinfo().SetCompleteness(objects::CMolInfo::eCompleteness_complete);
366  {
367  pdesc->SetMolinfo().SetCompleteness(objects::CMolInfo::eCompleteness_no_left);
368  }
370  {
371  if (pdesc->GetMolinfo().GetCompleteness() == objects::CMolInfo::eCompleteness_complete) {
372  pdesc->SetMolinfo().SetCompleteness(objects::CMolInfo::eCompleteness_no_right);
373  } else {
374  pdesc->SetMolinfo().SetCompleteness(objects::CMolInfo::eCompleteness_no_ends);
375  }
376  }
377  protein->SetDescr().Set().push_back(pdesc);
378  CRef<objects::CSeq_feat> prot_feat(new CSeq_feat);
379  prot_feat->SetData().SetProt();
380  if (m_ProductThis->GetValue())
381  {
382  new_product = m_ProductName->GetValue().ToStdString();
383  }
384  prot_feat->SetData().SetProt().SetName().push_back(new_product);
385  prot_feat->SetLocation().SetInt().SetId(*prot_id);
386  prot_feat->SetLocation().SetInt().SetFrom(0);
387  prot_feat->SetLocation().SetInt().SetTo(protein->GetLength() - 1);
388  prot_feat->SetLocation().SetPartialStart(new_cds->GetLocation().IsPartialStart(objects::eExtreme_Biological), objects::eExtreme_Biological);
389  prot_feat->SetLocation().SetPartialStop(new_cds->GetLocation().IsPartialStop(objects::eExtreme_Biological), objects::eExtreme_Biological);
391 
392  prot_annot->SetData().SetFtable().push_back(prot_feat);
393  protein->SetAnnot().push_back(prot_annot);
394  CRef<CSeq_entry> prot_entry(new CSeq_entry);
395  prot_entry->SetSeq(*protein);
396  new_entry->SetSet().SetSeq_set().push_back(prot_entry);
397 
399  explicit_seq_info->AddSeq(CSeq_id_Handle::GetHandle(*new_cds->GetProduct().GetId()), CSeq_loc_Mapper::eSeq_prot, protein->GetLength());
400  explicit_seq_info->AddSynonym(CSeq_id_Handle::GetHandle(*new_cds->GetProduct().GetId()),CSeq_id_Handle::GetHandle(*new_cds->GetProduct().GetId()));
401  for (size_t i = 0; i < bsh.GetId().size(); i++)
402  {
403  explicit_seq_info->AddSeq(bsh.GetId()[i], CSeq_loc_Mapper::eSeq_nuc, bsh.GetBioseqLength());
404  explicit_seq_info->AddSynonym(CSeq_id_Handle::GetHandle(*new_cds->GetLocation().GetId()),bsh.GetId()[i]);
405  }
406 
407 
408  size_t i = 0;
409  ITERATE(vector<CConstRef<CObject> >, it, objs)
410  {
411  const CSeq_feat* f = dynamic_cast<const CSeq_feat* >((*it).GetPointer());
413  mapper.SetMergeAbutting();
414  // change made for GB-7810
415  CRef<CSeq_loc> loc = mapper.MapTotalRange(f->GetLocation());
416  loc->SetId(*prot_id);
417  if (loc->GetStop(objects::eExtreme_Positional) >= protein->GetLength())
418  {
419  bool partial_stop = loc->IsPartialStop(objects::eExtreme_Positional);
420  CSeq_loc sub(*prot_id, protein->GetLength(), loc->GetStop(objects::eExtreme_Positional), loc->GetStrand());
422  loc->SetPartialStop(partial_stop, objects::eExtreme_Positional);
423  }
424  CRef<CSeq_feat> mat_peptide(new CSeq_feat);
425  mat_peptide->Assign(*f);
426  mat_peptide->SetLocation(*loc);
428  if (i < products.size())
429  mat_peptide->SetData().SetProt().SetName().push_back(products[i++]);
430  mat_peptide->SetData().SetProt().SetProcessed(CProt_ref::eProcessed_mature);
431  mat_peptide->ResetProduct();
432  prot_annot->SetData().SetFtable().push_back(mat_peptide);
433  }
434 
435  ITERATE(vector<CConstRef<CObject> >, it, objs)
436  {
437  const CSeq_feat* f = dynamic_cast<const CSeq_feat* >((*it).GetPointer());
438  CConstRef<CSeq_feat> gene = sequence::GetOverlappingGene(f->GetLocation(), scope);
439  if (gene)
440  {
441  RemoveFeature(new_entry, gene.GetPointer());
442  }
443  CConstRef<CSeq_feat> mrna = sequence::GetOverlappingmRNA(f->GetLocation(), scope);
444  if (mrna)
445  {
446  RemoveFeature(new_entry, mrna.GetPointer());
447  }
448  RemoveProteins(new_entry, f, seh);
449  RemoveFeature(new_entry, f);
450  }
451  cmd->AddCommand(*CRef<CCmdChangeSeqEntry>(new CCmdChangeSeqEntry(seh, new_entry)));
452  }
453 }
454 
456 {
457  CScope &scope = m_TopSeqEntry.GetScope();
459  GetProductToCDSMap(scope, product_to_cds);
460  CRef<edit::CStringConstraint> string_constraint(NULL);
461  vector<CConstRef<CObject> > objs;
462  objs = m_col->GetObjects(m_TopSeqEntry, kEmptyStr, string_constraint);
463  bool leave_original = false;
464  set<CSeq_feat_Handle> already_converted;
465  ITERATE(vector<CConstRef<CObject> >, it, objs) {
466  const CSeq_feat* f = dynamic_cast<const CSeq_feat* >((*it).GetPointer());
467  if (f->IsSetData() && f->GetData().GetSubtype() == CSeqFeatData::eSubtype_cdregion)
468  {
469  CSeq_feat_Handle fh = scope.GetSeq_featHandle(*f);
470  sequence::TFeatScores feats;
472  for (size_t i = 0; i < feats.size(); i++)
473  {
474  CConstRef<CSeq_feat> inner = feats[i].second;
475  CSeq_feat_Handle inner_fh = scope.GetSeq_featHandle(*inner);
476  if (!inner->Equals(*f) && already_converted.find(inner_fh) == already_converted.end()) //&& feature::IsLocationInFrame(fh,inner->GetLocation()) == feature::eLocationInFrame_InFrame)
477  {
478  already_converted.insert(inner_fh);
480  mapper.SetMergeAbutting();
481  // for GB-7810, need to use MapTotalRange to get correct location mapping when ribosomal slippage is present
482  //CRef<CSeq_loc> loc = mapper.Map(inner->GetLocation());
483  CRef<CSeq_loc> loc = mapper.MapTotalRange(inner->GetLocation());
484  CRef<CSeq_feat> mat_peptide(new CSeq_feat);
485  mat_peptide->Assign(*inner);
486  mat_peptide->SetLocation(*loc);
487  string product = m_converter->x_GetCDSProduct(*inner, scope);
488  mat_peptide->SetData().SetProt().SetName().push_back(product);
489  mat_peptide->SetData().SetProt().SetProcessed(CProt_ref::eProcessed_mature);
490  mat_peptide->ResetProduct();
491  mat_peptide->ResetComment();
492  CBioseq_Handle prot_bsh2 = scope.GetBioseqHandle(inner->GetProduct());
493  if (prot_bsh2 && prot_bsh2.IsProtein())
494  {
495  CFeat_CI prot_feat_ci(prot_bsh2, CSeqFeatData::e_Prot);
496  if (prot_feat_ci && prot_feat_ci->GetOriginalFeature().IsSetData() && prot_feat_ci->GetOriginalFeature().GetData().IsProt()
497  && prot_feat_ci->GetOriginalFeature().GetData().GetProt().IsSetDesc())
498  {
499  mat_peptide->SetData().SetProt().SetDesc(prot_feat_ci->GetOriginalFeature().GetData().GetProt().GetDesc());
500  }
501  }
502  CBioseq_Handle prot_bsh = scope.GetBioseqHandle(f->GetProduct());
503  if (mat_peptide->GetLocation().GetStop(eExtreme_Biological) > prot_bsh.GetInst_Length() - 1) {
504  // need to truncate
505  if (mat_peptide->GetLocation().IsInt()) {
506  mat_peptide->SetLocation().SetInt().SetTo(prot_bsh.GetInst_Length() - 1);
507  }
508  }
509 
510  CSeq_entry_Handle seh = prot_bsh.GetSeq_entry_Handle();
511  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(seh, *mat_peptide)));
512  cmd->AddCommand(*GetDeleteFeatureCommand(inner_fh, true, product_to_cds));
513  // cmd->AddCommand(*CRef<CCmdDelSeq_feat>(new CCmdDelSeq_feat(inner_fh)));
514  }
515  }
516  }
517  }
518 }
519 
521 {
522  CSeq_entry::TAnnot::iterator annot_it = entry->SetAnnot().begin();
523  while ( annot_it != entry->SetAnnot().end() )
524  {
525  if ((*annot_it)->IsSetData() && (*annot_it)->GetData().IsFtable())
526  {
527  EDIT_EACH_SEQFEAT_ON_SEQANNOT(feat_it, **annot_it)
528  {
529  if ((*feat_it)->IsSetData() && (*feat_it)->GetData().GetSubtype() == feat->GetData().GetSubtype() && feat->Equals(**feat_it))
530  {
531  ERASE_SEQFEAT_ON_SEQANNOT(feat_it, **annot_it);
532  }
533  }
534  if ((*annot_it)->GetData().GetFtable().empty())
535  {
536  annot_it = entry->SetAnnot().erase(annot_it);
537  }
538  else
539  ++annot_it;
540  }
541  else
542  ++annot_it;
543  }
544  if (entry->GetAnnot().empty())
545  {
546  if (entry->IsSet())
547  entry->SetSet().ResetAnnot();
548  else if (entry->IsSeq())
549  entry->SetSeq().ResetAnnot();
550  }
551 
552  if (entry->IsSet())
553  {
554  EDIT_EACH_SEQENTRY_ON_SEQSET(entry_it, entry->SetSet())
555  {
556  RemoveFeature(*entry_it, feat);
557  }
558  }
559 }
560 
561 
563 {
564  if (feat->IsSetProduct() && !validator::IsFarLocation(feat->GetProduct(), seh) && entry->IsSet())
565  {
566  EDIT_EACH_SEQENTRY_ON_SEQSET(entry_it, entry->SetSet())
567  {
568  if ((*entry_it)->IsSeq() && (*entry_it)->GetSeq().IsAa() && (*entry_it)->GetSeq().GetFirstId()->Match(*feat->GetProduct().GetId()))
569  {
570  ERASE_SEQENTRY_ON_SEQSET(entry_it, entry->SetSet());
571  }
572  }
573  }
574 }
575 
576 void CCdsToMatPeptide::OnRadioButton(wxCommandEvent& event)
577 {
578  if ( m_Merge->GetValue())
579  {
580  m_EntireRange->Enable();
581  m_ProductFirst->Enable();
582  m_ProductThis->Enable();
583  m_ProductName->Enable();
584  m_StringConstraintPanel->Enable();
585  m_FeatureConstraint->Enable();
586  }
587  else
588  {
589  m_EntireRange->Disable();
590  m_ProductFirst->Disable();
591  m_ProductThis->Disable();
592  m_ProductName->Disable();
593  m_StringConstraintPanel->Disable();
594  m_FeatureConstraint->Disable();
595  }
596  event.Skip();
597 }
598 
600 {
601  CSeq_entry::TAnnot::iterator annot_it = entry->SetAnnot().begin();
602  while ( annot_it != entry->SetAnnot().end() )
603  {
604  if ((*annot_it)->IsSetData() && (*annot_it)->GetData().IsFtable())
605  {
606  FOR_EACH_SEQFEAT_ON_SEQANNOT(feat_it, **annot_it)
607  {
608  if ((*feat_it)->IsSetData() && (*feat_it)->GetData().GetSubtype() == feat->GetData().GetSubtype() && feat->Compare(**feat_it) == 0)
609  {
610  annot = *annot_it;
611  break;
612  }
613  }
614 
615  }
616  if (annot)
617  break;
618  ++annot_it;
619  }
620 
621  if (!annot && entry->IsSet())
622  {
623  FOR_EACH_SEQENTRY_ON_SEQSET(entry_it, entry->SetSet())
624  {
625  FindAnnot(*entry_it, feat, annot);
626  }
627  }
628 }
629 
630 void CCdsToMatPeptide::ProcessUpdateFeatEvent( wxCommandEvent& event )
631 {
632  UpdateChildrenFeaturePanels(this->GetSizer());
633 }
634 
636 {
637  wxSizerItemList& slist = sizer->GetChildren();
638  int n =0;
639  for (wxSizerItemList::iterator iter = slist.begin(); iter != slist.end(); ++iter, ++n) {
640  if ((*iter)->IsSizer()) {
641  UpdateChildrenFeaturePanels((*iter)->GetSizer());
642  } else if ((*iter)->IsWindow()) {
643  wxWindow* child = (*iter)->GetWindow();
644  if (child) {
645  CFeatureTypePanel* panel = dynamic_cast<CFeatureTypePanel*>(child);
646  if (panel) {
648  } else {
649  wxSizer* subsizer = child->GetSizer();
650  if (subsizer) {
651  UpdateChildrenFeaturePanels(subsizer);
652  }
653  }
654  }
655  }
656  }
657 }
658 
659 
661 {
662  m_SeqType[idh] = seq_type;
663  m_SeqLen[idh] = seq_len;
664 
665  CConstRef<CSeq_id> id = idh.GetSeqId();
666  CSeq_id::TSeqIdHandles matches;
667  id->GetMatchingIds(matches);
668  ITERATE(CSeq_id::TSeqIdHandles, mit, matches)
669  {
670  m_SeqType[*mit] = seq_type;
671  m_SeqLen[*mit] = seq_len;
672  }
673 }
674 
676 {
677  return m_SeqType[idh];
678 }
679 
681 {
682  return m_SeqLen[idh];
683 }
684 
686 {
687  synonyms.insert(m_Synonyms[idh].begin(), m_Synonyms[idh].end());
688 }
689 
691 {
692  m_Synonyms[idh1].insert(idh1);
693  m_Synonyms[idh1].insert(idh2);
694  for (set<CSeq_id_Handle>::iterator it = m_Synonyms[idh1].begin(); it != m_Synonyms[idh1].end(); ++it)
695  {
696  m_Synonyms[*it].insert(m_Synonyms[idh1].begin(), m_Synonyms[idh1].end());
697  }
698 }
699 
701 
702 
703 
704 
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
@ eExtreme_Biological
5' and 3'
Definition: Na_strand.hpp:62
CRef< objects::CSeq_id > GetNewProtId(objects::CBioseq_Handle bsh, int &offset, string &id_label, bool general_only)
bool IsGeneralIdProtPresent(objects::CSeq_entry_Handle tse)
USING_SCOPE(ncbi::objects)
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
CBioseq_set_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()
void UpdateChildrenFeaturePanels(wxSizer *sizer)
void FindAnnot(CRef< CSeq_entry > entry, const CSeq_feat *feat, CRef< CSeq_annot > &annot)
wxCheckBox * m_EntireRange
~CCdsToMatPeptide()
Destructor.
void ConvertEach(CRef< CCmdComposite > cmd)
virtual CRef< CCmdComposite > GetCommand()
void RemoveFeature(CRef< CSeq_entry > entry, const CSeq_feat *feat)
void MergeConvert(CRef< CCmdComposite > cmd)
wxRadioButton * m_Merge
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
wxRadioButton * m_Each
CStringConstraintPanel * m_StringConstraintPanel
CRef< CMiscSeqTableColumn > m_col
CFeatureFieldNamePanel * m_FeatureConstraint
virtual string GetErrorMessage()
void RemoveProteins(CRef< CSeq_entry > entry, const CSeq_feat *feat, CSeq_entry_Handle seh)
CRef< CConvertFeatureBase > m_converter
static bool ShowToolTips()
Should we show tooltips?
CCdsToMatPeptide()
Constructors.
wxRadioButton * m_Inner
COkCancelPanel * m_OkCancel
void ConvertInner(CRef< CCmdComposite > cmd)
void OnRadioButton(wxCommandEvent &event)
wxRadioButton * m_ProductFirst
void Init()
Initialises member variables.
wxTextCtrl * m_ProductName
void CreateControls()
Creates the controls and sizers.
wxRadioButton * m_ProductThis
bool Create(wxWindow *parent, wxWindowID id=10568, const wxString &caption=_("Convert CDS to Mat-peptide"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(900, 500), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
void ProcessUpdateFeatEvent(wxCommandEvent &event)
static CRef< CConvertFeatureBase > Create(objects::CSeqFeatData::ESubtype subtype_from, objects::CSeqFeatData::ESubtype subtype_to)
virtual CRef< CCmdComposite > Convert(const objects::CSeq_feat &orig, bool keep_orig, objects::CScope &scope)
string x_GetCDSProduct(const objects::CSeq_feat &orig, objects::CScope &scope)
map< CSeq_id_Handle, TSeqPos > m_SeqLen
map< CSeq_id_Handle, set< CSeq_id_Handle > > m_Synonyms
void AddSeq(const CSeq_id_Handle &idh, TSeqType seq_type, TSeqPos seq_len)
virtual TSeqType GetSequenceType(const CSeq_id_Handle &idh)
Get information about sequence type (nuc or prot).
map< CSeq_id_Handle, TSeqType > m_SeqType
void AddSynonym(const CSeq_id_Handle &idh1, const CSeq_id_Handle &idh2)
virtual void CollectSynonyms(const CSeq_id_Handle &id, TSynonyms &synonyms)
Collect all synonyms for the id including the id itself.
virtual TSeqPos GetSequenceLength(const CSeq_id_Handle &idh)
Get sequence length or kInvalidSeqPos.
CFeat_CI –.
Definition: feat_ci.hpp:64
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
ESubtype GetSubtype(void) const
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
const TAnnot & GetAnnot(void) const
Definition: Seq_entry.cpp:179
TAnnot & SetAnnot(void)
Definition: Seq_entry.cpp:195
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
int Compare(const CSeq_feat &f2) const
Compare relative order of this feature and feature f2, ordering first by features' coordinates,...
Definition: Seq_feat.hpp:242
CSeq_loc_Mapper_Base –.
CSeq_loc_Mapper_Options –.
CSeq_loc_Mapper –.
CRef< edit::CStringConstraint > GetStringConstraint()
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
const_iterator end() const
Definition: map.hpp:152
iterator_bool insert(const value_type &val)
Definition: map.hpp:165
Definition: map.hpp:338
Definition: set.hpp:45
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
#define _(proto)
Definition: ct_nlmzip_i.h:78
#define wxFIXED_MINSIZE
const string kPartialStart
#define EVT_UPDATE_FEATURE_LIST(id, fn)
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
static void Init(void)
Definition: cursor6.c:76
int offset
Definition: replacements.h:160
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#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.
virtual bool Equals(const CSerialObject &object, ESerialRecursionMode how=eRecursive) const
Check if both objects contain the same values.
CConstRef< CSeq_id > GetSeqId(void) const
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
bool IsPartialStart(ESeqLocExtremes ext) const
check start or stop of location for e_Lim fuzz
Definition: Seq_loc.cpp:3222
ENa_strand GetStrand(void) const
Get the location's strand.
Definition: Seq_loc.cpp:882
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Override Assign() to incorporate cache invalidation.
Definition: Seq_loc.cpp:337
void SetId(CSeq_id &id)
set the 'id' field in all parts of this location
Definition: Seq_loc.cpp:3474
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
void SetPartialStop(bool val, ESeqLocExtremes ext)
Definition: Seq_loc.cpp:3313
bool IsPartialStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:3251
TSeqPos GetStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:963
@ fMerge_All
Definition: Seq_loc.hpp:331
CRef< CSeq_loc > Seq_loc_Subtract(const CSeq_loc &loc1, const CSeq_loc &loc2, CSeq_loc::TOpFlags flags, CScope *scope)
Subtract the second seq-loc from the first one.
CRef< CSeq_loc > Seq_loc_Add(const CSeq_loc &loc1, const CSeq_loc &loc2, CSeq_loc::TOpFlags flags, CScope *scope)
Add two seq-locs.
@ eOverlap_Subset
2nd is a subset of 1st ranges
CConstRef< CSeq_feat > GetOverlappingmRNA(const CSeq_loc &loc, CScope &scope)
Definition: sequence.cpp:1572
static CRef< CBioseq > TranslateToProtein(const CSeq_feat &cds, CScope &scope)
Definition: sequence.cpp:3839
CConstRef< CSeq_feat > GetOverlappingGene(const CSeq_loc &loc, CScope &scope, ETransSplicing eTransSplicing=eTransSplicing_Auto)
Definition: sequence.cpp:1366
vector< TFeatScore > TFeatScores
Definition: sequence.hpp:353
void GetOverlappingFeatures(const CSeq_loc &loc, CSeqFeatData::E_Choice feat_type, CSeqFeatData::ESubtype feat_subtype, EOverlapType overlap_type, TFeatScores &feats, CScope &scope, const TBestFeatOpts opts=0, CGetOverlappingFeaturesPlugin *plugin=NULL)
Find all features overlapping the location.
Definition: sequence.cpp:945
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CRef< CSeq_loc > MapTotalRange(const CSeq_loc &seq_loc)
Take the total range from the location and run it through the mapper.
CSeq_loc_Mapper_Base & SetMergeAbutting(void)
Merge only abutting intervals, keep overlapping.
CSeq_feat_Handle GetSeq_featHandle(const CSeq_feat &feat, EMissing action=eMissing_Default)
Definition: scope.cpp:200
@ eLocationToProduct
Map from the feature's location to product.
TSeqPos GetBioseqLength(void) const
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
CBioseq_set_Handle GetParentBioseq_set(void) const
Get parent bioseq-set handle.
bool IsProtein(void) const
CSeq_entry_Handle GetParentEntry(void) const
Return a handle for the parent seq-entry of the bioseq.
TInst_Length GetInst_Length(void) const
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
bool IsSet(void) const
CRef< CSeq_loc > GetRangeSeq_loc(TSeqPos start, TSeqPos stop, ENa_strand strand=eNa_strand_unknown) const
Return CSeq_loc referencing the given range and strand on the bioseq If start == 0,...
const TId & GetId(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
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
#define kEmptyStr
Definition: ncbistr.hpp:123
bool IsSetDesc(void) const
description (instead of name) Check if a value has been assigned to Desc data member.
Definition: Prot_ref_.hpp:391
const TDesc & GetDesc(void) const
Get the Desc member data.
Definition: Prot_ref_.hpp:403
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
Definition: Seq_feat_.hpp:913
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
void SetPartial(TPartial value)
Assign a value to Partial data member.
Definition: Seq_feat_.hpp:971
void SetProduct(TProduct &value)
Assign a value to Product data member.
Definition: Seq_feat_.cpp:110
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
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 TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1096
const TProt & GetProt(void) const
Get the variant data.
void ResetProduct(void)
Reset Product data member.
Definition: Seq_feat_.cpp:105
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
Definition: Seq_feat_.hpp:1084
bool IsInt(void) const
Check if variant Int is selected.
Definition: Seq_loc_.hpp:528
TSet & SetSet(void)
Select the variant.
Definition: Seq_entry_.cpp:130
bool IsSeq(void) const
Check if variant Seq is selected.
Definition: Seq_entry_.hpp:257
void ResetAnnot(void)
Reset Annot data member.
bool IsSet(void) const
Check if variant Set is selected.
Definition: Seq_entry_.hpp:263
TSeq & SetSeq(void)
Select the variant.
Definition: Seq_entry_.cpp:108
TSeq_set & SetSeq_set(void)
Assign a value to Seq_set data member.
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_annot_.cpp:244
void ResetAnnot(void)
Reset Annot data member.
Definition: Bioseq_.cpp:91
END_EVENT_TABLE()
int i
yy_size_t n
const struct ncbi::grid::netcache::search::fields::SIZE size
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
bool IsFarLocation(const CSeq_loc &loc, const CSeq_entry_Handle &seh)
Definition: utilities.cpp:159
Utility macros and typedefs for exploring NCBI objects from seq.asn.
#define ERASE_SEQFEAT_ON_SEQANNOT(Itr, Var)
ERASE_SEQFEAT_ON_SEQANNOT.
Definition: seq_macros.hpp:423
#define EDIT_EACH_SEQFEAT_ON_SEQANNOT(Itr, Var)
Definition: seq_macros.hpp:413
#define FOR_EACH_SEQFEAT_ON_SEQANNOT(Itr, Var)
FOR_EACH_SEQFEAT_ON_SEQANNOT EDIT_EACH_SEQFEAT_ON_SEQANNOT.
Definition: seq_macros.hpp:410
static static static wxID_ANY
Utility macros and typedefs for exploring NCBI objects from seqset.asn.
#define FOR_EACH_SEQENTRY_ON_SEQSET(Itr, Var)
FOR_EACH_SEQENTRY_ON_SEQSET EDIT_EACH_SEQENTRY_ON_SEQSET.
#define EDIT_EACH_SEQENTRY_ON_SEQSET(Itr, Var)
#define ERASE_SEQENTRY_ON_SEQSET(Itr, Var)
ERASE_SEQENTRY_ON_SEQSET.
void GetProductToCDSMap(objects::CScope &scope, map< objects::CBioseq_Handle, set< objects::CSeq_feat_Handle > > &product_to_cds)
CRef< CCmdComposite > GetDeleteFeatureCommand(const objects::CSeq_feat_Handle &fh, bool remove_proteins=true)
Modified on Wed Apr 17 13:08:15 2024 by modify_doxy.py rev. 669887