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

Go to the SVN repository for this file.

1 /* $Id: igsflankpanel.cpp 28329 2013-06-19 11:58:38Z bollin $
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>
32 
33 ////@begin includes
34 ////@end includes
35 
36 #include <wx/stattext.h>
38 
39 ////@begin XPM images
40 ////@end XPM images
41 
43 
44 /*!
45  * CIGSFlankPanel type definition
46  */
47 
48 IMPLEMENT_DYNAMIC_CLASS( CIGSFlankPanel, wxPanel )
49 
50 
51 /*!
52  * CIGSFlankPanel event table definition
53  */
54 
55 BEGIN_EVENT_TABLE( CIGSFlankPanel, wxPanel )
56 
57 ////@begin CIGSFlankPanel event table entries
59 
61 
62 ////@end CIGSFlankPanel event table entries
63 
65 
66 
67 /*!
68  * CIGSFlankPanel constructors
69  */
70 
72 {
73  Init();
74 }
75 
76 CIGSFlankPanel::CIGSFlankPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
77 {
78  Init();
79  Create(parent, id, pos, size, style);
80 }
81 
82 
83 /*!
84  * CIGSFlankPanel creator
85  */
86 
87 bool CIGSFlankPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
88 {
89 ////@begin CIGSFlankPanel creation
90  wxPanel::Create( parent, id, pos, size, style );
91 
93  if (GetSizer())
94  {
95  GetSizer()->SetSizeHints(this);
96  }
97  Centre();
98 ////@end CIGSFlankPanel creation
99  return true;
100 }
101 
102 
103 /*!
104  * CIGSFlankPanel destructor
105  */
106 
108 {
109 ////@begin CIGSFlankPanel destruction
110 ////@end CIGSFlankPanel destruction
111 }
112 
113 
114 /*!
115  * Member initialisation
116  */
117 
119 {
120 ////@begin CIGSFlankPanel member initialisation
121  m_IstRNA = NULL;
122  m_tRNA = NULL;
123  m_IsProtein = NULL;
125  m_GeneSymbol = NULL;
127 ////@end CIGSFlankPanel member initialisation
128 }
129 
130 
131 /*!
132  * Control creation for CIGSFlankPanel
133  */
134 
136 {
137 ////@begin CIGSFlankPanel content construction
138  // Generated by DialogBlocks, 10/06/2013 17:55:51 (unregistered)
139 
140  CIGSFlankPanel* itemPanel1 = this;
141 
142  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
143  itemPanel1->SetSizer(itemBoxSizer2);
144 
145  wxFlexGridSizer* itemFlexGridSizer3 = new wxFlexGridSizer(0, 2, 0, 0);
146  itemBoxSizer2->Add(itemFlexGridSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
147 
148  m_IstRNA = new wxRadioButton( itemPanel1, ID_RADIOBUTTON, _("tRNA"), wxDefaultPosition, wxDefaultSize, 0 );
149  m_IstRNA->SetValue(true);
150  itemFlexGridSizer3->Add(m_IstRNA, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
151 
152  wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
153  itemFlexGridSizer3->Add(itemBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
154 
155  wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("Select tRNA"), wxDefaultPosition, wxDefaultSize, 0 );
156  itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
157 
158  wxArrayString m_tRNAStrings;
159  m_tRNAStrings.Add(_("A Alanine"));
160  m_tRNAStrings.Add(_("B Asp or Asn"));
161  m_tRNAStrings.Add(_("C Cysteine"));
162  m_tRNAStrings.Add(_("D Aspartic Acid"));
163  m_tRNAStrings.Add(_("E Glutamic Acid"));
164  m_tRNAStrings.Add(_("F Phenylalanine"));
165  m_tRNAStrings.Add(_("G Glycine"));
166  m_tRNAStrings.Add(_("H Histidine"));
167  m_tRNAStrings.Add(_("I Isoleucine"));
168  m_tRNAStrings.Add(_("J Leu or Ile"));
169  m_tRNAStrings.Add(_("K Lysine"));
170  m_tRNAStrings.Add(_("L Leucine"));
171  m_tRNAStrings.Add(_("M Methionine"));
172  m_tRNAStrings.Add(_("N Asparagine"));
173  m_tRNAStrings.Add(_("O Pyrrolysine"));
174  m_tRNAStrings.Add(_("P Proline"));
175  m_tRNAStrings.Add(_("Q Glutamine"));
176  m_tRNAStrings.Add(_("R Arginine"));
177  m_tRNAStrings.Add(_("S Serine"));
178  m_tRNAStrings.Add(_("T Threonine"));
179  m_tRNAStrings.Add(_("U Selenocysteine"));
180  m_tRNAStrings.Add(_("V Valine"));
181  m_tRNAStrings.Add(_("W Tryptophan"));
182  m_tRNAStrings.Add(_("X Undetermined or atypical"));
183  m_tRNAStrings.Add(_("Y Tyrosine"));
184  m_tRNAStrings.Add(_("Z Glu or Gln"));
185  m_tRNA = new wxChoice( itemPanel1, ID_CHOICE, wxDefaultPosition, wxDefaultSize, m_tRNAStrings, 0 );
186  itemBoxSizer5->Add(m_tRNA, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
187 
188  m_IsProtein = new wxRadioButton( itemPanel1, ID_RADIOBUTTON1, _("protein coding gene"), wxDefaultPosition, wxDefaultSize, 0 );
189  m_IsProtein->SetValue(false);
190  itemFlexGridSizer3->Add(m_IsProtein, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
191 
192  wxFlexGridSizer* itemFlexGridSizer9 = new wxFlexGridSizer(0, 2, 0, 0);
193  itemFlexGridSizer3->Add(itemFlexGridSizer9, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
194 
195  wxStaticText* itemStaticText10 = new wxStaticText( itemPanel1, wxID_STATIC, _("Protein Name"), wxDefaultPosition, wxDefaultSize, 0 );
196  itemFlexGridSizer9->Add(itemStaticText10, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
197 
198  m_ProteinName = new wxTextCtrl( itemPanel1, ID_TEXTCTRL3, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
199  m_ProteinName->Enable(false);
200  itemFlexGridSizer9->Add(m_ProteinName, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
201 
202  wxStaticText* itemStaticText12 = new wxStaticText( itemPanel1, wxID_STATIC, _("Gene Symbol"), wxDefaultPosition, wxDefaultSize, 0 );
203  itemFlexGridSizer9->Add(itemStaticText12, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
204 
205  m_GeneSymbol = new wxTextCtrl( itemPanel1, ID_TEXTCTRL4, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
206  m_GeneSymbol->Enable(false);
207  itemFlexGridSizer9->Add(m_GeneSymbol, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
208 
209  wxArrayString m_IncludeFeatStrings;
210  m_IncludeFeatStrings.Add(_("&Yes"));
211  m_IncludeFeatStrings.Add(_("Yes, &but only in some of the sequences"));
212  m_IncludeFeatStrings.Add(_("&No, it is only the intergenic spacer on this end"));
213  m_IncludeFeat = new wxRadioBox( itemPanel1, ID_RADIOBOX1, _("Do your sequences contain part of the feature described above?"), wxDefaultPosition, wxDefaultSize, m_IncludeFeatStrings, 1, wxRA_SPECIFY_COLS );
214  m_IncludeFeat->SetSelection(0);
215  itemBoxSizer2->Add(m_IncludeFeat, 0, wxGROW|wxALL, 5);
216 
217 ////@end CIGSFlankPanel content construction
218 }
219 
220 
221 /*!
222  * Should we show tooltips?
223  */
224 
226 {
227  return true;
228 }
229 
230 /*!
231  * Get bitmap resources
232  */
233 
234 wxBitmap CIGSFlankPanel::GetBitmapResource( const wxString& name )
235 {
236  // Bitmap retrieval
237 ////@begin CIGSFlankPanel bitmap retrieval
238  wxUnusedVar(name);
239  return wxNullBitmap;
240 ////@end CIGSFlankPanel bitmap retrieval
241 }
242 
243 /*!
244  * Get icon resources
245  */
246 
247 wxIcon CIGSFlankPanel::GetIconResource( const wxString& name )
248 {
249  // Icon retrieval
250 ////@begin CIGSFlankPanel icon retrieval
251  wxUnusedVar(name);
252  return wxNullIcon;
253 ////@end CIGSFlankPanel icon retrieval
254 }
255 
257 {
258  string name = "";
259  if (m_IstRNA->GetValue()) {
260  string trna = ToStdString(m_tRNA->GetStringSelection());
261  if (!NStr::IsBlank(trna)) {
262  name = "trn" + trna.substr(0, 1);
263  }
264  } else if (m_IsProtein->GetValue()) {
265  string prot = ToStdString(m_ProteinName->GetValue());
266  string gene = ToStdString(m_GeneSymbol->GetValue());
267  if (NStr::IsBlank(gene)) {
268  name = prot;
269  } else {
270  name = gene;
271  }
272  }
273  return name;
274 }
275 
276 
277 string s_GetTRNAAbbrev (string trna_label)
278 {
279  string abbrev = "";
280 
281  // temporary
282  if (NStr::Find(trna_label, " or ")) {
283  abbrev = trna_label.substr(0, 2) + "x";
284  } else {
285  abbrev = trna_label.substr(0, 3);
286  }
287  return abbrev;
288 }
289 
291 {
292  string name = "";
293  if (m_IncludeFeat->GetSelection() == 0 || m_IncludeFeat->GetSelection() == 1) {
294  if (m_IstRNA->GetValue()) {
295  string trna = ToStdString(m_tRNA->GetStringSelection());
296  if (!NStr::IsBlank(trna)) {
297  name = "tRNA-" + s_GetTRNAAbbrev(trna.substr(2)) + " (trn" + trna.substr(0, 1) + ")";
298  }
299  } else if (m_IsProtein->GetValue()) {
300  string prot = ToStdString(m_ProteinName->GetValue());
301  string gene = ToStdString(m_GeneSymbol->GetValue());
302  if (NStr::IsBlank(prot)) {
303  if (!NStr::IsBlank(gene)) {
304  name = gene;
305  }
306  } else {
307  if (NStr::IsBlank(gene)) {
308  name = prot;
309  } else {
310  name = prot + " (" + gene + ")";
311  }
312  }
313  }
314  }
315  return name;
316 }
317 
318 
319 /*!
320  * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON
321  */
322 
323 void CIGSFlankPanel::OntrnabuttonSelected( wxCommandEvent& event )
324 {
325  m_tRNA->Enable(true);
326  m_ProteinName->Enable(false);
327  m_GeneSymbol->Enable(false);
328 }
329 
330 
331 /*!
332  * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON1
333  */
334 
335 void CIGSFlankPanel::OnProteinSelected( wxCommandEvent& event )
336 {
337  m_tRNA->Enable(false);
338  m_ProteinName->Enable(true);
339  m_GeneSymbol->Enable(true);
340 }
341 
342 
void CreateControls()
Creates the controls and sizers.
void Init()
Initialises member variables.
static bool ShowToolTips()
Should we show tooltips?
string GetIGSLabel()
CIGSFlankPanel()
Constructors.
wxTextCtrl * m_ProteinName
void OnProteinSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON1
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
wxTextCtrl * m_GeneSymbol
string GetFlankLabel()
void OntrnabuttonSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON
~CIGSFlankPanel()
Destructor.
wxRadioBox * m_IncludeFeat
wxRadioButton * m_IsProtein
wxRadioButton * m_IstRNA
wxChoice * m_tRNA
bool Create(wxWindow *parent, wxWindowID id=10036, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#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
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
Definition: ncbistr.cpp:2887
string s_GetTRNAAbbrev(string trna_label)
#define ID_RADIOBOX1
#define ID_TEXTCTRL4
#define ID_CHOICE
#define ID_RADIOBUTTON1
#define ID_TEXTCTRL3
#define ID_RADIOBUTTON
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Sun Mar 03 03:16:30 2024 by modify_doxy.py rev. 669887