- 论坛徽章:
- 0
|
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
FILE *fp,*fp1,*fp2,*fp3,*fp4;
int i,j,k=0,k1=0,k2=0,ii=0,jj=0;
char a[5000];
char b[5000];
char c[800];
char sign[800];
char d[21]={'A','R','G','D','S','W','Y','T','P','F','K','E','N','Q','H','I','V','L','M','C'};
char name[21];
int leng=0,length=0,length1=0;
int n=0,m=0,l=0,n1=0,m1=0,l1=0,n2=0,m2=0,l2=0,s=0,s1=0,s2=0,s3=0,s4=0,s5=0,s6=0,s7=0,s8=0,s9= 0,total=0;
double p=0.0,p1=0.0,p2=0.0,p3=0.0,p4=0.0,p5=0.0,p6=0.0,p7=0.0,p8=0.0,t=0.0,t1=0.0,t2=0.0,t3=0.0,t4=0.0,t5=0.0,t6=0.0,t7=0.0,t8=0.0;
double sum=0.0,sum1=0.0,q=0.0,total1=0;
fp3=fopen("mmmmmm.txt","w" ;
fp4=fopen("mmmmmm11.txt","w" ;
for(ii=0;ii<19;ii++) //19次
{
printf("d[%d]=%c\t",ii,d[ii]);
for(jj=ii+1;jj<20;jj=jj+1) //19次
{
fprintf(fp3,"d[%d]=%c,d[%d]=%c\n",jj,d[jj],ii,d[ii]);///d[j1]=d[i1];
if((fp2=fopen("tai2.txt","r" )==NULL)//打开每一个文件
{
printf("cannot open name\n" ;
}
fgets(c,801,fp2);
leng=strlen(c);
fclose(fp2);
for(k=0;k<leng;k=k+1)
{
if((c[k]==d[jj])) c[k]=d[ii];
}
fprintf(fp4,"%s\n",c);
for(k=0;k<leng;k=k+2)
{
if(sign[k]=='*') continue;
k2++;
for(i=0;i<leng;i=i+2)
{
if((c[k]==c)&&(c[k+1]==c[i+1]))
{
k1++;
if(k1>0) sign='*';
}
}
k1=0;
if((fp=fopen("file.txt","r" )==NULL)
{
printf("cannot open file\t" ;
}
while(!feof(fp))
{
fgets(name,22,fp);
//printf("%s\t",name);
if((fp1=fopen(name,"r" )==NULL)//打开每一个文件
{
printf("cannot open name\n" ;
}
fgets(a,5000,fp1);
fgets(b,5000,fp1);
length=strlen(a);
length1=strlen(b);
fclose(fp1);
for(i=4;i<length;i++) //去逗号的过程
if (a==',')
{
for(j=i;j<length;j++)
a[j]=a[j+1];
a[j]='\0';
length=length-1;
}
for(i=5;i<length1;i++) //去逗号的过程
if (b==',')
{
for(j=i;j<length1;j++)
b[j]=b[j+1];
b[j]='\0';
length1=length1-1;
}
printf("%s\n",a);
printf("%s\n",b);
for(j=4;j<length;j++) //字符转化的过程
{
if((a[j]=='A')||(b[j]=='G')) b[j]='A';//代表A库
}
for(j=5;j<length1;j++) //字符转化的过程
{
if((b[j]=='H')||(b[j]=='G')||(b[j]=='I')) b[j]='A';//代表A库
if((b[j]=='E')) b[j]='R'; //代表B库
if((b[j]=='S')||(b[j]=='B')||(b[j]=='T')||(b[j]=='_')) b[j]='C';//代表C库
if((b[j]=='?')) b[j]=' ';
}
for(j=5;j<length1-1;j++)
{
if((b[j]=='A')&&(b[j+2]=='A'))
{
if((a[j-1]==c[k])&&(a[j+1]==c[k+1])) n++;//
}
if((b[j]=='A')&&(b[j+2]=='C'))
{
if((a[j-1]==c[k])&&(a[j+1]==c[k+1])) n1++;//
}
if((b[j]=='A')&&(b[j+2]=='R'))
{
if((a[j-1]==c[k])&&(a[j+1]==c[k+1])) n2++;//
}
if((b[j]=='R')&&(b[j+2]=='R'))
{
if((a[j-1]==c[k])&&(a[j+1]==c[k+1])) m++;//
}
if((b[j]=='R')&&(b[j+2]=='C'))
{
if((a[j-1]==c[k])&&(a[j+1]==c[k+1])) m1++;//
}
if((b[j]=='R')&&(b[j+2]=='A'))
{
if((a[j-1]==c[k])&&(a[j+1]==c[k+1])) m2++;//
}
if((b[j]=='C')&&(b[j+2]=='C'))
{
if((a[j-1]==c[k])&&(a[j+1]==c[k+1])) l++;//
}
if((b[j]=='C')&&(b[j+2]=='A'))
{
if((a[j-1]==c[k])&&(a[j+1]==c[k+1])) l1++;//
}
if((b[j]=='C')&&(b[j+2]=='R'))
{
if((a[j-1]==c[k])&&(a[j+1]==c[k+1])) l2++;//
}
}
total+=n+n1+n2+m+m1+m2+l+l1+l2;
s+=n;s1+=n1;s2+=n2;s3+=m;s4+=m1;s5+=m2;s6+=l;s7+=l1;s8+=l2;
n=0;n1=0;n2=0;m=0;m1=0;m2=0;l=0;l1=0;l2=0;
}//while(!feof(fp))
fclose(fp);
printf("total=%d\t",total);
fprintf(fp3,"total=%d\n",total);
total1+=total;
q=(double)total/80509; //82933;
p=(double)s/total;
if(p!=0.0) t+=q*p*log10(p);//
else t=0.0;
p1=(double)s1/total;
if(p1!=0.0) t1+=q*p1*log10(p1);
else t1=0.0;
p2=(double)s2/total;
if(p2!=0.0) t2+=q*p2*log10(p2);
else t2=0.0;
p3=(double)s3/total;
if(p3!=0.0) t3+=q*p3*log10(p3);
else t3=0.0;
p4=(double)s4/total;
if(p4!=0.0) t4+=q*p4*log10(p4);
else t4=0.0;
p5=(double)s5/total;
if(p5!=0.0) t5+=q*p5*log10(p5);
else t5=0.0;
p6=(double)s6/total;
if(p6!=0.0) t6+=q*p6*log10(p6);
else t6=0.0;
p7=(double)s7/total;
if(p7!=0.0) t7+=q*p7*log10(p7);
else t7=0.0;
p8=(double)s8/total;
if(p8!=0.0) t8+=q*p8*log10(p ;
else t8=0.0;
p=0.0;p1=0.0;p2=0.0;p3=0.0;p4=0.0;p5=0.0;p6=0.0;p7=0.0;p8=0.0;
s=0;s1=0;s2=0;s3=0;s4=0;s5=0;s6=0;s7=0;s8=0;total=0;q=0.0;
}//361个2态
printf("t=%f,t1=%f,t2=%f,t3=%f,t4=%f,t5=%f,t6=%f,t7=%f,t8=%f,total1=%f\n",t,t1,t2,t3,t4,t5,t6,t7,t8,total1);
sum=t+t1+t2+t3+t4+t5+t6+t7+t8;
sum1=1+(double)sum/0.775189;
printf("k2=%d\t,sum=%f\t,sum1=%f\n",k2,sum,sum1);
fprintf(fp3,"sum=%f\t,sum1=%f\n",sum,sum1);
sum=0.0;sum1=0.0;t=0.0;t1=0.0;t2=0.0;t3=0.0;t4=0.0;t5=0.0;t6=0.0;t7=0.0;t8=0.0;k2=0;
}
}
fclose(fp3);
return(0);
} |
|