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

Go to the SVN repository for this file.

1 /* $Id: trna_product_panel.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: Colleen Bollin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
34 
38 #include "trna_product_panel.hpp"
39 
40 #include <wx/sizer.h>
41 #include <wx/choice.h>
42 #include <wx/stattext.h>
43 #include <wx/radiobox.h>
44 #include <wx/treebook.h>
45 
46 
49 
50 
51 /*!
52  * CtRNAProductPanel type definition
53  */
54 
55 IMPLEMENT_DYNAMIC_CLASS( CtRNAProductPanel, wxPanel )
56 
57 
58 /*!
59  * CtRNAProductPanel event table definition
60  */
61 
62 BEGIN_EVENT_TABLE( CtRNAProductPanel, wxPanel )
63 
64 ////@begin CtRNAProductPanel event table entries
65  EVT_CHOICE( ID_TRNAPRODUCT_CHOICE, CtRNAProductPanel::OnAminoAcidSelected )
66  EVT_RADIOBOX( ID_TRNAPRODUCT_RDBX, CtRNAProductPanel::OnInitiatorSelected )
67 ////@end CtRNAProductPanel event table entries
68 
70 
71 
72 /*!
73  * CtRNAProductPanel constructors
74  */
75 
77  : m_GbQualPanel(0)
78 {
79  Init();
80 }
81 
82 CtRNAProductPanel::CtRNAProductPanel(wxWindow* parent, CRef<CTrna_ext> trna, CConstRef<CSeq_feat> feat, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
83  : m_trna(trna), m_Feat(feat), m_GbQualPanel(0)
84 {
85  Init();
86  Create(parent, id, pos, size, style);
87 }
88 
89 
90 /*!
91  * CtRNAProductPanel creator
92  */
93 
94 bool CtRNAProductPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
95 {
96 ////@begin CtRNAProductPanel creation
97  wxPanel::Create( parent, id, pos, size, style );
98 
100  if (GetSizer())
101  {
102  GetSizer()->SetSizeHints(this);
103  }
104  Centre();
105 ////@end CtRNAProductPanel creation
106  return true;
107 }
108 
109 
110 /*!
111  * CtRNAProductPanel destructor
112  */
113 
115 {
116 ////@begin CtRNAProductPanel destruction
117 ////@end CtRNAProductPanel destruction
118 }
119 
120 
121 /*!
122  * Member initialisation
123  */
124 
126 {
127 ////@begin CtRNAProductPanel member initialisation
130 ////@end CtRNAProductPanel member initialisation
131 }
132 
133 
134 /*!
135  * Control creation for CtRNAProductPanel
136  */
137 
139 {
140 ////@begin CtRNAProductPanel content construction
141  CtRNAProductPanel* itemPanel1 = this;
142 
143  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
144  itemPanel1->SetSizer(itemBoxSizer2);
145 
146  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
147  itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER, 0);
148 
149  wxStaticText* itemStaticText4 = new wxStaticText( itemPanel1, wxID_STATIC, _("Amino Acid"), wxDefaultPosition, wxDefaultSize, 0 );
150  itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
151 
152  wxArrayString m_AminoAcidCtrlStrings;
153  m_AminoAcidCtrlStrings.Add(wxEmptyString);
154  m_AminoAcidCtrlStrings.Add(_("A Alanine"));
155  m_AminoAcidCtrlStrings.Add(_("B Asp or Asn"));
156  m_AminoAcidCtrlStrings.Add(_("C Cysteine"));
157  m_AminoAcidCtrlStrings.Add(_("D Aspartic Acid"));
158  m_AminoAcidCtrlStrings.Add(_("E Glutamic Acid"));
159  m_AminoAcidCtrlStrings.Add(_("F Phenylalanine"));
160  m_AminoAcidCtrlStrings.Add(_("G Glycine"));
161  m_AminoAcidCtrlStrings.Add(_("H Histidine"));
162  m_AminoAcidCtrlStrings.Add(_("I Isoleucine"));
163  m_AminoAcidCtrlStrings.Add(_("J Leu or Ile"));
164  m_AminoAcidCtrlStrings.Add(_("K Lysine"));
165  m_AminoAcidCtrlStrings.Add(_("L Leucine"));
166  m_AminoAcidCtrlStrings.Add(_("M Methionine"));
167  m_AminoAcidCtrlStrings.Add(_("N Asparagine"));
168  m_AminoAcidCtrlStrings.Add(_("O Pyrrolysine"));
169  m_AminoAcidCtrlStrings.Add(_("P Proline"));
170  m_AminoAcidCtrlStrings.Add(_("Q Glutamine"));
171  m_AminoAcidCtrlStrings.Add(_("R Arginine"));
172  m_AminoAcidCtrlStrings.Add(_("S Serine"));
173  m_AminoAcidCtrlStrings.Add(_("T Threonine"));
174  m_AminoAcidCtrlStrings.Add(_("U Selenocysteine"));
175  m_AminoAcidCtrlStrings.Add(_("V Valine"));
176  m_AminoAcidCtrlStrings.Add(_("W Tryptophan"));
177  m_AminoAcidCtrlStrings.Add(_("X Undetermined"));
178  m_AminoAcidCtrlStrings.Add(_("Y Tyrosine"));
179  m_AminoAcidCtrlStrings.Add(_("Z Glu or Gln"));
180  m_AminoAcidCtrlStrings.Add(_("* Stop Codon"));
181  m_AminoAcidCtrl = new wxChoice( itemPanel1, ID_TRNAPRODUCT_CHOICE, wxDefaultPosition, wxDefaultSize, m_AminoAcidCtrlStrings, 0 );
182  itemBoxSizer3->Add(m_AminoAcidCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
183 
184  wxArrayString m_InitiatorCtrlStrings;
185  m_InitiatorCtrlStrings.Add(_("&No"));
186  m_InitiatorCtrlStrings.Add(_("&fMet"));
187  m_InitiatorCtrlStrings.Add(_("&iMet"));
188  m_InitiatorCtrl = new wxRadioBox( itemPanel1, ID_TRNAPRODUCT_RDBX, _("Initiator"), wxDefaultPosition, wxDefaultSize, m_InitiatorCtrlStrings, 1, wxRA_SPECIFY_ROWS );
189  m_InitiatorCtrl->SetSelection(0);
190  m_InitiatorCtrl->Enable(false);
191  itemBoxSizer2->Add(m_InitiatorCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
192 
193 ////@end CtRNAProductPanel content construction
194 }
195 
196 
198 {
199  unsigned char aa = 0;
200  vector<char> seqData;
201  string str = "";
202 
203  if (!m_trna || !m_trna->IsSetAa()) {
204  m_AminoAcidCtrl->SetSelection(0);
205  } else {
206 
207  switch (m_trna->GetAa().Which()) {
209  str = m_trna->GetAa().GetIupacaa();
210  CSeqConvert::Convert(str, CSeqUtil::e_Iupacaa, 0, static_cast<TSeqPos>(str.size()), seqData, CSeqUtil::e_Ncbieaa);
211  aa = seqData[0];
212  break;
214  str = m_trna->GetAa().GetNcbi8aa();
215  CSeqConvert::Convert(str, CSeqUtil::e_Ncbi8aa, 0, static_cast<TSeqPos>(str.size()), seqData, CSeqUtil::e_Ncbieaa);
216  aa = seqData[0];
217  break;
219  str = m_trna->GetAa().GetNcbi8aa();
220  CSeqConvert::Convert(str, CSeqUtil::e_Ncbistdaa, 0, static_cast<TSeqPos>(str.size()), seqData, CSeqUtil::e_Ncbieaa);
221  aa = seqData[0];
222  break;
224  seqData.push_back(m_trna->GetAa().GetNcbieaa());
225  aa = seqData[0];
226  break;
227  default:
228  break;
229  }
230 
231  switch (aa) {
232  case 'A':
233  m_AminoAcidCtrl->SetSelection(1);
234  break;
235  case 'B':
236  m_AminoAcidCtrl->SetSelection(2);
237  break;
238  case 'C':
239  m_AminoAcidCtrl->SetSelection(3);
240  break;
241  case 'D':
242  m_AminoAcidCtrl->SetSelection(4);
243  break;
244  case 'E':
245  m_AminoAcidCtrl->SetSelection(5);
246  break;
247  case 'F':
248  m_AminoAcidCtrl->SetSelection(6);
249  break;
250  case 'G':
251  m_AminoAcidCtrl->SetSelection(7);
252  break;
253  case 'H':
254  m_AminoAcidCtrl->SetSelection(8);
255  break;
256  case 'I':
257  m_AminoAcidCtrl->SetSelection(9);
258  break;
259  case 'J':
260  m_AminoAcidCtrl->SetSelection(10);
261  break;
262  case 'K':
263  m_AminoAcidCtrl->SetSelection(11);
264  break;
265  case 'L':
266  m_AminoAcidCtrl->SetSelection(12);
267  break;
268  case 'M':
269  m_AminoAcidCtrl->SetSelection(13);
270  break;
271  case 'N':
272  m_AminoAcidCtrl->SetSelection(14);
273  break;
274  case 'O':
275  m_AminoAcidCtrl->SetSelection(15);
276  break;
277  case 'P':
278  m_AminoAcidCtrl->SetSelection(16);
279  break;
280  case 'Q':
281  m_AminoAcidCtrl->SetSelection(17);
282  break;
283  case 'R':
284  m_AminoAcidCtrl->SetSelection(18);
285  break;
286  case 'S':
287  m_AminoAcidCtrl->SetSelection(19);
288  break;
289  case 'T':
290  m_AminoAcidCtrl->SetSelection(20);
291  break;
292  case 'U':
293  m_AminoAcidCtrl->SetSelection(21);
294  break;
295  case 'V':
296  m_AminoAcidCtrl->SetSelection(22);
297  break;
298  case 'W':
299  m_AminoAcidCtrl->SetSelection(23);
300  break;
301  case 'X':
302  m_AminoAcidCtrl->SetSelection(24);
303  break;
304  case 'Y':
305  m_AminoAcidCtrl->SetSelection(25);
306  break;
307  case 'Z':
308  m_AminoAcidCtrl->SetSelection(26);
309  break;
310  case '*':
311  m_AminoAcidCtrl->SetSelection(27);
312  break;
313  default:
314  m_AminoAcidCtrl->SetSelection(0);
315  break;
316  }
317  }
318 }
319 
320 
322 {
323  if (!wxPanel::TransferDataToWindow())
324  return false;
325 
326  // amino acid
327  x_SetAminoAcid();
329 
330  // set the initiator radiobutton
331 
332  if (m_InitiatorCtrl->IsEnabled()) {
334  const CGb_qual& qual = **it;
335  if (NStr::EqualCase(qual.GetQual(), "product") && qual.IsSetVal()) {
337  m_InitiatorCtrl->SetSelection(1);
338  }
339  else if (NStr::EqualCase(qual.GetVal(), CGBQualPanel::stRNA_IMet)) {
340  m_InitiatorCtrl->SetSelection(2);
341  }
342  break;
343  }
344  }
345  }
346 
347  return true;
348 }
349 
350 
352 {
353  if (!wxPanel::TransferDataFromWindow())
354  return false;
355 
356  // amino acid
357  string aa = ToStdString( m_AminoAcidCtrl->GetStringSelection());
358  if (NStr::IsBlank(aa)) {
359  m_trna->ResetAa();
360  } else {
361  m_trna->SetAa().SetNcbieaa(aa.c_str()[0]);
362  }
363 
364  return true;
365 }
366 
367 
368 /*!
369  * Should we show tooltips?
370  */
371 
373 {
374  return true;
375 }
376 
377 /*!
378  * Get bitmap resources
379  */
380 
381 wxBitmap CtRNAProductPanel::GetBitmapResource( const wxString& name )
382 {
383  // Bitmap retrieval
384 ////@begin CtRNAProductPanel bitmap retrieval
385  wxUnusedVar(name);
386  return wxNullBitmap;
387 ////@end CtRNAProductPanel bitmap retrieval
388 }
389 
390 /*!
391  * Get icon resources
392  */
393 
394 wxIcon CtRNAProductPanel::GetIconResource( const wxString& name )
395 {
396  // Icon retrieval
397 ////@begin CtRNAProductPanel icon retrieval
398  wxUnusedVar(name);
399  return wxNullIcon;
400 ////@end CtRNAProductPanel icon retrieval
401 }
402 
403 void CtRNAProductPanel::OnAminoAcidSelected( wxCommandEvent& event )
404 {
406 }
407 
409 {
410  string aa = ToStdString(m_AminoAcidCtrl->GetStringSelection());
411  m_InitiatorCtrl->Enable(NStr::EqualNocase(aa, "M Methionine"));
412 }
413 
414 void CtRNAProductPanel::OnInitiatorSelected(wxCommandEvent& event)
415 {
417  switch (m_InitiatorCtrl->GetSelection()) {
418  case 0: // no
420  break;
421  case 1: // fMet
423  break;
424  case 2: // iMet
426  break;
427  }
428 }
429 
User-defined methods of the data storage class.
static const char * stRNA_IMet
static const char * stRNA_FMet
void Update_tRNA_ProductQual(const string &value)
@Gb_qual.hpp User-defined methods of the data storage class.
Definition: Gb_qual.hpp:61
CRef –.
Definition: ncbiobj.hpp:618
static SIZE_TYPE Convert(const CTempString &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst, TCoding dst_coding)
@ e_Ncbieaa
Definition: sequtil.hpp:57
@ e_Ncbi8aa
Definition: sequtil.hpp:56
@ e_Ncbistdaa
Definition: sequtil.hpp:58
@ e_Iupacaa
Definition: sequtil.hpp:55
~CtRNAProductPanel()
Destructor.
void OnInitiatorSelected(wxCommandEvent &event)
wxRadioBox * m_InitiatorCtrl
CtRNAProductPanel()
Constructors.
static bool ShowToolTips()
Should we show tooltips?
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
CConstRef< objects::CSeq_feat > m_Feat
virtual bool TransferDataFromWindow()
void OnAminoAcidSelected(wxCommandEvent &event)
wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_TRNAPRODUCT_CHOICE
CGBQualPanel * m_GbQualPanel
bool Create(wxWindow *parent, wxWindowID id=ID_TRNAPRODUCTPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
Creation.
virtual bool TransferDataToWindow()
void CreateControls()
Creates the controls and sizers.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
CRef< objects::CTrna_ext > m_trna
void Init()
Initialises member variables.
#define _(proto)
Definition: ct_nlmzip_i.h:78
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
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static bool EqualCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive equality of a substring with another string.
Definition: ncbistr.hpp:5325
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
const TVal & GetVal(void) const
Get the Val member data.
Definition: Gb_qual_.hpp:259
const TQual & GetQual(void) const
Get the Qual member data.
Definition: Gb_qual_.hpp:212
bool IsSetVal(void) const
Check if a value has been assigned to Val data member.
Definition: Gb_qual_.hpp:247
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
Utility macros and typedefs for exploring NCBI objects from seqfeat.asn.
#define FOR_EACH_GBQUAL_ON_FEATURE
static const char * str(char *buf, int n)
Definition: stats.c:84
#define _ASSERT
USING_SCOPE(objects)
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Fri Mar 01 10:07:31 2024 by modify_doxy.py rev. 669887