vector<double>& seq1_probs,
63 constvector<double>& seq2_probs)
75: m_GapOpening(options.m_GapOpening),
76m_GapExtension(options.m_GapExtension),
77m_LambdaAccuracy(options.m_LambdaAccuracy),
78m_KAccuracy(options.m_KAccuracy),
79m_ScoreMatrix(options.m_ScoreMatrix),
80m_Seq1ResidueProbs(options.m_Seq1ResidueProbs),
81m_Seq2ResidueProbs(options.m_Seq2ResidueProbs),
82m_NumResidues(options.m_NumResidues),
83m_MaxCalcTime(options.m_MaxCalcTime),
84m_MaxCalcMemory(options.m_MaxCalcMemory)
94 "Length of residue probabilities for both sequences do " 100 "Length of residue probabilities does not match number " 104 doublesum_probs_seq1 = 0.0;
108 "Negative probability value for sequence 1");
110sum_probs_seq1 += *it;
112 if(
fabs(1.0 - sum_probs_seq1) > 1e-10) {
114 "The sum of probability values does not equal 1");
117 doublesum_probs_seq2 = 0.0;
121 "Negative probability value for sequence 2");
123sum_probs_seq2 += *it;
125 if(
fabs(1.0 - sum_probs_seq2) > 1e-10) {
127 "The sum of probability values does not equal 1");
132 "Negative gap opening penalty");
137 "Negative gap extention penalty");
142 "Non-positive accuracy for lambda");
147 "Non-positive accuracy for K");
152 "Non-positive max calc time");
157 "Non-positive maximum memory");
162 "Gap opening or extension too large");
169 "Score matrix entry too large");
177 if(m_LambdaAccuracy < 0.001 || m_LambdaAccuracy > 0.01) {
178 m_Messages.push_back(
"The algorithm is designed for lambda accuracy" 179 " between 0.001 -- 0.01. Values outside this range" 180 " may cause increased bias or variance of" 181 " estimated parameter lambda");
185 if(m_KAccuracy < 0.005 || m_KAccuracy > 0.05) {
186 m_Messages.push_back(
"The algorithm is designed for K accuracy" 187 " between 0.005 -- 0.05. Values outside this range" 188 " may cause increased bias or variance of" 189 " estimated parameter K");
195 m_Messages.push_back(
"The maximum calculation time may be too small" 196 " and lead to inaccurate results. The suggested" 197 " maximum calculation time is at least 1s.");
202 m_Messages.push_back(
"The maximum allowed memory may be too small" 203 " and lead to inaccurate results. The suggsets" 204 " maximum allowed memory is at least 1Mb");
245 const size_tkNumResidues = 20;
251probs[ 0 ] = 0.07805 ;
252probs[ 1 ] = 0.05129 ;
253probs[ 2 ] = 0.04487 ;
254probs[ 3 ] = 0.05364 ;
255probs[ 4 ] = 0.01925 ;
256probs[ 5 ] = 0.04264 ;
257probs[ 6 ] = 0.06295 ;
258probs[ 7 ] = 0.07377 ;
259probs[ 8 ] = 0.02199 ;
260probs[ 9 ] = 0.05142 ;
261probs[ 10 ] = 0.09019 ;
262probs[ 11 ] = 0.05744 ;
263probs[ 12 ] = 0.02243 ;
264probs[ 13 ] = 0.03856 ;
265probs[ 14 ] = 0.05203 ;
266probs[ 15 ] = 0.0712 ;
267probs[ 16 ] = 0.05841 ;
268probs[ 17 ] = 0.0133 ;
269probs[ 18 ] = 0.03216 ;
270probs[ 19 ] = 0.06441 ;
311: m_Options(options), m_RandParams(rand)
315 template<
typenameT>
318 out.resize(
in.size());
326 Int4number_of_aa = -1;
330 doublecurrent_time1;
331 doublecurrent_time2;
332Sls::alp_data::get_current_time(current_time1);
343 doublegapless_time_portion = 0.5;
347 const double* background_probabilities1
350 const double* background_probabilities2
358gapless_calc_time *= gapless_time_portion;
361Njn::LocalMaxStatMatrix local_max_stat_matrix(number_of_aa,
363background_probabilities1,
364background_probabilities2,
368 if(local_max_stat_matrix.getTerminated()) {
369 throwSls::error(
"Please increase maximum allowed calculation time.",
374 doublecalculation_error = 1e-6;
376gumbel_params.
gapless_alpha= local_max_stat_matrix.getAlpha();
379gumbel_params.
gapless_a= local_max_stat_matrix.getA();
387gumbel_params.
lambda= local_max_stat_matrix.getLambda ();
390gumbel_params.
K= local_max_stat_matrix.getK ();
391gumbel_params.
K_error= calculation_error;
393gumbel_params.
C= local_max_stat_matrix.getC ();;
394gumbel_params.
C_error= calculation_error;
406gumbel_params.
ai_error= calculation_error;
409gumbel_params.
aj_error= calculation_error;
411Sls::alp_data::get_current_time(current_time2);
412 result->SetCalcTime(current_time2 - current_time1);
418sbs_arrays.
K_sbs.resize(2);
419sbs_arrays.
K_sbs[0]=gumbel_params.
K;
420sbs_arrays.
K_sbs[1]=gumbel_params.
K+calculation_error;
422sbs_arrays.
C_sbs.resize(2);
423sbs_arrays.
C_sbs[0]=gumbel_params.
C;
424sbs_arrays.
C_sbs[1]=gumbel_params.
C+calculation_error;
428sbs_arrays.
sigma_sbs[1]=gumbel_params.
sigma+ calculation_error;
438sbs_arrays.
ai_sbs.resize(2);
439sbs_arrays.
ai_sbs[0]=gumbel_params.
ai;
440sbs_arrays.
ai_sbs[1]=gumbel_params.
ai+ calculation_error;
442sbs_arrays.
aj_sbs.resize(2);
443sbs_arrays.
aj_sbs[0]=gumbel_params.
aj;
444sbs_arrays.
aj_sbs[1]=gumbel_params.
aj+ calculation_error;
457 doublecurrent_time_gapless_preliminary;
458Sls::alp_data::get_current_time(current_time_gapless_preliminary);
459 doublegapless_preliminary_time =
460current_time_gapless_preliminary - current_time1;
465data_obj.d_max_time =
466Sls::alp_data::Tmax((1.0 - gapless_time_portion)
467* data_obj.d_max_time,data_obj.d_max_time
468- gapless_preliminary_time);
470Sls::alp_sim sim_obj(&data_obj);
474gumbel_params.
lambda= sim_obj.m_Lambda;
477gumbel_params.
K= sim_obj.m_K;
478gumbel_params.
K_error= sim_obj.m_KError;
480gumbel_params.
C= sim_obj.m_C;
481gumbel_params.
C_error= sim_obj.m_CError;
483gumbel_params.
sigma= sim_obj.m_Sigma;
486gumbel_params.
alpha_i= sim_obj.m_AlphaI;
489gumbel_params.
alpha_j= sim_obj.m_AlphaJ;
492gumbel_params.
ai= sim_obj.m_AI;
493gumbel_params.
ai_error= sim_obj.m_AIError;
495gumbel_params.
aj= sim_obj.m_AJ;
496gumbel_params.
aj_error= sim_obj.m_AJError;
498Sls::alp_data::get_current_time(current_time2);
499 result->SetCalcTime(current_time2 - current_time1);
517sim_obj.d_alp_data->d_rand_all->d_random_factor);
519vector<Int4>& fsprelim_numbers
523->d_first_stage_preliminary_realizations_numbers_ALP,
526vector<Int4>& prelim_numbers
530->d_preliminary_realizations_numbers_ALP,
533vector<Int4>& prelim_numbers_killing
537->d_preliminary_realizations_numbers_killing,
538prelim_numbers_killing);
541->d_total_realizations_number_with_ALP);
544sim_obj.d_alp_data->d_rand_all
545->d_total_realizations_number_with_killing);
549 catch(Sls::error er) {
551 switch(er.error_code) {
553(
string)
"Time or memory limit exceeded.");
556(
string)
"The program could not estimate the " 557 "parameters. Please repeat calculation");
560(
string)
"Results cannot be computed for the " 561 "provided parameters. "+ er.st);
564(
string)
"Memory allocation error");
568(
string)
"Unexpected error");
Score matrix that can take any value.
Int4 GetScore(Uint4 i, Uint4 j) const
Get score matrix entry for at specified position.
unsigned int GetNumResidues(void) const
Get number of residues.
EScoreMatrixName
Names of standard scoring matrices.
CRef< CGumbelParamsResult > m_Result
CConstRef< CGumbelParamsOptions > m_Options
CRef< CGumbelParamsResult > Run(void)
Perform Gumbel parameter calculation.
CRef< CGumbelParamsRandDiagnostics > m_RandParams
CGumbelParamsCalc(const CRef< CGumbelParamsOptions > &opts)
Create calculation object with given options.
static CRef< CGumbelParamsOptions > CreateStandard20AAOptions(CGeneralScoreMatrix::EScoreMatrixName smat=CGeneralScoreMatrix::eBlosum62)
Creates standard options with score matrix and residue frequenceis for 20 aa alphabet.
static CRef< CGumbelParamsOptions > CreateBasicOptions(void)
Creates standard options with no score matrix or resiudie frequencies.
Input parameters for Gumbel parameters calculation.
void SetSeq2ResidueProbs(const TFrequencies &probs)
Set residue probabilities for sequence 2.
void SetLambdaAccuracy(double lambda_err)
Set relative error threshold for lambda parameter calculation for gapped aligmment.
bool Validate(void)
Validate parameter values.
const TFrequencies & GetSeq2ResidueProbs(void) const
Get sequence 2 residue probabilities.
CGumbelParamsOptions(void)
Create empty options object.
bool m_IsGapped
Gapped/gapless regime, true for gapped, false for gapless.
void SetGapExtension(Int4 g_exten)
Set gap extention penalty.
vector< double > TFrequencies
const TFrequencies & GetSeq1ResidueProbs(void) const
Get sequence 1 residue probabilities.
CConstRef< CGeneralScoreMatrix > m_ScoreMatrix
Scoring matrix.
void SetGapped(bool gapped)
Set gapped/gapless regime.
double m_KAccuracy
Desired accuracy for parameter K computation only for gapped alignment.
void SetMaxCalcTime(double time)
Set maximum calculation time allowed.
double m_MaxCalcTime
Maximum allowed calculation time.
double GetMaxCalcTime(void) const
Get maximum calculation time allowed.
double m_MaxCalcMemory
Maximum allowed calculation memory.
void SetKAccuracy(double k_err)
Set relative error threshold for K parameter calculation for gapped alignment.
Int4 m_GapOpening
Gap opening penalty.
Int4 GetGapOpening(void) const
Get gap opening penalty.
Int4 GetNumResidues(void) const
Get number of residues in utilized alphabet.
bool GetGapped(void) const
Get gapped/gapless regime.
const Int4 ** GetScoreMatrix(void) const
Get score matrix.
void SetGapOpening(Int4 g_open)
Set the value of gap opening penalty.
Int4 m_NumResidues
Number of residues in alphabet.
void SetMaxCalcMemory(double mem)
Set maximum memory allowed for computation.
void SetScoreMatrix(const CGeneralScoreMatrix &smatrix)
Set score matrix.
TFrequencies m_Seq2ResidueProbs
Residue frequencies for sequence 2.
void SetSeq1ResidueProbs(const TFrequencies &probs)
Set residue probabilities for sequence 1.
Int4 GetGapExtension(void) const
Get gap extention penalty.
double m_LambdaAccuracy
Desired accuracy for lambda computation only for gapped aligmment.
vector< string > m_Messages
Warning messages.
Int4 m_GapExtension
Gap extension penalty.
TFrequencies m_Seq1ResidueProbs
Residue frequencies for sequence 1.
Options that control random values used in internal parts of Gumbel parameter calculation for gapped ...
vector< Int4 > & SetPrelimReNumbers(void)
Set preliminary realizations numbers.
vector< Int4 > & SetFirstStagePrelimReNumbers(void)
Set first stage preliminary realizations numbers.
void SetTotalReNumber(Int4 num)
Set total realizations number.
void SetRandomSeed(Uint4 val)
Set random seed.
void SetTotalReNumberKilling(Int4 num)
Set total realizations number killing.
vector< Int4 > & SetPrelimReNumbersKilling(void)
Set perliminary realizations numbers killing array.
Result of Gumbel parameters calculation along with diagnostic info.
std::ofstream out("events_result.xml")
main entry point for tests
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
TObjectType * GetNonNullPointer(void)
Get pointer value and throw a null pointer exception if pointer is null.
void Reset(void)
Reset reference object.
void Reset(void)
Reset reference object.
bool Empty(void) const THROWS_NONE
Check if CRef is empty â not pointing to any object, which means having a null value.
int32_t Int4
4-byte (32-bit) signed integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
static void s_CopyVector(const vector< T > &in, vector< T > &out)
std::istream & in(std::istream &in_, double &x_)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
static const char * kMaxScore
vector< double > lambda_sbs
vector< double > alpha_i_sbs
vector< double > sigma_sbs
vector< double > alpha_j_sbs
Gumbel parameters and estimation errors.
double gapless_alpha_error
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4