Guest User

Untitled

a guest
Mar 26th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.13 KB | None | 0 0
  1. uint64_t find_all_regex1(char * str) {//"agggtaaa|tttaccct"
  2.   uint64_t count = 0;
  3.   char * a = str, * b = str;
  4.   uint64_t state = 0x3;
  5.   do {
  6.     if(a) { if((a = strstr(a, "agggtaaa"))) ++count, a += 8; else state &= 0x1;}
  7.     if(b) { if((b = strstr(b, "tttaccct"))) ++count, b += 8; else state &= 0x2;}
  8.   } while(state);
  9.   return count;
  10. }
  11.  
  12. uint64_t find_all_regex2(char * str) {//"[cgt]gggtaaa|tttaccc[acg]"
  13.   uint64_t count = 0;
  14.   char * a = str, * b = str;
  15.   uint64_t state = 0x3;
  16.   do {
  17.     if(a) {
  18.       if((a = strstr(a, "gggtaaa"))) {
  19.     switch(*(a - 1)) {
  20.       case 'c': case 'g': case 't': ++count;
  21.       default: a += 7; break;
  22.     }
  23.       } else state &= 0x1;
  24.     }
  25.  
  26.     if(b) {
  27.       if((b = strstr(b, "tttaccc"))) {
  28.     switch(*(b + 7)) {
  29.       case 'a': case 'c': case 'g': ++count, b += 1;
  30.       default: b += 7; break;
  31.     }
  32.       } else state &= 0x2;
  33.     }
  34.  
  35.   } while(state);
  36.   return count;
  37. }
  38.  
  39. uint64_t find_all_regex3(char * str) {//"a[act]ggtaaa|tttacc[agt]t"
  40.   uint64_t count = 0;
  41.   char * a = str, * b = str;
  42.   uint64_t state = 0x3;
  43.   do {
  44.     if(a) {
  45.       if((a = strstr(a, "ggtaaa"))) {
  46.     switch(*(a - 1)) {
  47.       case 'a': case 'c': case 't': if(*(a - 2) == 'a') ++count;
  48.       default: a += 6; break;
  49.     }
  50.       } else state &= 0x1;
  51.     }
  52.  
  53.     if(b) {
  54.       if((b = strstr(b, "tttacc"))) {
  55.     switch(*(b + 6)) {
  56.       case 'a': case 'g': case 't': if(*(b + 7) == 't') ++count, b += 2;
  57.       default: b += 6; break;
  58.     }
  59.       } else state &= 0x2;
  60.     }
  61.  
  62.   } while(state);
  63.   return count;
  64. }
  65.  
  66. uint64_t find_all_regex4(char * str) {//"ag[act]gtaaa|tttac[agt]ct"
  67.   uint64_t count = 0;
  68.   char * a = str, * b = str;
  69.   uint64_t state = 0x3;
  70.   do {
  71.     if(a) {
  72.       if((a = strstr(a, "gtaaa"))) {
  73.     switch(*(a - 1)) {
  74.       case 'a': case 'c': case 't': if(!memcmp(a - 3, "ag", 2)) ++count;
  75.       default: a += 5; break;
  76.     }
  77.       } else state &= 0x1;
  78.     }
  79.  
  80.     if(b) {
  81.       if((b = strstr(b, "tttac"))) {
  82.     switch(*(b + 5)) {
  83.       case 'a': case 'g': case 't': if(!memcmp(b + 6, "ct", 2)) ++count, b += 3;
  84.       default: b += 5; break;
  85.     }
  86.       } else state &= 0x2;
  87.     }
  88.  
  89.   } while(state);
  90.   return count;
  91. }
  92.  
  93. uint64_t find_all_regex5(char * str) {//"agg[act]taaa|ttta[agt]cct"
  94.   uint64_t count = 0;
  95.   char * a = str, * b = str;
  96.   uint64_t state = 0x3;
  97.   do {
  98.     if(a) {
  99.       if((a = strstr(a, "taaa"))) {
  100.     switch(*(a - 1)) {
  101.       case 'a': case 'c': case 't': if(!memcmp(a - 4, "agg", 3)) ++count;
  102.       default: a += 4; break;
  103.     }
  104.       } else state &= 0x1;
  105.     }
  106.  
  107.     if(b) {
  108.       if((b = strstr(b, "ttta"))) {
  109.     switch(*(b + 4)) {
  110.       case 'a': case 'g': case 't': if(!memcmp(b + 5, "cct", 3)) ++count, b += 4;
  111.       default: b += 4; break;
  112.     }
  113.       } else state &= 0x2;
  114.     }
  115.  
  116.   } while(state);
  117.   return count;
  118. }
  119.  
  120. uint64_t find_all_regex6(char * str) {//"ttt[cgt]ccct|aggg[acg]aaa"
  121.   uint64_t count = 0;
  122.   char * a = str, * b = str;
  123.   uint64_t state = 0x3;
  124.   do {
  125.     if(a) {
  126.       if((a = strstr(a, "ccct"))) {
  127.     switch(*(a - 1)) {
  128.       case 'c': case 'g': case 't': if(!memcmp(a - 4, "ttt", 3)) ++count;
  129.       default: a += 4; break;
  130.     }
  131.       } else state &= 0x1;
  132.     }
  133.  
  134.     if(b) {
  135.       if((b = strstr(b, "aggg"))) {
  136.     switch(*(b + 4)) {
  137.       case 'a': case 'c': case 'g': if(!memcmp(b + 5, "aaa", 3)) ++count, b += 4;
  138.       default: b += 4; break;
  139.     }
  140.       } else state &= 0x2;
  141.     }
  142.  
  143.   } while(state);
  144.   return count;
  145. }
  146.  
  147. uint64_t find_all_regex7(char * str) {//"tt[acg]accct|agggt[cgt]aa"
  148.   uint64_t count = 0;
  149.   char * a = str, * b = str;
  150.   uint64_t state = 0x3;
  151.   do {
  152.     if(a) {
  153.       if((a = strstr(a, "accct"))) {
  154.     switch(*(a - 1)) {
  155.       case 'a': case 'c': case 'g': if(!memcmp(a - 3, "tt", 2)) ++count;
  156.       default: a += 5; break;
  157.     }
  158.       } else state &= 0x1;
  159.     }
  160.  
  161.     if(b) {
  162.       if((b = strstr(b, "agggt"))) {
  163.     switch(*(b + 5)) {
  164.       case 'c': case 'g': case 't': if(!memcmp(b + 6, "aa", 2)) ++count, b += 3;
  165.       default: b += 5; break;
  166.     }
  167.       } else state &= 0x2;
  168.     }
  169.  
  170.   } while(state);
  171.   return count;
  172. }
  173.  
  174. uint64_t find_all_regex8(char * str) {//"t[acg]taccct|agggta[cgt]a"
  175.   uint64_t count = 0;
  176.   char * a = str, * b = str;
  177.   uint64_t state = 0x3;
  178.   do {
  179.     if(a) {
  180.       if((a = strstr(a, "taccct"))) {
  181.     switch(*(a - 1)) {
  182.       case 'a': case 'c': case 'g': if(!memcmp(a - 2, "t", 1)) ++count;
  183.       default: a += 6; break;
  184.     }
  185.       } else state &= 0x1;
  186.     }
  187.  
  188.     if(b) {
  189.       if((b = strstr(b, "agggta"))) {
  190.     switch(*(b + 6)) {
  191.       case 'c': case 'g': case 't': if(!memcmp(b + 7, "a", 1)) ++count, b += 2;
  192.       default: b += 6; break;
  193.     }
  194.       } else state &= 0x2;
  195.     }
  196.  
  197.   } while(state);
  198.   return count;
  199. }
  200.  
  201. uint64_t find_all_regex9(char * str) {//"[acg]ttaccct|agggtaa[cgt]"
  202.   uint64_t count = 0;
  203.   char * a = str, * b = str;
  204.   uint64_t state = 0x3;
  205.   do {
  206.     if(a) {
  207.       if((a = strstr(a, "ttaccct"))) {
  208.     switch(*(a - 1)) {
  209.       case 'a': case 'c': case 'g': ++count;
  210.       default: a += 7; break;
  211.     }
  212.       } else state &= 0x1;
  213.     }
  214.  
  215.     if(b) {
  216.       if((b = strstr(b, "agggtaa"))) {
  217.     switch(*(b + 7)) {
  218.       case 'c': case 'g': case 't': ++count, b += 1;
  219.       default: b += 7; break;
  220.     }
  221.       } else state &= 0x2;
  222.     }
  223.  
  224.   } while(state);
  225.   return count;
  226. }
Advertisement
Add Comment
Please, Sign In to add comment