NCBI C++ ToolKit
edit_sequence.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: edit_sequence.hpp 44613 2020-02-04 19:08:11Z filippov $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Igor Filippov
27  */
28 #ifndef _EDIT_SEQUENCE_H_
29 #define _EDIT_SEQUENCE_H_
30 
31 #include <corelib/ncbistd.hpp>
35 #include <gui/objutils/objects.hpp>
37 
38 /*!
39  * Includes
40  */
41 
42 ////@begin includes
43 ////@end includes
44 #include <wx/sizer.h>
45 #include <wx/bmpbuttn.h>
46 #include <wx/textctrl.h>
48 #include <wx/dialog.h>
49 #include <wx/radiobut.h>
50 #include <wx/checkbox.h>
51 #include <wx/choice.h>
52 #include <wx/frame.h>
53 #include <wx/timer.h>
54 
55 #include <unordered_map>
56 /*!
57  * Forward declarations
58  */
59 
60 ////@begin forward declarations
61 class wxBoxSizer;
62 ////@end forward declarations
63 
65 using namespace objects;
66 
67 /*!
68  * Control identifiers
69  */
70 
71 ////@begin control identifiers
72 #define ID_CEDIT_SEQUENCE wxID_ANY
73 #define SYMBOL_CEDIT_SEQUENCE_STYLE wxMINIMIZE_BOX | wxMAXIMIZE_BOX |wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL
74 #define SYMBOL_CEDIT_SEQUENCE_TITLE _("Edit Sequence")
75 #define SYMBOL_CEDIT_SEQUENCE_IDNAME ID_CEDIT_SEQUENCE
76 #define SYMBOL_CEDIT_SEQUENCE_SIZE wxSize(704, 504)
77 #define SYMBOL_CEDIT_SEQUENCE_POSITION wxDefaultPosition
78 ////@end control identifiers
79 #define ID_CLOSE_EDSEQ_BUTTON 11401
80 #define ID_ACCEPT_EDSEQ_BUTTON 11402
81 #define ID_GOTO_EDSEQ_BUTTON 11403
82 #define ID_SHOW_TRANSLATE_EDSEQ_MENU 11405
83 #define ID_SHOW_TRANSLATE1_EDSEQ_MENU 11406
84 #define ID_SHOW_TRANSLATE2_EDSEQ_MENU 11407
85 #define ID_SHOW_TRANSLATE_ALL_EDSEQ_MENU 11408
86 #define ID_SHOW_ONTHEFLY_EDSEQ_MENU 11409
87 #define ID_SHOW_MISMATCH_EDSEQ_MENU 11410
88 #define ID_SHOW_REVCOMP_EDSEQ_MENU 11411
89 #define ID_SHOW_FEATURES_EDSEQ_MENU 11412
90 #define ID_EDIT_COPY_EDSEQ_MENU 11413
91 #define ID_EDIT_CUT_EDSEQ_MENU 11414
92 #define ID_EDIT_PASTE_EDSEQ_MENU 11415
93 #define ID_SHOW_REVTRANSLATE_EDSEQ_MENU 11416
94 #define ID_SHOW_REVTRANSLATE1_EDSEQ_MENU 11417
95 #define ID_SHOW_REVTRANSLATE2_EDSEQ_MENU 11418
96 #define ID_SHOW_REVTRANSLATE_ALL_EDSEQ_MENU 11419
97 #define ID_CANCEL_EDSEQ_BUTTON 11420
98 #define ID_SHOW_TRANSLATE_EVERYTHING_EDSEQ_MENU 11421
99 #define ID_SHOW_TRANSLATE_NONE_EDSEQ_MENU 11422
100 #define ID_EDIT_FIND_EDSEQ_MENU 11423
101 #define ID_RETRANSLATE_EDSEQ_BUTTON 11424
102 #define ID_RANGE_EDSEQ_BUTTON 11425
103 #define READONLY_TIMER_ID 11426
104 
106 {
107  DECLARE_DYNAMIC_CLASS( CEditSequence )
108  DECLARE_EVENT_TABLE()
109 
110 public:
111  /// Constructors
112  CEditSequence();
113 
114  CEditSequence( wxWindow* parent, const CSeq_loc *loc, CScope &scope, ICommandProccessor* processor, int start = 0, wxWindowID id = SYMBOL_CEDIT_SEQUENCE_IDNAME, const wxString& caption = SYMBOL_CEDIT_SEQUENCE_TITLE, const wxPoint& pos = SYMBOL_CEDIT_SEQUENCE_POSITION, const wxSize& size = SYMBOL_CEDIT_SEQUENCE_SIZE, long style = SYMBOL_CEDIT_SEQUENCE_STYLE );
115 
116  /// Creation
117  bool Create( wxWindow* parent, wxWindowID id = SYMBOL_CEDIT_SEQUENCE_IDNAME, const wxString& caption = SYMBOL_CEDIT_SEQUENCE_TITLE, const wxPoint& pos = SYMBOL_CEDIT_SEQUENCE_POSITION, const wxSize& size = SYMBOL_CEDIT_SEQUENCE_SIZE, long style = SYMBOL_CEDIT_SEQUENCE_STYLE );
118 
119  /// Destructor
120  virtual ~CEditSequence();
121 
122  /// Initialises member variables
123  void Init();
124 
125  /// Creates the controls and sizers
126  void CreateControls();
127 
128  /// Retrieves bitmap resources
129  wxBitmap GetBitmapResource( const wxString& name );
130 
131  /// Retrieves icon resources
132  wxIcon GetIconResource( const wxString& name );
133 
134  /// Should we show tooltips?
135  static bool ShowToolTips();
136 
137  virtual void SetRegistryPath(const string& reg_path);
138  virtual void LoadSettings();
139  virtual void SaveSettings() const;
140 
141  void OnClose( wxCommandEvent& event );
142  void OnCancel( wxCommandEvent& event );
143  void OnAccept( wxCommandEvent& event );
144  void OnGoTo( wxCommandEvent& event );
145  void OnRange( wxCommandEvent& event );
146  void OnFind( wxCommandEvent& event );
147  void OnTranslate( wxCommandEvent& event );
148  void OnTranslate1( wxCommandEvent& event );
149  void OnTranslate2( wxCommandEvent& event );
150  void OnTranslateAll( wxCommandEvent& event );
151  void OnRevTranslate( wxCommandEvent& event );
152  void OnRevTranslate1( wxCommandEvent& event );
153  void OnRevTranslate2( wxCommandEvent& event );
154  void OnRevTranslateAll( wxCommandEvent& event );
155  void OnTranslateEverything( wxCommandEvent& event );
156  void OnTranslateNone( wxCommandEvent& event );
157  void OnOnTheFly( wxCommandEvent& event );
158  void OnMismatch( wxCommandEvent& event );
159  void OnComplement( wxCommandEvent& event );
160  void OnFeatures( wxCommandEvent& event );
161  void OnCopy( wxCommandEvent& event );
162  void OnCut( wxCommandEvent& event );
163  void OnPaste( wxCommandEvent& event );
164  void GetSequence();
165  void ReportPos(int pos);
166  void ReportRange(int pos1, int pos2);
167  void IsClipboard(wxUpdateUIEvent &event);
168  void IsSelection(wxUpdateUIEvent &event);
169  void IsSelectionAndClean(wxUpdateUIEvent &event);
170  void IsNucleotide(wxUpdateUIEvent &event);
171  void CreateFeature ( wxCommandEvent& event);
172  void CreateRegulatory( wxCommandEvent& event);
173  void EnableCommit(bool enable);
174  void OnRetranslate ( wxCommandEvent& event);
175  void ShowReadOnlyWarning();
176  void OnReadOnlyTimer(wxTimerEvent& event);
177 
178 private:
179  void GetFeatures(const CSeq_loc &loc, CScope &scope);
180  void GetProteinFeatures(CBioseq_Handle prot_bsh, int i, const CSeq_id* seq_id, const CSeq_feat &old_cds, TSeqPos seq_start);
182  void AdjustProtFeatureLocations(CRef<CCmdComposite> composite, const CSeq_feat &old_cds, const CSeq_feat &cds, int i, const CSeq_id* seq_id, TSeqPos seq_start);
183  string GetSeqTitle();
184  bool x_ExecuteCommand(IEditCommand* command);
185 
188  CSeq_entry_Handle m_seh, m_edited_seh;
189  vector<vector<pair<TSeqPos,TSeqPos> > > m_FeatRanges;
190  vector<pair<string,CSeqFeatData::ESubtype> > m_FeatTypes;
191  unordered_map<int, vector<vector<pair<TSeqPos,TSeqPos> > > > m_ProtFeatRanges;
192  vector<int> m_FeatFrames;
193  vector<bool> m_Feat5Partial;
194  vector< CRef<CGenetic_code> > m_GeneticCode;
196  wxStaticText *m_Pos;
197  wxStaticText *m_RangeLabel;
198  wxStaticText *m_Range;
199  wxTextCtrl* m_GoTo_TextCtrl;
200  wxTextCtrl* m_RangeFrom;
201  wxTextCtrl* m_RangeTo;
202  wxMenuItem *m_translate_item, *m_translate_item1, *m_translate_item2, *m_translate_item_all;
203  wxMenuItem *m_revtranslate_item, *m_revtranslate_item1, *m_revtranslate_item2, *m_revtranslate_item_all;
204  wxMenuItem *m_translate_item_everything, *m_translate_item_none;
205  wxButton* m_CommitButton;
207  wxStaticText* m_commit_warning;
208  wxStaticText* m_readonly_warning;
210  vector<string> m_RealProt;
211  vector<CBioseq_Handle::EVectorStrand> m_FeatStrand;
213  unsigned int m_NumCmds;
214  const CSeq_loc *m_loc;
216  int m_start;
217  string m_RegPath;
218 };
219 
220 
221 
222 ////@begin control identifiers
223 #define ID_CFINDEDITSEQUENCE 29000
224 #define ID_TEXTCTRL_FIND_EDIT_SEQ 29001
225 #define ID_NUC_FIND_EDIT_SEQ 29002
226 #define ID_REVCOMP_FIND_EDIT_SEQ 29003
227 #define ID_TRANSFRAME_FIND_EDIT_SEQ 29004
228 #define ID_FRAMECHOICE_FIND_EDIT_SEQ 29005
229 #define ID_PREV_FIND_EDIT_SEQ 29006
230 #define ID_NEXT_FIND_EDIT_SEQ 29007
231 #define ID_DISMISS_FIND_EDIT_SEQ 29008
232 #define SYMBOL_CFINDEDITSEQUENCE_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL
233 #define SYMBOL_CFINDEDITSEQUENCE_TITLE _("find")
234 #define SYMBOL_CFINDEDITSEQUENCE_IDNAME ID_CFINDEDITSEQUENCE
235 #define SYMBOL_CFINDEDITSEQUENCE_SIZE wxSize(400, 300)
236 #define SYMBOL_CFINDEDITSEQUENCE_POSITION wxDefaultPosition
237 ////@end control identifiers
238 
239 
240 /*!
241  * CFindEditSequence class declaration
242  */
243 
244 class CFindEditSequence : public wxDialog
245 {
246  DECLARE_DYNAMIC_CLASS( CFindEditSequence )
247  DECLARE_EVENT_TABLE()
248 
249 public:
250  /// Constructors
252  CFindEditSequence( wxWindow* parent, CPaintSequence *panel, bool is_nucleotide, wxWindowID id = SYMBOL_CFINDEDITSEQUENCE_IDNAME, const wxString& caption = SYMBOL_CFINDEDITSEQUENCE_TITLE, const wxPoint& pos = SYMBOL_CFINDEDITSEQUENCE_POSITION, const wxSize& size = SYMBOL_CFINDEDITSEQUENCE_SIZE, long style = SYMBOL_CFINDEDITSEQUENCE_STYLE );
253 
254  /// Creation
255  bool Create( wxWindow* parent, wxWindowID id = SYMBOL_CFINDEDITSEQUENCE_IDNAME, const wxString& caption = SYMBOL_CFINDEDITSEQUENCE_TITLE, const wxPoint& pos = SYMBOL_CFINDEDITSEQUENCE_POSITION, const wxSize& size = SYMBOL_CFINDEDITSEQUENCE_SIZE, long style = SYMBOL_CFINDEDITSEQUENCE_STYLE );
256 
257  /// Destructor
259 
260  /// Initialises member variables
261  void Init();
262 
263  /// Creates the controls and sizers
264  void CreateControls();
265 
266 ////@begin CFindEditSequence event handler declarations
267 
268 ////@end CFindEditSequence event handler declarations
269 
270 ////@begin CFindEditSequence member function declarations
271 
272  /// Retrieves bitmap resources
273  wxBitmap GetBitmapResource( const wxString& name );
274 
275  /// Retrieves icon resources
276  wxIcon GetIconResource( const wxString& name );
277 ////@end CFindEditSequence member function declarations
278 
279  /// Should we show tooltips?
280  static bool ShowToolTips();
281  void OnPrev( wxCommandEvent& event );
282  void OnNext( wxCommandEvent& event );
283  void OnDismiss( wxCommandEvent& event );
284  void OnClose(wxCloseEvent& event);
285  void OnChange( wxCommandEvent& event );
286 private:
287  void FindMatchPositions(const string &choice);
288  void SetHighlights();
289  string GetPattern();
290 
291 ////@begin CFindEditSequence member variables
292  wxTextCtrl* m_Pattern;
293  wxStaticText* m_ItemOfText;
294  wxRadioButton* m_Nuc;
295  wxCheckBox* m_RevComp;
296  wxRadioButton* m_TransFrame;
297  wxChoice* m_FrameChoice;
298  wxButton* m_Prev;
299  wxButton* m_Next;
300 ////@end CFindEditSequence member variables
301  int m_Num;
302  int m_Total;
307 };
308 
310 
311 #endif
312  // _EDIT_SEQUENCE_H_
CBioseq_Handle –.
wxStaticText * m_Range
wxMenuItem * m_translate_item_none
wxTextCtrl * m_RangeTo
CPaintSequence * m_Panel
wxStaticText * m_readonly_warning
wxTextCtrl * m_GoTo_TextCtrl
wxMenuItem * m_translate_item_all
vector< vector< pair< TSeqPos, TSeqPos > > > m_FeatRanges
wxStaticText * m_Pos
vector< pair< string, CSeqFeatData::ESubtype > > m_FeatTypes
CSeq_entry_Handle m_seh
vector< CBioseq_Handle::EVectorStrand > m_FeatStrand
vector< bool > m_Feat5Partial
const CSeq_loc * m_loc
vector< int > m_FeatFrames
wxButton * m_CommitButton
wxButton * m_RetranslateButton
vector< CRef< CGenetic_code > > m_GeneticCode
IUndoManager * m_UndoManager
wxTimer m_readonly_timer
unsigned int m_NumCmds
vector< string > m_RealProt
wxTextCtrl * m_RangeFrom
unordered_map< int, vector< vector< pair< TSeqPos, TSeqPos > > > > m_ProtFeatRanges
wxStaticText * m_RangeLabel
wxMenuItem * m_revtranslate_item_all
wxStaticText * m_commit_warning
CEventHandler.
wxCheckBox * m_RevComp
CPaintSequence * m_Panel
set< int >::iterator m_CurrentPos
wxChoice * m_FrameChoice
wxRadioButton * m_Nuc
wxTextCtrl * m_Pattern
wxRadioButton * m_TransFrame
wxStaticText * m_ItemOfText
CScope –.
Definition: scope.hpp:92
CSeq_entry_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Undo/Redo interface for editing operations.
Interface (functor) for object editing.
void AdjustFeatureLocations(const map< objects::CBioseq_Handle, vector< SGap >> &map_gaps, CRef< CCmdComposite > composite, bool split_gene_locations, bool break_features, bool keep_gap_length, bool create_general_only, objects::CObject_id::TId &max_feat_id, map< objects::CObject_id::TId, objects::CObject_id::TId > &old_to_new, bool create_xref_map)
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define SYMBOL_CEDIT_SEQUENCE_IDNAME
#define SYMBOL_CEDIT_SEQUENCE_POSITION
#define SYMBOL_CFINDEDITSEQUENCE_STYLE
#define SYMBOL_CFINDEDITSEQUENCE_SIZE
#define SYMBOL_CFINDEDITSEQUENCE_IDNAME
#define SYMBOL_CEDIT_SEQUENCE_SIZE
#define SYMBOL_CEDIT_SEQUENCE_STYLE
#define SYMBOL_CEDIT_SEQUENCE_TITLE
#define SYMBOL_CFINDEDITSEQUENCE_POSITION
#define SYMBOL_CFINDEDITSEQUENCE_TITLE
static void Init(void)
Definition: cursor6.c:76
SBlastSequence GetSequence(const objects::CSeq_loc &sl, EBlastEncoding encoding, objects::CScope *scope, objects::ENa_strand strand=objects::eNa_strand_plus, ESentinelType sentinel=eSentinels, std::string *warnings=NULL)
Retrieves a sequence using the object manager.
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIWIDGETS_EDIT_EXPORT
Definition: gui_export.h:526
int i
const struct ncbi::grid::netcache::search::fields::SIZE size
const char * command
string GetSeqTitle(CBioseq_Handle bsh)
Modified on Wed Jun 19 17:02:18 2024 by modify_doxy.py rev. 669887