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
|
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<math.h>
int main(int argc,char *argv[])
{
FILE *fp;
struct pdb{int resnum;
char residue[3];
};
struct pdb seq[10000];
char store[100];
int cnt=0,totatom,ALA[3],VAL[3],ILE[3];
double distance;
int freq=0;
fp=fopen(argv[1],"r");
while(fgets(store,100,fp)!=NULL)
{
sscanf(store,"%d %s",&seq[cnt].resnum,seq[cnt].residue);
cnt++;
}
totatom=cnt;
for(int u=0;u<3;u++){ ALA[u];VAL[u];ILE[u];}
for (int i=0;i<(totatom-1);i++)
{
for(int j=0;j<totatom;j++)
{
if(seq[j].resnum = seq[i].resnum+1)
{
if(strcmp(seq[i].residue,"A")==0)
{
if(strcmp(seq[j].residue,"A")==0)
{ freq=freq+1;
u=0;
ALA[u]=freq;}
else if (strcmp(seq[j].residue,"V")==0)
{freq=freq+1;
u=1;
ALA[u]=freq;}
else if (strcmp(seq[j].residue,"I")==0)
{freq=freq+1;
u=2;
ALA[u]=freq;}
}
if(strcmp(seq[i].residue,"V")==0)
{
if(strcmp(seq[j].residue,"A")==0)
{ freq=freq+1;
u=0;
VAL[u]=freq;}
else if (strcmp(seq[j].residue,"V")==0)
{freq=freq+1;
u=1;
VAL[u]=freq;}
else if (strcmp(seq[j].residue,"I")==0)
{freq=freq+1;
u=2;
VAL[u]=freq;}
}
if(strcmp(seq[i].residue,"I")==0)
{
if(strcmp(seq[j].residue,"A")==0)
{ freq=freq+1;
u=0;
ILE[u]=freq;}
else if (strcmp(seq[j].residue,"V")==0)
{freq=freq+1;
u=1;
ILE[u]=freq;}
else if (strcmp(seq[j].residue,"I")==0)
{freq=freq+1;
u=2;
ILE[u]=freq;}
}
}
}
for(int k=0;k<3;k++)
printf("%-8d%-8d%-8d%\n",ALA[k],VAL[k],ILE[k]);
}
}
|