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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_ALN_SCORE___QUALITY_SCORING_METHODS__HPP
2 #define GUI_WIDGETS_ALN_SCORE___QUALITY_SCORING_METHODS__HPP
3 
4 
5 /* $Id: quality_methods.hpp 40237 2018-01-12 17:40:24Z katargir $
6  * ===========================================================================
7  *
8  * PUBLIC DOMAIN NOTICE
9  * National Center for Biotechnology Information
10  *
11  * This software/database is a "United States Government Work" under the
12  * terms of the United States Copyright Act. It was written as part of
13  * the author's official duties as a United States Government employee and
14  * thus cannot be copyrighted. This software/database is freely available
15  * to the public for use. The National Library of Medicine and the U.S.
16  * Government have not placed any restriction on its use or reproduction.
17  *
18  * Although all reasonable efforts have been taken to ensure the accuracy
19  * and reliability of the software and data, the NLM and the U.S.
20  * Government do not and cannot warrant the performance or results that
21  * may be obtained by using this software or data. The NLM and the U.S.
22  * Government disclaim all warranties, express or implied, including
23  * warranties of performance, merchantability or fitness for any particular
24  * purpose.
25  *
26  * Please cite the author in any work or product based on this material.
27  *
28  * ===========================================================================
29  *
30  * Authors: Andrey Yazhuk
31  */
32 
33 #include <corelib/ncbistd.hpp>
34 
37 
39 
41 
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 /// CQualityScoringMethod -
46 /// Like CSimpleScoringMethod, in that it calculate the quality of the alignment
47 /// column and residue, based on how different each residue is from the columns
48 /// consensus.
49 
51  : public CObject,
52  public IScoringMethod,
53  public IColumnScoringMethod,
54  public IUIToolWithGUI
55 {
56 public:
57  enum EOptions {
58  fIgnoreEmptySpace = 0x01, ///< Do not count unaligned regions in score
59  fIgnoreGaps = 0x02, ///< Do not count gaps in the alignment in the score
60  fScoreWholeColumn = 0x04 ///< The column's total score is also the score for each residue.
61  };
62 
63  friend class CQualityScoringPanel;
64 
66  CQualityScoringMethod(int colors); // intializes color table
68  virtual ~CQualityScoringMethod();
69 
70  void CreateColorTable(int size);
71 
72  virtual TNCBIScore GetSubstitutionScore(int aa1, int aa2) const = 0;
73  virtual string GetAllowedSymbols() const = 0;
74  bool IsScoreWholeColumn() const;
75  void SetOptions(int options); // takes as argument combination of EOptions flags
76  int GetOptions() const;
77 
78  /// @name IScoringMethod implementation
79  /// @{
80  virtual string GetDescription() const;
81 
82  virtual bool IsAverageable() const;
83 
84  virtual int GetSupportedColorTypes() const;
85 
86  virtual const CRgbaColor& GetColorForScore(TScore score, EColorType type) const;
87  /// @}
88 
89  /// @name IColumnScoringMethod implementaion
90  /// @{
91  virtual void CalculateScores(char cons, const string& column,
92  TScore& col_score, TScoreVector& scores);
93 
94  /// Do we have what it takes to calculate scores? e.g. a master row selected?
95  virtual bool CanCalculateScores(const IScoringAlignment& aln);
96 
97  /// Call for display colors when CanCalculateScores returns false.
98  virtual const CRgbaColor& GetColorForNoScore(EColorType type) const;
99  virtual void SetColorForNoScore(EColorType type, const CRgbaColor& color);
100  /// @}
101 
102  /// @name IUIToolWithGUI implementation
103  /// @{
104  virtual const CMenuItem* GetMenu();
105  virtual bool HasPropertiesPanel() const;
106  virtual wxWindow* CreatePropertiesPanel(wxWindow* parent);
107  /// @}
108 
109 private:
110  void x_Init(int colors);
111 
112 protected:
116 
118  char m_Space;
119  char m_Gap;
120 };
121 
122 
123 ////////////////////////////////////////////////////////////////////////////////
124 /// CQualityScoringMethodNA -
125 /// Quality scoring method for Nucleic Acids (DNA alignments).
126 /// Use a fixed substition table.
128 {
129 public:
131  CQualityScoringMethodNA(int colors); // intializes color table
132  virtual ~CQualityScoringMethodNA();
133 
134  virtual string GetName() const;
135  virtual IUITool* Clone() const;
136 
137  virtual int GetType() const;
138  virtual string GetAllowedSymbols() const;
139  virtual TNCBIScore GetSubstitutionScore(int aa1, int aa2) const;
140 
141 };
142 
143 
144 ////////////////////////////////////////////////////////////////////////////////
145 /// CQualityScoringMethodAA -
146 /// Quality scoring method for Amino Acids (Protein alignments).
147 /// Use a user specified substition table.
149 {
150 public:
152  CQualityScoringMethodAA(int colors); // intializes color table
154  virtual ~CQualityScoringMethodAA();
155 
156  virtual string GetName() const;
157  virtual IUITool* Clone() const;
158 
159  virtual int GetType() const;
160  virtual TNCBIScore GetSubstitutionScore(int aa1, int aa2) const;
161  virtual string GetAllowedSymbols() const;
162 
163  void SetSubstitutionMatrix(const SNCBIPackedScoreMatrix* m);
164  const SNCBIPackedScoreMatrix* GetSubstitutionMatrix();
165 
166 protected:
169 };
170 
171 
172 ////////////////////////////////////////////////////////////////////////////////
173 /// CConservationScoringMethod - implementation of IScoringMethod.
174 ///
175 /// Scores are calculated as frequencies of symbols normalized to fit in range
176 /// [0, 1]. CreateColorTable() must be called once before any GetColorForScore()
177 /// calls.
179  : public CQualityScoringMethod
180 {
181 public:
182 
184 
185  enum EOptions
186  {
191  eIdentity
192  };
193 
195  CConservationScoringMethod(int colors); // initializes color table
197  virtual ~CConservationScoringMethod();
198 
199  /// @name IUITool implementation
200  /// @{
201  virtual IUITool* Clone() const;
202  virtual string GetName() const;
203  virtual string GetDescription() const;
204  /// @}
205 
206  /// @name IScoringMethod implementation
207  /// @{
208  virtual int GetType() const;
209  virtual int GetSupportedColorTypes() const;
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  /// @}
218 
219  /// @name CQualityScoringMethod implementation
220  /// @{
221  virtual TNCBIScore GetSubstitutionScore(int /*aa1*/, int /*aa2*/) const
222  {
223  return 0;
224  }
225  virtual string GetAllowedSymbols() const
226  {
227  return NcbiEmptyString;
228  }
229  /// @}
230 
231  /// @name IUIToolWithGUI implementation
232  /// @{
233  virtual wxWindow* CreatePropertiesPanel(wxWindow* parent);
234  /// @}
235 
236  void SetConservedOption(const string& name);
237 
238 private:
239  void x_Init(int colors);
240 
241 protected:
242  bool x_IsConserved(const vector<int>& counts,
243  int num_rows,
244  const double* std_prob) const;
245 
246 protected:
247  EOptions m_ConservedOption = eTwoBits;
249  double* m_StdProb = 0; // standard aa probabilities
250 };
251 
252 
254 
255 #endif // GUI_WIDGETS_ALN_SCORE___QUALITY_SCORING_METHODS__HPP
CConservationScoringMethod - implementation of IScoringMethod.
virtual string GetAllowedSymbols() const
virtual TNCBIScore GetSubstitutionScore(int, int) const
CConservationScoringPanel.
CMenuItem - represents a menu items in IMenu-style menus.
Definition: menu_item.hpp:53
CObject –.
Definition: ncbiobj.hpp:180
CQualityScoringMethodAA - Quality scoring method for Amino Acids (Protein alignments).
const SNCBIPackedScoreMatrix * m_SubstMatrix
SNCBIFullScoreMatrix m_FullSubstMatrix
CQualityScoringMethodNA - Quality scoring method for Nucleic Acids (DNA alignments).
CQualityScoringMethod - Like CSimpleScoringMethod, in that it calculate the quality of the alignment ...
CRgbaGradColorTable m_ColorTable
virtual TNCBIScore GetSubstitutionScore(int aa1, int aa2) const =0
virtual string GetAllowedSymbols() const =0
CQualityScoringPanel.
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...
IColumnScoringMethod - column-based method.
virtual void CalculateScores(char cons, const string &column, IScoringMethod::TScore &col_score, IScoringMethod::TScoreVector &scores)=0
virtual bool CanCalculateScores(const IScoringAlignment &aln)=0
Do we have what it takes to calculate scores? e.g. a master row selected?
IScoringAlignment.
IScoringMethod represents an abstract algorithm for calculating alignment scores and assigning colors...
virtual void SetColorForNoScore(IScoringMethod::EColorType type, const CRgbaColor &color)=0
virtual int GetSupportedColorTypes() const =0
returns a combination of EColorType flags
virtual const CRgbaColor & GetColorForScore(TScore score, EColorType type) const =0
returns a color corresponding to a given score value.
virtual bool IsAverageable() const =0
return "true" if scores could be averaged
vector< TScore > TScoreVector
virtual const CRgbaColor & GetColorForNoScore(IScoringMethod::EColorType type) const =0
Call for display colors when CanCalculateScores returns false.
virtual int GetType() const =0
returns combination of EAlignType flags defining types of alignments that can be colored with this me...
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.
IUITool represents an abstract algorithm that is bound to a UI component.
Definition: ui_tool.hpp:59
virtual IUITool * Clone() const =0
virtual string GetDescription() const =0
returns a detailed description of the method that is used in UI
virtual string GetName() const =0
returns unique name of the method that is used in UI to identify it
static const Colors colors
Definition: cn3d_colors.cpp:50
Include a standard set of the NCBI C++ Toolkit most basic headers.
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 NcbiEmptyString
Definition: ncbistr.hpp:122
#define NCBI_GUIWIDGETS_ALNSCORE_EXPORT
Definition: gui_export.h:521
n background color
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
EColorType
Definition: map_control.hpp:48
const struct ncbi::grid::netcache::search::fields::SIZE size
int TNCBIScore
data types
Definition: raw_scoremat.h:45
Definition: type.c:6
Modified on Wed May 22 11:27:15 2024 by modify_doxy.py rev. 669887