Guest User

Untitled

a guest
Apr 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.02 KB | None | 0 0
  1. for (i0 = 0; i0 < inputStrs->m_str[0].m_length - motifLen; i0++) {
  2.  
  3.         t1 = time(NULL);
  4.  
  5.         numExploredNodes = 0;      
  6.         totNumDNeighs = 0;
  7.  
  8.         HashStrV2_Reset(&hashStr);
  9.         strsTemp[0] = inputStrs->m_str[0].m_data + i0;     
  10.         for (group = 0; group <= maxGroup; group++) {
  11.            
  12.             numHits = 0;
  13.             maxNumDNeighs = 0;
  14.            
  15.             strIndex1 = 2 * group + 1;
  16.             strIndex2 = 2 * group + 2;
  17.            
  18.                 gettimeofday(&v1, 0);
  19.             for (i1 = 0; i1 < inputStrs->m_str[strIndex1].m_length - motifLen; i1++) {             
  20.                 strsTemp[1] = inputStrs->m_str[strIndex1].m_data + i1;
  21.                 a01 = hdmat[0][strIndex1][i0][i1];
  22.                 if ( a01 > 2 * hammingDist ) {
  23.                     continue;
  24.                 }              
  25.                 for (i2 = 0; i2 < inputStrs->m_str[strIndex2].m_length - motifLen; i2++) {                 
  26.                     strsTemp[2] = inputStrs->m_str[strIndex2].m_data + i2;
  27.                     a02 = hdmat[0][strIndex2][i0][i2];
  28.                     if ( a02 > 2 * hammingDist ) {
  29.                         continue;
  30.                     }                  
  31.                     a12 = HammingDistStrStr(strsTemp[1], strsTemp[2], motifLen);
  32.                     if ( a12 > 2 * hammingDist ) {
  33.                         continue;
  34.                     }                  
  35.                     if (GetDMinValue(strsTemp[0], strsTemp[1], strsTemp[2], motifLen) > hammingDist) {
  36.                         continue;
  37.                     }
  38.  
  39.                     ChooseRootStr3Strs(a01, a02, a12, strsTemp[0], strsTemp[1], strsTemp[2],
  40.                                         &(strs[0]), &(strs[1]), &(strs[2]));
  41.  
  42.                     if (group == 0) {
  43.                        
  44.                         numDNeighs = GenDNeigh3Strs(strs[0], strs[1], strs[2],
  45.                                                     hammingDist, motifLen, nodeStack, dst0, dst1,
  46.                                                     hashStr.m_lastStr, comMotifLen,
  47.                                                     maxDNeighsAllowed > (hashStr.m_bucketBufMaxSize - hashStr.m_bucketTotalSize)?
  48.                                                     (hashStr.m_bucketBufMaxSize - hashStr.m_bucketTotalSize): maxDNeighsAllowed);
  49.  
  50.  
  51.                         if (hashStr.m_bucketTotalSize + numDNeighs < hashStr.m_bucketBufMaxSize) {
  52.                             hashStr.m_bucketTotalSize += numDNeighs;
  53.                             hashStr.m_lastStr += comMotifLen * numDNeighs;                         
  54.                         }
  55.                     } else {
  56.                         numDNeighs = GenDNeigh3StrsNonEncoded(strs[0], strs[1], strs[2],
  57.                                                     hammingDist, motifLen, nodeStack, dst0, dst1,
  58.                                                     dNeighsBuf, comMotifLen, maxDNeighsAllowed);
  59.                         EncodeManyDNAStrings(dNeighsBuf, numDNeighs, motifLen, dNeighsBuf);
  60.                         gettimeofday(&v3, 0);
  61.                                     if (isWithHash[0] == 'y' || isWithHash[0] == 'Y') {
  62.                             dNeighsEnd = dNeighsBuf + comMotifLen * numDNeighs;
  63.                             for (dNeighsRun = dNeighsBuf; dNeighsRun < dNeighsEnd; dNeighsRun += comMotifLen) {
  64.                                 HashStrV2_FindAndMarkString(&hashStr, (char *)(dNeighsRun));
  65.                             }
  66.                         }
  67.                                     gettimeofday(&v4, 0);
  68.                                     interTime += (v4.tv_sec - v3.tv_sec) * 1000000 + (v4.tv_usec - v3.tv_usec);
  69.                     }                  
  70.                     numHits += numDNeighs;
  71.                     totNumDNeighs += numDNeighs;
  72.                     if (maxNumDNeighs < numDNeighs) {
  73.                         maxNumDNeighs = numDNeighs;
  74.                     }
  75.  
  76.                 }//end i2
  77.  
  78.             }//end i1
  79.             //subT2 = time(NULL);
  80.                     gettimeofday(&v2, 0);
  81.                     genTime += (v2.tv_sec - v1.tv_sec) * 1000000 + (v2.tv_usec - v1.tv_usec);
  82.  
  83.             if ( group == 0) {
  84.                 HashStrV2_SortStrings(&hashStr);
  85.                 HashStrV2_RemoveDuplicateStrings(&hashStr);
  86.                 HashStrV2_UpdateBucketPointers(&hashStr);
  87.             } else {
  88.                 HashStrV2_RmvUmrkdStrAndUpdtBcktPtr(&hashStr);
  89.             }
  90.             HashStrV2_ResetMarkBucket(&hashStr, 0);
  91.             if (hashStr.m_bucketTotalSize < 500) {
  92.                 break; 
  93.             }
  94.            
  95.         }//end group
  96.  
  97.  
  98.         if (totCanMotifs + hashStr.m_bucketTotalSize < maxCanMotifsAllowed) {
  99.             memcpy( canMotifsBuf + totCanMotifs * hashStr.m_strLen,
  100.                     hashStr.m_bucketBuf, hashStr.m_bucketTotalSize * hashStr.m_strLen);
  101.             totCanMotifs += hashStr.m_bucketTotalSize;
  102.         }
  103.        
  104.  
  105.         t2 = time(NULL);
  106.             total_genTime += (genTime - interTime);
  107.         if ( (i0 % 20) == 0) {
  108.             fprintf(stderr, "\ni0=%d nNodes=%d totNNeis=%d bksize= %d T=%d(s) generation = %lld(us) intersection = %lld(us)\n",
  109.                             i0, numExploredNodes, totNumDNeighs, hashStr.m_bucketTotalSize, t2 - t1, genTime - interTime, interTime);
  110.         }
  111.         genTime = interTime = 0;
  112.     }//end i0  
  113.    
  114.     fprintf(stderr, "\n Total generation time = %lld(s)\n", total_genTime);
Add Comment
Please, Sign In to add comment