Advertisement
Fahim_7861

profile motif 4

Dec 19th, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. typedef unsigned long long ull;
  5. typedef pair<ll,ll>pll;
  6. typedef pair<ll,pair<ll,ll>>plll;
  7. #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
  8. #define vll(v) v.begin(),v.end()
  9. #define all(x) x.rbegin(),x.rend()
  10. #define min3(a, b, c) min(a, min(b, c))
  11. #define max3(a, b, c) max(a, max(b, c))
  12. #define F first
  13. #define S second
  14. #define in freopen("input.txt", "r", stdin)
  15. #define out freopen("output.txt", "w", stdout)
  16. #define minheap int,vector<int>,greater<int>
  17. #define pb push_back
  18. #define eb emplace_back
  19. #define ischar(x) (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
  20. #define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
  21. #define bug cout<<"BUG"<<endl;
  22. const int Max = 2e5 + 10;
  23. const int Mod = 1e9 + 7;
  24. const double PI =3.141592653589793238463;
  25. bool compare(const string &a, const string &b)
  26. {
  27. for(ll i=0; i<a.size(); i++)
  28. {
  29. if(a[i]!=b[i] && (a[i]=='$' || b[i]=='$'))
  30. {
  31.  
  32. if(a[i]=='$')return 1;
  33.  
  34. else if(b[i]=='$')return 0;
  35. }
  36.  
  37. else if(a[i]<b[i])return 1;
  38.  
  39. else if(a[i]>b[i])return 0;
  40. }
  41.  
  42. return 1;
  43. }
  44. ll lcm(ll a,ll b)
  45. {
  46. if(a==0 || b==0)return 0;
  47.  
  48. return a/__gcd(a,b)*b;
  49. }
  50.  
  51. void input(ll ara[],ll n)
  52. {
  53. for(ll i=0; i<n; i++)cin>>ara[i];
  54. }
  55. void print(ll ara[],ll n)
  56. {
  57. for(ll i=0; i<n; i++)
  58. cout<<ara[i]<<" ";
  59. cout<<endl;
  60. }
  61.  
  62.  
  63.  
  64. void printCycleRotation(vector<string>cyclicRotation)
  65. {
  66.  
  67. for(auto x : cyclicRotation)
  68. cout<<x<<endl;
  69. }
  70.  
  71.  
  72. ll ara[5][100];
  73.  
  74. ll number(char ch)
  75. {
  76. if(ch=='A')return 1;
  77.  
  78. else if(ch=='C')return 2;
  79.  
  80. else if(ch=='G')return 3;
  81.  
  82. else return 4;
  83. }
  84.  
  85. void count_motif(string str[],ll n)
  86. {
  87. ll i,j,m=str[0].size();
  88.  
  89. for(i=0; i<n; i++)
  90. {
  91. for(j=0; j<m; j++)
  92. {
  93. ara[number(str[i][j])][j]++;
  94. }
  95. }
  96.  
  97. string temp="ACGT";
  98.  
  99. for(auto x : temp)
  100. {
  101. cout<<x<<" : ";
  102.  
  103. for(j=0; j<m; j++)
  104. {
  105. double aa=ara[number(x)][j];
  106.  
  107. double len=n;
  108.  
  109. double ans=(double)aa/len;
  110.  
  111. cout<<setprecision(2)<<fixed<<ans<<" ";
  112. }
  113.  
  114. cout<<endl;
  115. }
  116. }
  117.  
  118. int main()
  119. {
  120.  
  121. fastread();
  122.  
  123. ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;
  124.  
  125. bool flag=false;
  126.  
  127. cin>>n;
  128.  
  129. string str[n+2];
  130.  
  131. for(i=0; i<n; i++)
  132. {
  133. cin>>str[i];
  134. }
  135.  
  136. count_motif(str,n);
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147. }
  148.  
  149.  
  150. //GCAGGGTGCA
  151.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement