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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_ALN_SCORE___TEMPLATE_METHODS__HPP
2 #define GUI_WIDGETS_ALN_SCORE___TEMPLATE_METHODS__HPP
3 
4 /* $Id: template_methods.hpp 36328 2016-09-13 22:19:33Z evgeniev $
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  */
32 
33 #include <util/math/matrix.hpp>
35 
38 
39 
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// CColorTableMethod
45  : public CTemplateScoringMethod,
46  public IRowScoringMethod,
47  public IUIToolWithGUI
48 {
49 public:
51  virtual ~CColorTableMethod();
52 
53  virtual const CRgbaColor& GetColorForNoScore(EColorType type) const;
55 
56  /// @name ITemplateScoringMethod implementation
57  /// @{
58  virtual IScoringMethod* Clone() const;
59 
60  virtual bool Load(CNcbiRegistry& reg);
61 
62  virtual int GetSupportedColorTypes() const;
63 
64  virtual const CRgbaColor& GetColorForScore(TScore score, EColorType type) const;
65  /// @}
66 
67  /// @name IRowScoringMethod implementation
68  /// @{
70  const IScoringAlignment& aln_vec,
71  TScoreColl& scores);
72  /// @}
73 
74  // @name IUIToolWithGUI implementation
75  /// @{
76  virtual const CMenuItem* GetMenu();
77  virtual bool HasPropertiesPanel() const;
78  virtual wxWindow* CreatePropertiesPanel(wxWindow* parent);
79  /// @}
80 
81  /// @name Edit interface
82  /// @{
83  void Clear();
84  void SetColor(char cbase, const CRgbaColor& color, EColorType type = fForeground);
85  CRgbaColor GetColor(char cbase, EColorType type) const;
86 
87  /// Which bases have colors specified?
88  const string& GetSetBases() const;
89  void AddSetBase(char cbase);
90 
91  /// Opposite of Load().
92  bool Save(CNcbiRegistry& reg);
93 
94  /// @}
95 
96 protected:
98 
99 protected:
100  vector<CRgbaColor> m_Colors; ///> background colors
101  vector<CRgbaColor> m_ForeColors; ///> foreground or text colors
102  CRgbaColor m_DefaultBackColor; ///> Background color when nothing specified for a base.
103  CRgbaColor m_DefaultForeColor; ///> Foreground color when nothing specified for a base.
104  string m_SetBases; ///> the bases (characters) we have colors for. unordered.
105 };
106 
107 ////////////////////////////////////////////////////////////////////////////////
108 /// CColumnScoringMethod
110  : public CTemplateScoringMethod,
111  public IColumnScoringMethod,
112 // public IRowScoringMethod,
113  public IUIToolWithGUI,
114  public IWindowScoringMethod
115 {
116 public:
117  friend class CColumnScoringPanel;
118 
120  virtual ~CColumnScoringMethod();
121 
122  virtual void CreateColorTable(int size);
123 
124  /// @name IScoringMethod implementation
125  /// @{
126  virtual IScoringMethod* Clone() const;
127 
128  virtual bool Load(CNcbiRegistry& reg);
129 
130  virtual int GetSupportedColorTypes() const;
131 
132 // virtual void CalculateScores(TNumrow row, const objects::CAlnVec& aln_vec,
133 // TScoreColl& scores);
134 
135  virtual const CRgbaColor& GetColorForScore(TScore score, EColorType type) const;
136  /// @}
137 
138  /// @name IColumnScoringMethod implementation
139  /// @{
140  virtual void CalculateScores(char cons, const string& column,
141  TScore& col_score, TScoreVector& scores);
142 
143  bool CanCalculateScores(const IScoringAlignment& aln);
146  /// @}
147 
148  /// @name IWindowScoringMethod implementation
149  /// @{
150  size_t GetWindowSize() const;
151  /// @}
152 
153  // @name IUIToolWithGUI implementation
154  /// @{
155  virtual const CMenuItem* GetMenu();
156  virtual bool HasPropertiesPanel() const;
157  virtual wxWindow* CreatePropertiesPanel(wxWindow* parent);
158  /// @}
159 
160 protected:
164  void x_CalculateConsensusScores(char cons, const string& column,
165  TScore& col_score, TScoreVector& scores);
166  void x_CalculateNonConsensusScores(const string& column, TScore& col_score,
167  TScoreVector& scores);
168 
169 protected:
170  vector<TScore> m_vScore; /// weight matrix
171  TScore m_MinScore; /// possible range of scores.
174 
178 
180 
181  bool m_UseConsensus; /// relative, not absolute scores.
182  size_t m_WindowSize; /// if > 1, use running average.
183 };
184 
185 ////////////////////////////////////////////////////////////////////////////////
186 /// CMatrixScoringMethod
187 
189  : public CTemplateScoringMethod,
190  public IColumnScoringMethod,
191  public IUIToolWithGUI,
192  public IWindowScoringMethod
193 {
194  friend class CMatrixScoringPanel;
195 
196 public:
198  virtual ~CMatrixScoringMethod();
199 
200  virtual void CreateColorTable(int size);
201 
202  /// @name IScoringMethod implementation
203  /// @{
204  virtual IScoringMethod* Clone() const;
205 
206  virtual bool Load(CNcbiRegistry& reg);
207 
208  virtual int GetSupportedColorTypes() const;
209 
210  virtual const CRgbaColor& GetColorForScore(TScore score, EColorType type) const;
211  /// @}
212 
213  /// @name IColumnScoringMethod implementation
214  /// @{
215  virtual void CalculateScores(char cons, const string& column,
216  TScore& col_score, TScoreVector& scores);
217  bool CanCalculateScores(const IScoringAlignment& aln);
220 
221  /// @}
222 
223  /// @name IWindowScoringMethod implementation
224  /// @{
225  size_t GetWindowSize() const;
226  /// @}
227 
228  // @name IUIToolWithGUI implementation
229  /// @{
230  virtual const CMenuItem* GetMenu();
231  virtual bool HasPropertiesPanel() const;
232  virtual wxWindow* CreatePropertiesPanel(wxWindow* parent);
233  /// @}
234 protected:
236  void x_CalculateConsensusRange();
237  void x_CalculateNonConsensusRange();
238  static int x_BaseToIndex(char c);
239 
240 protected:
242  {
243  eNone = 0,
244  eConsensus = 1,
245  eNonConsesus = 2,
246  eBoth = 3
247  };
248  unsigned char m_CalculateRange;
249 
251 
258 
263 
265 
267  size_t m_WindowSize;
268  };
269 
271 
272 #endif // GUI_WIDGETS_ALN_SCORE___TEMPLATE_METHODS__HPP
@ eBoth
Both preliminary and traceback stages.
Definition: blast_def.h:332
CColorTableMethod.
void x_CreateColorTable(CNcbiRegistry &reg)
string m_SetBases
> Foreground color when nothing specified for a base.
CRgbaColor m_DefaultForeColor
> Background color when nothing specified for a base.
CRgbaColor m_DefaultBackColor
> foreground or text colors
vector< CRgbaColor > m_Colors
vector< CRgbaColor > m_ForeColors
> background colors
CColumnScoringMethod.
vector< TScore > m_vScore
void x_CreateScoreTable(CNcbiRegistry &reg)
size_t m_WindowSize
relative, not absolute scores.
CRgbaGradColorTable m_ColorTable
TScore m_MinScore
weight matrix
TScore m_MaxScore
possible range of scores.
CRgbaColor x_GetThreeColorScore(TScore score) const
CRgbaColor x_GetTwoColorScore(TScore score) const
CColumnScoringPanel.
CMatrixScoringMethod.
void x_CreateScoreTable(CNcbiRegistry &reg)
unsigned char m_CalculateRange
CNcbiMatrix< TScore > m_vScore
CRgbaGradColorTable m_ColorTable
CMatrixScoringPanel.
CMenuItem - represents a menu items in IMenu-style menus.
Definition: menu_item.hpp:53
CNcbiRegistry –.
Definition: ncbireg.hpp:913
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CRgbaGradColorTable Provides a storage for colors (to eliminate color creation overhead) and Function...
CTemplateMethod - describes a class of similar methods.
virtual bool Save(CNcbiRegistry &reg)
virtual bool Load(CNcbiRegistry &reg)
virtual int GetSupportedColorTypes() const
returns a combination of EColorType flags
IColumnScoringMethod - column-based method.
IRowScoringMethod - row-based method.
virtual void CalculateScores(IAlnExplorer::TNumrow row, const IScoringAlignment &aln, IScoringMethod::TScoreColl &scores)=0
IScoringAlignment.
IScoringMethod represents an abstract algorithm for calculating alignment scores and assigning colors...
virtual void SetColorForNoScore(IScoringMethod::EColorType type, const CRgbaColor &color)=0
virtual const CRgbaColor & GetColorForScore(TScore score, EColorType type) const =0
returns a color corresponding to a given score value.
vector< TScore > TScoreVector
virtual const CRgbaColor & GetColorForNoScore(IScoringMethod::EColorType type) const =0
Call for display colors when CanCalculateScores returns false.
IUIToolWithGUI - represents a method that can be integrated in GUI.
Definition: ui_tool.hpp:102
virtual bool HasPropertiesPanel() const =0
returns true if the method supports properties dialog
virtual wxWindow * CreatePropertiesPanel(wxWindow *parent)=0
This a factory method that shall produce a CPropertiesPanel representing properties of the method; th...
virtual const CMenuItem * GetMenu()=0
Returns a pointer to the submenu.
virtual IUITool * Clone() const =0
IWindowScoringMethod - Method that can be windowed, i.e.
CRgbaColor & GetColor(CSeqFeatData::ESubtype subtype)
static const char * column
Definition: stats.c:23
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIWIDGETS_ALNSCORE_EXPORT
Definition: gui_export.h:521
n background color
const struct ncbi::grid::netcache::search::fields::SIZE size
#define row(bind, expected)
Definition: string_bind.c:73
Definition: type.c:6
Modified on Fri Sep 20 14:58:27 2024 by modify_doxy.py rev. 669887