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

Go to the SVN repository for this file.

1 /* $Id: kalign_tool.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: Roman Katargin, Vladislav Evgeniev
27 *
28 */
29 
30 #include <ncbi_pch.hpp>
31 
34 
37 #include "kalign_tool_panel.hpp"
38 
39 #include <wx/msgdlg.h>
40 
43 
44 ///////////////////////////////////////////////////////////////////////////////
45 /// CKalignTool
47 : CAlgoToolManagerBase("Kalign",
48  "",
49  "Create an alignment using Kalign",
50  "Fast multiple sequence alignment tool, concentrating on local regions. Suitable for large alignments.",
51  "https://www.ncbi.nlm.nih.gov/tools/gbench/manual5/#MSATools",
52  "Multiple Sequence Aligners"),
53  m_Panel()
54 {
55 }
56 
58 {
59  return "kalign_tool";
60 }
61 
62 
64 {
65  return "Kalign Tool";
66 }
67 
69 {
71 
72  m_Panel = NULL;
73 }
74 
76 {
77  m_Panel = NULL;
79 }
80 
82 {
83  if (m_Panel == NULL) {
85 
87  wxDefaultPosition, wxSize(0, 0), SYMBOL_CKALIGNTOOLPANEL_STYLE, false);
90 
91  m_Panel->SetRegistryPath(m_RegPath + ".ParamsPanel");
93  }
94  return true;
95 }
96 
98 {
99  return true;
100 }
101 
103 {
104  x_ConvertInputObjects(CSeq_loc::GetTypeInfo(), m_Objects);
105 }
106 
108 {
109  CKalignToolPanel* panel = new CKalignToolPanel();
110  panel->Create(m_ParentWindow);
111  return panel;
112 }
113 
115 {
116  return m_Panel;
117 }
118 
120 {
121  return &m_Params;
122 }
123 
125 {
126  if (m_Panel) m_Params = m_Panel->GetData();
128  return job;
129 }
130 
132 {
134 
135  if (m_Objects.empty()) {
136  wxMessageBox(wxT("No objects that can be proccessed were selected."),
137  wxT("Kalign Tool Error"), wxOK | wxICON_ERROR);
138  return 0;
139  }
140 
142 
143  {{
144  TConstScopedObjects genomic, proteins;
145 
147  NON_CONST_ITERATE(TConstScopedObjects, it2, it->second) {
148  CIRef<IGuiSeqInfo> gui_seq_info(CreateObjectInterface<IGuiSeqInfo>(*it2, NULL));
149  if( gui_seq_info ) {
150  if (gui_seq_info->IsProtein()) {
151  proteins.push_back(*it2);
152  }
153  else {
154  genomic.push_back(*it2);
155  }
156  }
157  }
158  }
159  objects = (proteins.size() > genomic.size()) ? proteins : genomic;
160  }}
161 
162  if (objects.size() < 2) {
163  wxMessageBox(wxT("You have to select at least 2 either genomic or protein locations to run Kalign tool."),
164  wxT("Kalign Tool Error"), wxOK | wxICON_ERROR);
165  return 0;
166  }
167 
169 
171 
172  CProjectService* prj_srv =
174 
175  vector<CSelectProjectOptions::TProjectId> projects;
176  prj_srv->GetObjProjects(objects, projects);
177 
178  CSelectProjectOptions options;
179  if (projects.empty())
180  options.Set_CreateNewProject();
181  else
182  options.Set_AddToExistingProject(projects.front());
183 
184  CRef<CDataLoadingAppTask> task(new CDataLoadingAppTask(prj_srv, options, *job));
185  return task.Release();
186 }
187 
CAlgoToolManagerBase This is base class for simple algorithmic tool managers.
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.
CDataLoadingAppJob - a base class for Jobs loading data into projects.
CDataLoadingAppTask - a task that executes CDataLoadingAppJob.
CKalignToolJob.
void SetObjects(map< string, TConstScopedObjects > *objects)
CKalignToolParams & GetData()
virtual void SetRegistryPath(const string &path)
CAlgoToolManagerParamsPanel.
void SetData(const CKalignToolParams &data)
virtual void LoadSettings()
bool Create(wxWindow *parent, wxWindowID id=ID_CKALIGNPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL, bool visible=true)
CProjectService - a service providing API for operations with Workspaces and Projects.
void GetObjProjects(TConstScopedObjects &objects, vector< TProjectId > &ids)
CRef –.
Definition: ncbiobj.hpp:618
CProjectSelectOptions - describes how new Project Items shall be added to a workspace.
void Set_CreateNewProject(const string &folder=kEmptyStr)
void Set_AddToExistingProject(TProjectId &project_id, const string &folder=kEmptyStr)
IAppTask.
Definition: app_task.hpp:83
IRegSettings An interface for objects that save / restore settings using CGuiRegistry.
bool empty() const
Definition: map.hpp:149
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
Definition: service.hpp:91
TObjects m_Objects
Definition: kalign_tool.hpp:87
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
Definition: kalign_tool.cpp:57
virtual IAppTask * QuickLaunch()
CKalignToolParams m_Params
Definition: kalign_tool.hpp:88
virtual CAlgoToolManagerParamsPanel * x_GetParamsPanel()
returns a pointer to the parameters panel, override in derived classes
CKalignTool()
CKalignTool.
Definition: kalign_tool.cpp:46
virtual bool x_ValidateParams()
validates user input in Parameters panel, report errors if any
Definition: kalign_tool.cpp:97
virtual bool x_CreateParamsPanelIfNeeded()
returns / creates Parameters panel, override in derived classes see cpp file for example
Definition: kalign_tool.cpp:81
virtual void CleanUI()
override this function in a derived class and clean extra members
Definition: kalign_tool.cpp:75
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
Definition: kalign_tool.cpp:63
virtual IRegSettings * x_GetParamsAsRegSetting()
return a pointer to Parameters object as IRegSettings interface
CKalignToolPanel * m_Panel
Definition: kalign_tool.hpp:89
virtual CDataLoadingAppJob * x_CreateLoadingJob()
factory method for creating the job that executes the tool algorithm override in derived classes
virtual wxPanel * GetMaxPanel()
Return the panel that occupies max size on display, to calculate dialog window size.
TConstScopedObjects & SetObjects()
virtual void x_SelectCompatibleInputObjects()
virtual void InitUI()
override this function in a derived class and initialize extra members
Definition: kalign_tool.cpp:68
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
TObjectType * Release(void)
Release a reference to the object and return a pointer to the object.
Definition: ncbiobj.hpp:846
#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)
#define SYMBOL_CKALIGNTOOLPANEL_STYLE
#define wxT(x)
Definition: muParser.cpp:41
static static static wxID_ANY
Modified on Wed Apr 17 13:10:13 2024 by modify_doxy.py rev. 669887