/* ************************************************************************ * All Copyright Reserved! * * * * Prog: respgen * * Version: version 1.0 * * Author: Junmei Wang * * * * Department of Pharmaceutical Chemistry * * School of Pharmacy * * University of California * * San Francisco CA 94143 * * Octomber, 2001 * ************************************************************************ */ # include "common.h" # include "define.h" # include "atom.h" # include "utility.c" # include "common.c" # include "ac.c" # define MAXPATHATOMNUM 5000 # define MAX_RESP_ATOM 1000 ATOM *atom; BOND *bond; int atomnum = 0; int bondnum = 0; CONTROLINFO cinfo; MOLINFO minfo; int *selectindex; int *equatomno; int *pathnum; int *selectelement; int *pathatomnum; int maxlength = -1; double *pathscore[MAX_RESP_ATOM] ; int i, j, k, l; FILE *fpin; FILE *fpout; char line[MAXCHAR]; char ifilename[MAXCHAR]; char ofilename[MAXCHAR]; int overflow_flag = 0; int method = 0; int selectnum = 0; int pathnumindex = 0; int atomindex = 0; double charge = 0.0; void scorepath(ATOM atm[], int selectnum, int startnum) { int i, j, k; int start; double score; int resetindex; start = -1; resetindex = -1; selectindex[startnum] = selectnum; selectelement[selectnum++] = startnum; if(maxlength != -1 && selectnum > maxlength) return; for (i = 0; i < 6; i++) { if (atm[startnum].con[i] == -1) { score = 0.0; for (j = 0; j < selectnum; j++) { /* printf("%5d", selectelement[j]); */ score += (j + 1) * 0.11 + atom[selectelement[j]].atomicnum * 0.08; } pathscore[atomindex][pathnumindex++] = score; if (pathnumindex >= pathatomnum[atomindex]) { pathatomnum[atomindex] += MAXPATHATOMNUM; fprintf (stderr, "\nInfo: the number of the path atoms exceeds MAXPATHATOMNUM(%d) for atom[%d],extend the size and reallocate the memory automatically", pathatomnum[atomindex], atomindex); pathscore[atomindex] = (double *) realloc(pathscore[atomindex], pathatomnum[atomindex] * sizeof(double)); if (pathscore[atomindex] == NULL) { fprintf(stderr, " reallocate memory for pathscore[%d] failed\n", atomindex); exit(0); } } /* printf("\n %5d%8.4lf", selectnum, score); */ return; } start = atm[startnum].con[i]; for (k = 0; k < selectnum; k++) if (start == selectelement[k]) { resetindex = 1; break; } if (resetindex == 1) { resetindex = -1; continue; } if (start == -1) return; scorepath(atm, selectnum, start); /* we have already visited this atom */ } } void sort(double array[], int elemnum) { int i, j; double tmp; for (i = 0; i < elemnum; i++) for (j = i + 1; j < elemnum; j++) { if (array[j] < array[i]) { tmp = array[i]; array[i] = array[j]; array[j] = tmp; } } /* printf("\n"); */ /* printf("%8d", elemnum); for(i=0;i= 0) if (atom[atom[i].con[j]].atomicnum == 1) cindex++; if (cindex >= 2) { chindex[i] = 1; for (j = 0; j < 6; j++) if (atom[i].con[j] >= 0) if (atom[atom[i].con[j]].atomicnum == 1) chindex[atom[i].con[j]] = 1; } } /* for(i=0;i= -9990) charge = minfo.dcharge; selectindex = (int *) malloc(sizeof(int) * atomnum); if (selectindex == NULL) { fprintf(stderr, "memory allocation error for *selectindex\n"); exit(0); } equatomno = (int *) malloc(sizeof(int) * atomnum); if (equatomno == NULL) { fprintf(stderr, "memory allocation error for *equatomno\n"); exit(0); } pathnum = (int *) malloc(sizeof(int) * atomnum); if (pathnum == NULL) { fprintf(stderr, "memory allocation error for *pathnum\n"); exit(0); } selectelement = (int *) malloc(sizeof(int) * atomnum); if (selectelement == NULL) { fprintf(stderr, "memory allocation error for *selectelement\n"); exit(0); } pathatomnum = (int *) malloc(sizeof(int) * atomnum); if (pathatomnum == NULL) { fprintf(stderr, "memory allocation error for *pathatomnum\n"); exit(0); } if(atomnum > MAX_RESP_ATOM) { fprintf(stderr, "The number of atoms (%d) exceed the MAX_RESP_ATOM (%d) defined in respgen.c, extend MAX_RESP_ATOM and recompile the program\n, atomnum, MAX_RESP_ATOM"); exit(0); } for (i = 0; i < atomnum; i++) { pathatomnum[i] = MAXPATHATOMNUM; pathscore[i] = (double *) calloc(pathatomnum[i], sizeof(double)); if (pathscore == NULL) { fprintf(stderr, "memory allocation error for *pathscore[%d]\n", i + 1); exit(0); } } equatom(); respin(method); printf("\n"); /* free(atom); free(selectindex); free(selectelement); free(equatomno); free(pathnum); free(pathatomnum); for (i =0 ;i