Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int i = 0, a = 0, c = 0, g = 0, t = 0;
  9.     string s;
  10.     string line,line1;
  11.     int j = 0;
  12.     ifstream myfile("E:\\short.fasta");
  13.     getline(myfile, line1);
  14.     if (myfile.is_open())
  15.     {
  16.         while (!myfile.eof())
  17.         {
  18.                 getline(myfile, line);
  19.                 s += line;
  20.         }
  21.         myfile.close();
  22.     }
  23.     else cout << "Error!";
  24.  
  25.     for (int i = 0; i < s.length() - 1; i++)
  26.     {
  27.         if (s[i] == ('A')) { a++; } else
  28.         { if (s[i] == ('a')) { a++; } else
  29.             { if (s[i] == ('C')) { c++; } else
  30.                 { if (s[i] == ('c')) { c++; } else
  31.                     { if (s[i] == ('G')) { g++; } else
  32.                         { if (s[i] == ('g')) { g++; } else
  33.                             { if (s[i] == ('T')) { t++; } else
  34.                                 { if (s[i] == ('t')) { t++; } else
  35.                                     {
  36.  
  37.                                     }
  38.                                 }
  39.                             }
  40.                         }
  41.                     }
  42.                 }
  43.             }
  44.         }
  45.     }
  46.  
  47.     cout << "A - " << a << endl;
  48.     cout << "C - " << c << endl;
  49.     cout << "G - " << g << endl;
  50.     cout << "T - " << t << endl;
  51.     //f.close();
  52.     system("pause");
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement