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

Go to the SVN repository for this file.

1 /* $Id: splign_panel.cpp 37399 2017-01-05 17:42:22Z katargir $
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: Roman Katargin
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include <serial/typeinfo.hpp>
36 
37 #include <objects/seq/MolInfo.hpp>
38 
39 #include <objmgr/seqdesc_ci.hpp>
40 
43 
46 
47 #include <wx/sizer.h>
48 #include <wx/statbox.h>
49 #include <wx/stattext.h>
50 #include <wx/choice.h>
51 #include <wx/checkbox.h>
52 #include <wx/radiobox.h>
53 #include <wx/msgdlg.h>
54 
56 
57 ////@begin includes
58 ////@end includes
59 
62 
63 IMPLEMENT_DYNAMIC_CLASS( CSplignPanel, CAlgoToolManagerParamsPanel )
64 
65 BEGIN_EVENT_TABLE( CSplignPanel, CAlgoToolManagerParamsPanel )
66 
67 ////@begin CSplignPanel event table entries
68 ////@end CSplignPanel event table entries
69 
71 
72 
73 CConstRef<CObject> CMolTypeValidator::Validate(const CSeq_id& id, CScope& scope, wxString& errMessage)
74 {
77  CSeq_loc::GetTypeInfo()->GetName(), relations);
78 
79  if (relations.empty()) {
80  errMessage = wxT("Object cannot be converted to CSeq_loc.");
81  return CConstRef<CObject>();
82  }
83 
84  CRelation::TObjects related;
85  relations.front()->GetRelated(scope, id, related, CRelation::fConvert_NoExpensive);
86 
87  if (related.empty()) {
88  errMessage = wxT("Object cannot be converted to CSeq_loc.");
89  return CConstRef<CObject>();
90  }
91 
92  try {
93  ITERATE(CRelation::TObjects, it, related) {
94  const CSeq_loc& loc = dynamic_cast<const CSeq_loc&>(it->GetObject());
95  CBioseq_Handle handle = scope.GetBioseqHandle(*loc.GetId());
96 
97  if (m_MolType == kProtein && handle.IsAa()) {
98  return CConstRef<CObject>(it->GetObjectPtr());
99  } else if (m_MolType == kNucleotide && handle.IsNa()) {
100  return CConstRef<CObject>(it->GetObjectPtr());
101  }
102 
103  const CMolInfo* molInfo = 0;
104  CSeqdesc_CI desc_iter(handle, CSeqdesc::e_Molinfo);
105  if (desc_iter) molInfo = &desc_iter->GetMolinfo();
106  if (molInfo) {
107  CMolInfo::TBiomol biomol = molInfo->GetBiomol();
108  switch (biomol) {
110  if (m_MolType == kGenomic)
111  return CConstRef<CObject>(it->GetObjectPtr());
112  break;
114  return CConstRef<CObject>(it->GetObjectPtr());
116  break;
117  default:
118  if (m_MolType == kCDNA)
119  return CConstRef<CObject>(it->GetObjectPtr());
120  break;
121  }
122  }
123  }
124  }
125  catch (const CException& e) {
126  errMessage = e.GetMsg();
127  }
128  catch (const exception& e) {
129  errMessage = e.what();
130  }
131 
132  if (errMessage.empty()) {
133  switch (m_MolType) {
134  case (kGenomic) :
135  errMessage = wxT("Object is not a Genomic sequence.");
136  break;
137  case (kCDNA) :
138  errMessage = wxT("Object is not a cDNA/Transcript sequence.");
139  break;
140  case (kProtein):
141  errMessage = wxT("Object is not a protein sequence.");
142  break;
143  case (kNucleotide):
144  errMessage = wxT("Object is not a nucleotide sequence.");
145  break;
146  }
147  }
148 
149  return CConstRef<CObject>();
150 }
151 
153 : m_GenomicListAccValidator(CMolTypeValidator::kGenomic),
154  m_CDNAListAccValidator(CMolTypeValidator::kCDNA)
155 {
156  Init();
157 }
158 
159 CSplignPanel::CSplignPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, bool visible )
160 : m_GenomicListAccValidator(CMolTypeValidator::kGenomic),
161  m_CDNAListAccValidator(CMolTypeValidator::kCDNA)
162 {
163  Init();
164  Create(parent, id, pos, size, style, visible);
165 }
166 
167 bool CSplignPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, bool visible )
168 {
169  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
170 
171  CAlgoToolManagerParamsPanel::Create( parent, id, pos, size, style );
172 
173  if (!visible) {
174  Hide();
175  }
176 
177  CreateControls();
178  if (GetSizer())
179  {
180  GetSizer()->SetSizeHints(this);
181  }
182  Centre();
183 
184  return true;
185 }
186 
188 {
189 ////@begin CSplignPanel destruction
190 ////@end CSplignPanel destruction
191 }
192 
194 {
195 ////@begin CSplignPanel member initialisation
197  m_cDNAList = NULL;
198 ////@end CSplignPanel member initialisation
199 }
200 
202 {
203 ////@begin CSplignPanel content construction
204  CSplignPanel* itemCAlgoToolManagerParamsPanel1 = this;
205 
206  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
207  itemCAlgoToolManagerParamsPanel1->SetSizer(itemBoxSizer2);
208 
209  m_GenomicList = new CObjectListWidgetSel( itemCAlgoToolManagerParamsPanel1, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxLC_SINGLE_SEL );
210  itemBoxSizer2->Add(m_GenomicList, 1, wxGROW|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(1, -1)).x);
211 
212  m_cDNAList = new CObjectListWidgetSel( itemCAlgoToolManagerParamsPanel1, ID_PANEL2, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
213  itemBoxSizer2->Add(m_cDNAList, 1, wxGROW|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(1, -1)).x);
214 
215  wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
216  itemBoxSizer2->Add(itemBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
217 
218  wxStaticText* itemStaticText6 = new wxStaticText( itemCAlgoToolManagerParamsPanel1, wxID_STATIC, _("cDNA strand"), wxDefaultPosition, wxDefaultSize, 0 );
219  itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(5, -1)).x);
220 
221  wxArrayString itemChoice7Strings;
222  itemChoice7Strings.Add(_("plus"));
223  itemChoice7Strings.Add(_("minus"));
224  itemChoice7Strings.Add(_("both"));
225  wxChoice* itemChoice7 = new wxChoice( itemCAlgoToolManagerParamsPanel1, ID_CHOICE3, wxDefaultPosition, wxDefaultSize, itemChoice7Strings, 0 );
226  itemBoxSizer5->Add(itemChoice7, 0, wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(5, -1)).x);
227 
228  wxArrayString itemChoice8Strings;
229  itemChoice8Strings.Add(_("EST"));
230  itemChoice8Strings.Add(_("mRNA"));
231  wxChoice* itemChoice8 = new wxChoice( itemCAlgoToolManagerParamsPanel1, ID_CHOICE4, wxDefaultPosition, wxDefaultSize, itemChoice8Strings, 0 );
232  itemBoxSizer5->Add(itemChoice8, 0, wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(5, -1)).x);
233 
234  wxCheckBox* itemCheckBox9 = new wxCheckBox( itemCAlgoToolManagerParamsPanel1, ID_CHECKBOX3, _("EndGap Detection"), wxDefaultPosition, wxDefaultSize, 0 );
235  itemCheckBox9->SetValue(false);
236  itemBoxSizer5->Add(itemCheckBox9, 0, wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(5, -1)).x);
237 
238  wxCheckBox* itemCheckBox10 = new wxCheckBox( itemCAlgoToolManagerParamsPanel1, ID_CHECKBOX4, _("PolyA Detection"), wxDefaultPosition, wxDefaultSize, 0 );
239  itemCheckBox10->SetValue(false);
240  itemBoxSizer5->Add(itemCheckBox10, 0, wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(5, -1)).x);
241 
242  wxFlexGridSizer* itemFlexGridSizer11 = new wxFlexGridSizer(0, 4, 0, 0);
243  itemBoxSizer2->Add(itemFlexGridSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
244 
245  wxStaticText* itemStaticText12 = new wxStaticText( itemCAlgoToolManagerParamsPanel1, wxID_STATIC, _("Min compartment identity"), wxDefaultPosition, wxDefaultSize, 0 );
246  itemFlexGridSizer11->Add(itemStaticText12, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(2, -1)).x);
247 
248  wxTextCtrl* itemTextCtrl13 = new wxTextCtrl( itemCAlgoToolManagerParamsPanel1, ID_TEXTCTRL7, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
249  itemFlexGridSizer11->Add(itemTextCtrl13, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(2, -1)).x);
250 
251  wxStaticText* itemStaticText14 = new wxStaticText( itemCAlgoToolManagerParamsPanel1, wxID_STATIC, _("Maximum Genomic Extent"), wxDefaultPosition, wxDefaultSize, 0 );
252  itemFlexGridSizer11->Add(itemStaticText14, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(2, -1)).x);
253 
254  wxTextCtrl* itemTextCtrl15 = new wxTextCtrl( itemCAlgoToolManagerParamsPanel1, ID_TEXTCTRL6, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
255  itemFlexGridSizer11->Add(itemTextCtrl15, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(2, -1)).x);
256 
257  wxStaticText* itemStaticText16 = new wxStaticText( itemCAlgoToolManagerParamsPanel1, wxID_STATIC, _("Min exon identity"), wxDefaultPosition, wxDefaultSize, 0 );
258  itemFlexGridSizer11->Add(itemStaticText16, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(2, -1)).x);
259 
260  wxTextCtrl* itemTextCtrl17 = new wxTextCtrl( itemCAlgoToolManagerParamsPanel1, ID_TEXTCTRL8, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
261  itemFlexGridSizer11->Add(itemTextCtrl17, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(2, -1)).x);
262 
263  wxStaticText* itemStaticText18 = new wxStaticText( itemCAlgoToolManagerParamsPanel1, wxID_STATIC, _("Compartment penalty"), wxDefaultPosition, wxDefaultSize, 0 );
264  itemFlexGridSizer11->Add(itemStaticText18, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(2, -1)).x);
265 
266  wxTextCtrl* itemTextCtrl19 = new wxTextCtrl( itemCAlgoToolManagerParamsPanel1, ID_TEXTCTRL9, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
267  itemFlexGridSizer11->Add(itemTextCtrl19, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(2, -1)).x);
268 
269  wxStaticText* itemStaticText20 = new wxStaticText( itemCAlgoToolManagerParamsPanel1, wxID_STATIC, _("Maximum intron length"), wxDefaultPosition, wxDefaultSize, 0 );
270  itemFlexGridSizer11->Add(itemStaticText20, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(5, -1)).x);
271 
272  wxTextCtrl* itemTextCtrl21 = new wxTextCtrl( itemCAlgoToolManagerParamsPanel1, ID_TEXTCTRL13, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
273  itemFlexGridSizer11->Add(itemTextCtrl21, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, wxDLG_UNIT(itemCAlgoToolManagerParamsPanel1, wxSize(5, -1)).x);
274 
275  // Set validators
276  itemChoice7->SetValidator( wxGenericValidator(& GetData().m_cDNA_strand) );
277  itemChoice8->SetValidator( wxGenericValidator(& GetData().m_DiscType) );
278  itemCheckBox9->SetValidator( wxGenericValidator(& GetData().m_EndGapDetect) );
279  itemCheckBox10->SetValidator( wxGenericValidator(& GetData().m_PolyADetect) );
280  itemTextCtrl13->SetValidator( CFloatTextValidator(& GetData().m_MinCompIdentity,0.,1.) );
281  itemTextCtrl15->SetValidator( CNumberValidator(& GetData().m_MaxGenomicExtent,0,2000000) );
282  itemTextCtrl17->SetValidator( CFloatTextValidator(& GetData().m_MinExonIdentity,0.,1.) );
283  itemTextCtrl19->SetValidator( CFloatTextValidator(& GetData().m_CompPenalty,0.,1.) );
284  itemTextCtrl21->SetValidator( CNumberValidator(& GetData().m_MaxIntron,0,2000000) );
285 ////@end CSplignPanel content construction
286 
287  m_GenomicList->SetTitle(wxT("Select Genomic Sequence"));
289 
290  m_cDNAList->SetDoSelectAll(true);
291  m_cDNAList->SetTitle(wxT("Select cDNA/Transcript Sequences"));
293 }
294 
297 {
298  m_GenomicList->SetObjects(genomic);
299  m_cDNAList->SetObjects(na);
300 }
301 
303 {
304  return true;
305 }
306 wxBitmap CSplignPanel::GetBitmapResource( const wxString& name )
307 {
308  // Bitmap retrieval
309 ////@begin CSplignPanel bitmap retrieval
310  wxUnusedVar(name);
311  return wxNullBitmap;
312 ////@end CSplignPanel bitmap retrieval
313 }
314 wxIcon CSplignPanel::GetIconResource( const wxString& name )
315 {
316  // Icon retrieval
317 ////@begin CSplignPanel icon retrieval
318  wxUnusedVar(name);
319  return wxNullIcon;
320 ////@end CSplignPanel icon retrieval
321 }
322 
324 {
325  if (!CAlgoToolManagerParamsPanel::TransferDataFromWindow())
326  return false;
327 
329  m_GenomicSeq = selection[0];
331 
332  return true;
333 }
334 
335 static const char* kGenomicList = ".GenomicList";
336 static const char* kCDNAList = ".CDNAList";
337 
338 void CSplignPanel::SetRegistryPath(const string& path)
339 {
340  m_RegPath = path;
343 }
344 
346 {
349 }
350 
352 {
355 }
356 
358 {
359  GetData().Init();
360  TransferDataToWindow();
361 }
362 
CAlgoToolManagerParamsPanel.
CBioseq_Handle –.
CConstRef –.
Definition: ncbiobj.hpp:1266
vector< TRelation > TRelationVector
static void FindRelations(objects::CScope &scope, const CObject &obj, const string &to_type_in, TRelationVector &relations)
virtual void SetRegistryPath(const string &path)
IRegSettings.
TConstScopedObjects GetSelection() const
void SetAccessionValidator(IObjectListAccValidator *validator)
void SetObjects(const TObjectListMap &value)
void SetTitle(const wxString &value)
virtual void SaveSettings() const
CObject –.
Definition: ncbiobj.hpp:180
vector< SObject > TObjects
Definition: relation.hpp:130
@ fConvert_NoExpensive
do not perform any expensive tests (such as fetching from the network)
Definition: relation.hpp:60
CScope –.
Definition: scope.hpp:92
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
#define _(proto)
Definition: ct_nlmzip_i.h:78
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
CObjectListWidgetSel * m_GenomicList
bool Create(wxWindow *parent, wxWindowID id=ID_CSPLIGNPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCLIP_CHILDREN|wxTAB_TRAVERSAL, bool visibale=true)
virtual void LoadSettings()
wxBitmap GetBitmapResource(const wxString &name)
void CreateControls()
void RestoreDefaults()
override in derived classes
CSplignParams & GetData()
virtual void SaveSettings() const
override in derived classes
wxIcon GetIconResource(const wxString &name)
static bool ShowToolTips()
TConstScopedObjects m_cDNASeqs
SConstScopedObject m_GenomicSeq
virtual void SetRegistryPath(const string &path)
CAlgoToolManagerParamsPanel.
CMolTypeValidator m_GenomicListAccValidator
CMolTypeValidator m_CDNAListAccValidator
CObjectListWidgetSel * m_cDNAList
void SetObjects(map< string, TConstScopedObjects > *genomic, map< string, TConstScopedObjects > *na)
virtual bool TransferDataFromWindow()
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
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
bool IsAa(void) const
bool IsNa(void) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
TBiomol GetBiomol(void) const
Get the Biomol member data.
Definition: MolInfo_.hpp:447
const TMolinfo & GetMolinfo(void) const
Get the variant data.
Definition: Seqdesc_.cpp:588
@ e_Molinfo
info on the molecule and techniques
Definition: Seqdesc_.hpp:134
END_EVENT_TABLE()
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
USING_SCOPE(ncbi::objects)
static const char * kGenomicList
static const char * kCDNAList
#define const
Definition: zconf.h:232
Modified on Wed Sep 04 15:04:13 2024 by modify_doxy.py rev. 669887