# include # include # include # include # include # define MAXATOM 10000 # define MAXCHAR 256 # define COLORTEXT "YES" typedef struct { char name[5]; double x; double y; double z; } ATOM; char ifilename[MAXCHAR]; char rfilename[MAXCHAR]; char ofilename[MAXCHAR]; char mfilename[MAXCHAR]; char line[MAXCHAR]; ATOM atom1[MAXATOM]; ATOM atom2[MAXATOM]; ATOM atom3[MAXATOM]; int i; int numarg = 0; int jobtype = 1; int atomnum1, atomnum2, atomnum; FILE *fpout; double rms; double CG0[3] = {0,0,0}; double CG1[3]={0,0,0}; double ROT[3][3]={1,0,0,0,1,0,0,0,1}; char tmpchar1[MAXCHAR]; char tmpchar2[MAXCHAR]; /* PDB */ int rpdb(char *filename, int *atomnum, ATOM * atom) { int numatom; int tmpint; char line[MAXCHAR]; double x, y, z; FILE *fpin; if ((fpin = fopen(filename, "r")) == NULL) { fprintf(stdout, "Cannot open the pdb file %s in rpdb(), exit\n", filename); exit(1); } numatom = 0; for (;;) { if (fgets(line, MAXCHAR, fpin) == NULL) break; if (strncmp("ATOM", line, 4) == 0 || strncmp("HETATM", line, 6) == 0) { sscanf(&line[22], "%d%lf%lf%lf", &tmpint, &x, &y, &z); atom[numatom].name[0] = line[12]; atom[numatom].name[1] = line[13]; atom[numatom].name[2] = line[14]; atom[numatom].name[3] = line[15]; atom[numatom].x = x; atom[numatom].y = y; atom[numatom].z = z; numatom++; } } *atomnum = numatom; fclose(fpin); } int wpdb(char *filename1, char *filename2, ATOM *atom) { int numatom; int tmpint; double x, y, z; FILE *fpin, *fpout; if ((fpin = fopen(filename1, "r")) == NULL) { fprintf(stdout, "Cannot open file %s to read in wpdb(), exit\n", filename1); exit(1); } if ((fpout = fopen(filename2, "w")) == NULL) { fprintf(stdout, "Cannot open file %s to write in wpdb(), exit\n", filename2); exit(1); } numatom = 0; for (;;) { if (fgets(line, MAXCHAR, fpin) == NULL) break; if (strncmp("ATOM", line, 4) == 0 || strncmp("HETATM", line, 6) == 0) { strcpy(tmpchar1, ""); tmpchar1[0]='\0'; for(i=0;i<30;i++) tmpchar1[i] = line[i]; tmpchar1[30] = '\0'; tmpint = strlen(line); strcpy(tmpchar2, ""); tmpchar2[0]='\0'; for(i=54;i1000) goto a70; iy=ix+1; if(iy==4) iy=1; iz=6-ix-iy; sig=aa[iz-1][iy-1]-aa[iy-1][iz-1]; gam=aa[iy-1][iy-1]+aa[iz-1][iz-1]; sg=sqrt(sig*sig+gam*gam); if(sg==0) goto a50; sg=1.0/sg; if(fabs(sig)