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

Go to the SVN repository for this file.

1 /* $Id: quality_methods.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: Andrey Yazhuk, Andrei Shkeda, Greg Boratyn
27  */
28 
29 #include <ncbi_pch.hpp>
30 
32 
34 
36 
38 
41 
42 #include "wx/valgen.h"
43 #include "wx/choice.h"
44 #include "wx/checkbox.h"
45 
47 
48 ///////////////////////////////////////////////////////////////////////////////
49 /// CQualityScoringMethod
50 ///
52 : m_Space(0), m_Gap(0)
53 {
55 }
56 
57 
59 {
60 }
61 
62 
64 : m_Options(0), m_Space(0), m_Gap(0)
65 {
66  x_Init(colors);
67 }
68 
69 
71 {
72  m_Worst.Set(1.0f, 0.0f, 0.0f);
73  m_Best.Set(0.8f, 0.8f, 0.8f);
75 
77 }
78 
79 
81 : m_Worst(orig.m_Worst),
82  m_Best(orig.m_Best),
83  m_Options(orig.m_Options),
84  m_Space(orig.m_Space),
85  m_Gap(orig.m_Gap)
86 {
87  m_ColorTable = orig.m_ColorTable;
88 }
89 
90 
92 {
93  m_Options = options;
94  // for now, always ignore empty spaces.
95  m_Space = ' '; // (m_Options & fIgnoreEmptySpace) ? ' ' : 0;
96  m_Gap = (m_Options & fIgnoreGaps) ? '-' : 0;
97 }
98 
99 
101 {
102  return m_Options;
103 }
104 
105 
107 {
108  return (m_Options & fScoreWholeColumn) ? true : false;
109 }
110 
111 
113 {
114  _ASSERT(size >= 0);
115 
118 }
119 
120 
121 #define QUALITY_DESCR "This scheme assigns scores to residues" \
122 " based on how well a particular residue agrees with the others in a column."
123 
124 
126 {
127  return QUALITY_DESCR;
128 }
129 
130 
132 {
133  return true;
134 }
135 
136 
138  const string& column,
139  TScore& col_score,
140  TScoreVector& scores)
141 {
142  _ASSERT(scores.size() == column.size());
143 
144  const string symbols(GetAllowedSymbols());
145 
146  size_t n_space = 0;
147  vector<int> base_count(NCBI_FSM_DIM, 0);
148  ITERATE(string, c_it, column) {
149  char c = *c_it;
150  if (c != m_Space && c != m_Gap && c != m_AmbiguousResidue) {
151  ++base_count[*c_it];
152  } else {
153  ++n_space;
154  }
155  }
156 
157  // size of the column w/o spaces we are not counting.
158  size_t column_size = column.size() - n_space;
159  vector<double> X(symbols.size(), 0);
160  for (size_t r = 0; r <symbols.size(); ++r) {
161  ITERATE(string, c_it, symbols) {
162  X[r] += base_count[*c_it] * GetSubstitutionScore(*c_it, symbols[r]);
163  }
164  X[r] /= column_size;
165  }
166 
167  double quality_score = 0;
168  for (size_t i = 0; i < column.size(); ++i) {
169  char c = column[i];
170  if (c == m_AmbiguousResidue) {
171  if (!IsScoreWholeColumn()) {
173  }
174  } else if (c != m_Space && c != m_Gap) {
175  double score_sq_sum = 0;
176  for (size_t r = 0; r < symbols.size(); ++r) {
177  double score_diff = X[r] - GetSubstitutionScore(symbols[r], c);
178  score_sq_sum += score_diff * score_diff;
179  }
180  TScore resid_score = (TScore) sqrt(score_sq_sum);
181  if ( ! IsScoreWholeColumn()) {
182  scores[i] = resid_score;
183  }
184  quality_score += resid_score;
185  }
186  }
187 
188  col_score = (TScore) (quality_score / column_size);
189 
190  if (IsScoreWholeColumn()) {
191  for (size_t i = 0; i < column.size(); ++i) {
192  char c = column[i];
193  if (c == m_AmbiguousResidue) {
195  } else if (c != m_Space && c != m_Gap) {
196  scores[i] = col_score;
197  }
198  }
199  }
200 }
201 
202 
204 {
205  return true;
206 }
207 
208 
210 {
211  static CRgbaColor not_used;
212  _ASSERT(false);
213  return not_used;
214 }
215 
216 
218  const CRgbaColor& /*color*/)
219 {
220 }
221 
222 
224 {
225  return fBackground;
226 }
227 
228 
230  EColorType type) const
231 {
232  int size = (int)m_ColorTable.GetSize();
233  _ASSERT(size >= 0);
234  static const TScore kMaxScore = 15.0;
235  score = (kMaxScore - score) / kMaxScore;
236  if (score < 0.0) score = 0.0;
237 
238  if(type == fBackground) {
239  int index = (int) floor(score * size);
240  index = min(index, size - 1);
241  return m_ColorTable[index];
242  } else {
243  _ASSERT(false); // not supported
244  return m_ColorTable[0];
245  }
246 }
247 
248 
250 {
251  return 0;
252 }
253 
254 
256 {
257  return true;
258 }
259 
260 ///////////////////////////////////////////////////////////////////////////////
261 /// CQualityScoringPanel
262 
263 class CQualityScoringPanel : public wxPanel
264 {
265  DECLARE_EVENT_TABLE()
266 public:
267  CQualityScoringPanel(CQualityScoringMethod& method, wxWindow* parent, wxWindowID id = wxID_ANY);
268 protected:
269  void CreateControls();
270  void Init();
271  void OnApply ( wxCommandEvent& event );
273  wxChoice* m_MatrixChoice;
275 // data members
277  bool m_Gap;
278 };
279 
280 BEGIN_EVENT_TABLE( CQualityScoringPanel, wxPanel )
281  EVT_BUTTON( wxID_APPLY, CQualityScoringPanel::OnApply )
283 
285  CQualityScoringMethod& method, wxWindow* parent, wxWindowID id) :
286  m_Method(method),
287  m_MatrixChoice(), m_GradPanel()
288 {
289  Init();
290  Create(parent, id);
291  CreateControls();
292 }
293 
295 {
296  int options = m_Method.GetOptions();
298  m_Gap = (options & CQualityScoringMethod::fIgnoreGaps) != 0;
299 }
300 
302 {
303  wxBoxSizer* itemBoxSizer1 = new wxBoxSizer(wxVERTICAL);
304  this->SetSizer(itemBoxSizer1);
305 
307  params.m_FirstColor = m_Method.m_Worst;
308  params.m_LastColor = m_Method.m_Best;
310  params.m_ThreeColors = false;
311  params.m_Reversable = true;
312 
313  m_GradPanel = new CGradientColorPanel(params, this);
314  itemBoxSizer1->Add(m_GradPanel, 1, wxGROW|wxALL, 5);
315 
317  CQualityScoringMethodAA* aa_method = dynamic_cast<CQualityScoringMethodAA*>(&m_Method);
318  _ASSERT(aa_method);
319 
320  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
321  itemBoxSizer1->Add(itemBoxSizer2, 0, wxALIGN_RIGHT|wxALL, 5);
322 
323  itemBoxSizer2->Add(new wxStaticText(this, wxID_STATIC, _("Substitution matrix:")),
324  0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
325 
326  m_MatrixChoice = new wxChoice(this, wxID_ANY);
327  itemBoxSizer2->Add(m_MatrixChoice, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
328 
329  // add names to popup.
330  vector<string> table_names = CTableNames::AllTableNames();
331  ITERATE(vector<string>, iter, table_names) {
332  m_MatrixChoice->Append(ToWxString(*iter));
333  }
334 
335  // set the current name.
336  string matrix_name = CTableNames::TableToName(aa_method->GetSubstitutionMatrix()).c_str();
337  if (!matrix_name.empty()) {
338  m_MatrixChoice->SetStringSelection(ToWxString(matrix_name));
339  }
340  }
341 
342  wxCheckBox* itemCheckBox1 = new wxCheckBox(this, wxID_ANY, _("Score column as a whole"));
343  itemCheckBox1->SetValidator(wxGenericValidator(&m_ColScore));
344  itemBoxSizer1->Add(itemCheckBox1, 0, wxALIGN_LEFT|wxALL, 5);
345 
346  wxCheckBox* itemCheckBox2 = new wxCheckBox(this, wxID_ANY, _("Ignore Gaps"));
347  itemCheckBox2->SetValidator(wxGenericValidator(&m_Gap));
348  itemBoxSizer1->Add(itemCheckBox2, 0, wxALIGN_LEFT|wxALL, 5);
349 }
350 
351 void CQualityScoringPanel::OnApply ( wxCommandEvent& WXUNUSED(event) )
352 {
354  m_GradPanel->GetParams(params);
355  m_Method.m_Worst = params.m_FirstColor;
356  m_Method.m_Best = params.m_LastColor;
357 
359 
360  int options = 0;
363  m_Method.SetOptions(options);
364 
366  CQualityScoringMethodAA* aa_method = dynamic_cast<CQualityScoringMethodAA*>(&m_Method);
367  _ASSERT(aa_method);
368  wxString matrix_name = m_MatrixChoice->GetStringSelection();
369  if (!matrix_name.empty()) {
371  if (m != NULL)
372  aa_method->SetSubstitutionMatrix(m);
373  }
374  }
375 }
376 
378 {
379  return new CQualityScoringPanel(*this, parent);
380 }
381 
382 ///////////////////////////////////////////////////////////////////////////////
383 /// CQualityScoringMethodNA
384 ///
387 {
388 }
389 
390 
393 {
394 }
395 
396 
398 {
399 }
400 
401 
403 {
404  return "Column Quality score - DNA";
405 }
406 
407 
409 {
410  return new CQualityScoringMethodNA(*this);
411 }
412 
413 
415 {
416  return IAlnExplorer::fDNA;
417 }
418 
419 
421 {
422  return string("ACGTU");
423 }
424 
425 
427 {
428  if (aa1 == aa2)
429  return 15;
430 /*
431  if ((aa1 == 'T' && aa2 == 'U') || (aa1 == 'U' && aa2 == 'T'))
432  return 1;
433 */
434  return 0;
435 }
436 
437 
438 ///////////////////////////////////////////////////////////////////////////////
439 /// CQualityScoringMethodAA
440 ///
443 {
445  // or NCBISM_Blosum45 NCBISM_Blosum80 NCBISM_Pam30 NCBISM_Pam70 NCBISM_Pam250
446 }
447 
448 
451 {
453  // or NCBISM_Blosum45 NCBISM_Blosum80 NCBISM_Pam30 NCBISM_Pam70 NCBISM_Pam250
454 }
455 
456 
459 {
460  SetSubstitutionMatrix(orig.m_SubstMatrix);
461 }
462 
463 
465 {
466 }
467 
468 
470 {
471  return "Column Quality score - Protein";
472 }
473 
474 
476 {
477  return new CQualityScoringMethodAA(*this);
478 }
479 
480 
482 {
483  return IAlnExplorer::fProtein;
484 }
485 
486 
488 {
489  return m_FullSubstMatrix.s[aa1][aa2];
490 }
491 
492 
494 {
495  return m_SubstMatrix->symbols;
496 }
497 
498 
500 {
501  m_SubstMatrix = m;
503 }
504 
505 
507 {
508  return m_SubstMatrix;
509 }
510 
511 
512 ///////////////////////////////////////////////////////////////////////////////
513 /// CConservationScoringMethod
514 ///
516 {
518 }
519 
520 
522 {
523  if (m_StdProb)
524  free(m_StdProb);
525 }
526 
527 
529 {
530  x_Init(colors);
531 }
532 
533 
535 {
536  m_Worst = {30, 144, 255, 255 };
537  m_Best = { 255, 26, 26, 255 };
538  m_NotScored.Set(0.8f, 0.8f, 0.8f);
541 }
542 
543 
546  m_ConservedOption(orig.m_ConservedOption),
547  m_NotScored(orig.m_NotScored)
548 {
549  m_ColorTable = orig.m_ColorTable;
551 }
552 
553 
555 {
556  return new CConservationScoringMethod(*this);
557 }
558 
559 /*
560 void CConservationScoringMethod::CreateColorTable(int size)
561 {
562  _ASSERT(size >= 0);
563 
564  m_ColorTable.SetSize(size);
565  m_ColorTable.FillGradient(0, size, m_LessConserved, m_HighlyConserved);
566 }
567 */
568 
570 {
571  return "Conservation";
572 }
573 
574 const string CONSERVATION_METOD_DESCR = R"foo(This is a column-based method that highlights highly conserved and less conserved columns based on residues's relative entropy threshold.
575 Alignment columns with no gaps are colored in blue or red.
576 The red color indicates highly conserved columns and blue indicates less conserved ones.)foo";
577 
578 /*
579 #define CONSERVATION_METOD_DESCR "This is a column-based method that highlights \
580 highly conserved and less conserved columns based on residues's relative entropy threshold. \
581 Alignment columns with no gaps are colored in blue or red. \
582 The red color indicates highly conserved columns and blue indicates less conserved ones.\
583 The Conservation Setting can be used to select a threshold for determining which columns are colored in red. \
584 Numerical setting:\
585 The number is the relative entropy threshold, in bits, that must be met for an alignment column to be displayed in red.A larger number indicates higher degree of conservation.\
586 Identity setting: Only columns with one residue type will be colored in red.";
587 */
588 
590 {
592 }
593 
594 
596 {
597  return IAlnExplorer::fProtein;
598 }
599 
600 // Is it a column of only proper residues
601 static bool s_IsResidueOnlyColumn(const vector<int>& residue_counts)
602 {
603  const int kGap = AMINOACID_TO_NCBISTDAA[(int)'-'];
604  const int kResidueX = AMINOACID_TO_NCBISTDAA[(int)'X'];
605  const int kResidueB = AMINOACID_TO_NCBISTDAA[(int)'B'];
606  const int kResidueZ = AMINOACID_TO_NCBISTDAA[(int)'Z'];
607  const int kResidueU = AMINOACID_TO_NCBISTDAA[(int)'U'];
608  const int kResidueStar = AMINOACID_TO_NCBISTDAA[(int)'*'];
609  return residue_counts[kGap] == 0 && residue_counts[kResidueX] == 0
610  && residue_counts[kResidueB] == 0 && residue_counts[kResidueZ] == 0
611  && residue_counts[kResidueU] == 0 && residue_counts[kResidueStar] == 0;
612 }
613 
614 // Score calculation borrowed from blast / AlignFormatter / showalign_msa.cpp
615 
616 static const int kAlphabetSize = 28;
617 
618 static double s_GetInfoContent(const vector<int>& counts,
619  int num_rows,
620  const double* std_prob)
621 {
622  _ASSERT((int)counts.size() == kAlphabetSize);
623 
624  double retval = 0.0;
625  for (size_t i = 1; i < counts.size(); i++) {
626  if (counts[i] == 0) {
627  continue;
628  }
629  // _ASSERT(std_prob[i] > 0.0);
630  // We can't reasonably estimate an information value for AAs with probability
631  // zero, so we just skip them
632  if (!(std_prob[i] > 0.0)) continue;
633  double freq = (double)counts[i] / (double)num_rows;
634  retval += freq * log(freq / std_prob[i]) / log(2.0);
635  }
636 
637  return retval;
638 }
639 
640 static bool s_IsIdentity(const vector<int>& counts, int num_rows)
641 {
642  // if there are gaps, there is no identity
643  if (counts[0] > 0) {
644  return false;
645  }
646 
647  for (size_t i = 1; i < counts.size(); i++) {
648  if (counts[i] > 0 && counts[i] < num_rows) {
649  return false;
650  }
651  if (counts[i] == num_rows) {
652  return true;
653  }
654  }
655  return false;
656 }
657 
658 bool
660 int num_rows,
661 const double* std_prob) const
662 {
663  bool retval = false;
664 
665  if (m_ConservedOption == eIdentity) {
666  retval = s_IsIdentity(counts, num_rows);
667  } else {
668  double bit_threshold = 0.0;
669  switch (m_ConservedOption) {
670  case eOneBit: bit_threshold = 1.0; break;
671  case eTwoBits: bit_threshold = 2.0; break;
672  case eThreeBits: bit_threshold = 3.0; break;
673  case eFourBits: bit_threshold = 4.0; break;
674  case eIdentity:
675  default:
676  NCBI_THROW(CException, eInvalid, (string)"Unsupported conserved "
677  "column option " + NStr::IntToString(m_ConservedOption));
678  };
679  retval = s_GetInfoContent(counts, num_rows, std_prob) > bit_threshold;
680  }
681 
682  return retval;
683 }
684 
685 
686 void CConservationScoringMethod::CalculateScores(char /*cons*/, const string& column,
687  TScore& col_score, TScoreVector& scores)
688 {
689 
690  vector<int> residue_counts(kAlphabetSize, 0);
691  for (auto& aa : column) {
692  int residue = AMINOACID_TO_NCBISTDAA[(int)aa];
693  _ASSERT(residue < kAlphabetSize);
694  residue_counts[residue]++;
695  }
696  col_score = -1.0f;
697  if (s_IsResidueOnlyColumn(residue_counts)) {
698  if (x_IsConserved(residue_counts, static_cast<int>(column.size()), m_StdProb)) {
699  col_score = 1.f;
700  } else {
701  col_score = 0.f;
702  }
703  }
704  fill(scores.begin(), scores.end(), col_score);
705 }
706 
707 
709 {
710  return fBackground | fForeground;
711 
712 }
713 
715  EColorType type) const
716 {
717  if (score < 0.) {
718  if (type == fBackground) {
719  return m_NotScored;
720  } else {
721  static const CRgbaColor color_black("black");
722  return color_black;
723  }
724  }
725 
726  int size = (int)m_ColorTable.GetSize();
727  _ASSERT(size >= 0);
728 
729  if (type == fBackground) {
730  int index = (int)floor(score * size);
731  index = min(index, size - 1);
732  return m_ColorTable[index];
733  } else {
734  static const CRgbaColor color_white("white");
735  return color_white;
736  }
737 }
738 
740 {
744  { CConservationScoringMethod::eFourBits , "four_bits" },
745  { CConservationScoringMethod::eIdentity , "identity", }
746 };
747 
749 {
750  string l_name(name);
751  NStr::ToLower(l_name);
752  for (auto& opt : sm_ConservationValues) {
753  if (opt.second == l_name) {
754  m_ConservedOption = opt.first;
755  return;
756  }
757  }
758  ERR_POST("Invalid conservation setting:\"" << name << "\"");
759 }
760 
761 
762 ///////////////////////////////////////////////////////////////////////////////
763 /// CConservationScoringPanel
764 
765 class CConservationScoringPanel : public wxPanel
766 {
767  DECLARE_EVENT_TABLE()
768 public:
769  CConservationScoringPanel(CConservationScoringMethod& method, wxWindow* parent, wxWindowID id = wxID_ANY);
770 protected:
771  void CreateControls();
772  void Init();
773  void OnApply(wxCommandEvent& event);
777 };
778 
779 BEGIN_EVENT_TABLE(CConservationScoringPanel, wxPanel)
780 EVT_BUTTON(wxID_APPLY, CConservationScoringPanel::OnApply)
782 
784  m_Method(method),
785  m_ConservedOptionChoice(),
786  m_GradPanel()
787 {
788  Init();
789  Create(parent, id);
790  CreateControls();
791 }
792 
794 {
795 }
796 
798 {
799  wxBoxSizer* itemBoxSizer1 = new wxBoxSizer(wxVERTICAL);
800  this->SetSizer(itemBoxSizer1);
801 
803  params.m_FirstColor = m_Method.m_Worst;
804  params.m_LastColor = m_Method.m_Best;
806  params.m_ThreeColors = false;
807  params.m_Reversable = true;
808 
809  m_GradPanel = new CGradientColorPanel(params, this);
810  itemBoxSizer1->Add(m_GradPanel, 1, wxGROW | wxALL, 5);
811 
812  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
813  itemBoxSizer1->Add(itemBoxSizer2, 0, wxALIGN_RIGHT | wxALL, 5);
814 
815  itemBoxSizer2->Add(new wxStaticText(this, wxID_STATIC, _("Conservation Setting:")),
816  0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
817 
818  m_ConservedOptionChoice = new wxChoice(this, wxID_ANY);
819  itemBoxSizer2->Add(m_ConservedOptionChoice, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
820  for (auto& opt : sm_ConservationValues) {
821  wxString s = ToWxString(opt.second);
822  s.Replace(wxT("_"), wxT(" "));
823  s[0] = wxToupper(s[0]);
824  auto index = m_ConservedOptionChoice->Append(s);
825  if (opt.first == m_Method.m_ConservedOption)
826  m_ConservedOptionChoice->SetSelection(index);
827  }
828 
829 }
830 
831 void CConservationScoringPanel::OnApply(wxCommandEvent& WXUNUSED(event))
832 {
834  m_GradPanel->GetParams(params);
835  m_Method.m_Worst = params.m_FirstColor;
836  m_Method.m_Best = params.m_LastColor;
838  auto val = m_ConservedOptionChoice->GetString(m_ConservedOptionChoice->GetSelection());
839  val.Replace(wxT(" "), wxT("_"));
841 }
842 
844 {
845  return new CConservationScoringPanel(*this, parent);
846 }
847 
848 
Declarations of static arrays used to define some NCBI encodings to be used in a toolkit independent ...
Various auxiliary BLAST utility functions.
double * BLAST_GetStandardAaProbabilities(void)
Get the standard amino acid probabilities.
Definition: blast_util.c:1323
CConservationScoringMethod - implementation of IScoringMethod.
virtual const CRgbaColor & GetColorForScore(TScore score, EColorType type) const
returns a color corresponding to a given score value.
CConservationScoringMethod()
CConservationScoringMethod.
bool x_IsConserved(const vector< int > &counts, int num_rows, const double *std_prob) const
void SetConservedOption(const string &name)
virtual int GetType() const
returns combination of EAlignType flags defining types of alignments that can be colored with this me...
virtual wxWindow * CreatePropertiesPanel(wxWindow *parent)
This a factory method that shall produce a CPropertiesPanel representing properties of the method; th...
virtual void CalculateScores(char cons, const string &column, TScore &col_score, TScoreVector &scores)
virtual IUITool * Clone() const
virtual int GetSupportedColorTypes() const
returns a combination of EColorType flags
virtual string GetName() const
returns unique name of the method that is used in UI to identify it
virtual string GetDescription() const
returns a detailed description of the method that is used in UI
CConservationScoringPanel.
CConservationScoringPanel(CConservationScoringMethod &method, wxWindow *parent, wxWindowID id=wxID_ANY)
void OnApply(wxCommandEvent &event)
CConservationScoringMethod & m_Method
CGradientColorPanel * m_GradPanel
void GetParams(stParams &params) const
CMenuItem - represents a menu items in IMenu-style menus.
Definition: menu_item.hpp:53
CQualityScoringMethodAA - Quality scoring method for Amino Acids (Protein alignments).
virtual IUITool * Clone() const
const SNCBIPackedScoreMatrix * m_SubstMatrix
SNCBIFullScoreMatrix m_FullSubstMatrix
virtual string GetName() const
returns unique name of the method that is used in UI to identify it
const SNCBIPackedScoreMatrix * GetSubstitutionMatrix()
CQualityScoringMethodAA()
CQualityScoringMethodAA.
virtual TNCBIScore GetSubstitutionScore(int aa1, int aa2) const
virtual string GetAllowedSymbols() const
void SetSubstitutionMatrix(const SNCBIPackedScoreMatrix *m)
virtual int GetType() const
returns combination of EAlignType flags defining types of alignments that can be colored with this me...
virtual string GetAllowedSymbols() const
CQualityScoringMethodNA()
CQualityScoringMethodNA.
virtual string GetName() const
returns unique name of the method that is used in UI to identify it
virtual TNCBIScore GetSubstitutionScore(int aa1, int aa2) const
virtual IUITool * Clone() const
virtual int GetType() const
returns combination of EAlignType flags defining types of alignments that can be colored with this me...
CQualityScoringMethod - Like CSimpleScoringMethod, in that it calculate the quality of the alignment ...
CQualityScoringMethod()
CQualityScoringMethod.
virtual const CMenuItem * GetMenu()
Returns a pointer to the submenu.
CRgbaGradColorTable m_ColorTable
friend class CQualityScoringPanel
virtual const CRgbaColor & GetColorForNoScore(EColorType type) const
Call for display colors when CanCalculateScores returns false.
virtual bool CanCalculateScores(const IScoringAlignment &aln)
Do we have what it takes to calculate scores? e.g. a master row selected?
virtual TNCBIScore GetSubstitutionScore(int aa1, int aa2) const =0
bool IsScoreWholeColumn() const
virtual string GetDescription() const
returns a detailed description of the method that is used in UI
virtual void SetColorForNoScore(EColorType type, const CRgbaColor &color)
void CreateColorTable(int size)
virtual wxWindow * CreatePropertiesPanel(wxWindow *parent)
This a factory method that shall produce a CPropertiesPanel representing properties of the method; th...
@ fIgnoreGaps
Do not count gaps in the alignment in the score.
@ fScoreWholeColumn
The column's total score is also the score for each residue.
@ fIgnoreEmptySpace
Do not count unaligned regions in score.
virtual bool IsAverageable() const
return "true" if scores could be averaged
virtual const CRgbaColor & GetColorForScore(TScore score, EColorType type) const
returns a color corresponding to a given score value.
virtual void CalculateScores(char cons, const string &column, TScore &col_score, TScoreVector &scores)
virtual string GetAllowedSymbols() const =0
virtual int GetSupportedColorTypes() const
returns a combination of EColorType flags
void SetOptions(int options)
virtual bool HasPropertiesPanel() const
returns true if the method supports properties dialog
void x_Init(int colors)
CQualityScoringPanel.
void OnApply(wxCommandEvent &event)
CQualityScoringPanel(CQualityScoringMethod &method, wxWindow *parent, wxWindowID id=wxID_ANY)
CQualityScoringMethod & m_Method
CGradientColorPanel * m_GradPanel
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
char m_AmbiguousResidue
Ambiguous Residue, typically 'N' for nucleotides, 'X' for proteins.
static const int kAmbiguousResidueScore
IScoringAlignment.
vector< TScore > TScoreVector
virtual int GetType() const =0
returns combination of EAlignType flags defining types of alignments that can be colored with this me...
static const int sm_DefGradientSize
default number of colors in gradient
IUITool represents an abstract algorithm that is bound to a UI component.
Definition: ui_tool.hpp:59
Definition: map.hpp:338
static const Colors colors
Definition: cn3d_colors.cpp:50
#define _(proto)
Definition: ct_nlmzip_i.h:78
#define true
Definition: bool.h:35
static void Init(void)
Definition: cursor6.c:76
static const char * column
Definition: stats.c:23
const Uint1 AMINOACID_TO_NCBISTDAA[]
Translates between ncbieaa and ncbistdaa.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
size_t GetSize() const
void SetSize(size_t size)
void FillGradient(const CRgbaColor &start_c, const CRgbaColor &end_c)
initialize the whole table with gradient colors in [start_c, end_c] range
static const SNCBIPackedScoreMatrix * NameToTable(const string &name)
Definition: table_names.cpp:66
static vector< string > AllTableNames()
Definition: table_names.cpp:76
void Set(float r, float g, float b)
set the color from an Fl_Color
Definition: rgba_color.cpp:226
static string TableToName(const SNCBIPackedScoreMatrix *)
Definition: table_names.cpp:54
#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 string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static string & ToLower(string &str)
Convert string to lower case – string& version.
Definition: ncbistr.cpp:405
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
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
END_EVENT_TABLE()
int i
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
T min(T x_, T y_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
#define QUALITY_DESCR
static const int kAlphabetSize
static bool s_IsIdentity(const vector< int > &counts, int num_rows)
const string CONSERVATION_METOD_DESCR
static map< CConservationScoringMethod::EOptions, string > sm_ConservationValues
static bool s_IsResidueOnlyColumn(const vector< int > &residue_counts)
static double s_GetInfoContent(const vector< int > &counts, int num_rows, const double *std_prob)
const SNCBIPackedScoreMatrix NCBISM_Blosum62
Definition: sm_blosum62.c:92
#define NCBI_FSM_DIM
Recommended approach: unpack and index directly.
Definition: raw_scoremat.h:85
void NCBISM_Unpack(const SNCBIPackedScoreMatrix *psm, SNCBIFullScoreMatrix *fsm)
Expand a packed score matrix into an unpacked one, which callers can proceed to index directly by sta...
Definition: raw_scoremat.c:81
int TNCBIScore
data types
Definition: raw_scoremat.h:45
static static static wxID_ANY
static const string kMaxScore
Definition: showdefline.cpp:85
TNCBIScore s[128][128]
Definition: raw_scoremat.h:87
const char * symbols
order of residues
Definition: raw_scoremat.h:47
Definition: type.c:6
#define _ASSERT
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
void free(voidpf ptr)
Modified on Mon May 20 05:05:09 2024 by modify_doxy.py rev. 669887