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

Go to the SVN repository for this file.

1 /* $Id: simple_methods.cpp 46033 2021-01-21 14:32:03Z grichenk $
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
27  */
28 
29 #include <ncbi_pch.hpp>
30 
31 #include <corelib/ncbistd.hpp>
32 
35 
37 
39 
40 #include <wx/checkbox.h>
41 #include "wx/valgen.h"
42 
44 
45 static const int kDefGradientSize = 32;
46 
47 
48 static
49 bool s_CompareBases(char consensus, char base)
50 {
51  if (base == consensus)
52  return true;
53  switch (consensus) {
54  case 'A':
55  case 'C':
56  case 'G':
57  case 'T':
58  return base == consensus;
59  case 'M':
60  return base == 'C' || base == 'A';
61  case 'R':
62  return base == 'G' || base == 'A';
63  case 'S':
64  return base == 'G' || base == 'C';
65  case 'V':
66  return base == 'G' || base == 'C' || base == 'A';
67  case 'W':
68  return base == 'T' || base == 'A';
69  case 'Y':
70  return base == 'T' || base == 'C';
71  case 'H':
72  return base == 'T' || base == 'C' || base == 'A';
73  case 'K':
74  return base == 'T' || base == 'G';
75  case 'D':
76  return base == 'T' || base == 'G' || base == 'A';
77  case 'B':
78  return base == 'T' || base == 'G' || base == 'C';
79  case 'N':
80  return base == 'T' || base == 'G' || base == 'C' || base == 'A';
81  default:
82  return base == consensus;
83  }
84 }
85 
86 static
87 bool s_CompareResidues(char consensus, char residue)
88 {
89  if (consensus == residue)
90  return true;
91  switch (consensus) {
92  case 'B':
93  return residue == 'N' || residue == 'D';
94  case 'J':
95  return residue == 'I' || residue == 'L';
96  case 'Z':
97  return residue == 'Q' || residue == 'E';
98  default:
99  return consensus == residue;
100  }
101 }
102 
103 
104 /// Set alignment specifi settings
106 {
107  auto align_type = aln.GetAlignType();
108  switch (align_type) {
109  case IAlnExplorer::EAlignType::fDNA:
110  m_AmbiguousResidue = 'N';
112  break;
114  m_AmbiguousResidue = 'X';
116  break;
117  case IAlnExplorer::EAlignType::fMixed:
118  m_AmbiguousResidue = 'X';
119  mf_CompareResidue = [](char c, char b) { return c == b; };
120  break;
121  default:
122  break;
123  }
124 
125 
126 }
127 
128 
129 ///////////////////////////////////////////////////////////////////////////////
130 /// CSimpleScoringMethod
131 ///
133 : m_Space(0), m_Gap(0)
134 {
135  m_vCharCounts.resize(256);
137 
139 }
140 
141 
143 {
144 }
145 
146 
148 : m_Space(0), m_Gap(0)
149 {
150  x_Init(colors);
151 }
152 
153 
155 {
156  m_Worst.Set(1.0f, 0.0f, 0.0f);
157  m_Best.Set(0.8f, 0.8f, 0.8f);
158 
159  m_vCharCounts.resize(256);
161 
163 }
164 
165 
167 : m_Worst(orig.m_Worst),
168  m_Best(orig.m_Best),
169  m_Space(orig.m_Space),
170  m_Gap(orig.m_Gap)
171 {
172  m_vCharCounts.resize(256);
173  SetOptions(orig.m_Options);
174 
175  m_ColorTable = orig.m_ColorTable;
176 }
177 
178 
180 {
181  return new CSimpleScoringMethod(*this);
182 }
183 
184 
186 {
187  m_Options = options;
188  m_Space = (m_Options & fIgnoreEmptySpace) ? ' ' : 0;
189  m_Gap = (m_Options & fIgnoreGaps) ? '-' : 0;
190 }
191 
192 
194 {
195  return m_Options;
196 }
197 
198 
200 {
201  _ASSERT(size >= 0);
202 
205 }
206 
207 
209 {
210  return "Frequency-Based Difference";
211 }
212 
213 #define SIMPLE_DESCR "This is a column-based method that assigns scores \
214 to residues in a column based on their representation in the column's frequency \
215 profile. Residues that occur infrequently are highlighted darkly; columns \
216 that contain any degree of mismatch will alsobe highlighted."
217 
219 {
220  return SIMPLE_DESCR;
221 }
222 
223 
225 {
227 }
228 
229 
231 {
232  return true;
233 }
234 
235 void CSimpleScoringMethod::CalculateScores(char /*cons*/, const string& column,
236  TScore& col_score, TScoreVector& scores)
237 {
238  _ASSERT(scores.size() == column.size() && m_vCharCounts.size() == 256);
239 
240  // reset histogram
241  size_t space_n = 0;
242  fill(m_vCharCounts.begin(), m_vCharCounts.end(), 0);
243 
244  // calculate histogram
245  ITERATE(string, it, column) {
246  char c = *it;
247  if(c != m_Space && c != m_Gap && c != m_AmbiguousResidue) {
248  ++m_vCharCounts[(size_t) c];
249  } else {
250  space_n++;
251  }
252  }
253 
254  size_t total = column.size() - space_n;
255  col_score = 0.0;
256 
257  // calculate individual scores
258  for( size_t i = 0; i < column.size(); i++ ) {
259  char c = column[i];
260  if (c == m_AmbiguousResidue) {
262  } else if (c != m_Space && c != m_Gap) {
263  scores[i] = ((TScore)m_vCharCounts[(size_t)c]) / total;
264  } else {
265  scores[i] = 1.0;
266  }
267  }
268 }
269 
270 
272 {
273  return true;
274 }
275 
276 
278 {
279  static CRgbaColor not_used;
280  _ASSERT(false);
281  return not_used;
282 }
283 
284 
286  const CRgbaColor& /*color*/)
287 {
288 }
289 
290 
292 {
293  return fBackground;
294 }
295 
296 
298  EColorType type) const
299 {
300  int size = (int)m_ColorTable.GetSize();
301  _ASSERT(size >= 0);
302 
303  if(type == fBackground) {
304  int index = (int) floor(score * size);
305  index = min(index, size - 1);
306  return m_ColorTable[index];
307  } else {
308  _ASSERT(false); // not supported
309  return m_ColorTable[0];
310  }
311 }
312 
313 /* this is en example of how to define a method-specifc menu
314 static
315 WX_DEFINE_MENU(SimpleScoringMenu)
316  WX_MENU_ITEM(eCmd1, "Item 1")
317  WX_MENU_ITEM(eCmd 2, "Item 2")
318 WX_END_MENU()
319 */
320 
322 {
323  /* this is an example of how method can provide a menu
324  if(! m_Menu.get()) {
325  m_Menu.reset(CreateMenuItems(SimpleScoringMenu));
326  }*/
327  return m_Menu.get();
328 }
329 
330 
332 {
333  return true;
334 }
335 
336 class CSimpleScoringPanel : public wxPanel
337 {
338  DECLARE_EVENT_TABLE()
339 public:
340  CSimpleScoringPanel(CSimpleScoringMethod& method, wxWindow* parent, wxWindowID id = wxID_ANY);
341 protected:
342  void CreateControls();
343  void Init();
344  void OnApply ( wxCommandEvent& event );
347 // data members
348  bool m_Space;
349  bool m_Gap;
350 };
351 
352 BEGIN_EVENT_TABLE( CSimpleScoringPanel, wxPanel )
353  EVT_BUTTON( wxID_APPLY, CSimpleScoringPanel::OnApply )
355 
357  CSimpleScoringMethod& method, wxWindow* parent, wxWindowID id) :
358  m_Method(method), m_GradPanel()
359 {
360  Init();
361  Create(parent, id);
362  CreateControls();
363 }
364 
366 {
367  int options = m_Method.GetOptions();
369  m_Gap = (options & CSimpleScoringMethod::fIgnoreGaps) != 0;
370 }
371 
373 {
374  wxBoxSizer* itemBoxSizer1 = new wxBoxSizer(wxVERTICAL);
375  this->SetSizer(itemBoxSizer1);
376 
378  params.m_FirstColor = m_Method.m_Worst;
379  params.m_LastColor = m_Method.m_Best;
381  params.m_ThreeColors = false;
382  params.m_Reversable = true;
383 
384  m_GradPanel = new CGradientColorPanel(params, this);
385  itemBoxSizer1->Add(m_GradPanel, 1, wxGROW|wxALL, 5);
386 
387  wxCheckBox* itemCheckBox1 = new wxCheckBox(this, wxID_ANY, _("Ignore Empty Space"));
388  itemCheckBox1->SetValidator(wxGenericValidator(&m_Space));
389  itemBoxSizer1->Add(itemCheckBox1, 0, wxALIGN_LEFT|wxALL, 5);
390 
391  wxCheckBox* itemCheckBox2 = new wxCheckBox(this, wxID_ANY, _("Ignore Gaps"));
392  itemCheckBox2->SetValidator(wxGenericValidator(&m_Gap));
393  itemBoxSizer1->Add(itemCheckBox2, 0, wxALIGN_LEFT|wxALL, 5);
394 }
395 
396 void CSimpleScoringPanel::OnApply ( wxCommandEvent& event )
397 {
398  wxUnusedVar(event);
399 
401  m_GradPanel->GetParams(params);
402  m_Method.m_Worst = params.m_FirstColor;
403  m_Method.m_Best = params.m_LastColor;
404 
405  int options = 0;
408  m_Method.SetOptions(options);
409 
411 }
412 
414 {
415  return new CSimpleScoringPanel(*this, parent);
416 }
417 
418 ///////////////////////////////////////////////////////////////////////////////
419 /// CSNPScoringMethod
420 ///
421 
424  m_UndefColor(0.8f, 0.8f, 1.0f),
425  m_NoScores(false)
426 {
427 }
428 
429 
432  m_UndefColor(orig.m_UndefColor)
433 {
434 }
435 
436 
438 {
439  return new CSNPScoringMethod(*this);
440 }
441 
442 
444 {
445  return "Show Differences";
446 }
447 
448 
449 #define SNP_DESCR "This method highlights differences observed from the master \
450 sequence in an alignment. In order to see any coloration with this scheme, \
451 you must select a master sequence. You can adjust the master sequence \
452 on the fly and display differences by selecting a new master from the context menu.";
453 
455 {
456  return SNP_DESCR;
457 }
458 
459 
460 const static float kSameBase = 1.0f; // base is the same as consensus
461 const static float kSNP = 0.0f; // base is different (SNP)
462 const static float kUndef = -1.0f; // consensus is not specified
463 
464 
465 void CSNPScoringMethod::CalculateScores(char cons, const string& column,
466  TScore& /*col_score*/, TScoreVector& scores)
467 {
468  _ASSERT(scores.size() == column.size());
469  /**
470  _ASSERT(cons != 0);
471 
472  for( size_t i = 0; i < column.size(); i++ ) {
473  char c = column[i];
474  bool same = (c == cons) || (c == m_Gap) || (c == m_Space);
475  scores[i] = same ? kSameBase : kSNP;
476  }
477  **/
478  if(cons == 0) {
479  fill(scores.begin(), scores.end(), kUndef);
480  } else {
481  for( size_t i = 0; i < column.size(); i++ ) {
482  char c = column[i];
483  if (c == m_AmbiguousResidue) {
485  } else {
486  bool same = mf_CompareResidue(cons, c) || (c == m_Gap) || (c == m_Space);
487  scores[i] = same ? kSameBase : kSNP;
488  }
489  }
490  }
491 
492 }
493 
495 {
496  return fBackground;
497 }
498 
499 
501 {
502  return true;
503 }
504 
505 
507 {
509  return m_UndefColor;
510 }
511 
512 
514  const CRgbaColor& color)
515 {
518 }
519 
520 
522  EColorType type) const
523 {
524  if(score < 0) {
525  return m_UndefColor;
526  } else {
528  }
529 }
530 
531 
533 {
534  return m_Menu.get();
535 }
536 
537 
539 {
540  return true;
541 }
542 
543 ///////////////////////////////////////////////////////////////////////////////
544 /// CSNPScoringPanel
545 
546 class CSNPScoringPanel : public wxPanel
547 {
548  DECLARE_EVENT_TABLE()
549 public:
550  CSNPScoringPanel(CSNPScoringMethod& method, wxWindow* parent, wxWindowID id = wxID_ANY);
551 protected:
552  void CreateControls();
553  void Init();
554  void OnApply ( wxCommandEvent& event );
556 // data members
557  bool m_Space;
558  bool m_Gap;
559 };
560 
561 BEGIN_EVENT_TABLE( CSNPScoringPanel, wxPanel )
562  EVT_BUTTON( wxID_APPLY, CSNPScoringPanel::OnApply )
564 
566  CSNPScoringMethod& method, wxWindow* parent, wxWindowID id) :
567  m_Method(method)
568 {
569  Init();
570  Create(parent, id);
571  CreateControls();
572 }
573 
575 {
576  int options = m_Method.GetOptions();
578  m_Gap = (options & CSimpleScoringMethod::fIgnoreGaps) != 0;
579 }
580 
582 {
583  wxBoxSizer* itemBoxSizer1 = new wxBoxSizer(wxVERTICAL);
584  this->SetSizer(itemBoxSizer1);
585 
586  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
587 
588  wxColourPickerCtrl* itemColorPicker1 = new wxColourPickerCtrl(this, wxID_ANY);
589  itemColorPicker1->SetValidator(CColorPickerValidator(&m_Method.m_UndefColor));
590  itemBoxSizer2->Add(itemColorPicker1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
591  itemBoxSizer2->Add(new wxStaticText(this, wxID_STATIC, _("Neutral (no master specified)")),
592  0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
593  itemBoxSizer1->Add(itemBoxSizer2, 0, wxALIGN_LEFT|wxALL, 0);
594 
595  itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
596  wxColourPickerCtrl* itemColorPicker2 = new wxColourPickerCtrl(this, wxID_ANY);
597  itemColorPicker2->SetValidator(CColorPickerValidator(&m_Method.m_Worst));
598  itemBoxSizer2->Add(itemColorPicker2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
599  itemBoxSizer2->Add(new wxStaticText(this, wxID_STATIC, _("SNP")),
600  0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
601  itemBoxSizer1->Add(itemBoxSizer2, 0, wxALIGN_LEFT|wxALL, 0);
602 
603  itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
604  wxColourPickerCtrl* itemColorPicker3 = new wxColourPickerCtrl(this, wxID_ANY);
605  itemColorPicker3->SetValidator(CColorPickerValidator(&m_Method.m_Best));
606  itemBoxSizer2->Add(itemColorPicker3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
607  itemBoxSizer2->Add(new wxStaticText(this, wxID_STATIC, _("Normal")),
608  0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
609  itemBoxSizer1->Add(itemBoxSizer2, 0, wxALIGN_LEFT|wxALL, 0);
610 
611  wxCheckBox* itemCheckBox1 = new wxCheckBox(this, wxID_ANY, _("Ignore Empty Space"));
612  itemCheckBox1->SetValidator(wxGenericValidator(&m_Space));
613  itemBoxSizer1->Add(itemCheckBox1, 0, wxALIGN_LEFT|wxALL, 5);
614 
615  wxCheckBox* itemCheckBox2 = new wxCheckBox(this, wxID_ANY, _("Ignore Gaps"));
616  itemCheckBox2->SetValidator(wxGenericValidator(&m_Gap));
617  itemBoxSizer1->Add(itemCheckBox2, 0, wxALIGN_LEFT|wxALL, 5);
618 }
619 
620 void CSNPScoringPanel::OnApply ( wxCommandEvent& event )
621 {
622  wxUnusedVar(event);
623 
624  int options = 0;
627  m_Method.SetOptions(options);
628 }
629 
630 wxWindow* CSNPScoringMethod::CreatePropertiesPanel(wxWindow* parent)
631 {
632  return new CSNPScoringPanel(*this, parent);
633 }
634 
635 
636 ///////////////////////////////////////////////////////////////////////////////
637 /// CTestSeqBasedMethod
638 
640 {
642 }
643 
644 
646 {
647  return new CTestSeqBasedMethod();
648 }
649 
650 
652 {
653  m_vColors.resize(5);
654  m_vColors[0] = CRgbaColor(1.0f, 1.0f, 1.0f);
655  m_vColors[1] = CRgbaColor(1.0f, 0.8f, 0.8f);
656  m_vColors[2] = CRgbaColor(0.8f, 1.0f, 0.8f);
657  m_vColors[3] = CRgbaColor(0.8f, 0.8f, 1.0f);
658  m_vColors[4] = CRgbaColor(0.6f, 1.0f, 1.0f);
659 }
660 
661 
663 {
664  return "Test Sequence-based";
665 }
666 
667 
669 {
670  return "";
671 }
672 
673 
675 {
676  return IAlnExplorer::fDNA;
677 }
678 
679 
681 {
682  return false;
683 }
684 
685 
687  const IScoringAlignment& aln,
688  TScoreColl& scores)
689 {
691  string buf;
692  aln.GetAlnSeqString(row, buf, range);
693 
694  scores.SetFrom(range.GetFrom());
695 
696  size_t color_index = 0;
697  for( int i = 0; i < range.GetLength(); i++ ) {
698  switch(buf[i]) {
699  case 'A':
700  case 'a':
701  color_index = 1;
702  break;
703 
704  case 'C':
705  case 'c':
706  color_index = 2;
707  break;
708 
709  case 'T':
710  case 't':
711  color_index = 3;
712  break;
713 
714  case 'G':
715  case 'g':
716  color_index = 4;
717  break;
718 
719  default:
720  color_index = 0;
721  break;
722  }
723  scores.push_back((TScore) color_index, (int) 1);
724  }
725 }
726 
727 
729 {
730  return fBackground;
731 }
732 
733 
735  EColorType type) const
736 {
737  _VERIFY(type == fBackground); // the only type supported
738 
739  size_t index = (size_t) score;
740  _ASSERT(index < m_vColors.size());
741  return m_vColors[index];
742 }
743 
744 
746 {
748  return m_NoScoreColor;
749 }
750 
751 
753 {
754  wxUnusedVar(type);
755  wxUnusedVar(color);
756 }
757 
758 
759 
760 
761 ///////////////////////////////////////////////////////////////////////////////
762 /// CNonSynonymousScoringMethod
763 ///
765 {
766  x_Init();
767 }
768 
769 
771 {
772 
773 }
774 
775 
777 {
778  m_ColumnCount = 0;
779  // m_Colors[eMismatch] = { 255, 231, 198 }; // original FLU viewer yellowish
780  m_Colors[eMismatch] = { 255, 0, 0 };
781 
782  m_Colors[eMatch] = { 204, 204, 204 };
785 
788 
789 }
790 
791 
793  : m_ColumnCount(0), m_SequenceLevel(orig.m_SequenceLevel)
794 {
795  for (auto i = 0; i < EColors::eLast; ++i)
796  m_Colors[i] = orig.m_Colors[i];
797  m_ColorTable = orig.m_ColorTable;
798 }
799 
800 
802 {
803  return new CNonSynonymousScoringMethod(*this);
804 }
805 
806 
808 {
809  return "Nonsynonymous substitutions";
810 }
811 
812 const string CNONSYNONYMOUS_METHOD_DESCR = R"foo(All triplets with nonsynonymous substitutions are colored in red.
813 Note: nonsynonymous substitution coloring is available only for CDS alignments.
814 Any sequence in alignment or pre-calculated consensus with only ACGT letters can be set as a master.)foo";
815 
816 
818 {
820 }
821 
822 
824 {
825  return IAlnExplorer::fDNA;
826 }
827 
828 
830  TScore& col_score, TScoreVector& scores)
831 {
832  if (cons == 0) {
833  fill(scores.begin(), scores.end(), -1.);
834  } else {
835  for (size_t i = 0; i < column.size(); i++) {
836  bool same = (column[i] == cons);
837  if (same) {
838  scores[i] = m_SequenceLevel && m_ColumnCount % 2 != 0 ? kSameBase * 0.5 : kSameBase;
839  } else {
840  scores[i] = kSNP;
841  }
842  }
843  m_ColumnCount++;
844  }
845 }
846 
847 
849 {
850  return fBackground;
851 
852 }
853 
855 {
856 
857  if (m_SequenceLevel) {
858  if (score == kSNP)
859  return m_Colors[eMismatch];
860  if (score == kSameBase * 0.5)
861  return m_Colors[eMatchLight];
862  return m_Colors[eMatch];
863  }
864 
865  int size = (int)m_ColorTable.GetSize();
866  _ASSERT(size >= 0);
867  int index = (int) floor(score * size);
868  index = min(index, size - 1);
869  return m_ColorTable[index];
870 }
871 
873 {
874  static CRgbaColor not_used;
875  _ASSERT(false);
876  return not_used;
877 }
878 
879 
881  const CRgbaColor& /*color*/)
882 {
883 }
884 
void GetParams(stParams &params) const
CMenuItem - represents a menu items in IMenu-style menus.
Definition: menu_item.hpp:53
CNonSynonymousScoringMethod - implementation of IScoringMethod.
CRgbaGradColorTable m_ColorTable
virtual string GetName() const override
returns unique name of the method that is used in UI to identify it
virtual int GetType() const override
returns combination of EAlignType flags defining types of alignments that can be colored with this me...
virtual int GetSupportedColorTypes() const override
returns a combination of EColorType flags
virtual string GetDescription() const override
returns a detailed description of the method that is used in UI
virtual void CalculateScores(char cons, const string &column, TScore &col_score, TScoreVector &scores) override
virtual const CRgbaColor & GetColorForNoScore(EColorType type) const override
Call for display colors when CanCalculateScores returns false.
virtual const CRgbaColor & GetColorForScore(TScore score, EColorType type) const override
returns a color corresponding to a given score value.
CNonSynonymousScoringMethod()
CNonSynonymousScoringMethod.
virtual IUITool * Clone() const override
virtual void SetColorForNoScore(EColorType type, const CRgbaColor &color) override
CRgbaColor m_Colors[EColors::eLast]
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CSNPScoringMethod.
virtual string GetDescription() const
returns a detailed description of the method that is used in UI
virtual IUITool * Clone() const
virtual int GetSupportedColorTypes() const
returns a combination of EColorType flags
friend class CSNPScoringPanel
virtual bool HasPropertiesPanel() const
returns true if the method supports properties dialog
virtual bool CanCalculateScores(const IScoringAlignment &aln)
Do we have what it takes to calculate scores? e.g. a master row selected?
virtual const CMenuItem * GetMenu()
Returns a pointer to the submenu.
virtual const CRgbaColor & GetColorForNoScore(EColorType type) const
Call for display colors when CanCalculateScores returns false.
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)
CSNPScoringMethod()
CSNPScoringMethod.
virtual wxWindow * CreatePropertiesPanel(wxWindow *parent)
This a factory method that shall produce a CPropertiesPanel representing properties of the method; th...
virtual string GetName() const
returns unique name of the method that is used in UI to identify it
virtual void SetColorForNoScore(EColorType type, const CRgbaColor &color)
CSNPScoringPanel.
void OnApply(wxCommandEvent &event)
CSNPScoringPanel(CSNPScoringMethod &method, wxWindow *parent, wxWindowID id=wxID_ANY)
CSNPScoringMethod & m_Method
CSimpleScoringMethod - trivial implementation of IScoringMethod.
virtual IUITool * Clone() const
virtual void CalculateScores(char cons, const string &column, TScore &col_score, TScoreVector &scores)
friend class CSimpleScoringPanel
CSimpleScoringMethod()
CSimpleScoringMethod.
virtual int GetType() const
returns combination of EAlignType flags defining types of alignments that can be colored with this me...
unique_ptr< CMenuItem > m_Menu
virtual wxWindow * CreatePropertiesPanel(wxWindow *parent)
This a factory method that shall produce a CPropertiesPanel representing properties of the method; th...
CRgbaGradColorTable m_ColorTable
virtual bool CanCalculateScores(const IScoringAlignment &aln)
Do we have what it takes to calculate scores? e.g. a master row selected?
virtual string GetDescription() const
returns a detailed description of the method that is used in UI
virtual bool IsAverageable() const
return "true" if scores could be averaged
virtual const CRgbaColor & GetColorForNoScore(EColorType type) const
Call for display colors when CanCalculateScores returns false.
CRgbaColor m_Worst
combination of EOptions flags
void SetOptions(int options)
virtual void SetColorForNoScore(EColorType type, const CRgbaColor &color)
void x_Init(int colors)
vector< int > m_vCharCounts
char m_Space
histogramm of characters
virtual string GetName() const
returns unique name of the method that is used in UI to identify it
void CreateColorTable(int size)
virtual const CMenuItem * GetMenu()
Returns a pointer to the submenu.
virtual bool HasPropertiesPanel() const
returns true if the method supports properties dialog
virtual int GetSupportedColorTypes() const
returns a combination of EColorType flags
virtual const CRgbaColor & GetColorForScore(TScore score, EColorType type) const
returns a color corresponding to a given score value.
void OnApply(wxCommandEvent &event)
CSimpleScoringMethod & m_Method
CGradientColorPanel * m_GradPanel
CSimpleScoringPanel(CSimpleScoringMethod &method, wxWindow *parent, wxWindowID id=wxID_ANY)
int GetType() const
returns combination of EAlignType flags defining types of alignments that can be colored with this me...
virtual void CalculateScores(IAlnExplorer::TNumrow row, const IScoringAlignment &aln, TScoreColl &scores)
virtual int GetSupportedColorTypes() const
returns a combination of EColorType flags
CTestSeqBasedMethod()
CTestSeqBasedMethod.
virtual const CRgbaColor & GetColorForScore(TScore score, EColorType type) const
returns a color corresponding to a given score value.
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
virtual const CRgbaColor & GetColorForNoScore(IScoringMethod::EColorType type) const
Call for display colors when CanCalculateScores returns false.
vector< CRgbaColor > m_vColors
virtual void SetColorForNoScore(IScoringMethod::EColorType type, const CRgbaColor &color)
virtual bool IsAverageable() const
return "true" if scores could be averaged
virtual IUITool * Clone() const
virtual void UpdateSettings(const IScoringAlignment &aln)
Set alignment specifi settings.
std::function< bool(char c, char b)> mf_CompareResidue
char m_AmbiguousResidue
Ambiguous Residue, typically 'N' for nucleotides, 'X' for proteins.
static const int kAmbiguousResidueScore
IScoringAlignment.
virtual TSeqPos GetAlnStart() const =0
virtual IAlnExplorer::EAlignType GetAlignType() const =0
virtual TSeqPos GetAlnStop() const =0
virtual string & GetAlnSeqString(IAlnExplorer::TNumrow row, string &buffer, const IAlnExplorer::TSignedRange &aln_range) const =0
vector< TScore > TScoreVector
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
static const Colors colors
Definition: cn3d_colors.cpp:50
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define _(proto)
Definition: ct_nlmzip_i.h:78
#define false
Definition: bool.h:36
static void Init(void)
Definition: cursor6.c:76
static const char * column
Definition: stats.c:23
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define _VERIFY(expr)
Definition: ncbidbg.hpp:161
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
void SetFrom(TSeqPos start)
void Set(float r, float g, float b)
set the color from an Fl_Color
Definition: rgba_color.cpp:226
void Lighten(float scale)
Definition: rgba_color.cpp:463
void push_back(const attr_type &attr)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
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
END_EVENT_TABLE()
char * buf
int i
range(_Ty, _Ty) -> range< _Ty >
const struct ncbi::grid::netcache::search::fields::SIZE size
T min(T x_, T y_)
static static static wxID_ANY
static const float kUndef
#define SIMPLE_DESCR
const string CNONSYNONYMOUS_METHOD_DESCR
static bool s_CompareBases(char consensus, char base)
static bool s_CompareResidues(char consensus, char residue)
static const float kSNP
static const int kDefGradientSize
static const float kSameBase
#define SNP_DESCR
#define row(bind, expected)
Definition: string_bind.c:73
Definition: type.c:6
#define _ASSERT
Modified on Sun Jun 23 05:20:08 2024 by modify_doxy.py rev. 669887