Guest User

Untitled

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