/* This program counts the number of residues determined by the user at a */ /* given position in an alignment. The percentages are given as averages */ /* in a variable window. 8/24/94 st */ #include #include main(ac,av) int ac; char *av[]; { FILE *ALIGN,*INPout,*AAFout; char T,code[6],residues[12],seqarray[30][1000],str[200]; int ansarrleng,begin,c,e,end,i,length,numlines,numseq,pos,posn,algn_leng,row,start,s top,wsize,x,y,z; float Acnt,Rcnt,Ncnt,Dcnt,Gcnt,Ccnt,Qcnt,Ecnt,Hcnt,Icnt,Lcnt,Kcnt,Mcnt,Fcnt,Pcnt,Scnt, Tcnt,Wcnt,Ycnt,Vcnt; float Inputcnt,aafreq[29][1000],ARcount,Other,scorearray1[2][1000],scorearray2[2][1000 ],sum; wsize=atoi(av[1]); if(ac!=5 && wsize%2==0) { printf("aachk gathers statistical data on all the positions in an alignment.\nThe user is allowed to input a group (max. of 10) of amino acids.\n"); printf("Usage: aachk ws rf wf1 wf2.\n"); printf(" ws = window size-must be odd\n"); printf(" rf = alignment in NEWAT format\n"); printf(" wf1= save file for input amino acid frequencies\n"); printf(" wf2= save file frequency of amino acid appearance\n"); printf(" MAX length = 1000 MAX SEQ=30\n"); exit (1); } if((ALIGN=fopen(av[2],"r"))==NULL) { printf("File %s does not exist.\n", av[2]); exit (1); } INPout=fopen(av[3],"w"); AAFout=fopen(av[4],"w"); /* Get the amino acids from the user */ do { printf("Enter the amino acids with a space between each one (max. of 10): "); gets(residues); T=strlen(residues); } while(T%2==0 && T<20); fprintf(INPout,"input residues %s\n",residues); /* Approximate the length of the sequences for use in the loop for filling seqarray below */ numlines=0; fgets(str,sizeof str,ALIGN); while (strstr(str,"*")==NULL) { fgets(str,sizeof str,ALIGN); numlines++; } length=(numlines)*30; /* Read aligned sequences into the array seqarray. This is the array of sequences. */ rewind(ALIGN); row=0; numseq=0; for(;;) { c=fgetc(ALIGN); if(c==EOF) { fclose(ALIGN); break; } else { ungetc(c,ALIGN); fgets(str,sizeof str,ALIGN); if(str[0]=='T') { numseq++; y=0; for(i=0;i