Advertisement
Guest User

paula 2ª mais lynda da unicamp

a guest
Oct 31st, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. /* Allan Rossi Gomes RA:157654
  4.  
  5. Programa que verifica, dado um mRNA e um oligonucleotídeo, se o gene correspondente foi silenciado ou não.
  6.  
  7. */
  8.  
  9. /*
  10. Recebe o mRNA (com tamanho R) e Oligonucleotideo (com tamanho O)
  11. a ser comparados, e retorna:
  12. - caso o mRNA seja silenciado, retornar a primeira posicao inicial
  13. para o mRNA em que os trechos sao iguais;
  14. - caso nao haja trecho em comum, retornar -1.
  15. */
  16.  
  17. int ComparaRNA(char rna[], int R, char oligo[], int O){
  18.  
  19. int j, k, l, m, n, indice;
  20.  
  21. for(j = 0; j < O; j++){
  22.  
  23. if(oligo[j] == 'A')
  24. oligo[j] = 'U';
  25.  
  26. else if(oligo[j] == 'U')
  27. oligo[j] = 'A';
  28.  
  29. else if(oligo[j] == 'C')
  30. oligo[j] = 'G';
  31.  
  32. else if(oligo[j] == 'G')
  33. oligo[j] = 'C';
  34.  
  35. }
  36.  
  37. for(k = 0; k < R; k++)
  38. printf("%c", rna[k]);
  39.  
  40. printf("\n");
  41.  
  42. for(l = 0; l < O; l++)
  43. printf("%c", oligo[l]);
  44.  
  45. printf("\n");
  46.  
  47. for(m = 0; ; m++){
  48. if(oligo[m] == rna[m]){
  49. indice = m;
  50. for(n = m; ; n++){
  51. if(oligo[n] != rna[n]){
  52. break;
  53. }
  54. else if((oligo[n] == '\0') || (rna[n] == '\0')){
  55. return indice;
  56. }
  57. }
  58. }
  59. else if((oligo[m] == '\0') || (rna[m] == '\0')){
  60. return -1;
  61. }
  62. }
  63.  
  64. }
  65.  
  66. int main(){
  67.  
  68. int R, O, i, j, resultado;
  69.  
  70. char rna[101], oligo[26];
  71.  
  72. char troca;
  73.  
  74. scanf("%d %d", &R, &O);
  75.  
  76. scanf("%s", rna);
  77.  
  78. scanf("%s", oligo);
  79.  
  80. i = 0;
  81.  
  82. j = O - 1;
  83.  
  84. while(i < j){
  85.  
  86. troca = oligo[i];
  87.  
  88. oligo[i] = oligo[j];
  89.  
  90. oligo[j] = troca;
  91.  
  92. i++;
  93.  
  94. j--;
  95.  
  96. }
  97.  
  98. resultado = ComparaRNA(rna, R, oligo, O);
  99.  
  100. if(resultado != -1)
  101. printf("Silenciado em %d", resultado + 1);
  102.  
  103. else
  104. printf("Nao silenciado");
  105.  
  106. return 0;
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement