本文整理汇总了C++中SequenceSet::getOnePointProb方法的典型用法代码示例。如果您正苦于以下问题:C++ SequenceSet::getOnePointProb方法的具体用法?C++ SequenceSet::getOnePointProb怎么用?C++ SequenceSet::getOnePointProb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SequenceSet
的用法示例。
在下文中一共展示了SequenceSet::getOnePointProb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeMIonCPU
void computeMIonCPU(SequenceSet& sequences, Matrix<float>& MI) {
const int numChars = NUMPROTEINCHARS;
const int sequenceLength = sequences.getSequenceLength();
const int numSequences = sequences.getNumberOfSequences();
const double epsilon=1e-6;
timeval start, end;
gettimeofday(&start, 0);
for (int k = 0; k < LOOPCOUNT; k++) {
//iterate over all column combinations
for (int j = 0; j < sequenceLength; j++) {
for (int i = 0; i <= j; i++) {
//absolute number of occurrences of character pairs x,y: N_ij(x,y)
int twoPointOccs[numChars][numChars];
memset(twoPointOccs, 0, sizeof(twoPointOccs));
//iterate through all sequences and compute two-point occurrences
for (int seq = 0; seq < numSequences; seq++)
twoPointOccs[sequences.getData(seq, i)][sequences.getData(seq, j)]++;
/*
puts("===START===");
for (int m=0; m<numChars; m++) {
for (int n=0; n<numChars; n++)
printf("%d %d: %d\n", m, n, twoPointOccs[m][n]);
puts("");
}
puts("===STOP ===");
*/
double MI_ij = 0;
//sum over all x and y
for (int x = 0; x < numChars; x++) {
if (sequences.getOnePointProb(x, i) < epsilon)
continue;
for (int y = 0; y < numChars; y++) {
if (sequences.getOnePointProb(y, j) < epsilon || twoPointOccs[x][y] == 0)
continue;
double p_ij_xy = double(twoPointOccs[x][y]) / double(numSequences);
MI_ij += p_ij_xy * log2(p_ij_xy / (sequences.getOnePointProb(x, i) * sequences.getOnePointProb(y, j)));
}
}
MI.set(i, j, MI_ij);
}
}
}
gettimeofday(&end, 0);
std::cout << "execution time: "
<< (end.tv_sec - start.tv_sec ) * 1000 + ( end.tv_usec - start.tv_usec) / 1000
<< " milliseconds" << std::endl;
}