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

Go to the SVN repository for this file.

1 /* $Id: alignment_assistant.cpp 47479 2023-05-02 13:24:02Z ucko $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Igor Filippov
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 ////@begin includes
33 ////@end includes
34 #include <sstream>
35 
36 #include <objmgr/scope.hpp>
38 #include <objmgr/seq_vector.hpp>
39 #include <objmgr/align_ci.hpp>
40 #include <objmgr/graph_ci.hpp>
42 #include <objmgr/util/sequence.hpp>
43 #include <objmgr/util/feature.hpp>
44 #include <gui/objutils/utils.hpp>
56 #include <objects/seq/Pubdesc.hpp>
76 // For compilers that support precompilation, includes "wx/wx.h".
77 #include "wx/wxprec.h"
78 
79 #ifdef __BORLANDC__
80 #pragma hdrstop
81 #endif
82 
83 #ifndef WX_PRECOMP
84 #include "wx/wx.h"
85 #endif
86 
87 #include <wx/button.h>
88 #include <wx/statbox.h>
89 #include <wx/stattext.h>
90 #include <wx/textdlg.h>
91 #include <wx/msgdlg.h>
92 #include <wx/textfile.h>
93 
94 #include "location_panel.hpp"
97 
98 ////@begin XPM images
99 ////@end XPM images
100 
101 
102 
104 
105 
106 
107 IMPLEMENT_DYNAMIC_CLASS( CAlignmentAssistant, wxFrame )
108 
109 
110 /*!
111  * CAlignmentAssistant event table definition
112  */
113 
114 
115 
116 BEGIN_EVENT_TABLE( CAlignmentAssistant, wxFrame )
117 
122 
135 
194 
196 
198 
199 
200 static
201 WX_DEFINE_MENU(kAnnotateMenu)
202  WX_SUBMENU("Genes and Named Regions")
220  WX_SUBMENU("Coding Regions and Transcripts")
229  WX_SUBMENU("Structural RNAs")
236  WX_SUBMENU("Bibliographic and Comments")
240  WX_SUBMENU("Sites and Bonds")
249  WX_SUBMENU("Remaining Features")
269 WX_END_MENU()
270 
271 
272 /*!
273  * CAlignmentAssistant constructors
274  */
275 
277 {
278  Init();
279 }
280 
281 
283  wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
284  : m_TopSeqEntry(seh), m_CmdProcessor(processor)
285 {
286  Init();
287  GetAlignment(align);
288  Create(parent, id, caption, pos, size, style);
291 }
292 
293 
294 bool CAlignmentAssistant::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
295 {
296 ////@begin CAlignmentAssistant creation
297 // SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
298  wxFrame::Create( parent, id, caption, pos, size, style );
299 
300  CreateControls();
301  if (GetSizer())
302  {
303  GetSizer()->SetSizeHints(this);
304  }
305 
306  Centre(wxBOTH|wxCENTRE_ON_SCREEN);
307 
308 ////@end CAlignmentAssistant creation
309 
310  return true;
311 }
312 
313 
314 /*!
315  * CAlignmentAssistant destructor
316  */
317 
319 {
320 ////@begin CAlignmentAssistant destruction
321 ////@end CAlignmentAssistant destruction
322 }
323 
324 
325 /*!
326  * Member initialisation
327  */
328 
330 {
331  m_Panel = NULL;
334 }
335 
336 
337 /*!
338  * Control creation for CAlignmentAssistant
339  */
340 
342 {
343  wxMenuBar *menubar = new wxMenuBar();
344 
345  wxMenu *file_menu = new wxMenu();
346  menubar->Append(file_menu, wxT("&File"));
347 
348  wxMenu *export_submenu = new wxMenu();
349  file_menu->AppendSubMenu(export_submenu, _("Export"));
350 
351  wxMenuItem *interleave_item = new wxMenuItem(export_submenu, ID_EXPORT_INTER_ALIGNMENT_ASSISTANT_MENU, "Interleave", wxEmptyString, wxITEM_NORMAL);
352  export_submenu->Append(interleave_item);
353  wxMenuItem *cont_item = new wxMenuItem(export_submenu, ID_EXPORT_CONT_ALIGNMENT_ASSISTANT_MENU, "Contiguous", wxEmptyString, wxITEM_NORMAL);
354  export_submenu->Append(cont_item);
355 // wxMenuItem *text_item = new wxMenuItem(export_submenu, ID_EXPORT_TEXT_ALIGNMENT_ASSISTANT_MENU, "Text Representation", wxEmptyString, wxITEM_NORMAL);
356 // export_submenu->Append(text_item);
357 
358  wxMenuItem *close_item = new wxMenuItem(file_menu, wxID_CLOSE, _("Close"), _("Close"), wxITEM_NORMAL);
359  file_menu->Append(close_item);
360 
361  wxMenu *edit_menu = new wxMenu();
362  menubar->Append(edit_menu, wxT("&Edit"));
363 
364  wxMenuItem *remove_seq_item = new wxMenuItem(edit_menu, ID_EDIT_RM_SEQ_ALIGNMENT_ASSISTANT_MENU, _("Remove Sequence from Alignment"), wxEmptyString, wxITEM_NORMAL);
365  edit_menu->Append(remove_seq_item);
366 
367  wxMenuItem *rev_strands_item = new wxMenuItem(edit_menu, ID_EDIT_REV_STRANDS_ALIGNMENT_ASSISTANT_MENU, _("Reverse Sequence Strands"), wxEmptyString, wxITEM_NORMAL);
368  edit_menu->Append(rev_strands_item);
369 
370  wxMenuItem *validate_item = new wxMenuItem(edit_menu, ID_EDIT_VALIDATE_ALIGNMENT_ASSISTANT_MENU, _("Validate Alignment"), wxEmptyString, wxITEM_NORMAL);
371  edit_menu->Append(validate_item);
372 
373  wxMenuItem *propagate_item = new wxMenuItem(edit_menu, ID_EDIT_PROPAGATE_ALIGNMENT_ASSISTANT_MENU, _("Propagate Features"), wxEmptyString, wxITEM_NORMAL);
374  edit_menu->Append(propagate_item);
375 
376  wxMenu *view_menu = new wxMenu();
377  menubar->Append(view_menu, wxT("&View"));
378 
379  m_target_submenu = new wxMenu();
380  view_menu->AppendSubMenu(m_target_submenu, _("Target"));
381 
382  for (size_t i = 0; i < m_Labels.size(); i++)
383  {
384  wxMenuItem *target_item = new wxMenuItem(m_target_submenu, wxID_ANY, wxString(m_Labels[i]), wxEmptyString, wxITEM_NORMAL);
385  m_target_submenu->Append(target_item);
386  }
387  m_target_submenu->Bind(wxEVT_MENU, &CAlignmentAssistant::OnTarget, this);
388 
389  wxMenuItem *substitute_item = new wxMenuItem(view_menu, ID_SHOW_SUBSTITUTE_ALIGNMENT_ASSISTANT_MENU, _("Show all bases\tAlt+s"), _("Show all bases"), wxITEM_CHECK);
390  view_menu->Append(substitute_item);
391 
392  wxMenuItem *features_item = new wxMenuItem(view_menu, ID_SHOW_FEATURES_ALIGNMENT_ASSISTANT_MENU, _("Features\tAlt+f"), _("Show features"), wxITEM_CHECK);
393  view_menu->Append(features_item);
394 
395  wxMenu *feature_menu = new wxMenu();
396  menubar->Append(feature_menu, wxT("Features"));
397 
398  wxMenu *annotate_seq_submenu = CUICommandRegistry::GetInstance().CreateMenu(kAnnotateMenu);
399  feature_menu->AppendSubMenu(annotate_seq_submenu,_("Apply To Target Sequence"));
400 
401  wxMenu *annotate_alignment_submenu = new wxMenu();
402  feature_menu->AppendSubMenu(annotate_alignment_submenu,_("Apply To Alignment"));
403 
404  wxMenuItem *align_cds_item = new wxMenuItem(annotate_alignment_submenu, ID_ADD_ALIGN_CDS_ALIGNMENT_ASSISTANT_MENU, _("CDS"), _("CDS"), wxITEM_NORMAL);
405  annotate_alignment_submenu->Append(align_cds_item);
406 
407  wxMenuItem *align_rna_item = new wxMenuItem(annotate_alignment_submenu, ID_ADD_ALIGN_RNA_ALIGNMENT_ASSISTANT_MENU, _("RNA"), _("RNA"), wxITEM_NORMAL);
408  annotate_alignment_submenu->Append(align_rna_item);
409 
410  wxMenuItem *align_other_item = new wxMenuItem(annotate_alignment_submenu, ID_ADD_ALIGN_OTHER_ALIGNMENT_ASSISTANT_MENU, _("Other Feature"), _("Other Feature"), wxITEM_NORMAL);
411  annotate_alignment_submenu->Append(align_other_item);
412 
413  SetMenuBar(menubar);
414 
415  wxPanel *Dialog1 = new wxPanel(this, wxID_ANY);
416 
417  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
418  Dialog1->SetSizer(itemBoxSizer2);
419 
420  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
421  itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_LEFT, 0);
422 
423  wxButton* itemButton6 = new wxButton( Dialog1, ID_GOTO_ALIGNMENT_ASSISTANT_BUTTON, wxT("Go to alignment position:"), wxDefaultPosition, wxDefaultSize, 0 );
424  itemBoxSizer3->Add(itemButton6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
425 
426  m_GoTo_TextCtrl = new wxTextCtrl( Dialog1, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
427  itemBoxSizer3->Add(m_GoTo_TextCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
428 
429  wxButton* itemButton7 = new wxButton( Dialog1, ID_GOTO_SEQ_ALIGNMENT_ASSISTANT_BUTTON, wxT("Go to sequence position:"), wxDefaultPosition, wxDefaultSize, 0 );
430  itemBoxSizer3->Add(itemButton7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
431 
432  m_GoToSeq_TextCtrl = new wxTextCtrl( Dialog1, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
433  itemBoxSizer3->Add(m_GoToSeq_TextCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
434 
435  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
436  itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_LEFT, 0);
437 
438  m_Range = new wxStaticText( Dialog1, wxID_STATIC, wxT(""), wxDefaultPosition, wxSize(Dialog1->ConvertDialogToPixels(wxSize(40, -1)).x, -1), wxNO_BORDER );
439  itemBoxSizer4->Add(m_Range, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5);
440 
441  wxBoxSizer *BoxSizer = new wxBoxSizer(wxHORIZONTAL);
442  itemBoxSizer2->Add(BoxSizer, 1, wxGROW, 0);
444  BoxSizer->Add(m_Panel, 1, wxGROW|wxALL, 5);
445 
446  m_Panel->SetFocus();
447 
448  wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
449  itemBoxSizer2->Add(itemBoxSizer12, 0, wxALIGN_CENTER_HORIZONTAL, 0);
450 
451  wxButton* itemButton13 = new wxButton( Dialog1, ID_CLOSE_ALIGNMENT_ASSISTANT_BUTTON, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
452  itemBoxSizer12->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
453 
454  wxStatusBar *status = CreateStatusBar();
455 }
456 
457 
458 
460 {
461  m_Alignment.Reset();
462  if (m_TopSeqEntry)
463  {
464  for (CAlign_CI align_ci(m_TopSeqEntry); align_ci; ++align_ci)
465  if (!align || align->Equals(align_ci.GetOriginalSeq_align()) || align->Equals(*align_ci))
466  {
467  m_Alignment = align_ci.GetSeq_align_Handle();
468  break;
469  }
470  }
471 
472  if (!m_Alignment)
473  {
474  NCBI_THROW( CException, eUnknown, "No Seq-align found" );
475  }
476 
477  GetFeatures();
478 }
479 
480 /*!
481  * Should we show tooltips?
482  */
483 
485 {
486  return true;
487 }
488 
489 /*!
490  * Get bitmap resources
491  */
492 
493 wxBitmap CAlignmentAssistant::GetBitmapResource( const wxString& name )
494 {
495  // Bitmap retrieval
496  wxUnusedVar(name);
497  return wxNullBitmap;
498 }
499 
500 /*!
501  * Get icon resources
502  */
503 
504 wxIcon CAlignmentAssistant::GetIconResource( const wxString& name )
505 {
506  // Icon retrieval
507  wxUnusedVar(name);
508  return wxNullIcon;
509 }
510 
511 
512 void CAlignmentAssistant::OnClose( wxCommandEvent& event )
513 {
514  Close();
515 }
516 
517 
518 void CAlignmentAssistant::ReportPos(int pos, const string &label)
519 {
520  wxStatusBar *status = GetStatusBar();
521  status->SetStatusText(_("current position: ") + wxString(label) + _(" ") + ToWxString(NStr::IntToString(pos)));
522 }
523 
524 void CAlignmentAssistant::ReportRange(int pos1, int pos2, const string &label)
525 {
526  if (pos1 > 0 && pos2 > 0)
527  {
528  m_Range->SetLabel(wxString(label) + _(" ") + ToWxString(NStr::IntToString(pos1)+"-"+NStr::IntToString(pos2)));
529  }
530  else
531  {
532  m_Range->SetLabel(wxEmptyString);
533  }
534 }
535 
536 
537 void CAlignmentAssistant::OnGoTo( wxCommandEvent& event )
538 {
539  wxString val = m_GoTo_TextCtrl->GetValue();
540  long pos;
541  if(val.ToLong(&pos))
542  {
543  m_Panel->SetPos(static_cast<int>(pos));
544  m_Panel->SetFocus();
545  }
546 }
547 
548 void CAlignmentAssistant::OnGoToSeq( wxCommandEvent& event )
549 {
550  wxString val = m_GoToSeq_TextCtrl->GetValue();
551  long pos;
552  if(val.ToLong(&pos))
553  {
554  m_Panel->SetPosSeq(static_cast<int>(pos));
555  m_Panel->SetFocus();
556  }
557 }
558 
560 {
562  {
563  const CDense_seg& denseg = m_Alignment.GetSegs().GetDenseg();
564  if ( denseg.IsSetDim() && denseg.IsSetNumseg() &&
565  denseg.IsSetIds() && denseg.IsSetStarts() &&
566  denseg.IsSetLens())
567  {
568  vector<string> labels;
569  CDense_seg::TDim num_rows = denseg.GetDim();
570  CDense_seg::TNumseg num_segs = denseg.GetNumseg();
571  for (CDense_seg::TDim row = 0; row < num_rows; ++row)
572  {
573  const CSeq_id& id = denseg.GetSeq_id(row);
575  if (!bsh)
576  {
577  string label;
578  id.GetLabel(&label, CSeq_id::eContent);
579  labels.push_back(label);
580  }
581  }
582  if (!labels.empty())
583  {
584  string msg;
585  msg = "Cannot resolve the following bioseq";
586  msg += (labels.size() > 1) ? "s: \n" : ": \n";
587  msg += NStr::Join(labels, "\n");
588  CGenericReportDlg* report = new CGenericReportDlg(this);
589  report->SetTitle(wxT("Unresolved bioseqs"));
590  report->SetText(ToWxString(msg));
591  report->Show(true);
592  report->SetFocus();
593  }
594  }
595  }
596 }
597 
599 {
600  m_FeatRanges.clear();
601  m_FeatTypes.clear();
602  m_FeatStrand.clear();
603  m_Labels.clear();
604 
606  {
607  const CDense_seg& denseg = m_Alignment.GetSegs().GetDenseg();
608  if ( denseg.IsSetDim() && denseg.IsSetNumseg() &&
609  denseg.IsSetIds() && denseg.IsSetStarts() &&
610  denseg.IsSetLens())
611  {
612  CDense_seg::TDim num_rows = denseg.GetDim();
613  CDense_seg::TNumseg num_segs = denseg.GetNumseg();
614  for (CDense_seg::TDim row = 0; row < num_rows; ++row)
615  {
616  const CSeq_id& id = denseg.GetSeq_id(row);
618  if (!bsh)
619  continue;
620  m_Labels.push_back(CPaintAlignment::GetSeqTitle(bsh));
621 
623  int length = bsh.GetBioseqLength();
624  CRef<CSeq_loc> loc = bsh.GetRangeSeq_loc(0,0);
626  vector<vector<pair<TSeqPos,TSeqPos> > > feat_ranges;
627  vector<pair<string,CSeqFeatData::ESubtype> > feat_types;
628  vector<CBioseq_Handle::EVectorStrand> feat_strand;
629  CFeat_CI feat_it(bsh);
630  while (feat_it)
631  {
632  if (feat_it->GetOriginalFeature().IsSetData())
633  {
634  const CSeq_loc& feat_loc = feat_it->GetLocation();
636  if (feat_loc.GetStrand() == eNa_strand_minus)
638  vector<pair<TSeqPos,TSeqPos> > vec;
639  for(CSeq_loc_CI loc_it(feat_loc, CSeq_loc_CI::eEmpty_Skip, CSeq_loc_CI::eOrder_Positional); loc_it; ++loc_it)
640  {
641  CSeq_loc_CI::TRange feat_range = loc_it.GetRange();
642  TSeqPos feat_start = feat_range.GetFrom() - seq_start;
643  TSeqPos feat_stop = feat_range.GetTo() - seq_start;
644  vec.push_back(pair<TSeqPos,TSeqPos>(feat_start,feat_stop));
645  }
646  if (!vec.empty())
647  {
649  string label;
651  feat_types.push_back(pair<string,CSeqFeatData::ESubtype>(label,subtype));
652  feat_ranges.push_back(vec);
653  feat_strand.push_back(strand);
654  }
655  }
656  ++feat_it;
657  }
658  m_FeatTypes.push_back(feat_types);
659  m_FeatRanges.push_back(feat_ranges);
660  m_FeatStrand.push_back(feat_strand);
661  }
662  }
663  }
664 }
665 
667 {
669  {
671  return true;
672  }
673  return false;
674 }
675 
676 
677 void CAlignmentAssistant::OnFeatures( wxCommandEvent& event )
678 {
679  if (event.IsChecked())
680  {
681  m_Panel->EnableFeatures(true);
682  }
683  else
684  {
685  m_Panel->EnableFeatures(false);
686  }
687  m_Panel->Refresh();
688  m_Panel->SetFocus();
689 }
690 
691 void CAlignmentAssistant::OnSubstitute( wxCommandEvent& event )
692 {
693  if (event.IsChecked())
694  {
695  m_Panel->EnableSubstitute(false);
696  }
697  else
698  {
699  m_Panel->EnableSubstitute(true);
700  }
701  m_Panel->Refresh();
702  m_Panel->SetFocus();
703 }
704 
705 
706 
707 void CAlignmentAssistant::IsSelectionAndClean(wxUpdateUIEvent &event)
708 {
710  bool allow = true;
714  allow = false;
715  event.Enable(m_Panel->IsSelection() && allow && m_TopSeqEntry && m_Panel->GetVisibleRow() >= 0);
716 }
717 
718 void CAlignmentAssistant::IsNucleotide(wxUpdateUIEvent &event)
719 {
720  event.Enable(m_is_nucleotide && m_TopSeqEntry);
721 }
722 
723 
724 void CAlignmentAssistant::CreateFeature ( wxCommandEvent& event)
725 {
726  if (!m_TopSeqEntry)
727  return;
728  int row = m_Panel->GetVisibleRow();
729  if (row < 0)
730  return;
731  pair<int,int> sel = m_Panel->GetSelection(row);
732  row = m_Panel->GetRow();
733 
734  if (sel.first >=0 && sel.second >= 0 && sel.second != sel.first)
735  {
736  CRef<CSeq_loc> interval(new CSeq_loc);
737  if (sel.first > sel.second)
738  {
739  interval->SetInt().SetStrand(eNa_strand_minus);
740  swap(sel.first, sel.second);
741  }
742  interval->SetInt().SetFrom(sel.first);
743  interval->SetInt().SetTo(sel.second);
744 
745  CRef<CSeq_id> id(new CSeq_id);
746 
747  const CDense_seg& denseg = m_Alignment.GetSegs().GetDenseg();
748  const CSeq_id& row_id = denseg.GetSeq_id(row);
750  CRef<CSeq_loc> loc = bsh.GetRangeSeq_loc(0,0);
751  id->Assign(*loc->GetId());
752  interval->SetInt().SetId(*id);
755  feat->SetLocation().Assign(*interval);
756 
757  CIRef<IEditObject> editor(new CEditObjectSeq_feat(*feat, bsh.GetSeq_entry_Handle(), bsh.GetScope(), true));
758  CEditObjViewDlgModal edit_dlg(NULL, true);
759  wxWindow* editorWindow = editor->CreateWindow(&edit_dlg);
760  edit_dlg.SetEditorWindow(editorWindow);
761  edit_dlg.SetEditor(editor);
762  if (edit_dlg.ShowModal() == wxID_OK)
763  {
764  CIRef<IEditCommand> cmd(editor->GetEditCommand());
765  if (cmd && x_ExecuteCommand(cmd)) {
766  GetFeatures();
768  m_Panel->Refresh();
769  m_Panel->SetFocus();
770  }
771  } else
772  m_Panel->SetFocus();
773  }
774 }
775 
777 {
778  if (!m_TopSeqEntry || !m_Panel || !m_Panel->IsSelection())
779  return;
780  pair<int, int> align_sel = m_Panel->GetAlignSelection();
781  int from_align = align_sel.first;
782  int to_align = align_sel.second;
783  if (from_align == 0 && to_align == m_Panel->GetTotalLength() - 1)
784  return;
785  if (from_align != 0 && to_align != m_Panel->GetTotalLength() - 1)
786  {
787  if (wxYES != wxMessageBox(_("You are not trimming the ends, the selection is internal. Are you sure?"), wxT("Confirm"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION))
788  return;
789  }
790 
791  CRef<CCmdComposite> cmd(new CCmdComposite("Delete Selection"));
792 
793  const CDense_seg& denseg = m_Alignment.GetSegs().GetDenseg();
794  CDense_seg::TDim num_rows = denseg.GetDim();
795  int visible_row = 0;
796  vector<int> offset(num_rows, 0);
797  for (CDense_seg::TDim row = 0; row < num_rows; ++row)
798  {
799  const CSeq_id& row_id = denseg.GetSeq_id(row);
801  if (!bsh)
802  continue;
803  pair<int,int> sel = m_Panel->GetSelection(visible_row);
804  visible_row++;
805  if (sel.first < 0 || sel.second < 0)
806  continue;
807  int from = sel.first;
808  int to = sel.second;
809  if (from > to)
810  swap(from, to);
811  offset[row] = to - from + 1;
812  AdjustBioseq(bsh, from, to, cmd);
813  AdjustFeatureLocations(bsh, from, to, cmd);
814  TrimQualityScores(bsh, from, to, cmd);
815  }
816 
817 
818  CRef<CSeq_align> align = AdjustAlign(from_align, to_align, offset, cmd);
819 
820  if (cmd && x_ExecuteCommand(cmd))
821  {
822  GetAlignment(align);
825  m_Panel->Refresh();
826  }
827  m_Panel->SetFocus();
828 }
829 
830 
832 {
834  CRef<CScope> scope_copy(new CScope(*object_manager));
837  CSeq_entry_Handle edited_seh = scope_copy->AddTopLevelSeqEntry(*copy);
838  CBioseq_Handle edited_bsh = edited_seh.GetSeq();
839  SSeqMapSelector selector;
840  selector.SetFlags(CSeqMap::fFindData);
841  CBioseq_EditHandle besh(edited_bsh);
842  CSeqMap_I seqmap_i(besh, selector);
843  int start = 0;
844  while (seqmap_i)
845  {
846  TSeqPos len = seqmap_i.GetLength();
847  if (start >= from && start + len - 1 <= to)
848  {
849  seqmap_i = seqmap_i.Remove();
850  }
851  else if (from > start && from < start+len && to >= start+len-1)
852  {
853  string seq_in;
854  if (besh.IsNa())
855  seqmap_i.GetSequence(seq_in, CSeqUtil::e_Iupacna);
856  else
857  seqmap_i.GetSequence(seq_in, CSeqUtil::e_Iupacaa);
858  string seq_out = seq_in.substr(0, from - start);
859  if (besh.IsNa())
861  else
863  ++seqmap_i;
864  }
865  else if (from > start && from < start+len && to < start+len-1)
866  {
867  string seq_in;
868  if (besh.IsNa())
869  seqmap_i.GetSequence(seq_in, CSeqUtil::e_Iupacna);
870  else
871  seqmap_i.GetSequence(seq_in, CSeqUtil::e_Iupacaa);
872  string seq_out = seq_in.substr(0, from - start) + seq_in.substr(to - start + 1);
873  if (besh.IsNa())
875  else
877  ++seqmap_i;
878  }
879  else if (from <= start && to >= start && to < start + len - 1)
880  {
881  string seq_in;
882  if (besh.IsNa())
883  seqmap_i.GetSequence(seq_in, CSeqUtil::e_Iupacna);
884  else
885  seqmap_i.GetSequence(seq_in, CSeqUtil::e_Iupacaa);
886  string seq_out = seq_in.substr(to - start + 1);
887  if (besh.IsNa())
889  else
891  ++seqmap_i;
892  }
893  else
894  {
895  ++seqmap_i;
896  }
897  start += len;
898  }
899 
901  cmd->AddCommand(*cmd_bioseq);
902 }
903 
905 {
906  CRef<CSeq_align> align(new CSeq_align());
907  align->Assign(*m_Alignment.GetSeq_align());
908  align->ResetSegs();
909  const CDense_seg& denseg = m_Alignment.GetSegs().GetDenseg();
910  CDense_seg::TDim num_rows = denseg.GetDim();
911  CDense_seg::TNumseg num_segs = denseg.GetNumseg();
912 
914  ds->SetDim(num_rows);
915 
916 
917  ITERATE(CDense_seg::TIds, idI, denseg.GetIds())
918  {
919  CSeq_id *si = new CSeq_id;
920  si->Assign(**idI);
921  ds->SetIds().push_back(CRef<CSeq_id>(si));
922  }
923  bool already_moved = false;
924  TSeqPos pos = 0;
925  for (CDense_seg::TNumseg seg = 0; seg < num_segs; ++seg)
926  {
927  TSeqPos len = denseg.GetLens()[seg];
928  TSeqPos new_len = len;
929  if (from > pos && from < pos + len && to >= pos + len - 1)
930  {
931  new_len = from - pos;
932  ds->SetLens().push_back(new_len);
933  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
934  {
935  TSignedSeqPos start = denseg.GetStarts()[seg * num_rows + dim];
936  if (start != -1)
937  {
938  if (denseg.IsSetStrands() && denseg.GetStrands()[seg * num_rows + dim] == eNa_strand_minus)
939  {
940  start += len - new_len - offset[dim];
941  }
942  else
943  {
944  // no change
945  }
946  }
947  ds->SetStarts().push_back(start);
948  }
949  if (!already_moved)
950  {
951  already_moved = true;
952  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
953  {
954  for (CDense_seg::TNumseg seg1 = 0; seg1 < seg; ++seg1)
955  {
956  TSignedSeqPos start1 = ds->GetStarts()[seg1 * num_rows + dim];
957  if (start1 != -1 && ds->IsSetStrands() && ds->GetStrands()[seg1 * num_rows + dim] == eNa_strand_minus)
958  {
959  start1 -= offset[dim];
960  ds->SetStarts()[seg1 * num_rows + dim] = start1;
961  }
962  }
963  }
964  }
965 
966  if (denseg.IsSetStrands())
967  {
968  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
969  {
970  ds->SetStrands().push_back(denseg.GetStrands()[seg * num_rows + dim]);
971  }
972  }
973  }
974  else if (from <= pos && to >= pos + len - 1)
975  {
976  // remove segment
977  if (!already_moved)
978  {
979  already_moved = true;
980  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
981  {
982  for (CDense_seg::TNumseg seg1 = 0; seg1 < seg; ++seg1)
983  {
984  TSignedSeqPos start1 = ds->GetStarts()[seg1 * num_rows + dim];
985  if (start1 != -1 && ds->IsSetStrands() && ds->GetStrands()[seg1 * num_rows + dim] == eNa_strand_minus)
986  {
987  start1 -= offset[dim];
988  ds->SetStarts()[seg1 * num_rows + dim] = start1;
989  }
990  }
991  }
992  }
993  }
994  else if (from <= pos && to >= pos && to < pos + len - 1)
995  {
996  new_len = pos + len - 1 - to;
997  ds->SetLens().push_back(new_len);
998  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
999  {
1000  TSignedSeqPos start = denseg.GetStarts()[seg * num_rows + dim];
1001  if (start != -1)
1002  {
1003  if (denseg.IsSetStrands() && denseg.GetStrands()[seg * num_rows + dim] == eNa_strand_minus)
1004  {
1005  // no change
1006  }
1007  else
1008  {
1009  start += len - new_len - offset[dim];
1010  }
1011  }
1012  ds->SetStarts().push_back(start);
1013  }
1014  if (denseg.IsSetStrands())
1015  {
1016  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
1017  {
1018  ds->SetStrands().push_back(denseg.GetStrands()[seg * num_rows + dim]);
1019  }
1020  }
1021  }
1022  else if (from > pos && from < pos + len - 1 && to > pos && to < pos + len - 1)
1023  {
1024  TSeqPos new_len1 = from - pos;
1025  ds->SetLens().push_back(new_len1);
1026  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
1027  {
1028  TSignedSeqPos start = denseg.GetStarts()[seg * num_rows + dim];
1029  if (start != -1)
1030  {
1031  if (denseg.IsSetStrands() && denseg.GetStrands()[seg * num_rows + dim] == eNa_strand_minus)
1032  {
1033  start += len - new_len1 - offset[dim];
1034  }
1035  else
1036  {
1037  // no change
1038  }
1039  }
1040  ds->SetStarts().push_back(start);
1041  }
1042  if (!already_moved)
1043  {
1044  already_moved = true;
1045  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
1046  {
1047  for (CDense_seg::TNumseg seg1 = 0; seg1 < seg; ++seg1)
1048  {
1049  TSignedSeqPos start1 = ds->GetStarts()[seg1 * num_rows + dim];
1050  if (start1 != -1 && ds->IsSetStrands() && ds->GetStrands()[seg1 * num_rows + dim] == eNa_strand_minus)
1051  {
1052  start1 -= offset[dim];
1053  ds->SetStarts()[seg1 * num_rows + dim] = start1;
1054  }
1055  }
1056  }
1057  }
1058 
1059  TSeqPos new_len2 = pos + len - 1 - to;
1060  ds->SetLens().push_back(new_len2);
1061  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
1062  {
1063  TSignedSeqPos start = denseg.GetStarts()[seg * num_rows + dim];
1064  if (start != -1)
1065  {
1066  if (denseg.IsSetStrands() && denseg.GetStrands()[seg * num_rows + dim] == eNa_strand_minus)
1067  {
1068  // no change
1069  }
1070  else
1071  {
1072  start += len - new_len2 - offset[dim];
1073  }
1074  }
1075  ds->SetStarts().push_back(start);
1076  }
1077  if (denseg.IsSetStrands())
1078  {
1079  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
1080  {
1081  ds->SetStrands().push_back(denseg.GetStrands()[seg * num_rows + dim]);
1082  }
1083  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
1084  {
1085  ds->SetStrands().push_back(denseg.GetStrands()[seg * num_rows + dim]);
1086  }
1087  }
1088  }
1089  else if (from < pos && to < pos)
1090  {
1091  ds->SetLens().push_back(new_len);
1092  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
1093  {
1094  TSignedSeqPos start = denseg.GetStarts()[seg * num_rows + dim];
1095  if (start != -1)
1096  {
1097  if (denseg.IsSetStrands() && denseg.GetStrands()[seg * num_rows + dim] == eNa_strand_minus)
1098  {
1099  // no change
1100  }
1101  else
1102  {
1103  start -= offset[dim];
1104  }
1105  }
1106  ds->SetStarts().push_back(start);
1107  }
1108  if (denseg.IsSetStrands())
1109  {
1110  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
1111  {
1112  ds->SetStrands().push_back(denseg.GetStrands()[seg * num_rows + dim]);
1113  }
1114  }
1115  }
1116  else
1117  {
1118  ds->SetLens().push_back(new_len);
1119  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
1120  {
1121  TSignedSeqPos start = denseg.GetStarts()[seg * num_rows + dim];
1122  ds->SetStarts().push_back(start);
1123  }
1124  if (denseg.IsSetStrands())
1125  {
1126  for (CDense_seg::TDim dim = 0; dim < num_rows; ++dim)
1127  {
1128  ds->SetStrands().push_back(denseg.GetStrands()[seg * num_rows + dim]);
1129  }
1130  }
1131  }
1132 
1133  pos += len;
1134  }
1135  ds->SetNumseg(static_cast<CDense_seg::TNumseg>(ds->GetLens().size()));
1136  align->SetSegs().SetDenseg(*ds);
1137 
1138  CIRef<IEditCommand> cmd_align(new CCmdChangeAlign(m_Alignment,*align));
1139  cmd->AddCommand(*cmd_align);
1140  return align;
1141 }
1142 
1144 {
1145  CRef<CSeq_loc> loc = bsh.GetRangeSeq_loc(0,0);
1146  SAnnotSelector sel;
1147  CScope &scope = bsh.GetScope();
1148 
1149  for (CFeat_CI feat_it(scope, *loc, sel); feat_it; ++feat_it)
1150  {
1151  CRef<CSeq_feat> new_feat(new CSeq_feat);
1152  new_feat->Assign(feat_it->GetOriginalFeature());
1153  const CSeq_loc& feat_loc = feat_it->GetLocation();
1154  bool modified = false;
1155  bool removed = false;
1156  CRef<CSeq_loc> loc = AdjustLoc(feat_loc, from, to, modified, removed);
1157 
1158  if (modified)
1159  {
1160  if (removed)
1161  {
1162  CRef<CCmdDelSeq_feat> cmd_del(new CCmdDelSeq_feat(feat_it->GetSeq_feat_Handle()));
1163  if (cmd_del)
1164  {
1165  cmd->AddCommand(*cmd_del);
1166  }
1167  }
1168  else
1169  {
1170  if (new_feat->IsSetData() && new_feat->GetData().IsCdregion())
1171  {
1172  EDIT_EACH_CODEBREAK_ON_CDREGION(code_break, new_feat->SetData().SetCdregion())
1173  {
1174  if ((*code_break)->IsSetLoc())
1175  {
1176  bool cb_modified = false;
1177  bool cb_removed = false;
1178  CRef<CSeq_loc> cb_loc = AdjustLoc((*code_break)->GetLoc(), from, to, cb_modified, cb_removed);
1179  if (cb_modified)
1180  {
1181  if (cb_removed)
1182  ERASE_CODEBREAK_ON_CDREGION(code_break, new_feat->SetData().SetCdregion());
1183  else
1184  (*code_break)->SetLoc(*cb_loc);
1185  }
1186  }
1187  }
1188  if (from <= feat_loc.GetStart(objects::eExtreme_Biological) && to >= feat_loc.GetStart(objects::eExtreme_Biological))
1189  {
1190  new_feat->SetData().SetCdregion().ResetFrame();
1191  }
1192  //int diff = loc->GetStart(objects::eExtreme_Biological) - feat_loc.GetStart(objects::eExtreme_Biological);
1193  //if (feat_loc.GetStrand() == eNa_strand_minus)
1194  //diff = feat_loc.GetStart(objects::eExtreme_Biological) - loc->GetStart(objects::eExtreme_Biological);
1195  //AdjustFrame(new_feat->SetData().SetCdregion(), diff);
1196  }
1197  if (new_feat->IsSetData() && new_feat->GetData().IsRna() && new_feat->GetData().GetRna().IsSetExt()
1198  && new_feat->GetData().GetRna().GetExt().IsTRNA() && new_feat->GetData().GetRna().GetExt().GetTRNA().IsSetAnticodon())
1199  {
1200  bool ac_modified = false;
1201  bool ac_removed = false;
1202  CRef<CSeq_loc> ac_loc = AdjustLoc(new_feat->GetData().GetRna().GetExt().GetTRNA().GetAnticodon(), from, to, ac_modified, ac_removed);
1203  if (ac_modified)
1204  {
1205  if (ac_removed)
1206  new_feat->SetData().SetRna().SetExt().SetTRNA().ResetAnticodon();
1207  else
1208  new_feat->SetData().SetRna().SetExt().SetTRNA().SetAnticodon(*ac_loc);
1209  }
1210  }
1211  new_feat->SetLocation(*loc);
1212  CRef< CCmdChangeSeq_feat > cmd_change_feat(new CCmdChangeSeq_feat(feat_it->GetSeq_feat_Handle(),*new_feat));
1213  if (cmd_change_feat)
1214  {
1215  cmd->AddCommand(*cmd_change_feat);
1216  }
1217  }
1218  }
1219 
1220  }
1221 }
1222 
1223 CRef<CSeq_loc> CAlignmentAssistant::AdjustLoc(const CSeq_loc& feat_loc, int from, int to, bool &modified, bool &removed)
1224 {
1225  CRef<CSeq_loc> new_loc(new CSeq_loc);
1226  new_loc->Assign(feat_loc);
1227  CSeq_loc_I loc_it(*new_loc);
1228  while(loc_it)
1229  {
1230  CSeq_loc_CI::TRange feat_range = loc_it.GetRange();
1231  TSeqPos feat_start = feat_range.GetFrom();
1232  TSeqPos feat_stop = feat_range.GetTo();
1233 
1234  if (feat_start < from && feat_stop >= from && feat_stop <= to)
1235  {
1236  loc_it.SetTo(from - 1);
1237  }
1238  else if (feat_start < from && feat_stop > to)
1239  {
1240  loc_it.SetTo(feat_stop - (to - from + 1));
1241  }
1242  else if (feat_start >= from && feat_start <= to && feat_stop > to)
1243  {
1244  loc_it.SetFrom(to + 1 - (to - from + 1));
1245  loc_it.SetTo(feat_stop - (to - from + 1));
1246  }
1247  else if (feat_start >= from && feat_start <= to && feat_stop >= from && feat_stop <= to)
1248  {
1249  loc_it.Delete();
1250  continue;
1251  }
1252  else if (feat_start > to)
1253  {
1254  loc_it.SetFrom(feat_start - (to - from + 1));
1255  loc_it.SetTo(feat_stop - (to - from + 1));
1256  }
1257 
1258  ++loc_it;
1259  }
1260  CRef<CSeq_loc> loc = loc_it.MakeSeq_loc();
1261  modified = loc_it.HasChanges();
1262  removed = (loc_it.GetSize() == 0 || loc->GetStart(objects::eExtreme_Positional) == loc->GetStop(objects::eExtreme_Positional));
1263  loc_it.Rewind();
1264  return loc;
1265 }
1266 /*
1267 void CAlignmentAssistant::AdjustFrame(CCdregion &feat, int diff)
1268 {
1269  if (diff <= 0)
1270  return;
1271  int orig_frame = 0;
1272  if (feat.IsSetFrame())
1273  {
1274  if (feat.GetFrame() == CCdregion::eFrame_two)
1275  {
1276  orig_frame = 1;
1277  } else if (feat.GetFrame() == CCdregion::eFrame_three)
1278  {
1279  orig_frame = 2;
1280  }
1281  }
1282  int new_offset = (orig_frame - diff) % 3;
1283  if (orig_frame < diff && new_offset != 0)
1284  {
1285  new_offset = 3 - ((diff - orig_frame) % 3);
1286  }
1287 
1288  CCdregion::EFrame new_frame = CCdregion::eFrame_not_set;
1289  switch (new_offset) {
1290  case 0:
1291  new_frame = CCdregion::eFrame_one;
1292  break;
1293  case 1:
1294  new_frame = CCdregion::eFrame_two;
1295  break;
1296  case 2:
1297  new_frame = CCdregion::eFrame_three;
1298  break;
1299  default:
1300  new_frame = CCdregion::eFrame_not_set;
1301  break;
1302  }
1303  feat.SetFrame(new_frame);
1304 }
1305 */
1306 
1308 {
1309  CRef<CSeq_loc> loc = bsh.GetRangeSeq_loc(0,0);
1310 
1312  CGraph_CI graph_ci(bsh, graph_sel);
1313  for (; graph_ci; ++graph_ci)
1314  {
1315 
1316  const CMappedGraph& graph = *graph_ci;
1317 
1318  CRef<CSeq_graph> new_graph(new CSeq_graph());
1319  new_graph->Assign(graph.GetOriginalGraph());
1320 
1321  if (new_graph->IsSetLoc())
1322  {
1323  bool g_modified = false;
1324  bool g_removed = false;
1325  CRef<CSeq_loc> g_loc = AdjustLoc(new_graph->GetLoc(), from, to, g_modified, g_removed);
1326  if (g_modified)
1327  {
1328  if (g_removed)
1329  {
1330  new_graph->ResetLoc();
1331  CIRef<IEditCommand> delGraph(new CCmdDelSeq_graph( graph.GetSeq_graph_Handle() ));
1332  command->AddCommand(*delGraph);
1333  }
1334  else
1335  {
1336  CSeq_graph::TGraph& dst_data = new_graph->SetGraph();
1337  const CSeq_graph::TGraph& src_data = graph.GetOriginalGraph().GetGraph();
1338  switch ( src_data.Which() )
1339  {
1341  {
1342  dst_data.SetByte().ResetValues();
1343  }
1344  break;
1346  {
1347  dst_data.SetInt().ResetValues();
1348  }
1349  break;
1351  {
1352  dst_data.SetReal().ResetValues();
1353  }
1354  break;
1355  default: break;
1356  }
1357 
1358  int graph_pos = 0;
1359  int step = 1;
1360  if (new_graph->IsSetComp())
1361  step = new_graph->GetComp();
1362  for (CSeq_loc_CI loc_it(new_graph->GetLoc(), CSeq_loc_CI:: eEmpty_Skip, CSeq_loc_CI::eOrder_Positional); loc_it; ++loc_it)
1363  {
1364  CSeq_loc_CI::TRange feat_range = loc_it.GetRange();
1365  TSeqPos feat_start = feat_range.GetFrom();
1366  TSeqPos feat_stop = feat_range.GetTo();
1367  for (TSeqPos pos = feat_start; pos <= feat_stop; pos += step, graph_pos++)
1368  {
1369  if (pos >= from && pos <= to)
1370  continue;
1371  switch ( src_data.Which() )
1372  {
1374  {
1375  if (graph_pos < src_data.GetByte().GetValues().size())
1376  dst_data.SetByte().SetValues().push_back(src_data.GetByte().GetValues()[graph_pos]);
1377  }
1378  break;
1380  {
1381  if (graph_pos < src_data.GetInt().GetValues().size())
1382  dst_data.SetInt().SetValues().push_back(src_data.GetInt().GetValues()[graph_pos]);
1383  }
1384  break;
1386  {
1387  if (graph_pos < src_data.GetReal().GetValues().size())
1388  dst_data.SetReal().SetValues().push_back(src_data.GetReal().GetValues()[graph_pos]);
1389 
1390  }
1391  break;
1392  default: break;
1393  }
1394  }
1395  }
1396 
1397  new_graph->SetLoc(*g_loc);
1398  switch ( src_data.Which() )
1399  {
1401  {
1402  new_graph->SetNumval(static_cast<CSeq_graph::TNumval>(dst_data.SetByte().SetValues().size()));
1403  }
1404  break;
1406  {
1407  new_graph->SetNumval(static_cast<CSeq_graph::TNumval>(dst_data.SetInt().SetValues().size()));
1408  }
1409  break;
1411  {
1412  new_graph->SetNumval(static_cast<CSeq_graph::TNumval>(dst_data.SetReal().SetValues().size()));
1413 
1414  }
1415  break;
1416  default: break;
1417  }
1418  CIRef<IEditCommand> chgGraph( new CCmdChangeGraph( graph.GetSeq_graph_Handle(), *new_graph ));
1419  command->AddCommand(*chgGraph);
1420  }
1421  }
1422  }
1423  }
1424 }
1425 
1426 void CAlignmentAssistant::OnAddAlignCDS(wxCommandEvent& /*event*/)
1427 {
1428  if (!m_TopSeqEntry)
1429  return;
1430 
1431  pair<int,int> sel = m_Panel->GetAlignSelection();
1432 
1433  CRef<CSeq_loc> interval(new CSeq_loc);
1434  if (sel.first > sel.second)
1435  {
1436  interval->SetInt().SetStrand(eNa_strand_minus);
1437  swap(sel.first, sel.second);
1438  }
1439  interval->SetInt().SetFrom(sel.first);
1440  interval->SetInt().SetTo(sel.second);
1441 
1442  string str(m_Labels[0]);
1443  for (size_t i = 1; i < m_Labels.size(); i++)
1444  str += ", " + m_Labels[i];
1445  CRef<CSeq_id> id(new CSeq_id);
1446  id->SetLocal().SetStr(str);
1447 
1448  interval->SetInt().SetId(*id);
1449 
1450  CAlignCDSAddPanel edit_dlg(this, interval, m_TopSeqEntry.GetScope());
1451 
1452  if (edit_dlg.ShowModal() == wxID_OK)
1453  {
1454  CIRef<IEditCommand> cmd(edit_dlg.GetCommand());
1455  if (cmd && x_ExecuteCommand(cmd))
1456  {
1457  GetFeatures();
1459  m_Panel->Refresh();
1460  }
1461  }
1462 
1463  m_Panel->SetFocus();
1464 }
1465 
1466 void CAlignmentAssistant::OnAddAlignRNA(wxCommandEvent& /*event*/)
1467 {
1468  if (!m_TopSeqEntry)
1469  return;
1470 
1471  pair<int,int> sel = m_Panel->GetAlignSelection();
1472 
1473  CRef<CSeq_loc> interval(new CSeq_loc);
1474  if (sel.first > sel.second)
1475  {
1476  interval->SetInt().SetStrand(eNa_strand_minus);
1477  swap(sel.first, sel.second);
1478  }
1479  interval->SetInt().SetFrom(sel.first);
1480  interval->SetInt().SetTo(sel.second);
1481 
1482  string str(m_Labels[0]);
1483  for (size_t i = 1; i < m_Labels.size(); i++)
1484  str += ", " + m_Labels[i];
1485  CRef<CSeq_id> id(new CSeq_id);
1486  id->SetLocal().SetStr(str);
1487 
1488  interval->SetInt().SetId(*id);
1489 
1490  CAlignRNAAddPanel edit_dlg(this, interval, m_TopSeqEntry.GetScope());
1491 
1492  if (edit_dlg.ShowModal() == wxID_OK)
1493  {
1494  CIRef<IEditCommand> cmd(edit_dlg.GetCommand());
1495  if (cmd && x_ExecuteCommand(cmd))
1496  {
1497  GetFeatures();
1499  m_Panel->Refresh();
1500  }
1501  }
1502 
1503  m_Panel->SetFocus();
1504 }
1505 
1506 void CAlignmentAssistant::OnAddAlignOther(wxCommandEvent& /*event*/)
1507 {
1508  if (!m_TopSeqEntry)
1509  return;
1510 
1511  pair<int,int> sel = m_Panel->GetAlignSelection();
1512 
1513  CRef<CSeq_loc> interval(new CSeq_loc);
1514  if (sel.first > sel.second)
1515  {
1516  interval->SetInt().SetStrand(eNa_strand_minus);
1517  swap(sel.first, sel.second);
1518  }
1519  interval->SetInt().SetFrom(sel.first);
1520  interval->SetInt().SetTo(sel.second);
1521 
1522  string str(m_Labels[0]);
1523  for (size_t i = 1; i < m_Labels.size(); i++)
1524  str += ", " + m_Labels[i];
1525  CRef<CSeq_id> id(new CSeq_id);
1526  id->SetLocal().SetStr(str);
1527 
1528  interval->SetInt().SetId(*id);
1529 
1530  CAlignOtherAddPanel edit_dlg(this, interval, m_TopSeqEntry);
1531 
1532  if (edit_dlg.ShowModal() == wxID_OK)
1533  {
1534  CIRef<IEditCommand> cmd(edit_dlg.GetCommand());
1535  if (cmd && x_ExecuteCommand(cmd))
1536  {
1537  GetFeatures();
1539  m_Panel->Refresh();
1540  }
1541  }
1542 
1543  m_Panel->SetFocus();
1544 }
1545 
1547 {
1548  const CDense_seg& denseg = m_Alignment.GetSegs().GetDenseg();
1549  CDense_seg::TDim num_rows = denseg.GetDim();
1550  for (CDense_seg::TDim row = 0; row < num_rows; ++row)
1551  {
1552  CRef<CSeq_loc> new_loc(new CSeq_loc);
1553  new_loc->Assign(*loc);
1554  const CSeq_id& row_id = denseg.GetSeq_id(row);
1557  int length = bsh.GetBioseqLength();
1558  CRef<CSeq_id> id(new CSeq_id);
1559  id->Assign(row_id);
1560  new_loc->SetId(*id);
1562  CSeq_loc_I loc_it(*new_loc);
1563  while(loc_it)
1564  {
1565  if (loc_it.IsEmpty())
1566  {
1567  loc_it.Delete();
1568  continue;
1569  }
1570  CSeq_loc_CI::TRange range = loc_it.GetRange();
1571  TSeqPos start = range.GetFrom() - seq_start;
1572  TSeqPos stop = range.GetTo() - seq_start;
1573  TSeqPos new_start = m_Panel->AlignPosToSeqPos(start, row, true);
1574  TSeqPos new_stop = m_Panel->AlignPosToSeqPos(stop, row, false);
1575  if (new_start < 0 || new_stop < 0)
1576  {
1577  loc_it.Delete();
1578  continue;
1579  }
1580  if (new_stop < new_start)
1581  {
1582  swap(new_start, new_stop);
1583  }
1584  ENa_strand strand = loc_it.GetStrand();
1585  if (IsReverse(row_strand))
1586  {
1587  loc_it.SetStrand(Reverse(strand));
1588  CRef<CInt_fuzz> fuzz_from;
1589  if (loc_it.GetFuzzFrom())
1590  {
1591  fuzz_from.Reset(new CInt_fuzz);
1592  fuzz_from->Assign(*loc_it.GetFuzzFrom());
1593  loc_it.ResetFuzzFrom();
1594  }
1595  CRef<CInt_fuzz> fuzz_to;
1596  if (loc_it.GetFuzzTo())
1597  {
1598  fuzz_to.Reset(new CInt_fuzz);
1599  fuzz_to->Assign(*loc_it.GetFuzzTo());
1600  loc_it.ResetFuzzTo();
1601  }
1602  if (fuzz_from)
1603  {
1604  loc_it.SetFuzzTo(*fuzz_from->Negative(0));
1605  }
1606  if (fuzz_to)
1607  {
1608  loc_it.SetFuzzFrom(*fuzz_to->Negative(0));
1609  }
1610  }
1611  loc_it.SetFrom(new_start);
1612  loc_it.SetTo(new_stop);
1613  ++loc_it;
1614  }
1615  CRef<CSeq_loc> add_loc = loc_it.MakeSeq_loc();
1616  if (add_loc && add_loc->Which() != CSeq_loc::e_not_set && add_loc->Which() != CSeq_loc::e_Null && add_loc->Which() != CSeq_loc::e_Empty)
1617  locations.push_back(pair<CRef<CSeq_loc>, CBioseq_Handle>(add_loc, bsh));
1618  }
1619 }
1620 
1621 
1622 void CAlignmentAssistant::OnTarget( wxCommandEvent& event)
1623 {
1624  wxMenuBar *menu_bar = GetMenuBar();
1625  wxMenuItem *menu_item = menu_bar->FindItem( event.GetId() );
1626  string label = menu_item->GetItemLabelText().ToStdString();
1627  int row = -1;
1628  for (size_t i = 0; i < m_Labels.size(); i++)
1629  if (m_Labels[i] == label)
1630  {
1631  row = static_cast<int>(i);
1632  break;
1633  }
1634  m_Panel->SetTarget(row);
1635  m_Panel->SetFocus();
1636 }
1637 
1638 void CAlignmentAssistant::OnExportInter( wxCommandEvent& event)
1639 {
1640  wxFileDialog save_file(this, wxT("Export to file"), wxEmptyString, wxEmptyString,
1642  wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
1643 
1644  if (save_file.ShowModal() == wxID_OK)
1645  {
1646  wxString path = save_file.GetPath();
1647  if( !path.IsEmpty())
1648  {
1649  ios::openmode mode = ios::out;
1650  CNcbiOfstream os(path.fn_str(), mode);
1651  os << m_Panel->GetExportInter();
1652  }
1653  }
1654  m_Panel->SetFocus();
1655 }
1656 
1657 void CAlignmentAssistant::OnExportCont( wxCommandEvent& event)
1658 {
1659  wxFileDialog save_file(this, wxT("Export to file"), wxEmptyString, wxEmptyString,
1661  wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
1662 
1663  if (save_file.ShowModal() == wxID_OK)
1664  {
1665  wxString path = save_file.GetPath();
1666  if( !path.IsEmpty())
1667  {
1668  ios::openmode mode = ios::out;
1669  CNcbiOfstream os(path.fn_str(), mode);
1670  os << m_Panel->GetExportCont();
1671  }
1672  }
1673  m_Panel->SetFocus();
1674 }
1675 
1676 
1677 void CAlignmentAssistant::OnValidate( wxCommandEvent& event)
1678 {
1679  unsigned int options = validator::CValidator::eVal_val_align;
1680 
1682  validator::CValidErrorFormat::SetSuppressionRules(m_TopSeqEntry, *errors);
1683 
1685  validator::CValidator validator(*objmgr);
1686  validator.Validate(m_Alignment.GetAnnot(), options, *errors);
1687 
1688  string msg;
1689  for ( CValidError_CI vit(*errors); vit; ++vit)
1690  {
1691  string description = vit->GetAccnver() + ":"
1692  + CValidErrItem::ConvertSeverity(vit->GetSeverity()) + ":"
1693  + vit->GetErrCode() + ":"
1694  + vit->GetMsg();
1695  if (!description.empty())
1696  msg += description + "\n";
1697  }
1698  if (msg.empty())
1699  msg = "Validation test of the alignment succeeded";
1700  CGenericReportDlg* report = new CGenericReportDlg(NULL);
1701  report->SetTitle(wxT("Validator Report"));
1702  report->SetText(ToWxString(msg));
1703  report->Show(true);
1704  report->SetFocus();
1705 }
1706 
1707 void CAlignmentAssistant::OnPropagateFeatures(wxCommandEvent& /*event*/)
1708 {
1709  int row = m_Panel->GetTarget();
1710  const CDense_seg& denseg = m_Alignment.GetSegs().GetDenseg();
1711  const CSeq_id& id = denseg.GetSeq_id(row);
1713  if (!bsh) {
1714  return;
1715  }
1716 
1717  vector<CConstRef<CSeq_feat>> propagatedFeats;
1718  for (CFeat_CI ci(bsh); ci; ++ci) {
1719  propagatedFeats.push_back(ci->GetSeq_feat());
1720  }
1721 
1722  //Create and trigger the magic object editor that will take care of the
1723  // rest
1724  CIRef<IEditObject> editor(
1725  new CEditObjectFeaturePropagate(bsh, propagatedFeats));
1726 
1727  CEditObjViewDlgModal edit_dlg(NULL, true);
1728  wxWindow* editorWindow = editor->CreateWindow(&edit_dlg);
1729  edit_dlg.SetEditorWindow(editorWindow);
1730  edit_dlg.SetEditor(editor);
1731  if (edit_dlg.ShowModal() == wxID_OK)
1732  {
1733  try
1734  {
1735  CIRef<IEditCommand> cmd(editor->GetEditCommand());
1736  if (cmd && x_ExecuteCommand(cmd)) {
1737  GetFeatures();
1739  m_Panel->Refresh();
1740  m_Panel->SetFocus();
1741  }
1742  } catch(CException &e) {} catch (exception &e) {}
1743  } else
1744  m_Panel->SetFocus();
1745 
1746 }
1747 
1748 void CAlignmentAssistant::OnRemoveSeqFromAlign(wxCommandEvent& /*event*/)
1749  {
1750  int index = m_Panel->GetTarget();
1751  if (index < 0)
1752  return;
1753  if (wxYES != wxMessageBox(_("You are about to remove 1 sequence from the alignment. Are you sure?"), wxT("Confirm"), wxYES_NO | wxICON_QUESTION))
1754  return;
1755 
1756  CRef<CSeq_align> align(new CSeq_align());
1757  align->Assign(*m_Alignment.GetSeq_align());
1758 
1759  unsigned int dim = static_cast<unsigned int>(align->GetSegs().GetDenseg().GetIds().size());
1760 
1761  int row = 0;
1762  CDense_seg::TIds ids;
1763  for (CDense_seg::TIds::const_iterator id_iter = align->GetSegs().GetDenseg().GetIds().begin(); id_iter != align->GetSegs().GetDenseg().GetIds().end(); ++id_iter)
1764  {
1765  if (row != index)
1766  ids.push_back(*id_iter);
1767  row++;
1768  }
1769 
1770 
1771  if (align->GetSegs().GetDenseg().IsSetNumseg() && index < dim)
1772  {
1773  unsigned int numseg = align->GetSegs().GetDenseg().GetNumseg();
1774  // remove starts, strands
1775  CDense_seg::TStarts starts;
1776  CDense_seg::TStarts::const_iterator start_iter;
1777  CDense_seg::TStrands strands;
1778  CDense_seg::TStrands::const_iterator strand_iter;
1779 
1780  if (align->GetSegs().GetDenseg().IsSetStarts()) start_iter = align->GetSegs().GetDenseg().GetStarts().begin();
1781  if (align->GetSegs().GetDenseg().IsSetStrands()) strand_iter = align->GetSegs().GetDenseg().GetStrands().begin();
1782 
1783  for (unsigned int seg = 0; seg<numseg; seg++)
1784  for (unsigned int i=0; i<dim; i++)
1785  if (i != index)
1786  {
1787  if (align->GetSegs().GetDenseg().IsSetStarts() && start_iter != align->GetSegs().GetDenseg().GetStarts().end())
1788  {
1789  starts.push_back(*start_iter);
1790  start_iter++;
1791  }
1792  if (align->GetSegs().GetDenseg().IsSetStrands() && strand_iter != align->GetSegs().GetDenseg().GetStrands().end())
1793  {
1794  strands.push_back(*strand_iter);
1795  strand_iter++;
1796  }
1797  }
1798  else
1799  {
1800  if (align->GetSegs().GetDenseg().IsSetStarts() && start_iter != align->GetSegs().GetDenseg().GetStarts().end())
1801  start_iter++;
1802 
1803  if (align->GetSegs().GetDenseg().IsSetStrands() && strand_iter != align->GetSegs().GetDenseg().GetStrands().end())
1804  strand_iter++;
1805  }
1806 
1807  if (align->GetSegs().GetDenseg().IsSetStarts()) align->SetSegs().SetDenseg().SetStarts().swap(starts);
1808  if (align->GetSegs().GetDenseg().IsSetStrands()) align->SetSegs().SetDenseg().SetStrands().swap(strands);
1809  }
1810 
1811  align->SetSegs().SetDenseg().SetDim(static_cast<CDense_seg::TDim>(ids.size()));
1812  align->SetDim(static_cast<CSeq_align::TDim>(ids.size()));
1813  align->SetSegs().SetDenseg().SetIds().swap(ids);
1814  align->SetSegs().SetDenseg().RemovePureGapSegs(); // sets numsegs correctly
1815 
1816 
1817 
1818  if (ids.size() < 2)
1819  {
1820  wxMessageBox(_("Cannot remove last pair of bioseqs from alignment"), wxT("Error"), wxOK|wxICON_ERROR);
1821  }
1822  else
1823  {
1825  if (cmd && x_ExecuteCommand(cmd))
1826  {
1827  int item_id = m_target_submenu->FindItem(wxString(m_Labels[index]));
1828  m_target_submenu->Destroy(item_id);
1829  GetAlignment(align);
1833  }
1834  }
1835  m_Panel->SetFocus();
1836  }
1837 
1838 void CAlignmentAssistant::OnReverseStrand(wxCommandEvent& /*event*/)
1839  {
1840  int row = m_Panel->GetTarget();
1841  if (row < 0)
1842  return;
1843  if (wxYES != wxMessageBox(_("You are about to reverse 1 sequence in the alignment. Are you sure?"), wxT("Confirm"), wxYES_NO | wxICON_QUESTION))
1844  return;
1845 
1846  CRef<CSeq_align> align(new CSeq_align());
1847  align->Assign(*m_Alignment.GetSeq_align());
1848 
1849  CDense_seg& denseg = align->SetSegs().SetDenseg();
1850  CDense_seg::TDim num_rows = denseg.GetDim();
1851  CDense_seg::TNumseg num_segs = denseg.GetNumseg();
1852  const CSeq_id& id = denseg.GetSeq_id(row);
1854  if (!bsh)
1855  return;
1856  int length = bsh.GetBioseqLength();
1857  if (!denseg.IsSetStrands())
1858  {
1859  vector<ENa_strand> new_strands(num_rows * num_segs, eNa_strand_plus);
1860  denseg.SetStrands() = new_strands;
1861  }
1862  for (CDense_seg::TNumseg seg = 0; seg < num_segs; ++seg)
1863  {
1864  TSignedSeqPos start = denseg.GetStarts()[seg * num_rows + row];
1865  ENa_strand strand = denseg.GetStrands()[seg * num_rows + row];
1866  TSignedSeqPos len = denseg.GetLens()[seg];
1867  if (start != -1)
1868  denseg.SetStarts()[seg * num_rows + row] = length - start - len;
1869  if (strand == eNa_strand_plus)
1870  denseg.SetStrands()[seg * num_rows + row] = eNa_strand_minus;
1871  else
1872  denseg.SetStrands()[seg * num_rows + row] = eNa_strand_plus;
1873  }
1874 
1875 
1876 
1878  if (cmd && x_ExecuteCommand(cmd)) {
1879  GetAlignment(align);
1883  }
1884  }
1885 
1886 
1887 
1888 
1889 /*!
1890  * CAlignCDSAddPanel type definition
1891  */
1892 
1893 IMPLEMENT_DYNAMIC_CLASS( CAlignCDSAddPanel, wxDialog )
1894 
1895 
1896 /*!
1897  * CAlignCDSAddPanel event table definition
1898  */
1899 
1900 BEGIN_EVENT_TABLE( CAlignCDSAddPanel, wxDialog )
1901 
1902 ////@begin CAlignCDSAddPanel event table entries
1903 ////@end CAlignCDSAddPanel event table entries
1904 
1906 
1907 
1908 /*!
1909  * CAlignCDSAddPanel constructors
1910  */
1911 
1913 {
1914  Init();
1915 }
1916 
1917 CAlignCDSAddPanel::CAlignCDSAddPanel( wxWindow* parent, CRef<CSeq_loc> align_loc, CScope &scope, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
1918  : m_Loc(align_loc), m_scope(&scope)
1919 {
1920  Init();
1921  Create(parent, id, pos, size, style);
1922 }
1923 
1924 
1925 /*!
1926  * CAlignCDSAddPanel creator
1927  */
1928 
1929 bool CAlignCDSAddPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
1930 {
1931 ////@begin CAlignCDSAddPanel creation
1932  wxDialog::Create( parent, id, SYMBOL_CALIGNCDSADDPANEL_TITLE, pos, size, style );
1933 
1934  CreateControls();
1935  if (GetSizer())
1936  {
1937  GetSizer()->SetSizeHints(this);
1938  }
1939  Centre();
1940 ////@end CAlignCDSAddPanel creation
1941  return true;
1942 }
1943 
1944 
1945 /*!
1946  * CAlignCDSAddPanel destructor
1947  */
1948 
1950 {
1951 ////@begin CAlignCDSAddPanel destruction
1952 ////@end CAlignCDSAddPanel destruction
1953 }
1954 
1955 
1956 /*!
1957  * Member initialisation
1958  */
1959 
1961 {
1962 ////@begin CAlignCDSAddPanel member initialisation
1963  m_ProteinName = NULL;
1965  m_GeneSymbol = NULL;
1967  m_Comment = NULL;
1968  m_Location = NULL;
1969 ////@end CAlignCDSAddPanel member initialisation
1970 }
1971 
1972 
1973 /*!
1974  * Control creation for CAlignCDSAddPanel
1975  */
1976 
1978 {
1979 ////@begin CAlignCDSAddPanel content construction
1980  CAlignCDSAddPanel* itemCBulkCmdPanel1 = this;
1981 
1982  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
1983  itemCBulkCmdPanel1->SetSizer(itemBoxSizer2);
1984 
1985  wxFlexGridSizer* itemFlexGridSizer3 = new wxFlexGridSizer(0, 2, 0, 0);
1986  itemBoxSizer2->Add(itemFlexGridSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
1987 
1988  wxStaticText* itemStaticText8 = new wxStaticText( itemCBulkCmdPanel1, wxID_STATIC, _("Gene Symbol"), wxDefaultPosition, wxDefaultSize, 0 );
1989  itemFlexGridSizer3->Add(itemStaticText8, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
1990 
1991  m_GeneSymbol = new wxTextCtrl( itemCBulkCmdPanel1, ID_ALIGNCDSADD_GENE_NAME, wxEmptyString, wxDefaultPosition, wxSize(200, -1), 0 );
1992  itemFlexGridSizer3->Add(m_GeneSymbol, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
1993 
1994  wxStaticText* itemStaticText9 = new wxStaticText( itemCBulkCmdPanel1, wxID_STATIC, _("Gene Description"), wxDefaultPosition, wxDefaultSize, 0 );
1995  itemFlexGridSizer3->Add(itemStaticText9, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
1996 
1997  m_GeneDescription = new wxTextCtrl( itemCBulkCmdPanel1, ID_ALIGNCDSADD_GENE_DESC, wxEmptyString, wxDefaultPosition, wxSize(200, -1), 0 );
1998  itemFlexGridSizer3->Add(m_GeneDescription, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
1999 
2000  wxStaticText* itemStaticText4 = new wxStaticText( itemCBulkCmdPanel1, wxID_STATIC, _("Protein Name"), wxDefaultPosition, wxDefaultSize, 0 );
2001  itemFlexGridSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2002 
2003  m_ProteinName = new wxTextCtrl( itemCBulkCmdPanel1, ID_ALIGNCDSADD_PROTEIN_NAME, wxEmptyString, wxDefaultPosition, wxSize(200, -1), 0 );
2004  itemFlexGridSizer3->Add(m_ProteinName, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2005 
2006  wxStaticText* itemStaticText6 = new wxStaticText( itemCBulkCmdPanel1, wxID_STATIC, _("Protein Description"), wxDefaultPosition, wxDefaultSize, 0 );
2007  itemFlexGridSizer3->Add(itemStaticText6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2008 
2009  m_ProteinDescription = new wxTextCtrl( itemCBulkCmdPanel1, ID_ALIGNCDSADD_PROTEIN_DESC, wxEmptyString, wxDefaultPosition, wxSize(200, -1), 0 );
2010  itemFlexGridSizer3->Add(m_ProteinDescription, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2011 
2012  wxStaticText* itemStaticText10 = new wxStaticText( itemCBulkCmdPanel1, wxID_STATIC, _("Comment"), wxDefaultPosition, wxDefaultSize, 0 );
2013  itemFlexGridSizer3->Add(itemStaticText10, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2014 
2015  m_Comment = new wxTextCtrl( itemCBulkCmdPanel1, ID_ALIGNCDSADD_COMMENT, wxEmptyString, wxDefaultPosition, wxSize(300, 70), wxTE_MULTILINE );
2016  itemFlexGridSizer3->Add(m_Comment, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2017 
2018  m_Location = new CLocationPanel(itemCBulkCmdPanel1, *m_Loc, m_scope, true, false, false, wxID_ANY, wxDefaultPosition, wxDefaultSize);
2019  itemBoxSizer2->Add(m_Location, 1, wxALIGN_CENTER_HORIZONTAL|wxALL|wxFIXED_MINSIZE, 5);
2021 
2022  wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
2023  itemBoxSizer2->Add(itemBoxSizer12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
2024 
2025  wxButton* itemButton13 = new wxButton( itemCBulkCmdPanel1, wxID_OK, _("Accept"), wxDefaultPosition, wxDefaultSize, 0 );
2026  itemBoxSizer12->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2027 
2028  wxButton* itemButton14 = new wxButton( itemCBulkCmdPanel1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
2029  itemBoxSizer12->Add(itemButton14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2030 ////@end CAlignCDSAddPanel content construction
2031 }
2032 
2033 
2034 /*!
2035  * Should we show tooltips?
2036  */
2037 
2039 {
2040  return true;
2041 }
2042 
2043 /*!
2044  * Get bitmap resources
2045  */
2046 
2047 wxBitmap CAlignCDSAddPanel::GetBitmapResource( const wxString& name )
2048 {
2049  // Bitmap retrieval
2050 ////@begin CAlignCDSAddPanel bitmap retrieval
2051  wxUnusedVar(name);
2052  return wxNullBitmap;
2053 ////@end CAlignCDSAddPanel bitmap retrieval
2054 }
2055 
2056 /*!
2057  * Get icon resources
2058  */
2059 
2060 wxIcon CAlignCDSAddPanel::GetIconResource( const wxString& name )
2061 {
2062  // Icon retrieval
2063 ////@begin CAlignCDSAddPanel icon retrieval
2064  wxUnusedVar(name);
2065  return wxNullIcon;
2066 ////@end CAlignCDSAddPanel icon retrieval
2067 }
2068 
2069 
2071 {
2074  CAlignmentAssistant *parent = dynamic_cast<CAlignmentAssistant*>(GetParent());
2075  vector<pair<CRef<CSeq_loc>, CBioseq_Handle> > locations;
2076  parent->TranslateLocations(loc, locations);
2077  m_create_general_only = false;
2078  if (!locations.empty())
2079  m_create_general_only = objects::edit::IsGeneralIdProtPresent(locations.front().second.GetTopLevelEntry());
2080  CRef<CCmdComposite> cmd (new CCmdComposite("Align Add CDS"));
2081  for (size_t i = 0; i < locations.size(); ++i)
2082  {
2083  CRef<CSeq_loc> seq_loc = locations[i].first;
2084  CBioseq_Handle bsh = locations[i].second;
2085  AddOneCommand(bsh,seq_loc,cmd);
2086  }
2087 
2088  return cmd;
2089 }
2090 
2092 {
2093  if (!seq_loc || !bsh || (seq_loc->IsMix() && !seq_loc->GetMix().IsSet()))
2094  return;
2095 
2096 
2097  string prot_name = ToStdString(m_ProteinName->GetValue());
2098  string prot_desc = ToStdString(m_ProteinDescription->GetValue());
2099  string cds_comment = ToStdString(m_Comment->GetValue());
2100  string gene_symbol = ToStdString(m_GeneSymbol->GetValue());
2101  string gene_desc = ToStdString(m_GeneDescription->GetValue());
2102 
2103  CRef<objects::CSeq_feat> cds(new objects::CSeq_feat());
2104  cds->SetData().SetCdregion();
2105  if (!NStr::IsBlank(cds_comment)) {
2106  cds->SetComment(cds_comment);
2107  }
2108 
2109  // add appropriate genetic code
2111  if (code) {
2112  cds->SetData().SetCdregion().SetCode(*code);
2113  }
2114 
2115  cds->SetLocation().Assign(*seq_loc);
2116  cds->SetPartial(cds->GetLocation().IsPartialStart(objects::eExtreme_Biological) || cds->GetLocation().IsPartialStop(objects::eExtreme_Biological));
2117 
2118  objects::CSeq_entry_Handle seh = bsh.GetSeq_entry_Handle();
2119  CCleanup cleanup;
2120 
2121  if (seq_loc->IsPnt())
2122  {
2123  cds->SetData().SetCdregion().SetFrame(CCdregion::eFrame_not_set);
2124  }
2125  else
2126  {
2127  cds->SetData().SetCdregion().SetFrame(objects::CSeqTranslator::FindBestFrame(*cds, bsh.GetScope()));
2128 
2131  cds->GetLocation().IsPartialStart(objects::eExtreme_Biological),
2132  cds->GetLocation().IsPartialStop(objects::eExtreme_Biological));
2133 
2134  if (!NStr::IsBlank(prot_name)) {
2135  prot->SetData().SetProt().SetName().push_back(prot_name);
2136  }
2137  if (!NStr::IsBlank(prot_desc)) {
2138  prot->SetData().SetProt().SetDesc(prot_desc);
2139  }
2140 
2141  cleanup.BasicCleanup(*prot);
2142  cmd->AddCommand(*CRef<objects::CCmdAddSeqEntry>(new objects::CCmdAddSeqEntry(protein, seh)));
2143  }
2144 
2145  if (!NStr::IsBlank(gene_symbol) || !NStr::IsBlank(gene_desc))
2146  {
2147  // create gene feature
2148  CRef<objects::CSeq_feat> new_gene(new objects::CSeq_feat());
2149  if (!NStr::IsBlank(gene_symbol))
2150  new_gene->SetData().SetGene().SetLocus(gene_symbol);
2151  if (!NStr::IsBlank(gene_desc))
2152  new_gene->SetData().SetGene().SetDesc(gene_desc);
2153  new_gene->SetLocation().Assign(cds->GetLocation());
2154  if (new_gene->GetLocation().IsPartialStart(objects::eExtreme_Biological)
2155  || new_gene->GetLocation().IsPartialStop(objects::eExtreme_Biological))
2156  {
2157  new_gene->SetPartial(true);
2158  }
2159  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(seh, *new_gene)));
2160  }
2161 
2162  cleanup.BasicCleanup(*cds);
2163  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(seh, *cds)));
2164 }
2165 
2166 
2167 
2168 
2169 /*!
2170  * CAlignRNAAddPanel type definition
2171  */
2172 
2173 IMPLEMENT_DYNAMIC_CLASS( CAlignRNAAddPanel, wxDialog )
2174 
2175 
2176 /*!
2177  * CAlignRNAAddPanel event table definition
2178  */
2179 
2180 BEGIN_EVENT_TABLE( CAlignRNAAddPanel, wxDialog )
2181 
2182 ////@begin CAlignRNAAddPanel event table entries
2184 
2186 
2188 
2189 ////@end CAlignRNAAddPanel event table entries
2190 
2192 
2193 
2194 /*!
2195  * CAlignRNAAddPanel constructors
2196  */
2197 
2199 {
2200  Init();
2201 }
2202 
2203 CAlignRNAAddPanel::CAlignRNAAddPanel( wxWindow* parent, CRef<CSeq_loc> align_loc, CScope &scope, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
2204  : m_Loc(align_loc), m_scope(&scope)
2205 {
2206  Init();
2207  Create(parent, id, pos, size, style);
2208 }
2209 
2210 
2211 /*!
2212  * CAlignRNAAddPanel creator
2213  */
2214 
2215 bool CAlignRNAAddPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
2216 {
2217 ////@begin CAlignRNAAddPanel creation
2218  wxDialog::Create( parent, id, SYMBOL_CALIGN_RNA_ADD_PANEL_TITLE, pos, size, style );
2219 
2220  CreateControls();
2221  if (GetSizer())
2222  {
2223  GetSizer()->SetSizeHints(this);
2224  }
2225  Centre();
2226 ////@end CAlignRNAAddPanel creation
2227  return true;
2228 }
2229 
2230 
2231 /*!
2232  * CAlignRNAAddPanel destructor
2233  */
2234 
2236 {
2237 ////@begin CAlignRNAAddPanel destruction
2238 ////@end CAlignRNAAddPanel destruction
2239 }
2240 
2241 
2242 /*!
2243  * Member initialisation
2244  */
2245 
2247 {
2248 ////@begin CAlignRNAAddPanel member initialisation
2249  m_RNAType = NULL;
2250  m_ncRNAClass = NULL;
2251  m_FieldSizer = NULL;
2252  m_RNANameSizer = NULL;
2253  m_Comment = NULL;
2254  m_ButtonsSizer = NULL;
2255  m_Location = NULL;
2256 ////@end CAlignRNAAddPanel member initialisation
2257  m_Locus = NULL;
2258  m_GeneDesc = NULL;
2259  m_tRNAname = NULL;
2260  m_RNAname = NULL;
2261  m_rRNAname = NULL;
2262 }
2263 
2264 
2265 /*!
2266  * Control creation for CAlignRNAAddPanel
2267  */
2268 
2270 {
2271 ////@begin CAlignRNAAddPanel content construction
2272  CAlignRNAAddPanel* itemCBulkCmdPanel1 = this;
2273 
2274  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
2275  itemCBulkCmdPanel1->SetSizer(itemBoxSizer2);
2276 
2277  itemBoxSizer2->Add(0, 500, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
2278 
2279  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
2280  itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2281 
2282  wxStaticBox* itemStaticBoxSizer5Static = new wxStaticBox(itemCBulkCmdPanel1, wxID_ANY, _("RNA Type"));
2283  wxStaticBoxSizer* itemStaticBoxSizer5 = new wxStaticBoxSizer(itemStaticBoxSizer5Static, wxVERTICAL);
2284  itemBoxSizer4->Add(itemStaticBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
2285 
2286  wxArrayString m_RNATypeStrings;
2287  m_RNATypeStrings.Add(_("preRNA"));
2288  m_RNATypeStrings.Add(_("mRNA"));
2289  m_RNATypeStrings.Add(_("tRNA"));
2290  m_RNATypeStrings.Add(_("rRNA"));
2291  m_RNATypeStrings.Add(_("ncRNA"));
2292  m_RNATypeStrings.Add(_("tmRNA"));
2293  m_RNATypeStrings.Add(_("miscRNA"));
2294  m_RNAType = new wxChoice( itemStaticBoxSizer5->GetStaticBox(), ID_CALIGN_RNA_ADD_PANEL_CHOICE1, wxDefaultPosition, wxDefaultSize, m_RNATypeStrings, 0 );
2295  m_RNAType->SetStringSelection(_("rRNA"));
2296  itemStaticBoxSizer5->Add(m_RNAType, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
2297 
2298  wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
2299  itemStaticBoxSizer5->Add(itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
2300 
2301  wxStaticText* itemStaticText8 = new wxStaticText( itemStaticBoxSizer5->GetStaticBox(), wxID_STATIC, _("ncRNA class"), wxDefaultPosition, wxDefaultSize, 0 );
2302  itemBoxSizer7->Add(itemStaticText8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2303 
2304  wxArrayString m_ncRNAClassStrings;
2305  m_ncRNAClass = new wxComboBox( itemStaticBoxSizer5->GetStaticBox(), ID_CALIGN_RNA_ADD_PANEL_COMBOBOX, wxEmptyString, wxDefaultPosition, wxDefaultSize, m_ncRNAClassStrings, wxCB_DROPDOWN );
2306  m_ncRNAClass->Enable(false);
2307  itemBoxSizer7->Add(m_ncRNAClass, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2308 
2309  m_FieldSizer = new wxFlexGridSizer(0, 2, 0, 0);
2310  itemBoxSizer4->Add(m_FieldSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
2311 
2312  wxStaticText* itemStaticText11 = new wxStaticText( itemCBulkCmdPanel1, wxID_STATIC, _("RNA Name"), wxDefaultPosition, wxDefaultSize, 0 );
2313  m_FieldSizer->Add(itemStaticText11, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2314 
2315  m_RNANameSizer = new wxBoxSizer(wxHORIZONTAL);
2316  m_FieldSizer->Add(m_RNANameSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
2317 
2318  wxStaticText* itemStaticText13 = new wxStaticText( itemCBulkCmdPanel1, wxID_STATIC, _("Comment"), wxDefaultPosition, wxDefaultSize, 0 );
2319  m_FieldSizer->Add(itemStaticText13, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2320 
2321  m_Comment = new wxTextCtrl( itemCBulkCmdPanel1, ID_CALIGN_RNA_ADD_PANEL_TEXTCTRL10, wxEmptyString, wxDefaultPosition, wxSize(300, 70), wxTE_MULTILINE );
2322  m_FieldSizer->Add(m_Comment, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2323 
2324  m_ButtonsSizer = new wxBoxSizer(wxHORIZONTAL);
2325  itemBoxSizer4->Add(m_ButtonsSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
2326 
2327  wxButton* itemButton16 = new wxButton( itemCBulkCmdPanel1, ID_CALIGN_RNA_ADD_PANEL_BUTTON11, _("Add '18S-ITS-5.8S-ITS-28S' to comment"), wxDefaultPosition, wxDefaultSize, 0 );
2328  m_ButtonsSizer->Add(itemButton16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2329 
2330  wxButton* itemButton17 = new wxButton( itemCBulkCmdPanel1, ID_CALIGN_RNA_ADD_PANEL_BUTTON12, _("Add '16S-IGS-23S' to comment"), wxDefaultPosition, wxDefaultSize, 0 );
2331  m_ButtonsSizer->Add(itemButton17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2332 
2333  m_Location = new CLocationPanel(itemCBulkCmdPanel1, *m_Loc, m_scope, true, false, false, wxID_ANY, wxDefaultPosition, wxDefaultSize);
2334  itemBoxSizer4->Add(m_Location, 1, wxALIGN_CENTER_HORIZONTAL|wxALL|wxFIXED_MINSIZE, 5);
2336 
2337 ////@end CAlignRNAAddPanel content construction
2338  vector<string> class_vals = CRNA_gen::GetncRNAClassList();
2339  ITERATE(vector<string>, it, class_vals) {
2340  m_ncRNAClass->AppendString(ToWxString(*it));
2341  }
2342  // because we start with rRNA as the default:
2343  x_AddrRNAName();
2344  m_ButtonsSizer->ShowItems(false);
2345 
2346  wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
2347  itemBoxSizer4->Add(itemBoxSizer12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
2348 
2349  wxButton* itemButton13 = new wxButton( itemCBulkCmdPanel1, wxID_OK, _("Accept"), wxDefaultPosition, wxDefaultSize, 0 );
2350  itemBoxSizer12->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2351 
2352  wxButton* itemButton14 = new wxButton( itemCBulkCmdPanel1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
2353  itemBoxSizer12->Add(itemButton14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2354 }
2355 
2356 
2357 /*!
2358  * Should we show tooltips?
2359  */
2360 
2362 {
2363  return true;
2364 }
2365 
2366 /*!
2367  * Get bitmap resources
2368  */
2369 
2370 wxBitmap CAlignRNAAddPanel::GetBitmapResource( const wxString& name )
2371 {
2372  // Bitmap retrieval
2373 ////@begin CAlignRNAAddPanel bitmap retrieval
2374  wxUnusedVar(name);
2375  return wxNullBitmap;
2376 ////@end CAlignRNAAddPanel bitmap retrieval
2377 }
2378 
2379 /*!
2380  * Get icon resources
2381  */
2382 
2383 wxIcon CAlignRNAAddPanel::GetIconResource( const wxString& name )
2384 {
2385  // Icon retrieval
2386 ////@begin CAlignRNAAddPanel icon retrieval
2387  wxUnusedVar(name);
2388  return wxNullIcon;
2389 ////@end CAlignRNAAddPanel icon retrieval
2390 }
2391 
2392 
2394 {
2395  // hide feature details
2396  if (m_RNANameSizer->GetItemCount() > 0) {
2397  int pos = 0;
2398  m_RNANameSizer->GetItem(pos)->DeleteWindows();
2399  m_RNANameSizer->Remove(pos);
2400  m_RNAname = NULL;
2401  m_tRNAname = NULL;
2402  m_rRNAname = NULL;
2403  }
2404 }
2405 
2406 
2408 {
2409  if (m_Locus == NULL && m_GeneDesc == NULL) {
2410  wxStaticText* itemStaticText11 = new wxStaticText( this, wxID_STATIC, _("Gene Symbol"), wxDefaultPosition, wxDefaultSize, 0 );
2411  m_FieldSizer->Add(itemStaticText11, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2412 
2413  m_Locus = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, -1), 0 );
2414  m_FieldSizer->Add(m_Locus, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2415 
2416  wxStaticText* itemStaticText13 = new wxStaticText( this, wxID_STATIC, _("Gene Description"), wxDefaultPosition, wxDefaultSize, 0 );
2417  m_FieldSizer->Add(itemStaticText13, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2418 
2419  m_GeneDesc = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, -1), 0 );
2420  m_FieldSizer->Add(m_GeneDesc, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2421  return true;
2422  } else {
2423  return false;
2424  }
2425 
2426 }
2427 
2428 
2430 {
2431  bool need_layout = false;
2432  size_t num_items = m_FieldSizer->GetItemCount();
2433  while (num_items > 4) {
2434  size_t pos = num_items - 1;
2435  m_FieldSizer->GetItem(pos)->DeleteWindows();
2436  m_FieldSizer->Remove(static_cast<int>(pos));
2437  need_layout = true;
2438  num_items = m_FieldSizer->GetItemCount();
2439  }
2440  m_Locus = NULL;
2441  m_GeneDesc = NULL;
2442  return need_layout;
2443 }
2444 
2445 
2447 {
2448  bool need_layout = false;
2449  if (m_rRNAname == NULL) {
2450  x_RemoveRNANames();
2451  wxArrayString m_NameStrings;
2452  m_NameStrings.Add(_("16S ribosomal RNA"));
2453  m_NameStrings.Add(_("18S ribosomal RNA"));
2454  m_NameStrings.Add(_("23S ribosomal RNA"));
2455  m_NameStrings.Add(_("26S ribosomal RNA"));
2456  m_NameStrings.Add(_("28S ribosomal RNA"));
2457  m_NameStrings.Add(_("5.8S ribosomal RNA"));
2458  m_NameStrings.Add(_("large subunit ribosomal RNA"));
2459  m_NameStrings.Add(_("small subunit ribosomal RNA"));
2460  m_rRNAname = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, m_NameStrings, wxCB_DROPDOWN );
2461  m_RNANameSizer->Add(m_rRNAname, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2462  need_layout = true;
2463  }
2464  return need_layout;
2465 }
2466 
2467 
2468 /*!
2469  * wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_CHOICE1
2470  */
2471 
2472 void CAlignRNAAddPanel::OnSelectRNAType( wxCommandEvent& event )
2473 {
2474  string rna_type = ToStdString(m_RNAType->GetStringSelection());
2475  bool need_layout = false;
2476  if (NStr::Equal(rna_type, "ncRNA")) {
2477  m_ncRNAClass->Enable(true);
2478  } else {
2479  m_ncRNAClass->Enable(false);
2480  }
2481  bool buttons_shown = m_ButtonsSizer->IsShown((size_t)0);
2482  if (NStr::Equal(rna_type, "miscRNA")) {
2483  if (!buttons_shown) {
2484  m_ButtonsSizer->ShowItems(true);
2485  need_layout = true;
2486  }
2487  } else {
2488  if (buttons_shown) {
2489  m_ButtonsSizer->ShowItems(false);
2490  need_layout = true;
2491  }
2492  }
2493  // create RNA Name control
2494  if (NStr::Equal(rna_type, "tRNA")) {
2495  if (m_tRNAname == NULL) {
2496  x_RemoveRNANames();
2497  wxArrayString m_tRNAStrings;
2498  m_tRNAStrings.Add(_("A Alanine"));
2499  m_tRNAStrings.Add(_("B Asp or Asn"));
2500  m_tRNAStrings.Add(_("C Cysteine"));
2501  m_tRNAStrings.Add(_("D Aspartic Acid"));
2502  m_tRNAStrings.Add(_("E Glutamic Acid"));
2503  m_tRNAStrings.Add(_("F Phenylalanine"));
2504  m_tRNAStrings.Add(_("G Glycine"));
2505  m_tRNAStrings.Add(_("H Histidine"));
2506  m_tRNAStrings.Add(_("I Isoleucine"));
2507  m_tRNAStrings.Add(_("J Leu or Ile"));
2508  m_tRNAStrings.Add(_("K Lysine"));
2509  m_tRNAStrings.Add(_("L Leucine"));
2510  m_tRNAStrings.Add(_("M Methionine"));
2511  m_tRNAStrings.Add(_("N Asparagine"));
2512  m_tRNAStrings.Add(_("O Pyrrolysine"));
2513  m_tRNAStrings.Add(_("P Proline"));
2514  m_tRNAStrings.Add(_("Q Glutamine"));
2515  m_tRNAStrings.Add(_("R Arginine"));
2516  m_tRNAStrings.Add(_("S Serine"));
2517  m_tRNAStrings.Add(_("T Threonine"));
2518  m_tRNAStrings.Add(_("U Selenocysteine"));
2519  m_tRNAStrings.Add(_("V Valine"));
2520  m_tRNAStrings.Add(_("W Tryptophan"));
2521  m_tRNAStrings.Add(_("X Undetermined or atypical"));
2522  m_tRNAStrings.Add(_("Y Tyrosine"));
2523  m_tRNAStrings.Add(_("Z Glu or Gln"));
2524  m_tRNAname = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_tRNAStrings, 0 );
2525  m_RNANameSizer->Add(m_tRNAname, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2526  need_layout = true;
2527  }
2528  need_layout |= x_AddGeneFields();
2529  } else if (NStr::Equal(rna_type, "rRNA")) {
2530  need_layout |= x_RemoveGeneFields();
2531  need_layout |= x_AddrRNAName();
2532 
2533  } else {
2534  if (NStr::Equal(rna_type, "ncRNA") || NStr::Equal(rna_type, "mRNA")) {
2535  need_layout |= x_AddGeneFields();
2536  } else {
2537  need_layout |= x_RemoveGeneFields();
2538  }
2539 
2540  if (m_RNAname == NULL) {
2541  x_RemoveRNANames();
2542  m_RNAname = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, -1), 0 );
2543  m_RNANameSizer->Add(m_RNAname, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2544  need_layout = true;
2545  }
2546  }
2547  if (need_layout) {
2548  Fit();
2549  Layout();
2550  }
2551 }
2552 
2553 
2554 /*!
2555  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON11
2556  */
2557 
2558 void CAlignRNAAddPanel::OnAdd18SToComment( wxCommandEvent& event )
2559 {
2560  string comment = ToStdString(m_Comment->GetValue());
2561  if (!NStr::IsBlank(comment)) {
2562  comment += "; ";
2563  }
2564  comment += "contains 18S ribosomal RNA, internal transcribed spacer 1, 5.8S ribosomal RNA, internal transcribed spacer 2, and 28S ribosomal RNA";
2565  m_Comment->SetValue(ToWxString(comment));
2566 }
2567 
2568 
2569 /*!
2570  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON12
2571  */
2572 
2573 void CAlignRNAAddPanel::OnAdd16StoComment( wxCommandEvent& event )
2574 {
2575  string comment = ToStdString(m_Comment->GetValue());
2576  if (!NStr::IsBlank(comment)) {
2577  comment += "; ";
2578  }
2579  comment += "contains 16S ribosomal RNA, 16S-23S ribosomal RNA intergenic spacer, and 23S ribosomal RNA";
2580  m_Comment->SetValue(ToWxString(comment));
2581 }
2582 
2583 
2584 static void s_SettRNAProduct(string aa, CRef<CRNA_ref> rna)
2585 {
2586  rna->SetExt().SetTRNA();
2587  if (NStr::IsBlank(aa)) {
2588  return;
2589  }
2590  aa = NStr::ToUpper(aa);
2591  char a = aa.c_str()[0];
2592  rna->SetExt().SetTRNA().SetAa().SetIupacaa(a);
2593 }
2594 
2595 
2597 {
2599  switch (m_RNAType->GetSelection()) {
2600  case 0:
2601  rna_type = CRNA_ref::eType_premsg;
2602  break;
2603  case 1:
2604  rna_type = CRNA_ref::eType_mRNA;
2605  break;
2606  case 2:
2607  rna_type = CRNA_ref::eType_tRNA;
2608  break;
2609  case 3:
2610  rna_type = CRNA_ref::eType_rRNA;
2611  break;
2612  case 4:
2613  rna_type = CRNA_ref::eType_ncRNA;
2614  break;
2615  case 5:
2616  rna_type = CRNA_ref::eType_tmRNA;
2617  break;
2618  case 6:
2619  rna_type = CRNA_ref::eType_miscRNA;
2620  break;
2621  case 7:
2622  rna_type = CRNA_ref::eType_other;
2623  break;
2624  }
2625  return rna_type;
2626 }
2627 
2628 
2630 {
2631  string rna_name = "";
2632  if (m_RNAname != NULL) {
2633  rna_name = ToStdString(m_RNAname->GetValue());
2634  } else if (m_rRNAname != NULL) {
2635  rna_name = ToStdString(m_rRNAname->GetValue());
2636  }
2637  rna_name = GetAdjustedRnaName(rna_name);
2638  return rna_name;
2639 }
2640 
2641 
2643 {
2644  CRNA_ref::TType rna_type = x_GetRnaType();
2645  string rna_name = x_GetRnaName();
2646 
2647  if (NStr::IsBlank(rna_name) && rna_type == CRNA_ref::eType_rRNA) {
2649  return empty;
2650  }
2651 
2654  CAlignmentAssistant *parent = dynamic_cast<CAlignmentAssistant*>(GetParent());
2655  vector<pair<CRef<CSeq_loc>, CBioseq_Handle> > locations;
2656  parent->TranslateLocations(loc, locations);
2657 
2658  CRef<CCmdComposite> cmd (new CCmdComposite("Align Add RNA"));
2659  for (size_t i = 0; i < locations.size(); ++i)
2660  {
2661  CRef<CSeq_loc> seq_loc = locations[i].first;
2662  CBioseq_Handle bsh = locations[i].second;
2663  AddOneCommand(bsh,seq_loc,cmd);
2664  }
2665 
2666 
2667  return cmd;
2668 }
2669 
2671 {
2672  if (!seq_loc || !bsh || (seq_loc->IsMix() && !seq_loc->GetMix().IsSet()))
2673  return;
2674 
2675  CRNA_ref::TType rna_type = x_GetRnaType();
2676  string rna_name = x_GetRnaName();
2677  string comment = ToStdString(m_Comment->GetValue());
2678  string ncrna_class = ToStdString (m_ncRNAClass->GetStringSelection());
2679  string gene_symbol = "";
2680  if (m_Locus) {
2681  gene_symbol = ToStdString(m_Locus->GetValue());
2682  }
2683  string gene_desc = "";
2684  if (m_GeneDesc) {
2685  gene_desc = ToStdString(m_GeneDesc->GetValue());
2686  }
2687  CRef<CRNA_ref> rna_ref(new CRNA_ref());
2688  rna_ref->SetType(rna_type);
2689  // set product
2690  switch (rna_type) {
2691  case CRNA_ref::eType_ncRNA:
2692  case CRNA_ref::eType_tmRNA:
2694  rna_ref->SetExt().SetGen();
2695  if (!NStr::IsBlank(rna_name)) {
2696  rna_ref->SetExt().SetGen().SetProduct(rna_name);
2697  }
2698  if (rna_type == CRNA_ref::eType_ncRNA && !NStr::IsBlank(ncrna_class)) {
2699  rna_ref->SetExt().SetGen().SetClass(ncrna_class);
2700  }
2701  break;
2702  case CRNA_ref::eType_tRNA:
2703  if (m_tRNAname != NULL) {
2704  s_SettRNAProduct(ToStdString(m_tRNAname->GetStringSelection()), rna_ref);
2705  }
2706  break;
2707  default:
2708  if (!NStr::IsBlank(rna_name)) {
2709  rna_ref->SetExt().SetName(rna_name);
2710  }
2711  break;
2712  }
2713 
2714  objects::CSeq_entry_Handle seh = bsh.GetSeq_entry_Handle();
2715  CRef<objects::CSeq_feat> rna(new objects::CSeq_feat());
2716  rna->SetData().SetRna().Assign(*rna_ref);
2717 
2718  if (!NStr::IsBlank(comment)) {
2719  rna->SetComment(comment);
2720  }
2721 
2722  rna->SetLocation().Assign(*seq_loc);
2723  if (rna->GetLocation().IsPartialStart(objects::eExtreme_Biological)
2724  || rna->GetLocation().IsPartialStop(objects::eExtreme_Biological)) {
2725  rna->SetPartial(true);
2726  }
2727  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(seh, *rna)));
2728 
2729  if (!NStr::IsBlank(gene_symbol) || !NStr::IsBlank(gene_desc)) {
2730  // create gene feature
2731  CRef<objects::CSeq_feat> new_gene(new objects::CSeq_feat());
2732  new_gene->SetData().SetGene().SetLocus(gene_symbol);
2733  new_gene->SetData().SetGene().SetDesc(gene_desc);
2734  new_gene->SetLocation().Assign(*seq_loc);
2735  if (new_gene->GetLocation().IsPartialStart(objects::eExtreme_Biological)
2736  || new_gene->GetLocation().IsPartialStop(objects::eExtreme_Biological)) {
2737  new_gene->SetPartial(true);
2738  }
2739  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(seh, *new_gene)));
2740  }
2741 }
2742 
2743 
2744 
2745 
2746 /*!
2747  * CAlignOtherAddPanel type definition
2748  */
2749 
2750 IMPLEMENT_DYNAMIC_CLASS( CAlignOtherAddPanel, wxDialog )
2751 
2752 
2753 /*!
2754  * CAlignOtherAddPanel event table definition
2755  */
2756 
2757 BEGIN_EVENT_TABLE( CAlignOtherAddPanel, wxDialog )
2758 
2759 ////@begin CAlignOtherAddPanel event table entries
2761 
2762 ////@end CAlignOtherAddPanel event table entries
2763 
2765 
2766 
2767 /*!
2768  * CAlignOtherAddPanel constructors
2769  */
2770 
2772 {
2773  Init();
2774 }
2775 
2776 CAlignOtherAddPanel::CAlignOtherAddPanel( wxWindow* parent, CRef<CSeq_loc> align_loc, CSeq_entry_Handle seh, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
2777  : m_Loc(align_loc), m_TopSeqEntry(seh), m_scope(&seh.GetScope())
2778 {
2779  Init();
2780  Create(parent, id, pos, size, style);
2781 }
2782 
2783 
2784 /*!
2785  * CAlignOtherAddPanel creator
2786  */
2787 
2788 bool CAlignOtherAddPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
2789 {
2790 ////@begin CAlignOtherAddPanel creation
2791  wxDialog::Create( parent, id, SYMBOL_CALIGN_OTHER_ADDPANEL_TITLE, pos, size, style );
2792 
2793  CreateControls();
2794  if (GetSizer())
2795  {
2796  GetSizer()->SetSizeHints(this);
2797  }
2798  Centre();
2799 ////@end CAlignOtherAddPanel creation
2800  return true;
2801 }
2802 
2803 
2804 /*!
2805  * CAlignOtherAddPanel destructor
2806  */
2807 
2809 {
2810 ////@begin CAlignOtherAddPanel destruction
2811 ////@end CAlignOtherAddPanel destruction
2812 }
2813 
2814 
2815 /*!
2816  * Member initialisation
2817  */
2818 
2820 {
2821 ////@begin CAlignOtherAddPanel member initialisation
2822  m_FeatureType = NULL;
2823  m_GBQualSizer = NULL;
2824  m_Locus = NULL;
2825  m_GeneDesc = NULL;
2826  m_Comment = NULL;
2827  m_Location = NULL;
2828 ////@end CAlignOtherAddPanel member initialisation
2829  m_GBQualPanel = NULL;
2830  m_QualFeat.Reset(new CSeq_feat());
2831  m_QualFeat->SetData().SetImp().SetKey("misc_feature");
2832 }
2833 
2834 
2835 /*!
2836  * Control creation for CAlignOtherAddPanel
2837  */
2838 
2840 {
2841 ////@begin CAlignOtherAddPanel content construction
2842  CAlignOtherAddPanel* itemCBulkCmdPanel1 = this;
2843 
2844  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
2845  itemCBulkCmdPanel1->SetSizer(itemBoxSizer2);
2846 
2847  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
2848  itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_LEFT|wxALL, 5);
2849 
2850  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
2851  itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2852 
2853  wxStaticText* itemStaticText5 = new wxStaticText( itemCBulkCmdPanel1, wxID_STATIC, _("Feature Type"), wxDefaultPosition, wxDefaultSize, 0 );
2854  itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
2855 
2856  wxArrayString m_FeatureTypeStrings;
2857  m_FeatureType = new wxListBox( itemCBulkCmdPanel1, ID_CALIGN_OTHER_ADDPANEL_FEATURE_TYPE_LISTBOX, wxDefaultPosition, wxDefaultSize, m_FeatureTypeStrings, wxLB_SINGLE );
2858  itemBoxSizer4->Add(m_FeatureType, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
2859 
2860  m_GBQualSizer = new wxBoxSizer(wxVERTICAL);
2861  itemBoxSizer3->Add(m_GBQualSizer, 0, wxGROW|wxALL, 5);
2862 
2863  wxFlexGridSizer* itemFlexGridSizer8 = new wxFlexGridSizer(0, 2, 0, 0);
2864  itemBoxSizer2->Add(itemFlexGridSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
2865 
2866  wxStaticText* itemStaticText9 = new wxStaticText( itemCBulkCmdPanel1, wxID_STATIC, _("Gene Symbol"), wxDefaultPosition, wxDefaultSize, 0 );
2867  itemFlexGridSizer8->Add(itemStaticText9, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2868 
2869  m_Locus = new wxTextCtrl( itemCBulkCmdPanel1, ID_CALIGN_OTHER_ADDPANEL_TEXTCTRL11, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
2870  itemFlexGridSizer8->Add(m_Locus, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2871 
2872  wxStaticText* itemStaticText11 = new wxStaticText( itemCBulkCmdPanel1, wxID_STATIC, _("Gene Description"), wxDefaultPosition, wxDefaultSize, 0 );
2873  itemFlexGridSizer8->Add(itemStaticText11, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2874 
2875  m_GeneDesc = new wxTextCtrl( itemCBulkCmdPanel1, ID_CALIGN_OTHER_ADDPANEL_TEXTCTRL12, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
2876  itemFlexGridSizer8->Add(m_GeneDesc, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2877 
2878  wxStaticText* itemStaticText13 = new wxStaticText( itemCBulkCmdPanel1, wxID_STATIC, _("Comment"), wxDefaultPosition, wxDefaultSize, 0 );
2879  itemFlexGridSizer8->Add(itemStaticText13, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2880 
2881  m_Comment = new wxTextCtrl( itemCBulkCmdPanel1, ID_CALIGN_OTHER_ADDPANEL_TEXTCTRL14, wxEmptyString, wxDefaultPosition, wxSize(300, 70), wxTE_MULTILINE );
2882  itemFlexGridSizer8->Add(m_Comment, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
2883 
2884 
2885  m_Location = new CLocationPanel(itemCBulkCmdPanel1, *m_Loc, m_scope, true, false, false, wxID_ANY, wxDefaultPosition, wxDefaultSize);
2886  itemBoxSizer2->Add(m_Location, 1, wxALIGN_CENTER_HORIZONTAL|wxALL|wxFIXED_MINSIZE, 5);
2888 
2889  itemBoxSizer2->Add(500, 0, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
2890 
2891 ////@end CAlignOtherAddPanel content construction
2892 
2893  x_ListFeatures();
2894 
2895  m_GBQualPanel = new CGBQualPanel (this, *m_QualFeat);
2896  m_GBQualSizer->Add(m_GBQualPanel, 1, wxGROW|wxALL, 0);
2897  x_ChangeFeatureType("Gene");
2898 
2899  wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
2900  itemBoxSizer2->Add(itemBoxSizer12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
2901 
2902  wxButton* itemButton13 = new wxButton( itemCBulkCmdPanel1, wxID_OK, _("Accept"), wxDefaultPosition, wxDefaultSize, 0 );
2903  itemBoxSizer12->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2904 
2905  wxButton* itemButton14 = new wxButton( itemCBulkCmdPanel1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
2906  itemBoxSizer12->Add(itemButton14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2907 
2908 }
2909 
2910 static bool s_IsRNAFeature(int feat_subtype)
2911 {
2912  if (feat_subtype == CSeqFeatData::eSubtype_preRNA
2913  || feat_subtype == CSeqFeatData::eSubtype_mRNA
2914  || feat_subtype == CSeqFeatData::eSubtype_tRNA
2915  || feat_subtype == CSeqFeatData::eSubtype_rRNA
2916  || feat_subtype == CSeqFeatData::eSubtype_otherRNA
2917  || feat_subtype == CSeqFeatData::eSubtype_misc_RNA
2918  || feat_subtype == CSeqFeatData::eSubtype_precursor_RNA
2919  || feat_subtype == CSeqFeatData::eSubtype_ncRNA
2920  || feat_subtype == CSeqFeatData::eSubtype_tmRNA) {
2921  return true;
2922  }
2923  return false;
2924 }
2925 
2927 {
2928  vector<string> listed_feat;
2929  set<string> existing;
2930  map<pair<int,int>,string> types;
2931 
2932  listed_feat.push_back("Gene");
2933  listed_feat.push_back("misc_feature");
2934  existing.insert(listed_feat[0]);
2935  existing.insert(listed_feat[1]);
2936 
2937  vector<const CFeatListItem *> featlist = GetSortedFeatList(m_TopSeqEntry);
2938  ITERATE(vector<const CFeatListItem *>, feat_it, featlist) {
2939  const CFeatListItem& item = **feat_it;
2940  string desc = item.GetDescription();
2941  int feat_type = item.GetType();
2943  if (feat_type == CSeqFeatData::e_Imp
2945  && !CSeqFeatData::IsRegulatory(feat_subtype)) {
2946  types[pair<int,int>(feat_type,feat_subtype)] = desc;
2947  if (existing.find(desc) == existing.end()) {
2948  existing.insert(desc);
2949  listed_feat.push_back(desc);
2950  }
2951  }
2952  }
2953 
2954  m_FeatureType->Clear();
2955  for (size_t i = 0; i < listed_feat.size(); ++i) {
2956  m_FeatureType->Append(ToWxString(listed_feat[i]));
2957  }
2958 
2959  if (find(listed_feat.begin(), listed_feat.end(), m_DefaultKey) != listed_feat.end()) {
2960  m_FeatureType->SetStringSelection(ToWxString(m_DefaultKey));
2961  m_QualFeat->SetData().SetImp().SetKey(m_DefaultKey);
2962  }
2963 
2964 }
2965 
2966 /*!
2967  * Should we show tooltips?
2968  */
2969 
2971 {
2972  return true;
2973 }
2974 
2975 /*!
2976  * Get bitmap resources
2977  */
2978 
2979 wxBitmap CAlignOtherAddPanel::GetBitmapResource( const wxString& name )
2980 {
2981  // Bitmap retrieval
2982 ////@begin CAlignOtherAddPanel bitmap retrieval
2983  wxUnusedVar(name);
2984  return wxNullBitmap;
2985 ////@end CAlignOtherAddPanel bitmap retrieval
2986 }
2987 
2988 /*!
2989  * Get icon resources
2990  */
2991 
2992 wxIcon CAlignOtherAddPanel::GetIconResource( const wxString& name )
2993 {
2994  // Icon retrieval
2995 ////@begin CAlignOtherAddPanel icon retrieval
2996  wxUnusedVar(name);
2997  return wxNullIcon;
2998 ////@end CAlignOtherAddPanel icon retrieval
2999 }
3000 
3002 {
3003  string key = ToStdString(m_FeatureType->GetStringSelection());
3004 
3005  if (NStr::IsBlank(key)) {
3007  return empty;
3008  }
3009 
3012  CAlignmentAssistant *parent = dynamic_cast<CAlignmentAssistant*>(GetParent());
3013  vector<pair<CRef<CSeq_loc>, CBioseq_Handle> > locations;
3014  parent->TranslateLocations(loc, locations);
3015 
3016  CRef<CCmdComposite> cmd (new CCmdComposite("Align Add Other Feature"));
3017  for (size_t i = 0; i < locations.size(); ++i)
3018  {
3019  CRef<CSeq_loc> seq_loc = locations[i].first;
3020  CBioseq_Handle bsh = locations[i].second;
3021  AddOneCommand(bsh,seq_loc,cmd);
3022  }
3023 
3024 
3025  return cmd;
3026 }
3027 
3029 {
3030  if (!seq_loc || !bsh || (seq_loc->IsMix() && !seq_loc->GetMix().IsSet()))
3031  return;
3032 
3033  string key = ToStdString(m_FeatureType->GetStringSelection());
3034  string comment = ToStdString(m_Comment->GetValue());
3035  string gene_symbol = ToStdString(m_Locus->GetValue());
3036  string gene_desc = ToStdString(m_GeneDesc->GetValue());
3039 
3040  objects::CSeq_entry_Handle seh = bsh.GetSeq_entry_Handle();
3041 
3042  if (!NStr::EqualNocase(key, "Gene")) {
3043  CRef<objects::CSeq_feat> feat(new objects::CSeq_feat());
3044  feat->SetData().SetImp().SetKey(key);
3045  if (!NStr::IsBlank(comment)) {
3046  feat->SetComment(comment);
3047  }
3048  feat->SetLocation().Assign(*seq_loc);
3049  if (feat->GetLocation().IsPartialStart(objects::eExtreme_Biological)
3050  || feat->GetLocation().IsPartialStop(objects::eExtreme_Biological)) {
3051  feat->SetPartial(true);
3052  }
3053  x_AddQuals(*feat);
3054  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(seh, *feat)));
3055  }
3056  if (!NStr::IsBlank(gene_symbol) || !NStr::IsBlank(gene_desc) || NStr::EqualNocase(key, "Gene")) {
3057  // create gene feature
3058  CRef<objects::CSeq_feat> new_gene(new objects::CSeq_feat());
3059  new_gene->SetData().SetGene().SetLocus(gene_symbol);
3060  if (!NStr::IsBlank(gene_desc)) {
3061  new_gene->SetData().SetGene().SetDesc(gene_desc);
3062  }
3063  if (NStr::EqualNocase(key, "Gene") && !NStr::IsBlank(comment)) {
3064  new_gene->SetComment(comment);
3065  }
3066  new_gene->SetLocation().Assign(*seq_loc);
3067  if (new_gene->GetLocation().IsPartialStart(objects::eExtreme_Biological)
3068  || new_gene->GetLocation().IsPartialStop(objects::eExtreme_Biological)) {
3069  new_gene->SetPartial(true);
3070  }
3071  x_AddGeneQuals(*new_gene);
3072  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(seh, *new_gene)));
3073  }
3074 }
3075 
3076 
3078 {
3081  if (NStr::EqualNocase(key, "Gene")) {
3082  m_QualFeat->SetData().SetGene();
3083  m_QualFeat->ResetQual();
3084  } else {
3085  m_QualFeat->SetData().SetImp().SetKey(key);
3086  }
3087  while (m_GBQualSizer->GetItemCount() > 0) {
3088  int pos = 0;
3089  m_GBQualSizer->GetItem(pos)->DeleteWindows();
3090  m_GBQualSizer->Remove(pos);
3091  }
3092  m_GBQualPanel = new CGBQualPanel (this, *m_QualFeat);
3093  m_GBQualSizer->Add(m_GBQualPanel, 1, wxGROW|wxALL, 0);
3095 // if (NStr::EqualNocase(key, "Gene")) {
3096 // m_GBQualPanel->Show(false);
3097 // }
3098  Layout();
3099 }
3100 
3101 
3102 /*!
3103  * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_CALIGN_OTHER_ADDPANEL_FEATURE_TYPE_LISTBOX
3104  */
3105 
3107 {
3108  string key = ToStdString(m_FeatureType->GetStringSelection());
3110 }
3111 
3112 
3113 void CAlignOtherAddPanel::x_AddQuals(objects::CSeq_feat& feat)
3114 {
3115  if (m_QualFeat && m_QualFeat->IsSetQual()) {
3116  ITERATE(CSeq_feat::TQual, it, m_QualFeat->GetQual()) {
3117  CRef<CGb_qual> q(new CGb_qual());
3118  q->Assign(**it);
3119  feat.SetQual().push_back(q);
3120 
3121  if ( NStr::EqualNocase(q->GetQual(), "mobile_element_type") && feat.IsSetData() && feat.GetData().IsImp()
3122  && feat.GetData().GetImp().IsSetKey() && feat.GetData().GetImp().GetKey() == "repeat_region" )
3123  {
3124  feat.SetData().SetImp().SetKey("mobile_element");
3125  }
3126  }
3127  }
3128 }
3129 
3130 void CAlignOtherAddPanel::x_AddGeneQuals(objects::CSeq_feat& gene)
3131 {
3132  if (m_QualFeat && m_QualFeat->IsSetQual())
3133  {
3134  ITERATE(CSeq_feat::TQual, it, m_QualFeat->GetQual())
3135  {
3136  string val = (*it)->GetVal();
3137  string qual = (*it)->GetQual();
3138  if (qual == "locus")
3139  gene.SetData().SetGene().SetLocus(val);
3140  if (qual == "locus_tag")
3141  gene.SetData().SetGene().SetLocus_tag(val);
3142  if (qual == "allele")
3143  gene.SetData().SetGene().SetAllele(val);
3144  if (qual == "map")
3145  gene.SetData().SetGene().SetMaploc(val);
3146  if (qual == "gene_synonym")
3147  gene.SetData().SetGene().SetSyn().push_back(val);
3148  }
3149  }
3150 }
#define static
bool IsReverse(ENa_strand s)
Definition: Na_strand.hpp:75
ENa_strand Reverse(ENa_strand s)
Definition: Na_strand.hpp:90
@ 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.
static bool s_IsRNAFeature(int feat_subtype)
static void s_SettRNAProduct(string aa, CRef< CRNA_ref > rna)
#define ID_CALIGN_RNA_ADD_PANEL_COMBOBOX
#define ID_SHOW_FEATURES_ALIGNMENT_ASSISTANT_MENU
#define ID_SHOW_SUBSTITUTE_ALIGNMENT_ASSISTANT_MENU
#define ID_GOTO_ALIGNMENT_ASSISTANT_BUTTON
#define ID_EDIT_REV_STRANDS_ALIGNMENT_ASSISTANT_MENU
#define ID_EDIT_RM_SEQ_ALIGNMENT_ASSISTANT_MENU
#define ID_ALIGNCDSADD_COMMENT
#define SYMBOL_CALIGNCDSADDPANEL_TITLE
#define ID_CALIGN_RNA_ADD_PANEL_TEXTCTRL10
#define ID_ALIGNCDSADD_GENE_DESC
#define ID_EDIT_PROPAGATE_ALIGNMENT_ASSISTANT_MENU
#define SYMBOL_CALIGN_RNA_ADD_PANEL_TITLE
#define ID_ADD_ALIGN_RNA_ALIGNMENT_ASSISTANT_MENU
#define ID_CALIGN_OTHER_ADDPANEL_TEXTCTRL12
#define ID_ALIGNCDSADD_PROTEIN_NAME
#define ID_EXPORT_CONT_ALIGNMENT_ASSISTANT_MENU
#define ID_CLOSE_ALIGNMENT_ASSISTANT_BUTTON
#define ID_CALIGN_OTHER_ADDPANEL_FEATURE_TYPE_LISTBOX
#define ID_EDIT_VALIDATE_ALIGNMENT_ASSISTANT_MENU
#define ID_ALIGNCDSADD_PROTEIN_DESC
#define ID_CALIGN_RNA_ADD_PANEL_BUTTON11
#define ID_ALIGNCDSADD_GENE_NAME
#define ID_ADD_ALIGN_OTHER_ALIGNMENT_ASSISTANT_MENU
#define ID_EXPORT_INTER_ALIGNMENT_ASSISTANT_MENU
#define ID_GOTO_SEQ_ALIGNMENT_ASSISTANT_BUTTON
#define ID_CALIGN_RNA_ADD_PANEL_BUTTON12
#define ID_CALIGN_OTHER_ADDPANEL_TEXTCTRL11
#define ID_CALIGN_OTHER_ADDPANEL_TEXTCTRL14
#define SYMBOL_CALIGN_OTHER_ADDPANEL_TITLE
#define ID_ADD_ALIGN_CDS_ALIGNMENT_ASSISTANT_MENU
#define ID_CALIGN_RNA_ADD_PANEL_CHOICE1
@ eCmdCreateSigPeptide
@ eCmdCreateRegion
@ eCmdCreateMiscRecomb
@ eCmdCreateRepeatRegion
@ eCmdCreatetRNA
@ eCmdCreateAssemblyGap
@ eCmdCreateBond
@ eCmdCreateRegulatory
@ eCmdCreateCRegion
@ eCmdCreateProt
@ eCmdCreateVSegment
@ eCmdCreateMiscFeature
@ eCmdCreateModifiedBase
@ eCmdCreateMobileElement
@ eCmdCreateNRegion
@ eCmdCreateTelomere
@ eCmdCreateMiscStructure
@ eCmdCreaterRNA
@ eCmdCreatetmRNA
@ eCmdCreatePrimerBind
@ eCmdCreateBiosourceFeat
@ eCmdCreateExon
@ eCmdCreateMatPeptide
@ eCmdCreateCentromere
@ eCmdCreateiDNA
@ eCmdCreatePrimTranscript
@ eCmdCreateJSegment
@ eCmdCreateMiscBinding
@ eCmdCreateOriT
@ eCmdCreateDSegment
@ eCmdCreateVRegion
@ eCmdCreateSTS
@ eCmdCreatePolyASite
@ eCmdCreateSRegion
@ eCmdCreateCommentDescriptor
@ eCmdCreate5UTR
@ eCmdCreatePubFeatureLabeled
@ eCmdCreateMRNA
@ eCmdCreateGene
@ eCmdCreateCodingRegion
@ eCmdCreateSite
@ eCmdCreateUnsure
@ eCmdCreateVariation
@ eCmdCreatePreRNA
@ eCmdCreateTransitPeptide
@ eCmdCreateIntron
@ eCmdCreateDLoop
@ eCmdCreateSecondaryStructure
@ eCmdCreateProprotein
@ eCmdCreatencRNA
@ eCmdCreateProteinBind
@ eCmdCreate3UTR
@ eCmdCreateRepOrigin
@ eCmdCreateLTR
@ eCmdCreateStemLoop
@ eCmdCreateRNA
@ eCmdCreateOperon
@ eCmdCreateMiscDifference
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 CreateControls()
Creates the controls and sizers.
void AddOneCommand(const objects::CBioseq_Handle &bsh, CRef< CSeq_loc > seq_loc, CRef< CCmdComposite > cmd)
wxTextCtrl * m_GeneDescription
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
CAlignCDSAddPanel()
Constructors.
void Init()
Initialises member variables.
wxTextCtrl * m_ProteinDescription
CRef< CSeq_loc > m_Loc
static bool ShowToolTips()
Should we show tooltips?
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
CLocationPanel * m_Location
CRef< CCmdComposite > GetCommand()
CRef< CCmdComposite > GetCommand()
void Init()
Initialises member variables.
CAlignOtherAddPanel()
Constructors.
CLocationPanel * m_Location
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
void x_ChangeFeatureType(const string &key)
void x_AddQuals(objects::CSeq_feat &feat)
CSeq_entry_Handle m_TopSeqEntry
void CreateControls()
Creates the controls and sizers.
static bool ShowToolTips()
Should we show tooltips?
CRef< objects::CSeq_feat > m_QualFeat
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void x_AddGeneQuals(objects::CSeq_feat &gene)
void AddOneCommand(const objects::CBioseq_Handle &bsh, CRef< CSeq_loc > seq_loc, CRef< CCmdComposite > cmd)
void OnFeatureTypeListboxSelected(wxCommandEvent &event)
wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_FEATURE_TYPE_LISTBOX
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void CreateControls()
Creates the controls and sizers.
CLocationPanel * m_Location
void OnAdd18SToComment(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON11
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
CRef< CSeq_loc > m_Loc
void AddOneCommand(const objects::CBioseq_Handle &bsh, CRef< CSeq_loc > seq_loc, CRef< CCmdComposite > cmd)
wxFlexGridSizer * m_FieldSizer
CAlignRNAAddPanel()
Constructors.
static bool ShowToolTips()
Should we show tooltips?
objects::CRNA_ref::TType x_GetRnaType()
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
void OnSelectRNAType(wxCommandEvent &event)
wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_CHOICE1
void Init()
Initialises member variables.
void OnAdd16StoComment(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON12
CRef< CCmdComposite > GetCommand()
CAlign_CI –.
Definition: align_ci.hpp:63
void OnTarget(wxCommandEvent &event)
CRef< CSeq_align > AdjustAlign(int from, int to, const vector< int > &offset, CRef< CCmdComposite > cmd)
void OnGoTo(wxCommandEvent &event)
void TrimQualityScores(CBioseq_Handle bsh, int from, int to, CRef< CCmdComposite > command)
vector< vector< pair< string, CSeqFeatData::ESubtype > > > m_FeatTypes
void OnValidate(wxCommandEvent &event)
void OnExportCont(wxCommandEvent &event)
void IsNucleotide(wxUpdateUIEvent &event)
void AdjustBioseq(CBioseq_Handle bsh, int from, int to, CRef< CCmdComposite > cmd)
vector< vector< vector< pair< TSeqPos, TSeqPos > > > > m_FeatRanges
void OnRemoveSeqFromAlign(wxCommandEvent &)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void AdjustFeatureLocations(CBioseq_Handle bsh, int from, int to, CRef< CCmdComposite > cmd)
void OnAddAlignCDS(wxCommandEvent &)
void OnFeatures(wxCommandEvent &event)
static bool ShowToolTips()
Should we show tooltips?
void OnExportInter(wxCommandEvent &event)
CPaintAlignment * m_Panel
void IsSelectionAndClean(wxUpdateUIEvent &event)
void OnReverseStrand(wxCommandEvent &)
ICommandProccessor * m_CmdProcessor
CSeq_entry_Handle m_TopSeqEntry
void OnAddAlignRNA(wxCommandEvent &)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
CRef< CSeq_loc > AdjustLoc(const CSeq_loc &feat_loc, int from, int to, bool &modified, bool &removed)
virtual ~CAlignmentAssistant()
Destructor.
void OnAddAlignOther(wxCommandEvent &)
void GetAlignment(CConstRef< CSeq_align > align)
void ReportPos(int pos, const string &label)
void CreateControls()
Creates the controls and sizers.
CSeq_align_Handle m_Alignment
void CreateFeature(wxCommandEvent &event)
void Init()
Initialises member variables.
void OnSubstitute(wxCommandEvent &event)
void TranslateLocations(CRef< CSeq_loc > loc, vector< pair< CRef< CSeq_loc >, CBioseq_Handle > > &locations)
CAlignmentAssistant()
Constructors.
void OnPropagateFeatures(wxCommandEvent &)
bool x_ExecuteCommand(IEditCommand *command)
vector< vector< CBioseq_Handle::EVectorStrand > > m_FeatStrand
void ReportRange(int pos1, int pos2, const string &label)
void OnClose(wxCommandEvent &event)
void OnGoToSeq(wxCommandEvent &event)
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=_("Alignment Assistant"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(775, 595), long style=wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
static CRef< objects::CSeq_feat > MakeDefaultFeature(objects::CSeqFeatData::ESubtype subtype)
static objects::CSeqFeatData::ESubtype GetFeatTypeFromCmdID(int cmd_id)
CBioseq_EditHandle –.
CBioseq_Handle –.
const CSeq_id & GetSeq_id(TDim row) const
Definition: Dense_seg.cpp:154
void SetEditorWindow(wxWindow *editorWindow)
void SetEditor(CIRef< IEditObject > editor)
CFeatListItem - basic configuration data for one "feature" type.
int GetSubtype() const
string GetDescription() const
int GetType() const
CFeat_CI –.
Definition: feat_ci.hpp:64
static bool s_IsRarelyUsedOrDiscouragedFeatureType(int subtype)
static wxString GetDialogFilter(EFileType fileType)
virtual bool TransferDataToWindow()
virtual bool TransferDataFromWindow()
void PopulateGBQuals(objects::CSeq_feat &seq_feat)
@Gb_qual.hpp User-defined methods of the data storage class.
Definition: Gb_qual.hpp:61
void SetText(const wxString &text)
CGraph_CI –.
Definition: graph_ci.hpp:234
CRef< CInt_fuzz > Negative(TSeqPos n) const
Definition: Int_fuzz.hpp:106
virtual bool TransferDataFromWindow()
CRef< objects::CSeq_loc > GetSeq_loc() const
virtual bool TransferDataToWindow()
CMappedGraph –.
Definition: graph_ci.hpp:61
void SetPos(int pos)
int AlignPosToSeqPos(int pos, int row, bool left) const
static string GetSeqTitle(CBioseq_Handle bsh)
pair< int, int > GetSelection(int row)
void SetAlign(CSeq_align_Handle ah)
void SetTarget(int row)
void EnableSubstitute(bool enable)
void EnableFeatures(bool enable)
pair< int, int > GetAlignSelection(void)
size_t GetTotalLength() const
void SetPosSeq(int pos)
void UpdateFeatures(const vector< vector< vector< pair< TSeqPos, TSeqPos > > > > &feat_ranges, const vector< vector< pair< string, objects::CSeqFeatData::ESubtype > > > &feat_types, const vector< vector< objects::CBioseq_Handle::EVectorStrand > > &feat_strand)
static vector< string > GetncRNAClassList()
Definition: RNA_gen.cpp:86
@RNA_ref.hpp User-defined methods of the data storage class.
Definition: RNA_ref.hpp:54
CScope –.
Definition: scope.hpp:92
static EFeatureLocationAllowed AllowedFeatureLocation(ESubtype subtype)
@ eFeatureLocationAllowed_NucOnly
@ eFeatureLocationAllowed_ProtOnly
ESubtype GetSubtype(void) const
static bool IsRegulatory(ESubtype subtype)
Non-const iterator over CSeqMap (allows to edit the sequence).
Definition: seq_map_ci.hpp:407
@ e_Iupacna
Definition: sequtil.hpp:47
@ e_Iupacaa
Definition: sequtil.hpp:55
ENa_strand GetSeqStrand(TDim row) const
Get strand (the first one if segments have different strands).
Definition: Seq_align.cpp:294
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
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
Seq-loc iterator class – iterates all intervals from a seq-loc in the correct order.
Definition: Seq_loc.hpp:593
static CUICommandRegistry & GetInstance()
the main instance associated with the application
Definition: ui_command.cpp:176
wxMenu * CreateMenu(const SwxMenuItemRec *items)
create a menu from a static definition (see WX_*_MENU macros)
Definition: ui_command.cpp:349
static const string & ConvertSeverity(EDiagSev sev)
Undo/Redo interface for editing operations.
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
Interface (functor) for object editing.
Definition: map.hpp:338
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
CRef< objects::CSeq_entry > CreateTranslatedProteinSequence(CRef< objects::CSeq_feat > cds, objects::CBioseq_Handle nuc_h, bool create_general_only, int *offset=nullptr)
CRef< objects::CSeq_feat > AddProteinFeatureToProtein(CRef< objects::CSeq_entry > protein, bool partial5, bool partial3)
#define _(proto)
Definition: ct_nlmzip_i.h:78
static const char si[8][64]
Definition: des.c:146
#define wxFIXED_MINSIZE
std::ofstream out("events_result.xml")
main entry point for tests
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static void cleanup(void)
Definition: ct_dynamic.c:30
static void Init(void)
Definition: cursor6.c:76
static const char * str(char *buf, int n)
Definition: stats.c:84
static const struct type types[]
Definition: type.c:22
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
int TSignedSeqPos
Type for signed sequence position.
Definition: ncbimisc.hpp:887
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
Definition: ncbimisc.hpp:1508
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
vector< const objects::CFeatListItem * > GetSortedFeatList(objects::CSeq_entry_Handle seh, size_t max=numeric_limits< size_t >::max())
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.
string GetLabel(const CSeq_id &id)
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:605
CRef< CSeq_loc > MakeSeq_loc(EMakeType make_type=eMake_CompactType) const
return constructed CSeq_loc with all changes
Definition: Seq_loc.cpp:2946
void Rewind(void)
Reset the iterator to the initial state.
Definition: Seq_loc.hpp:1104
void SetFrom(TSeqPos from)
Set the range from position.
Definition: Seq_loc.cpp:2818
void SetTo(TSeqPos to)
Set the range to position.
Definition: Seq_loc.cpp:2829
void Delete(void)
Delete current element, and make iterator to point to the next element.
Definition: Seq_loc.cpp:2724
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
void ResetFuzzTo(void)
Reset fuzz to.
Definition: Seq_loc.cpp:2901
void ResetFuzzFrom(void)
Reset fuzz from.
Definition: Seq_loc.cpp:2879
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
Definition: Seq_loc.cpp:915
void SetStrand(ENa_strand strand)
Set the range strand.
Definition: Seq_loc.cpp:2868
bool HasChanges(void) const
return true of any part was changed since initialization
Definition: Seq_loc.cpp:2706
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
const CInt_fuzz * GetFuzzFrom(void) const
Definition: Seq_loc.hpp:1063
const CInt_fuzz * GetFuzzTo(void) const
Definition: Seq_loc.hpp:1070
void SetFuzzTo(CInt_fuzz &fuzz)
Change fuzz to values.
Definition: Seq_loc.cpp:2912
bool IsEmpty(void) const
True if the current location is empty.
Definition: Seq_loc.hpp:1084
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
size_t GetSize(void) const
Get number of ranges.
Definition: Seq_loc.cpp:2636
TRange GetRange(void) const
Get the range.
Definition: Seq_loc.hpp:1042
void SetFuzzFrom(CInt_fuzz &fuzz)
Change fuzz from.
Definition: Seq_loc.cpp:2890
ENa_strand GetStrand(void) const
Definition: Seq_loc.hpp:1056
TSeqPos GetStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:963
@ eOrder_Positional
Definition: Seq_loc.hpp:461
@ fFGL_Content
Include its content if there is any.
Definition: feature.hpp:73
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
CSeq_entry_Handle AddTopLevelSeqEntry(CSeq_entry &top_entry, TPriority pri=kPriority_Default, EExist action=eExist_Default)
Add seq_entry, default priority is higher than for defaults or loaders Add object to the score with p...
Definition: scope.cpp:522
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
bool IsNucleotide(void) const
CScope & GetScope(void) const
Get scope this handle belongs to.
TSeqPos GetBioseqLength(void) const
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
const CSeq_align::TSegs & GetSegs(void) const
CConstRef< CSeq_align > GetSeq_align(void) const
Get const reference to current seq-align.
TSeq GetSeq(void) const
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
CScope & GetScope(void) const
Get scope this handle belongs to.
CScope & GetScope(void) const
Get scope this handle belongs to.
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,...
bool IsNa(void) const
const CSeq_annot_Handle & GetAnnot(void) const
Get handle to the seq-annot.
@ eStrand_Plus
Plus strand.
@ eStrand_Minus
Minus strand.
CSeqMap_I & Remove(void)
Remove current segment.
Definition: seq_map_ci.cpp:893
void GetSequence(string &buffer, CSeqUtil::ECoding buffer_coding) const
Get current sequence as a string with the selected encoding.
Definition: seq_map_ci.cpp:901
const CSeq_loc & GetLocation(void) const
SSeqMapSelector & SetFlags(TFlags flags)
Select segment type(s)
Definition: seq_map_ci.hpp:179
void SetSequence(const string &buffer, CSeqUtil::ECoding buffer_coding, CSeq_data::E_Choice seq_data_coding)
Set sequence data.
Definition: seq_map_ci.cpp:937
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
const CSeq_graph & GetOriginalGraph(void) const
Get original graph with unmapped location/product.
Definition: graph_ci.hpp:70
TSeqPos GetLength(void) const
return length of current segment
Definition: seq_map_ci.hpp:672
CSeq_graph_Handle GetSeq_graph_Handle(void) const
Get original graph handle.
Definition: graph_ci.cpp:93
@ fFindData
Definition: seq_map.hpp:129
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
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
Definition: ncbistre.hpp:500
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
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
static string & ToUpper(string &str)
Convert string to upper case – string& version.
Definition: ncbistr.cpp:424
static const char label[]
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
const TAnticodon & GetAnticodon(void) const
Get the Anticodon member data.
Definition: Trna_ext_.hpp:649
bool IsTRNA(void) const
Check if variant TRNA is selected.
Definition: RNA_ref_.hpp:498
bool IsSetAnticodon(void) const
location of anticodon Check if a value has been assigned to Anticodon data member.
Definition: Trna_ext_.hpp:637
EType
type of RNA feature
Definition: RNA_ref_.hpp:95
void SetExt(TExt &value)
Assign a value to Ext data member.
Definition: RNA_ref_.cpp:211
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
void SetType(TType value)
Assign a value to Type data member.
Definition: RNA_ref_.hpp:538
const TExt & GetExt(void) const
Get the Ext member data.
Definition: RNA_ref_.hpp:616
const TTRNA & GetTRNA(void) const
Get the variant data.
Definition: RNA_ref_.cpp:134
@ eType_ncRNA
non-coding RNA; subsumes snRNA, scRNA, snoRNA
Definition: RNA_ref_.hpp:104
bool IsSetLens(void) const
lengths in ids order within segs Check if a value has been assigned to Lens data member.
Definition: Dense_seg_.hpp:543
const TDenseg & GetDenseg(void) const
Get the variant data.
Definition: Seq_align_.cpp:153
bool IsSetDim(void) const
dimensionality Check if a value has been assigned to Dim data member.
Definition: Dense_seg_.hpp:396
TLens & SetLens(void)
Assign a value to Lens data member.
Definition: Dense_seg_.hpp:561
bool IsSetNumseg(void) const
number of segments here Check if a value has been assigned to Numseg data member.
Definition: Dense_seg_.hpp:446
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_align_.hpp:691
bool IsSetStrands(void) const
Check if a value has been assigned to Strands data member.
Definition: Dense_seg_.hpp:568
void ResetSegs(void)
Reset Segs data member.
Definition: Seq_align_.cpp:301
const TStarts & GetStarts(void) const
Get the Starts member data.
Definition: Dense_seg_.hpp:530
void SetSegs(TSegs &value)
Assign a value to Segs data member.
Definition: Seq_align_.cpp:310
vector< ENa_strand > TStrands
Definition: Dense_seg_.hpp:109
const TLens & GetLens(void) const
Get the Lens member data.
Definition: Dense_seg_.hpp:555
void SetDim(TDim value)
Assign a value to Dim data member.
Definition: Seq_align_.hpp:865
vector< TSignedSeqPos > TStarts
Definition: Dense_seg_.hpp:107
void SetDim(TDim value)
Assign a value to Dim data member.
Definition: Dense_seg_.hpp:427
vector< CRef< CSeq_id > > TIds
Definition: Dense_seg_.hpp:106
TDim GetDim(void) const
Get the Dim member data.
Definition: Dense_seg_.hpp:421
TStarts & SetStarts(void)
Assign a value to Starts data member.
Definition: Dense_seg_.hpp:536
TStrands & SetStrands(void)
Assign a value to Strands data member.
Definition: Dense_seg_.hpp:586
bool IsSetStarts(void) const
start OFFSETS in ids order within segs Check if a value has been assigned to Starts data member.
Definition: Dense_seg_.hpp:518
void SetNumseg(TNumseg value)
Assign a value to Numseg data member.
Definition: Dense_seg_.hpp:474
const TIds & GetIds(void) const
Get the Ids member data.
Definition: Dense_seg_.hpp:505
TNumseg GetNumseg(void) const
Get the Numseg member data.
Definition: Dense_seg_.hpp:465
TIds & SetIds(void)
Assign a value to Ids data member.
Definition: Dense_seg_.hpp:511
const TStrands & GetStrands(void) const
Get the Strands member data.
Definition: Dense_seg_.hpp:580
const TSegs & GetSegs(void) const
Get the Segs member data.
Definition: Seq_align_.hpp:921
bool IsSetIds(void) const
sequences in order Check if a value has been assigned to Ids data member.
Definition: Dense_seg_.hpp:493
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
Definition: Seq_feat_.hpp:913
void SetLocation(TLocation &value)
Assign a value to Location data member.
Definition: Seq_feat_.cpp:131
bool IsCdregion(void) const
Check if variant Cdregion is selected.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
vector< CRef< CGb_qual > > TQual
Definition: Seq_feat_.hpp:117
const TQual & GetQual(void) const
Get the Qual member data.
Definition: Gb_qual_.hpp:212
const TRna & GetRna(void) const
Get the variant data.
bool IsRna(void) const
Check if variant Rna is selected.
@ eFrame_not_set
not set, code uses one
Definition: Cdregion_.hpp:95
bool IsMix(void) const
Check if variant Mix is selected.
Definition: Seq_loc_.hpp:552
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_loc_.hpp:475
bool IsSet(void) const
Check if a value has been assigned to data member.
const TMix & GetMix(void) const
Get the variant data.
Definition: Seq_loc_.cpp:282
bool IsPnt(void) const
Check if variant Pnt is selected.
Definition: Seq_loc_.hpp:540
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
@ e_not_set
No variant selected.
Definition: Seq_loc_.hpp:97
@ e_Null
not placed
Definition: Seq_loc_.hpp:98
@ e_Empty
to NULL one Seq-id in a collection
Definition: Seq_loc_.hpp:99
bool IsSetComp(void) const
compression (residues/value) Check if a value has been assigned to Comp data member.
Definition: Seq_graph_.hpp:981
bool IsSetLoc(void) const
region this applies to Check if a value has been assigned to Loc data member.
Definition: Seq_graph_.hpp:857
void ResetValues(void)
Reset Values data member.
Definition: Real_graph_.cpp:50
TValues & SetValues(void)
Assign a value to Values data member.
TByte & SetByte(void)
Select the variant.
Definition: Seq_graph_.cpp:159
const TInt & GetInt(void) const
Get the variant data.
Definition: Seq_graph_.cpp:131
void SetNumval(TNumval value)
Assign a value to Numval data member.
TReal & SetReal(void)
Select the variant.
Definition: Seq_graph_.cpp:115
TInt & SetInt(void)
Select the variant.
Definition: Seq_graph_.cpp:137
const TGraph & GetGraph(void) const
Get the Graph member data.
TValues & SetValues(void)
Assign a value to Values data member.
const TValues & GetValues(void) const
Get the Values member data.
Definition: Int_graph_.hpp:425
const TByte & GetByte(void) const
Get the variant data.
Definition: Seq_graph_.cpp:153
void SetGraph(TGraph &value)
Assign a value to Graph data member.
Definition: Seq_graph_.cpp:250
const TReal & GetReal(void) const
Get the variant data.
Definition: Seq_graph_.cpp:109
void ResetValues(void)
Reset Values data member.
Definition: Int_graph_.cpp:50
void ResetLoc(void)
Reset Loc data member.
Definition: Seq_graph_.cpp:215
const TValues & GetValues(void) const
Get the Values member data.
void ResetValues(void)
Reset Values data member.
Definition: Byte_graph_.cpp:50
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_graph_.hpp:716
const TValues & GetValues(void) const
Get the Values member data.
void SetLoc(TLoc &value)
Assign a value to Loc data member.
Definition: Seq_graph_.cpp:224
const TLoc & GetLoc(void) const
Get the Loc member data.
Definition: Seq_graph_.hpp:869
TComp GetComp(void) const
Get the Comp member data.
TValues & SetValues(void)
Assign a value to Values data member.
Definition: Int_graph_.hpp:431
const TSeq & GetSeq(void) const
Get the variant data.
Definition: Seq_entry_.cpp:102
const TInst & GetInst(void) const
Get the Inst member data.
Definition: Bioseq_.hpp:336
@ e_Iupacna
IUPAC 1 letter nuc acid code.
Definition: Seq_data_.hpp:104
@ e_Iupacaa
IUPAC 1 letter amino acid code.
Definition: Seq_data_.hpp:105
string GetAdjustedRnaName(const string &orig_rna_name)
Definition: utilities.cpp:70
END_EVENT_TABLE()
int i
int len
CMinPanelContainer::OnRestoreWindow EVT_UPDATE_UI_RANGE(eCmdCloseDockPanel, eCmdWindowRestore, CMinPanelContainer::OnUpdateWindowCommand) CMinPanelContainer
#define wxT(x)
Definition: muParser.cpp:41
void ReportUsage(const wxString &dialog_name)
Report opening & accepting events in the editing package.
range(_Ty, _Ty) -> range< _Ty >
constexpr bool empty(list< Ts... >) noexcept
mdb_mode_t mode
Definition: lmdb++.h:38
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
unsigned int a
Definition: ncbi_localip.c:102
const char * command
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Definition: njn_matrix.hpp:613
The Object manager core.
#define EDIT_EACH_CODEBREAK_ON_CDREGION(Itr, Var)
#define ERASE_CODEBREAK_ON_CDREGION(Itr, Var)
ERASE_CODEBREAK_ON_CDREGION.
static static static wxID_ANY
ViewerWindowBase::OnEditMenu ViewerWindowBase::OnJustification EVT_MENU(MID_SHOW_GEOM_VLTNS, ViewerWindowBase::OnShowGeomVltns) EVT_MENU(MID_FIND_PATTERN
#define row(bind, expected)
Definition: string_bind.c:73
SAnnotSelector –.
Selector used in CSeqMap methods returning iterators.
Definition: seq_map_ci.hpp:113
Definition: inftrees.h:24
#define WX_DEFINE_MENU(name)
New macros for defining menus for use with CUICommandRegistry.
Definition: ui_command.hpp:266
#define WX_SUBMENU(label)
Definition: ui_command.hpp:288
#define WX_END_MENU()
Definition: ui_command.hpp:294
#define WX_MENU_ITEM(cmd)
Definition: ui_command.hpp:270
#define WX_MENU_ITEM_INT(cmd)
Definition: ui_command.hpp:302
#define WX_END_SUBMENU()
Definition: ui_command.hpp:291
CScope & GetScope()
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Tue Apr 23 07:37:31 2024 by modify_doxy.py rev. 669887