Advertisement
Guest User

Untitled

a guest
Jan 28th, 2023
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. char convert(char c)
  7. {
  8.     if (c == 'A') return 'C';
  9.     if (c == 'C') return 'G';
  10.     if (c == 'G') return 'T';
  11.     if (c == 'T') return 'A';
  12.     return ' ';
  13. }
  14.  
  15. int main()
  16. {
  17.     cout << "Start" << endl;
  18.  
  19.     string opt = "ACGT";
  20.     string s = "";
  21.     string s_last = "";
  22.     int len_str = 13;
  23.     bool change_next;
  24.  
  25.     for (int i=0; i<len_str; i++)
  26.     {
  27.         s += opt[0];
  28.     }
  29.  
  30.     for (int i=0; i<len_str; i++)
  31.     {
  32.         s_last += opt.back();
  33.     }
  34.  
  35.     int pos = 0;
  36.     int counter = 1;
  37.     while (s != s_last)
  38.     {  
  39.         counter ++;
  40.         // You can uncomment the next line to see all k-mers.
  41.         // cout << s << endl;  
  42.         change_next = true;
  43.         for (int i=0; i<len_str; i++)
  44.         {
  45.             if (change_next)
  46.             {
  47.                 if (s[i] == opt.back())
  48.                 {
  49.                     s[i] = convert(s[i]);
  50.                     change_next = true;
  51.                 } else {
  52.                     s[i] = convert(s[i]);
  53.                     break;
  54.                 }
  55.             }
  56.         }
  57.     }
  58.  
  59.     // You can uncomment the next line to see all k-mers.
  60.     // cout << s << endl;
  61.     cout << "Number of generated k-mers: " << counter << endl;
  62.     cout << "Finish!" << endl;
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement