ee_error_flag=
false;
54 erroree_error(
"",0);
76 throw error(
"Unexpected error\n",4);
93_CrtMemCheckpoint( &
d_s1);
97 Int4number_of_AA_RR1;
98 Int4number_of_AA_RR2;
107 throw error(
"Error - number of letters in the scoring matrix file must be greater than 0\n",3);
146 throw error(
"Number of letters is different for the scoring matrix and probabilities array\n",3);
151 throw error(
"Number of letters is different for the scoring matrix and probabilities array\n",3);
176 Uint4random_factor = 0;
181 if(AdvancedParams_tmp.
Empty())
184 #ifndef NCBI_OS_MSWIN 188random_factor+=tv.tv_usec*10000000;
190 struct_timeb timebuffer;
192_ftime( &timebuffer );
193timeline = ctime( & ( timebuffer.time ) );
194random_factor+=timebuffer.millitm*10000000;
305 doubletmp_size=
Tmin((
double)(tmp_size1),
311(
double)(
sizeof(
double)*12)+(
double)(
sizeof(
Int4)*17)
320ee_error_flag=
true;
326ee_error_flag=
true;
327ee_error=
error(
"Internal error in the program\n",4);
343 stringsmatr_file_name_,
344 stringRR1_file_name_,
345 stringRR2_file_name_,
350 stringout_file_name_)
354 boolee_error_flag=
false;
355 erroree_error(
"",0);
383 #ifndef NCBI_OS_MSWIN 386_CrtMemCheckpoint( &
d_s1);
390 Int4number_of_AA_RR1;
391 Int4number_of_AA_RR2;
422 throw error(
"Number of letters is different in the files "+smatr_file_name_+
" and "+RR1_file_name_+
"\n",3);
427 throw error(
"Number of letters is different in the files "+smatr_file_name_+
" and "+RR2_file_name_+
"\n",3);
431 for(
t=0;
t<number_of_AA_RR1;
t++)
457 Uint4random_factor=rand_;
460 if((
Int4)random_factor<0)
463 #ifndef NCBI_OS_MSWIN 467random_factor+=tv.tv_usec*10000000;
469 struct_timeb timebuffer;
471_ftime( &timebuffer );
472timeline = ctime( & ( timebuffer.time ) );
473random_factor+=timebuffer.millitm*10000000;
485frand.open(rand_st.data(),
ios::in);
502 throw error(
"Unexpected error in randomization seed\n",3);
604 doubletmp_size=
Tmin((
double)(tmp_size1),
610(
double)(
sizeof(
double)*12)+(
double)(
sizeof(
Int4)*17)
619ee_error_flag=
true;
625ee_error_flag=
true;
626ee_error=
error(
"Internal error in the program\n",4);
646 if(value_<0||value_>1.0||dim_<=0)
648 throw error(
"Unexpected error",4);
694 stringout_file_name_)
696 boolee_error_flag=
false;
697 erroree_error(
"",0);
705 f.open(out_file_name_.data(),
ios::in);
711 boolsymmetric_case_flag;
715str_ch=
new char[
str.length()+1];
718 throw error(
"Memory allocation error\n",41);
722 for(k=0;k<(
Int4)
str.length();k++)
726str_ch[
str.length()]=
'\0';
729 charstr_for_test0[]=
"number of realizations with killing";
730 char*test_flag0= strstr(str_ch,str_for_test0);
734 throw error(
"The output file "+out_file_name_+
" exists and does not have correct format;\nplease delete the file and rerun the program\n",3);
737 charstr_for_test[]=
"0.5*";
739 char*test_flag= strstr(str_ch,str_for_test);
742symmetric_case_flag=
true;
746symmetric_case_flag=
false;
752 if(symmetric_case_flag)
756 throw error(
"The output file "+out_file_name_+
" exists and corresponds to symmetric case; \ncurrent calculation uses non-symmetric parameters;\nplease define another output file name\n",3);
760 if(!symmetric_case_flag)
764 throw error(
"The output file "+out_file_name_+
" exists and corresponds to non-symmetric case; \ncurrent calculation uses symmetric parameters;\nplease define another output file name\n",3);
772ee_error_flag=
true;
778ee_error_flag=
true;
779ee_error=
error(
"Internal error in the program\n",4);
782 delete[]str_ch;str_ch=
NULL;
800 #ifndef NCBI_OS_MSWIN 805_CrtMemCheckpoint( &
d_s2);
811 for(use = 0; use < _MAX_BLOCKS; use++)
813total+=
d_s3.lSizes[use];
816total/=(double)1048576;
825 #if defined(NCBI_COMPILER_ICC) && defined(__OPTIMIZE__) \ 826 && NCBI_COMPILER_VERSION >= 1000 && NCBI_COMPILER_VERSION < 1100 827 # pragma optimization_level 1 832 Int4d_number_of_AA=
data->d_number_of_AA;
834 double*d_RR1=
data->d_RR1;
835 double*d_RR2=
data->d_RR2;
840 for(
i=0;
i<d_number_of_AA;
i++)
842 for(j=0;j<d_number_of_AA;j++)
844res+=d_RR1[
i]*d_RR2[j]*exp(x_*d_smatr[
i][j]);
852 stringsmatr_file_name_,
854 Int4&number_of_AA_smatr_)
856 boolee_error_flag=
false;
857 erroree_error(
"",0);
866 f.open(smatr_file_name_.data(),
ios::in);
869 throw error(
"Error - file "+smatr_file_name_+
" is not found\n",3);
872 f>>number_of_AA_smatr_;
874 if(number_of_AA_smatr_<=0)
876 throw error(
"Error - number of letters in the scoring matrix file must be greater than 0\n",3);
882 for(
i=0;
i<number_of_AA_smatr_;
i++)
884 for(j=0;j<number_of_AA_smatr_;j++)
893 for(
i=0;
i<number_of_AA_smatr_;
i++)
897 if(smatr_[
i][j]!=smatr_[j][
i])
911ee_error_flag=
true;
917ee_error_flag=
true;
918ee_error=
error(
"Internal error in the program\n",4);
935 stringRR_file_name_,
938 Int4*&RR_sum_elements_,
939 Int4&number_of_AA_RR_)
941 boolee_error_flag=
false;
942 erroree_error(
"",0);
951 f.open(RR_file_name_.data(),
ios::in);
954 throw error(
"Error - file "+RR_file_name_+
" is not found\n",3);
957 f>>number_of_AA_RR_;
959 if(number_of_AA_RR_<=0)
961 throw error(
"Error - number of letters in the probabilities file must be greater than 0\n",3);
964RR_=
new double[number_of_AA_RR_];
967RR_sum_=
new double[number_of_AA_RR_];
970RR_sum_elements_=
new Int4[number_of_AA_RR_];
976 for(
i=0;
i<number_of_AA_RR_;
i++)
982 throw error(
"Error - input letter's probability number "+
long_to_string(
i+1)+
" is negative\n",3);
987 throw error(
"Error - input letter's probability number "+
long_to_string(
i+1)+
" is greater than 1.0\n",3);
993RR_sum_[
i]=RR_sum_[
i-1]+RR_[
i];
997RR_sum_[
i]=RR_[
i];
999RR_sum_elements_[
i]=
i;
1002 if(
fabs(RR_sum_[number_of_AA_RR_-1]-1.0)>0.000000000001)
1012ee_error_flag=
true;
1018ee_error_flag=
true;
1019ee_error=
error(
"Internal error in the program\n",4);
1036 constvector<double> &vector_,
1039 Int4*&RR_sum_elements_,
1040 Int4&number_of_AA_RR_)
1042 boolee_error_flag=
false;
1043 erroree_error(
"",0);
1052number_of_AA_RR_=vector_.size();
1054 if(number_of_AA_RR_<=0)
1056 throw error(
"Error - number of letters in the probabilities file must be greater than 0\n",3);
1059RR_=
new double[number_of_AA_RR_];
1062RR_sum_=
new double[number_of_AA_RR_];
1065RR_sum_elements_=
new Int4[number_of_AA_RR_];
1071 for(
i=0;
i<number_of_AA_RR_;
i++)
1073RR_[
i]=vector_[
i];
1077 throw error(
"Error - input letter's probability number "+
long_to_string(
i+1)+
" is negative\n",3);
1082 throw error(
"Error - input letter's probability number "+
long_to_string(
i+1)+
" is greater than 1.0\n",3);
1088RR_sum_[
i]=RR_sum_[
i-1]+RR_[
i];
1092RR_sum_[
i]=RR_[
i];
1094RR_sum_elements_[
i]=
i;
1097 if(
fabs(RR_sum_[number_of_AA_RR_-1]-1.0)>0.000000000001)
1106ee_error_flag=
true;
1112ee_error_flag=
true;
1113ee_error=
error(
"Internal error in the program\n",4);
1144number_=
abs(number_);
1146 Int4reminder=number_%10;
1147number_=(number_-reminder)/10;
1156 returntmp_string+res_;
1164 case0:
return '0';
1165 case1:
return '1';
1166 case2:
return '2';
1167 case3:
return '3';
1168 case4:
return '4';
1169 case5:
return '5';
1170 case6:
return '6';
1171 case7:
return '7';
1172 case8:
return '8';
1173 case9:
return '9';
1174 default:
return '?';
1185 throw error(
"Memory allocation error\n",41);
1192 doublex_floor=floor(x_);
1193 doublex_ceil=ceil(x_);
1194 if(
fabs(x_-x_floor)<0.5)
1221 throw error(
"Unexpected error",4);
1224 boolee_error_flag=
false;
1225 erroree_error(
"",0);
1240tmp_ptr.
d_RR1=RR1_;
1241tmp_ptr.
d_RR2=RR2_;
1245 Int4smatr_max=smatr_[0][0];
1248 Int4smatr_min=smatr_[0][0];
1254 doublethreshold=DBL_MIN*10.0;
1256 doubleaver_score=0;
1258 for(
i=0;
i<number_of_AA_;
i++)
1260 for(j=0;j<number_of_AA_;j++)
1262 if(RR1_[j]*RR2_[
i]<=threshold)
1267aver_score+=RR1_[
i]*RR2_[j]*smatr_[
i][j];
1269 if(smatr_max<smatr_[
i][j])
1271smatr_max=smatr_[
i][j];
1278 if(smatr_[
i][j]>0)
1283 if(smatr_[
i][j]<0)
1291 if(aver_score>=-threshold)
1293 throw error(
"Error - sum[i,j] RR1[i]*RR2[j]*smatr[i][j]>=0; the program cannot continue the calculation\n",3);
1298 throw error(
"Error - at least one element of the scoring matrix must be positive\n",3);
1309 if(
a<threshold*100.0)
1311 throw error(
"Error - the input parameters correspond to non-logarithmic regime\n",3);
1315 if(
a<threshold*100.0)
1317 throw error(
"Error - the input parameters define the regime which is too close to the critical regime\n",3);
1323 doubletmp_pr=RR1_[smatr_max_i]*RR2_[smatr_max_j];
1324 double b=(
log(1+10*eps)-
log(tmp_pr))/(
double)smatr_max;
1328std::vector<double> res_lambda;
1333(
void*)(&tmp_ptr),
1340 sort(res_lambda.begin(),res_lambda.end());
1342 if(res_lambda.size()==0)
1344 throw error(
"Error - the program is not able to find the ungapped lambda\n",3);
1347 d_lambda=res_lambda[res_lambda.size()-1];
1372 for(
a=0;
a<number_of_AA_;
a++)
1374 for(
b=0;
b<number_of_AA_;
b++)
1384 for(
a=0;
a<number_of_AA_;
a++)
1386 for(
b=0;
b<number_of_AA_;
b++)
1393 for(ind=0;ind<number_of_AA_*number_of_AA_;ind++)
1399 for(ind=1;ind<number_of_AA_*number_of_AA_;ind++)
1406 for(
a=0;
a<number_of_AA_;
a++)
1408 for(
b=0;
b<number_of_AA_;
b++)
1454ee_error_flag=
true;
1460ee_error_flag=
true;
1461ee_error=
error(
"Internal error in the program\n",4);
1491 #ifndef NCBI_OS_MSWIN 1500seconds_=(double)(
t)+(double)(tv.tv_usec) * 0.000001;
1504 struct_timeb timebuffer;
1506_ftime( &timebuffer );
1508seconds_=timebuffer.time+(double)(timebuffer.millitm)/1000.0;
const TFrequencies & GetSeq2ResidueProbs(void) const
Get sequence 2 residue probabilities.
const TFrequencies & GetSeq1ResidueProbs(void) const
Get sequence 1 residue probabilities.
double GetMaxCalcMemory(void) const
Get maximum memory allowed for computation.
double GetMaxCalcTime(void) const
Get maximum calculation time allowed.
Int4 GetGapOpening(void) const
Get gap opening penalty.
double GetKAccuracy(void) const
Get relative error threshold for K parameter calculation for gapped alignment.
Int4 GetNumResidues(void) const
Get number of residues in utilized alphabet.
const Int4 ** GetScoreMatrix(void) const
Get score matrix.
double GetLambdaAccuracy(void) const
Get relative error threshold for lambda parameter calculation for gapped aligmment.
Int4 GetGapExtension(void) const
Get gap extention penalty.
Int4 GetTotalReNumber(void) const
Get total realizations number.
const vector< Int4 > & GetPrelimReNumbersKilling(void) const
Get perliminary realizations numbers killing array.
const vector< Int4 > & GetFirstStagePrelimReNumbers(void) const
Get first stage preliminary realizations numbers.
Int4 GetTotalReNumberKilling(void) const
Get total realizations number killing.
Uint4 GetRandomSeed(void) const
Get random seed.
const vector< Int4 > & GetPrelimReNumbers(void) const
Get preliminary realizations numbers.
bool d_smatr_symmetric_flag
importance_sampling * d_is
struct_for_randomization * d_rand_all
void get_memory_for_matrix(Int4 dim_, T **&matr_)
static double round(const double &x_)
alp_data(Int4 rand_, Int4 open_, Int4 epen_, string smatr_file_name_, string RR1_file_name_, string RR2_file_name_, double max_time_, double max_mem_, double eps_lambda_, double eps_K_, string out_file_name_)
Int4 * d_RR2_sum_elements
static T Tmax(T i_, T j_)
static void get_current_time(double &seconds_)
void read_smatr(string smatr_file_name_, Int4 **&smatr_, Int4 &number_of_AA_smatr_)
static T Tmin(T i_, T j_)
Int4 d_minimum_realizations_number
static Int4 random_long(double value_, Int4 dim_)
Int4 d_number_of_AA_smatr
double get_allocated_memory_in_MB()
void delete_memory_for_matrix(Int4 dim_, T **&matr_)
Int4 * d_RR1_sum_elements
static void assert_mem(void *pointer_)
static char digit_to_string(Int4 digit_)
void check_out_file(string out_file_name_)
double d_memory_size_in_MB
void read_RR(string RR_file_name_, double *&RR_, double *&RR_sum_, Int4 *&RR_sum_elements_, Int4 &number_of_AA_RR_)
static string long_to_string(Int4 number_)
static void find_tetta_general(function_type *func_, void *func_pointer_, double a_, double b_, Int4 n_partition_, double eps_, std::vector< double > &res_)
importance_sampling(alp_data *alp_data_, Int4 open_, Int4 epen_, Int4 number_of_AA_, Int4 **smatr_, double *RR1_, double *RR2_)
double * d_elements_values
static double lambda_equation(double x_, void *func_number_)
static const char * str(char *buf, int n)
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
void SetSeed(TValue seed)
Seed the random number generator with "seed".
constexpr auto sort(_Init &&init)
const struct ncbi::grid::netcache::search::fields::SIZE size
int gettimeofday(struct timeval *tp, void *unused)
std::istream & in(std::istream &in_, double &x_)
Int4 d_total_realizations_number_with_ALP
vector< Int4 > d_preliminary_realizations_numbers_ALP
Int4 d_total_realizations_number_with_killing
vector< Int4 > d_preliminary_realizations_numbers_killing
vector< Int4 > d_first_stage_preliminary_realizations_numbers_ALP
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