Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. char nfunkcia(char pole[]){
  2.     FILE *fr;
  3.     if ((fr = fopen("DNAsekvencia.dat", "r")) == NULL) {
  4.         printf("Neotvoreny subor\n");
  5.         return 0;
  6.     }
  7.     char c;
  8.     int i = 0;
  9.     while ((c = getc(fr)) != EOF){
  10.         if (c == 'A' || c == 'a' || c == 'C' || c == 'c' || c == 'G' || c == 'g' || c == 'T' || c == 't'){
  11.             pole[i] = c;
  12.             i++;
  13.         }
  14.         else if (c == ' ' || c == '\n') continue;
  15.         else{
  16.             printf("Sekvencia nesplna podmienky\n");
  17.             return 0;
  18.         }
  19.     }
  20.     printf("Sekvenciu sa podarilo nacitat\n");
  21.     return pole;
  22. }
  23.  
  24. void hist(char pole[]){
  25.     int i;
  26.     int ac = 0, cc = 0, gc = 0, tc = 0;
  27.     if ((pole[0] == 'A') || (pole[0] == 'a') || (pole[0] == 'C') || (pole[0] == 'c') || (pole[0] == 'G') || (pole[0] == 'g') || (pole[0] == 'T') || (pole[0] == 't')){
  28.         for (i = 0; i < MAX; i++){
  29.             if ((pole[i] == 'A') || (pole[i] == 'a')){
  30.                 ac++;
  31.             }
  32.             else if ((pole[i] == 'C') || (pole[i] == 'c')){
  33.                 cc++;
  34.             }
  35.             else if ((pole[i] == 'G') || (pole[i] == 'g')){
  36.                 gc++;
  37.             }
  38.             else if ((pole[i] == 'T') || (pole[i] == 't')){
  39.                 tc++;
  40.             }
  41.         }
  42.  
  43.         printf("A: %d\n", ac);
  44.         printf("C: %d\n", cc);
  45.         printf("G: %d\n", gc);
  46.         printf("T: %d\n", tc);
  47.     }
  48.     else printf("Sekvencia nie je nacitana\n");
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement