1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| int read_proteines(char * src, entete t[1000])
{
FILE * fsrc;
char str[15000];
char * res;
char * ch;
char ch1[1500];
char * occ;
int l;
int i;
char flag[2];
i=0;
fsrc = fopen(src, "r");
if (fsrc == NULL)
{
perror(src);
exit(EXIT_FAILURE);
}
while ((res=super_gets(str, sizeof str, fsrc))!=NULL)
{
strncpy(flag, res, 2);
if (strncmp(flag,"ID",2)==0)
{
l=strlen (res)-1;
ch=str_sub (res,5,l);
t[i].ID=ch;
}
else if (strncmp(flag,"AC",2)==0)
{
l=strlen (res)-1;
ch=str_sub (res,5,l);
res=super_gets(str, sizeof str, fsrc);
strncpy(flag, res, 2);
while (strncmp(flag,"AC",2)==0)
{
l=strlen (res)-1;
occ=str_sub (res,5,l);
strcat (ch, " ");
strcat (ch, occ);
res=super_gets(str, sizeof str, fsrc);
strncpy(flag, res, 2);
}
t[i].AC=ch;
}
else if (strncmp(flag,"DE",2)==0)
{
l=strlen (res)-1;
ch=str_sub (res,5,l);
res=super_gets(str, sizeof str, fsrc);
strncpy(flag, res, 2);
while (strncmp(flag,"DE",2)==0)
{
l=strlen (res)-1;
occ=str_sub (res,5,l);
strcat (ch, " ");
strcat (ch, occ);
res=super_gets(str, sizeof str, fsrc);
strncpy(flag, res, 2);
}
t[i].DE=ch;
}
else if (strncmp(flag," ",2)==0)
{
strcpy(ch1,"");
ch1[0]='\0';
l=strlen (res)-1;
occ=str_sub (res,5,l);
strcat (ch1, occ);
res=super_gets(str, sizeof str, fsrc);
strncpy(flag, res, 2);
while (strncmp(flag," ",2)==0)
{
l=strlen (res)-1;
occ=str_sub (res,5,l);
strcat (ch1, occ);
res=super_gets(str, sizeof str, fsrc);
strncpy(flag, res, 2);
}
t[i].SQ=str_strip(ch1);
i=i+1;
}
}
fclose(fsrc);
return i;
} |
Partager