42 #include "wx/valgen.h"
43 #include "wx/choice.h"
44 #include "wx/checkbox.h"
52 : m_Space(0), m_Gap(0)
64 : m_Options(0), m_Space(0), m_Gap(0)
81 : m_Worst(
orig.m_Worst),
83 m_Options(
orig.m_Options),
84 m_Space(
orig.m_Space),
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."
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) {
167 double quality_score = 0;
168 for (
size_t i = 0;
i <
column.size(); ++
i) {
175 double score_sq_sum = 0;
176 for (
size_t r = 0;
r < symbols.size(); ++
r) {
178 score_sq_sum += score_diff * score_diff;
182 scores[
i] = resid_score;
184 quality_score += resid_score;
188 col_score = (
TScore) (quality_score / column_size);
191 for (
size_t i = 0;
i <
column.size(); ++
i) {
196 scores[
i] = col_score;
236 if (score < 0.0) score = 0.0;
239 int index = (
int) floor(score *
size);
265 DECLARE_EVENT_TABLE()
271 void OnApply ( wxCommandEvent& event );
287 m_MatrixChoice(), m_GradPanel()
303 wxBoxSizer* itemBoxSizer1 =
new wxBoxSizer(wxVERTICAL);
304 this->SetSizer(itemBoxSizer1);
314 itemBoxSizer1->Add(
m_GradPanel, 1, wxGROW|wxALL, 5);
320 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxHORIZONTAL);
321 itemBoxSizer1->Add(itemBoxSizer2, 0, wxALIGN_RIGHT|wxALL, 5);
323 itemBoxSizer2->Add(
new wxStaticText(
this, wxID_STATIC,
_(
"Substitution matrix:")),
324 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
327 itemBoxSizer2->Add(
m_MatrixChoice, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
331 ITERATE(vector<string>, iter, table_names) {
337 if (!matrix_name.empty()) {
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);
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);
369 if (!matrix_name.empty()) {
404 return "Column Quality score - DNA";
471 return "Column Quality score - Protein";
536 m_Worst = {30, 144, 255, 255 };
537 m_Best = { 255, 26, 26, 255 };
546 m_ConservedOption(
orig.m_ConservedOption),
547 m_NotScored(
orig.m_NotScored)
571 return "Conservation";
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";
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;
620 const double* std_prob)
625 for (
size_t i = 1;
i < counts.size();
i++) {
626 if (counts[
i] == 0) {
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);
647 for (
size_t i = 1;
i < counts.size();
i++) {
648 if (counts[
i] > 0 && counts[
i] < num_rows) {
651 if (counts[
i] == num_rows) {
661 const double* std_prob)
const
668 double bit_threshold = 0.0;
670 case eOneBit: bit_threshold = 1.0;
break;
671 case eTwoBits: bit_threshold = 2.0;
break;
673 case eFourBits: bit_threshold = 4.0;
break;
694 residue_counts[residue]++;
704 fill(scores.begin(), scores.end(), col_score);
730 int index = (
int)floor(score *
size);
753 if (opt.second == l_name) {
758 ERR_POST(
"Invalid conservation setting:\"" << name <<
"\"");
767 DECLARE_EVENT_TABLE()
773 void OnApply(wxCommandEvent& event);
785 m_ConservedOptionChoice(),
799 wxBoxSizer* itemBoxSizer1 =
new wxBoxSizer(wxVERTICAL);
800 this->SetSizer(itemBoxSizer1);
810 itemBoxSizer1->Add(
m_GradPanel, 1, wxGROW | wxALL, 5);
812 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxHORIZONTAL);
813 itemBoxSizer1->Add(itemBoxSizer2, 0, wxALIGN_RIGHT | wxALL, 5);
815 itemBoxSizer2->Add(
new wxStaticText(
this, wxID_STATIC,
_(
"Conservation Setting:")),
816 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
822 s.Replace(
wxT(
"_"),
wxT(
" "));
823 s[0] = wxToupper(s[0]);
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.
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 ~CConservationScoringMethod()
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
EOptions m_ConservedOption
virtual string GetDescription() const
returns a detailed description of the method that is used in UI
friend class CConservationScoringPanel
CConservationScoringPanel.
CConservationScoringPanel(CConservationScoringMethod &method, wxWindow *parent, wxWindowID id=wxID_ANY)
void OnApply(wxCommandEvent &event)
CConservationScoringMethod & m_Method
CGradientColorPanel * m_GradPanel
wxChoice * m_ConservedOptionChoice
void GetParams(stParams ¶ms) const
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 ~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...
virtual ~CQualityScoringMethodNA()
CQualityScoringMethod - Like CSimpleScoringMethod, in that it calculate the quality of the alignment ...
virtual ~CQualityScoringMethod()
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 OnApply(wxCommandEvent &event)
CQualityScoringPanel(CQualityScoringMethod &method, wxWindow *parent, wxWindowID id=wxID_ANY)
wxChoice * m_MatrixChoice
CQualityScoringMethod & m_Method
CGradientColorPanel * m_GradPanel
class CRgbaColor provides a simple abstraction for managing colors.
char m_AmbiguousResidue
Ambiguous Residue, typically 'N' for nucleotides, 'X' for proteins.
static const int kAmbiguousResidueScore
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
static const Colors colors
static const char * column
const Uint1 AMINOACID_TO_NCBISTDAA[]
Translates between ncbieaa and ncbistdaa.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
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)
static vector< string > AllTableNames()
void Set(float r, float g, float b)
set the color from an Fl_Color
static string TableToName(const SNCBIPackedScoreMatrix *)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string & ToLower(string &str)
Convert string to lower case – string& version.
unsigned int
A callback function used to compare two keys in a database.
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
const struct ncbi::grid::netcache::search::fields::SIZE size
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
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
#define NCBI_FSM_DIM
Recommended approach: unpack and index directly.
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...
static const char * kMaxScore
const char * symbols
order of residues
wxString ToWxString(const string &s)
string ToStdString(const wxString &s)