Advertisement
Fahim_7861

Consensus string and score motif 3

Dec 19th, 2020
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 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.  
  52. ll ara[5][1000];
  53.  
  54. ll number(char ch)
  55. {
  56. if(ch=='A')return 1;
  57.  
  58. else if(ch=='C')return 2;
  59.  
  60. else if(ch=='G')return 3;
  61.  
  62. else return 4;
  63. }
  64.  
  65. int main()
  66. {
  67.  
  68. fastread();
  69.  
  70. ll i,j,n,m,p,sum=0,k,t,cnt=0,q,l,r;
  71.  
  72. bool flag=false;
  73.  
  74. cin>>n;
  75.  
  76. m=0;
  77.  
  78. string str;
  79.  
  80. for(i=0; i<n; i++)
  81. {
  82. cin>>str;
  83.  
  84. m=str.size();
  85.  
  86. for(j=0; j<m; j++)
  87. {
  88. ara[number(str[j])][j]++;
  89. }
  90. }
  91.  
  92.  
  93. ll ans=0;
  94.  
  95. string temp="ACGT",Ans;
  96. for(i=0; i<m; i++)
  97. {
  98. ll mx=max(ara[1][i],max3(ara[2][i],ara[3][i],ara[4][i]));
  99.  
  100. ans+=(n-mx);
  101.  
  102. for(j=0; j<4; j++)
  103. {
  104. if(mx==ara[j+1][i])
  105. {
  106. Ans+=temp[j];
  107. break;
  108. }
  109.  
  110. }
  111.  
  112. }
  113.  
  114. cout<<"score "<<ans<<"\nConsensus(Motifs) : "<<Ans<<endl;
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121. }
  122. /*
  123. 10
  124. TCGGGGGTTTTT
  125. CCGGTGACTTAC
  126. ACGGGGATTTTC
  127. TTGGGGACTTTT
  128. AAGGGGACTTCC
  129. TTGGGGACTTCC
  130. TCGGGGATTCAT
  131. TCGGGGATTCCT
  132. TAGGGGAACTAC
  133. TCGGGTATAACC
  134.  
  135. */
  136.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement