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

Go to the SVN repository for this file.

1 /* $Id: ngalign_tool.cpp 47080 2022-07-22 18:11:54Z 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: Roman Katargin
27  *
28  */
29 
30 #include <ncbi_pch.hpp>
31 
33 #include <serial/serial.hpp>
34 #include <serial/typeinfo.hpp>
35 
38 #include "ngalign_panel.hpp"
39 #include "ngalign_blast_panel.hpp"
40 
43 
45 
46 #include <gui/objutils/label.hpp>
47 
50 
53 
54 ///////////////////////////////////////////////////////////////////////////////
55 /// CNGAlignTool
57 : CAlgoToolManagerBase("Genomic Aligner (NG Aligner)",
58  "",
59  "NCBI Genomic Aligner",
60  "The Genomic Aligner, also known as the NG aligner, attempts to find polished, consistent alignments of short-to-medium length genomic sequences (up to 1 megabase) aligned to long genomic sequences such as chromosomes.",
61  "https://www.ncbi.nlm.nih.gov/tools/gbench/",
62  "Alignment Creation"),
63  m_Panel(), m_BLASTPanel(), m_CurrentPage(0)
64 {
65 }
66 
68 {
69  return "ngalign_tool";
70 }
71 
72 
74 {
75  return "NGAlign Tool";
76 }
77 
79 {
81 
82  m_Panel = NULL;
84 }
85 
87 {
88  m_Panel = NULL;
91 }
92 
94 {
96 }
97 
98 
100 {
101  bool next = (action == eNext);
102 
103  if (m_State == eInvalid) {
104  if (next) {
105  /// initial state - display first page
106  m_State = eParams;
107  return x_GoFirstPage();
108  }
109  }
110  else if (m_State == eParams) {
111  if (x_IsFirstPage() && m_Panel)
113 
114  if (next) {
115  wxPanel* panel = x_GetCurrentPage();
116  _ASSERT(panel);
117  if (panel->Validate() && panel->TransferDataFromWindow()) {
118  if (x_IsLastPage()) {
120  // The new code begins here.
121  if (m_ProjectSelPanel) {
124  } else {
126  }
127  // The new code ends here.
128  return true;
129  }
130  return x_GoNextPage();
131  }
132  return false;
133  }
134  else {
135  if (x_IsFirstPage()) {
136  m_State = eInvalid;
137  return true;
138  }
139  return x_GoPrevPage();
140  }
141  }
142  else if (m_State == eSelectProject) {
143  if (next) {
146  return true;
147  }
148  return false;
149  }
150  else {
151  m_State = eParams;
152  return x_GoLastPage();
153  }
154  }
155 
156  _ASSERT(false);
157  return false;
158 }
159 
161 {
162  switch(m_State) {
163  case eParams:
164  return x_GetCurrentPage();
165  case eSelectProject:
166  return m_ProjectSelPanel;
167  default:
168  return NULL;
169  }
170 }
171 
173 {
174  m_CurrentPage = 0;
175  return x_LoadPage();
176 }
177 
179 {
180  _ASSERT(m_CurrentPage == 0);
181  ++m_CurrentPage;
182  return x_LoadPage();
183 }
184 
186 {
187  _ASSERT(m_CurrentPage == 1);
188  --m_CurrentPage;
189  return x_LoadPage();
190 }
191 
193 {
194  m_CurrentPage = 1;
195  return x_LoadPage();
196 }
197 
199 {
200  if (m_CurrentPage == 0)
202  else
204 
205  wxPanel* panel = x_GetCurrentPage();
206  _ASSERT(panel);
207  if (panel) {
208  panel->TransferDataToWindow();
209  return true;
210  }
211  NcbiErrorBox("Failed to create parameters page");
212  return false;
213 }
214 
215 
217 {
218  if (m_CurrentPage == 0)
219  return m_Panel;
220  else if (m_CurrentPage == 1)
221  return m_BLASTPanel;
222 
223  return NULL;
224 }
225 
227 {
228  return (m_CurrentPage == 0);
229 }
230 
232 {
233  return (m_CurrentPage == 1);
234 }
235 
237 {
238  if (m_Panel == NULL) {
239 
241 
244  m_Panel->SetRegistryPath(m_RegPath + ".ParamsPanel");
246  }
247  return true;
248 }
249 
251 {
252  if (m_BLASTPanel == NULL) {
254  m_BLASTPanel->SetRegistryPath(m_RegPath + ".BLASTPanel");
256  }
257 }
258 
260 {
261  return true;
262 }
263 
265 {
267  x_ConvertInputObjects(CSeq_loc::GetTypeInfo(), objects);
268 
269  m_SeqIds.clear();
271  CIRef<IGuiSeqInfo> gui_seq_info(CreateObjectInterface<IGuiSeqInfo>(*it, NULL));
272  if( !gui_seq_info.IsNull() && gui_seq_info->IsDNA() ){
273  m_SeqIds.push_back(*it);
274  }
275  }
276 }
277 
279 {
280  return m_Panel;
281 }
282 
284 {
285  return &m_Params;
286 }
287 
289 {
291  if (m_Panel) {
294  }
295 
296  CNGAlignJob* job = new CNGAlignJob(m_Params);
297  return job;
298 }
299 
CAlgoToolManagerBase This is base class for simple algorithmic tool managers.
virtual void x_CreateProjectPanelIfNeeded()
returns / creates Project panel
EState m_State
tool manager state (int the Run Tool wizard)
CProjectSelectorPanel * m_ProjectSelPanel
virtual void InitUI()
override this function in a derived class and initialize extra members
string m_RegPath
registry path to the settings
wxWindow * m_ParentWindow
a window that will serve as a parent for our panels
virtual void CleanUI()
override this function in a derived class and clean extra members
void x_ConvertInputObjects(const CTypeInfo *typeInfo, map< string, TConstScopedObjects > &results)
CAlgoToolManagerParamsPanel.
virtual void SetRegistryPath(const string &reg_path)
CAlgoToolManagerParamsPanel.
CDataLoadingAppJob - a base class for Jobs loading data into projects.
CNGAlignParams & GetData()
CNGAlignJob.
Definition: ngalign_job.hpp:51
IRegSettings An interface for objects that save / restore settings using CGuiRegistry.
virtual bool UsesSingleOMScope()
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
Definition: dlist.tmpl.h:56
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
virtual IRegSettings * x_GetParamsAsRegSetting()
return a pointer to Parameters object as IRegSettings interface
virtual CAlgoToolManagerParamsPanel * x_GetParamsPanel()
returns a pointer to the parameters panel, override in derived classes
void SetObjects(TConstScopedObjects *objects)
bool x_IsLastPage() const
virtual void SaveSettings() const
override in derived classes
CNGAlignPanel * m_Panel
const SConstScopedObject & GetSubject() const
bool x_GoNextPage()
virtual wxPanel * GetCurrentPanel()
Return the panel corresponding to the current state of Tool Manager.
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual bool DoTransition(EAction action)
Performs transition if possible and returns true, otherwise the function shall warn the user about th...
virtual void x_SelectCompatibleInputObjects()
SConstScopedObject & SetSubject()
CNGAlignTool()
CNGAlignTool.
virtual void CleanUI()
override this function in a derived class and clean extra members
bool x_GoFirstPage()
TConstScopedObjects & SetQueries()
virtual CDataLoadingAppJob * x_CreateLoadingJob()
factory method for creating the job that executes the tool algorithm override in derived classes
bool x_IsFirstPage() const
virtual bool x_ValidateParams()
validates user input in Parameters panel, report errors if any
virtual bool x_CreateParamsPanelIfNeeded()
returns / creates Parameters panel, override in derived classes see cpp file for example
CNGAlignParams m_Params
bool x_GoPrevPage()
CNGAlignBLASTPanel * m_BLASTPanel
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
virtual bool IsFinalState()
True if Tool Manager has reached its final state, i.e.
virtual void InitUI()
override this function in a derived class and initialize extra members
TConstScopedObjects m_SeqIds
virtual void LoadSettings()
void x_CreateBALSTPanelIfNeeded()
bool x_GoLastPage()
wxPanel * x_GetCurrentPage()
const TConstScopedObjects & GetQueries() const
void NcbiErrorBox(const string &message, const string &title="Error")
specialized Message Box function for reporting critical errors
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:735
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
USING_SCOPE(ncbi::objects)
The Object manager core.
#define _ASSERT
Modified on Tue Dec 05 02:06:33 2023 by modify_doxy.py rev. 669887