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

Go to the SVN repository for this file.

1 /* $Id: restore_rna_edit.cpp 45340 2020-07-08 14:24:59Z asztalos $
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 
33 // For compilers that support precompilation, includes "wx/wx.h".
34 #include "wx/wxprec.h"
35 
36 #ifdef __BORLANDC__
37 #pragma hdrstop
38 #endif
39 
40 #ifndef WX_PRECOMP
41 #include "wx/wx.h"
42 #endif
43 
49 #include <objmgr/feat_ci.hpp>
50 #include <objmgr/bioseq_handle.hpp>
51 #include <objmgr/seq_vector.hpp>
53 
54 ////@begin includes
55 ////@end includes
56 
57 
58 ////@begin XPM images
59 ////@end XPM images
60 
63 
64 /*
65  * CRestoreRNAediting type definition
66  */
67 
68 IMPLEMENT_DYNAMIC_CLASS( CRestoreRNAediting, wxDialog )
69 
70 
71 /*
72  * CRestoreRNAediting event table definition
73  */
74 
75 BEGIN_EVENT_TABLE( CRestoreRNAediting, wxDialog )
76 
77 ////@begin CRestoreRNAediting event table entries
79 ////@end CRestoreRNAediting event table entries
80 
82 
83 
84 /*
85  * CRestoreRNAediting constructors
86  */
87 
89 {
90  Init();
91 }
92 
93 CRestoreRNAediting::CRestoreRNAediting( wxWindow* parent, objects::CSeq_entry_Handle seh, ICommandProccessor* cmdProcessor,
94  wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
95  : m_TopSeqEntry(seh), m_CmdProcessor(cmdProcessor)
96 {
97  Init();
98  Create(parent, id, caption, pos, size, style);
99 }
100 
101 
102 /*
103  * CRestoreRNAediting creator
104  */
105 
106 bool CRestoreRNAediting::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
107 {
108 ////@begin CRestoreRNAediting creation
109  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY|wxWS_EX_BLOCK_EVENTS);
110  wxDialog::Create( parent, id, caption, pos, size, style );
111 
112  CreateControls();
113  if (GetSizer())
114  {
115  GetSizer()->SetSizeHints(this);
116  }
117  Centre();
118 ////@end CRestoreRNAediting creation
119  return true;
120 }
121 
122 
123 /*
124  * CRestoreRNAediting destructor
125  */
126 
128 {
129 ////@begin CRestoreRNAediting destruction
130 ////@end CRestoreRNAediting destruction
131 }
132 
133 
134 /*
135  * Member initialisation
136  */
137 
139 {
140 ////@begin CRestoreRNAediting member initialisation
141  m_Name = NULL;
142  m_LeaveUp = NULL;
143 ////@end CRestoreRNAediting member initialisation
144 }
145 
146 
147 /*
148  * Control creation for CRestoreRNAediting
149  */
150 
152 {
153 ////@begin CRestoreRNAediting content construction
154  CRestoreRNAediting* itemDialog1 = this;
155 
156  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
157  itemDialog1->SetSizer(itemBoxSizer2);
158 
159  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
160  itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5);
161 
162  wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Protein name"), wxDefaultPosition, wxDefaultSize, 0 );
163  itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
164 
165  m_Name = new wxTextCtrl( itemDialog1, ID_RESTORE_PROTEINNAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
166  itemBoxSizer3->Add(m_Name, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
167 
168  wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
169  itemBoxSizer2->Add(itemBoxSizer6, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
170 
171  wxButton* itemButton7 = new wxButton( itemDialog1, ID_RESTORE_RNA_EDIT_APPLY, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 );
172  itemBoxSizer6->Add(itemButton7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
173 
174  wxButton* itemButton8 = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
175  itemBoxSizer6->Add(itemButton8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
176 
177  m_LeaveUp = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Leave dialog up"), wxDefaultPosition, wxDefaultSize, 0 );
178  m_LeaveUp->SetValue(false);
179  itemBoxSizer6->Add(m_LeaveUp, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
180 
181 ////@end CRestoreRNAediting content construction
182 }
183 
184 
185 /*
186  * Should we show tooltips?
187  */
188 
190 {
191  return true;
192 }
193 
194 /*
195  * Get bitmap resources
196  */
197 
198 wxBitmap CRestoreRNAediting::GetBitmapResource( const wxString& name )
199 {
200  // Bitmap retrieval
201 ////@begin CRestoreRNAediting bitmap retrieval
202  wxUnusedVar(name);
203  return wxNullBitmap;
204 ////@end CRestoreRNAediting bitmap retrieval
205 }
206 
207 /*
208  * Get icon resources
209  */
210 
211 wxIcon CRestoreRNAediting::GetIconResource( const wxString& name )
212 {
213  // Icon retrieval
214 ////@begin CRestoreRNAediting icon retrieval
215  wxUnusedVar(name);
216  return wxNullIcon;
217 ////@end CRestoreRNAediting icon retrieval
218 }
219 
220 void CRestoreRNAediting::OnApply(wxCommandEvent& event)
221 {
222  string name = m_Name->GetValue().ToStdString();
224  CRef<CCmdComposite> cmd(new CCmdComposite("Restore RNA Editing"));
226  {
227  if (!cds->IsSetProduct())
228  continue;
229 
230  const CSeq_id *id = cds->GetProduct().GetId();
231  if (!id)
232  continue;
233 
234  CBioseq_Handle bsh = m_TopSeqEntry.GetScope().GetBioseqHandle(*id);
235  if (!bsh)
236  continue;
237 
238  string prot_seq;
239  CSeqVector prot_vec(*(bsh.GetCompleteBioseq()), &m_TopSeqEntry.GetScope());
241  prot_vec.GetSeqData(0, prot_vec.size(), prot_seq);
242 
243  if (prot_seq.empty() || prot_seq.front() == 'M')
244  continue;
245 
247  if( !prot_feat_ci)
248  continue;
249 
250  CSeq_feat_Handle prot_fh = prot_feat_ci->GetSeq_feat_Handle();
251  CConstRef<CSeq_feat> feat = prot_fh.GetSeq_feat();
252  if (!feat->IsSetData() || !feat->GetData().IsProt())
253  continue;
254 
255  bool found = false;
256  FOR_EACH_NAME_ON_PROTREF(name_it, feat->GetData().GetProt()) {
257  if (name == *name_it) {
258  found = true;
259  break;
260  }
261  }
262 
263  if (!found)
264  continue;
265 
266  CRef<CSeq_feat> new_cds(new CSeq_feat);
267  new_cds->Assign(*cds->GetOriginalSeq_feat());
268  if (CCleanup::FixRNAEditingCodingRegion(*new_cds)) {
269  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(cds->GetSeq_feat_Handle(), *new_cds));
270  cmd->AddCommand(*chgFeat);
271  }
272 
273  CRef<objects::CSeq_inst> new_inst(new objects::CSeq_inst());
274  new_inst->Assign(bsh.GetInst());
275  if (new_inst->IsSetSeq_data()) {
276  new_inst->ResetSeq_data();
277  }
278  prot_seq[0] = 'M';
279  new_inst->ResetExt();
280  new_inst->SetRepr(objects::CSeq_inst::eRepr_raw);
281  new_inst->SetSeq_data().SetNcbieaa().Set(prot_seq);
282  new_inst->SetLength(TSeqPos(prot_seq.length()));
283  new_inst->SetMol(CSeq_inst::eMol_aa);
284  CRef<CCmdChangeBioseqInst> chgInst (new CCmdChangeBioseqInst(bsh, *new_inst));
285  cmd->AddCommand(*chgInst);
286 
287  }
289  if (!m_LeaveUp->GetValue())
290  Close();
291 }
CBioseq_Handle –.
static bool FixRNAEditingCodingRegion(CSeq_feat &cds)
From GB-7563 An action has been requested that will do the following: 1.
Definition: cleanup.cpp:4849
CFeat_CI –.
Definition: feat_ci.hpp:64
void Init()
Initialises member variables.
objects::CSeq_entry_Handle m_TopSeqEntry
void OnApply(wxCommandEvent &event)
static bool ShowToolTips()
Should we show tooltips?
~CRestoreRNAediting()
Destructor.
ICommandProccessor * m_CmdProcessor
void CreateControls()
Creates the controls and sizers.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=_("Restore RNA editing of coding region"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
CRestoreRNAediting()
Constructors.
CSeqVector –.
Definition: seq_vector.hpp:65
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Undo/Redo interface for editing operations.
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
#define _(proto)
Definition: ct_nlmzip_i.h:78
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static void Init(void)
Definition: cursor6.c:76
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define NULL
Definition: ncbistd.hpp:225
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
virtual CConstRef< CSeq_feat > GetSeq_feat(void) const
const TInst & GetInst(void) const
const CSeq_feat_Handle & GetSeq_feat_Handle(void) const
Get original feature handle.
Definition: mapped_feat.hpp:71
void GetSeqData(TSeqPos start, TSeqPos stop, string &buffer) const
Fill the buffer string with the sequence data for the interval [start, stop).
Definition: seq_vector.cpp:304
TSeqPos size(void) const
Definition: seq_vector.hpp:291
void SetCoding(TCoding coding)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3201
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
Definition: Seq_feat_.hpp:913
bool IsProt(void) const
Check if variant Prot is selected.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
const TProt & GetProt(void) const
Get the variant data.
@ e_Ncbieaa
extended ASCII 1 letter aa codes
Definition: Seq_data_.hpp:111
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
USING_SCOPE(objects)
#define ID_RESTORE_PROTEINNAME
#define ID_RESTORE_RNA_EDIT_APPLY
#define ID_CHECKBOX
Utility macros and typedefs for exploring NCBI objects from seqfeat.asn.
#define FOR_EACH_NAME_ON_PROTREF(Itr, Var)
FOR_EACH_NAME_ON_PROTREF EDIT_EACH_NAME_ON_PROTREF.
SAnnotSelector –.
Modified on Sun Apr 14 05:28:15 2024 by modify_doxy.py rev. 669887