NCBI C++ ToolKit
feature_search_tool.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_SERVICES___FEATURE_SEARCH_TOOL_HPP
2 #define GUI_SERVICES___FEATURE_SEARCH_TOOL_HPP
3 
4 /* $Id: feature_search_tool.hpp 47029 2022-05-16 18:09:35Z asztalos $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
37 
38 #include <util/xregexp/regexp.hpp>
39 
42 
43 #include <wx/hyperlink.h>
44 
45 class wxTextCtrl;
46 class wxChoice;
47 class wxSearchCtrl;
48 class wxHyperlink;
49 
50 
52 
53 
54 /** @addtogroup GUI_PKG_SEQUENCE
55  *
56  * @{
57  */
58 
59 ///////////////////////////////////////////////////////////////////////////////
60 /// CFeatureSearchTool
62 {
63 public:
65 
66  /// @name IUITool implementation
67  /// @{
68  virtual IUITool* Clone() const;
69  virtual string GetName() const;
70  virtual string GetDescription() const;
71  /// @}
72 
73  /// @name IDMSearchTool implementation
74  /// @{
77  /// @}
78 
79  /// @name IExtension implementation
80  /// @{
81  virtual string GetExtensionIdentifier() const;
82  virtual string GetExtensionLabel() const;
83  /// @}
84 
85 protected:
86  /// implementing CSearchToolBase pure virtual function
88 };
89 
90 
91 ///////////////////////////////////////////////////////////////////////////////
92 /// CFeatureSearchTool
94  public CSearchQueryBase
95 {
96 public:
98 
99  typedef objects::CFeatListItem TFeatTypeItem;
101 
103  const string& pattern,
104  bool case_sensitive,
105  TPatternType pt_type,
106  const TFeatTypeItemSet& feat_types);
107 
108  string GetPattern() { return m_Pattern; }
112 
113  virtual string ToString() const;
114 protected:
115  string m_Pattern;
118  TFeatTypeItemSet m_FeatTypesSet; /// Feature types to search
120 };
121 
122 
123 ///////////////////////////////////////////////////////////////////////////////
124 /// CFeatureSearchForm
125 class CComboBox;
126 
128 {
129 public:
131 
134 
135  /// @name IDMSearchForm implementation
136  /// @{
137  virtual void Create();
138  virtual void Init();
139  virtual void Update();
140  /// @}
141 
143  virtual wxSizer * GetWidget(wxWindow * parent);
144 protected:
145 
146  /// @name CSearchFormBase overridables
147  /// @{
148  //virtual string x_GetRunningText();
149  virtual void x_LoadSettings(const CRegistryReadView& view);
150  virtual void x_SaveSettings(CRegistryWriteView view) const;
151 
152  virtual IDMSearchTool* x_GetTool();
153  virtual void x_CreateWidgets();
154 
155  virtual void UpdateContexts()
156  {
158  }
159 
160 protected:
163 
165 
166  wxChoice * m_DbCombo;
167  wxChoice * m_TypeCombo;
168  wxHyperlinkCtrl * m_HyperLink;
169 
170  vector<ISeqLocSearchContext*> m_SeqLocContexts;
172 
173 
176 
177  // serializable
179  list<string> m_FeatureTypes;
180 };
181 
182 
183 ///////////////////////////////////////////////////////////////////////////////
184 /// CFeatureSearchJob
185 class CFeatureSearchJob : public CSearchJobBase
186 {
187 public:
189 
190  string SeqLocToString(const objects::CSeq_loc& loc);
191 
192 protected:
197 
198  /// @name CSearchJobBase overridables
199  /// @{
200  virtual bool x_ValidateParams();
202  virtual void x_SetupColumns(CObjectList& obj_list);
203  /// @}
204 
205  void x_SearchFeatures(TScopedLocs& scoped_locs,
206  const TFeatTypeItemSet& feat_types);
207 
208  bool x_Match(const string& text) const;
209  bool x_Match(const objects::CGene_ref& gene_ref) const;
210  void x_AddFeatToResults(const objects::CSeq_feat& feat, objects::CScope& scope,
211  const string& loc_label,
212  const int cnt,
213  const int cnt_found,
214  const string& ctx_name);
215  void x_AddToResults(CObject& obj, objects::CScope& scope,
216  const string& loc_name,
217  const string& strand,
218  const string& acc_name,
219  const string& ctx_name);
220  bool x_IsSNP() const;
221  objects::CSeq_feat_Handle x_SearchForSNP(const objects::CSeq_loc& seq_loc, objects::CScope& scope, const set<string>& annot_names);
222 
223 protected:
225 
228  string m_SearchStr; /// search pattern for "Exact Match" and "Wildcard" modes
229  CRegexp* m_Pattern; /// regular expression to apply
230  bool m_CaseSensitive;
231 };
232 
233 
234 /* @} */
235 
237 
238 #endif // GUI_SERVICES___FEATURE_SEARCH_TOOL_HPP
CFeatureSearchJob.
CSeqLocToolQuery::TFeatTypeItemSet TFeatTypeItemSet
CFeatureSearchJob(CSeqLocToolQuery &query)
bool x_Match(const string &text)
CSeqLocToolQuery::TScopedLocs TScopedLocs
CFeatureSearchTool.
CFeatureSearchTool.
CObjectList Data structure representing a list of CObjects with associated Scopes and other optional ...
Definition: object_list.hpp:63
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
CRegexp –.
Definition: regexp.hpp:70
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
CSearchFormBase.
virtual void UpdateContexts()
updates m_ContextCombo
CSearchJobBase.
CSearchQueryBase.
vector< SScopedLoc > TScopedLocs
CSearchToolBase.
IDMSearchQuery - abstract data mining query.
IDMSearchTool interface representing a single search tool in Data Mining Service.
IDataMiningContext IDataMiningContext represents an abstract context for a Search.
IUITool represents an abstract algorithm that is bound to a UI component.
Definition: ui_tool.hpp:59
bool m_CaseSensitive
regular expression to apply
objects::CSeq_feat_Handle x_SearchForSNP(const objects::CSeq_loc &seq_loc, objects::CScope &scope, const set< string > &annot_names)
virtual void x_LoadSettings(const CRegistryReadView &view)
CFeatureSearchForm(CFeatureSearchTool &tool)
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
CRef< CFeatureSearchTool > m_Tool
virtual string ToString() const
Prepare a string representation of a query (for logging and debugging)
virtual CRef< CSearchJobBase > x_CreateJob(IDMSearchQuery &query)
implementing CSearchToolBase pure virtual function
virtual EJobState x_DoSearch()
performs searching, assuming that params are correct; Implement in derived classes
CSearchToolBase::EPatternType TPatternType
virtual void x_SaveSettings(CRegistryWriteView view) const
wxHyperlinkCtrl * m_HyperLink
CRegexp * m_Pattern
search patteern for "Exact Match" and "Wildcard" modes
virtual void UpdateContexts()
updates m_ContextCombo
CFeatureSearchQuery::TScopedLocs TScopedLocs
TPatternType m_PatternType
CFeatureSearchQuery(TScopedLocs &locs, const string &pattern, bool case_sensitive, TPatternType pt_type, const TFeatTypeItemSet &feat_types)
CFeatureSearchQuery.
CSearchToolBase::EPatternType TPatternType
CFeatureSearchQuery::TFeatTypeItem TFeatTypeItem
CFeatureSearchQuery::TFeatTypeItem TFeatTypeItem
CFeatureSearchTool()
CFeatureSearchTool.
virtual IDMSearchTool * x_GetTool()
CRef< CFeatureSearchQuery > m_Query
virtual string GetName() const
returns unique name of the method that is used in UI to identify it
virtual CIRef< IDMSearchQuery > ConstructQuery()
CFeatureSearchQuery::TFeatTypeItemSet TFeatTypeItemSet
virtual CIRef< IDMSearchForm > CreateSearchForm()
factory method for creating a form representing the tool
const TFeatTypeItemSet & GetFeatTypes()
virtual wxSizer * GetWidget(wxWindow *parent)
return a widget associated with the form; the form controls the lifetime of the widget (do not delete...
CFeatureSearchQuery::TFeatTypeItemSet TFeatTypeItemSet
string SeqLocToString(const objects::CSeq_loc &loc)
virtual void x_CreateWidgets()
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual bool IsCompatible(IDataMiningContext *context)
retuns true if the tool is compatible with the provided Search Context
virtual void x_SetupColumns(CObjectList &obj_list)
add custom columns if needed
virtual string GetDescription() const
returns a detailed description of the method that is used in UI
CFeatureSearchQuery::SScopedLoc TScopedLoc
void x_SearchFeatures(TScopedLocs &scoped_locs, const TFeatTypeItemSet &feat_types)
CFeatureSearchQuery::TScopedLocs TScopedLocs
vector< ISeqLocSearchContext * > m_SeqLocContexts
list< string > m_FeatureTypes
objects::CFeatListItem TFeatTypeItem
void x_AddFeatToResults(const objects::CSeq_feat &feat, objects::CScope &scope, const string &loc_label, const int cnt, const int cnt_found, const string &ctx_name)
CFeatureSearchTool::EPatternType TPatternType
void x_AddToResults(CObject &obj, objects::CScope &scope, const string &loc_name, const string &strand, const string &acc_name, const string &ctx_name)
TFeatTypeItemSet m_FeatTypesSet
set< string > m_AnnotNames
Feature types to search.
virtual IUITool * Clone() const
set< TFeatTypeItem > TFeatTypeItemSet
virtual bool x_ValidateParams()
returns true if Job params are correct, implement in derived classes
EJobState
Job states (describe FSM)
Definition: app_job.hpp:86
#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 void text(MDB_val *v)
Definition: mdb_dump.c:62
static unsigned cnt[256]
static string query
C++ wrappers for the Perl-compatible regular expression (PCRE) library.
static CS_CONTEXT * context
Definition: will_convert.c:21
Modified on Mon May 20 05:04:33 2024 by modify_doxy.py rev. 669887