static void calc_all_pos(t_atoms *pdba, rvec x[], int nab[], t_hack *ab[], gmx_bool bCheckMissing) { int i, j, ii, jj, m, ia, d, rnr,l=0; #define MAXH 4 rvec xa[4]; /* control atoms for calc_h_pos */ rvec xh[MAXH]; /* hydrogen positions from calc_h_pos */ gmx_bool bFoundAll; jj = 0; for(i=0; i < pdba->nr; i++) { rnr = pdba->atom[i].resind; for(j=0; j < nab[i]; j+=ab[i][j].nr) { /* check if we're adding: */ if (ab[i][j].oname==NULL && ab[i][j].tp > 0) { bFoundAll = TRUE; for(m=0; (m<ab[i][j].nctl && bFoundAll); m++) { ia = pdbasearch_atom(ab[i][j].a[m], rnr, pdba, bCheckMissing ? "atom" : "check", !bCheckMissing); if (ia < 0) { /* not found in original atoms, might still be in t_hack (ab) */ hacksearch_atom(&ii, &jj, ab[i][j].a[m], nab, ab, rnr, pdba); if (ii >= 0) { copy_rvec(ab[ii][jj].newx, xa[m]); } else { bFoundAll = FALSE; if (bCheckMissing) { gmx_fatal(FARGS,"Atom %s not found in residue %s %d" ", rtp entry %s" " while adding hydrogens", ab[i][j].a[m], *pdba->resinfo[rnr].name, pdba->resinfo[rnr].nr, *pdba->resinfo[rnr].rtp); } } } else { copy_rvec(x[ia], xa[m]); } } if (bFoundAll) { for(m=0; (m<MAXH); m++) for(d=0; d<DIM; d++) if (m<ab[i][j].nr) xh[m][d] = 0; else xh[m][d] = NOTSET; calc_h_pos(ab[i][j].tp, xa, xh, &l); for(m=0; m<ab[i][j].nr; m++) { copy_rvec(xh[m],ab[i][j+m].newx); ab[i][j+m].bXSet = TRUE; } } } } } }
static int check_atoms_present(t_atoms *pdba, int nab[], t_hack *ab[]) { int i, j, k, d, rnr, nadd; nadd = 0; for (i = 0; i < pdba->nr; i++) { rnr = pdba->atom[i].resind; for (j = 0; j < nab[i]; j++) { if (ab[i][j].oname == NULL) { /* we're adding */ if (ab[i][j].nname == NULL) { gmx_incons("ab[i][j].nname not allocated"); } /* check if the atom is already present */ k = pdbasearch_atom(ab[i][j].nname, rnr, pdba, "check", TRUE); if (k != -1) { /* We found the added atom. */ ab[i][j].bAlreadyPresent = TRUE; if (debug) { fprintf(debug, "Atom '%s' in residue '%s' %d is already present\n", ab[i][j].nname, *pdba->resinfo[rnr].name, pdba->resinfo[rnr].nr); } } else { ab[i][j].bAlreadyPresent = FALSE; /* count how many atoms we'll add */ nadd++; } } else if (ab[i][j].nname == NULL) { /* we're deleting */ nadd--; } } } return nadd; }
static void calc_all_pos(t_atoms *pdba, rvec x[], int nab[], t_hack *ab[], bool bMissing) { int i, j, ii, jj, m, ia, d, rnr; #define MAXH 4 rvec xa[4]; /* control atoms for calc_h_pos */ rvec xh[MAXH]; /* hydrogen positions from calc_h_pos */ jj = 0; for(i=0; i < pdba->nr; i++) { rnr = pdba->atom[i].resind; for(j=0; j < nab[i]; j+=ab[i][j].nr) { /* check if we're adding: */ if (ab[i][j].oname==NULL && ab[i][j].tp > 0) { for(m=0; (m<ab[i][j].nctl); m++) { ia = pdbasearch_atom(ab[i][j].a[m], rnr, pdba, "atom", bMissing); if (ia < 0) { /* not found in original atoms, might still be in t_hack (ab) */ hacksearch_atom(&ii, &jj, ab[i][j].a[m], nab, ab, rnr, pdba); if (ii < 0) gmx_fatal(FARGS,"Atom %s not found in residue %s%d" " while adding hydrogens", ab[i][j].a[m], *pdba->resinfo[rnr].name, pdba->resinfo[rnr].nr); else copy_rvec(ab[ii][jj].newx, xa[m]); } else copy_rvec(x[ia], xa[m]); } for(m=0; (m<MAXH); m++) for(d=0; d<DIM; d++) if (m<ab[i][j].nr) xh[m][d] = 0; else xh[m][d] = NOTSET; calc_h_pos(ab[i][j].tp, xa, xh); for(m=0; m<ab[i][j].nr; m++) copy_rvec(xh[m],ab[i][j+m].newx); } } } }
static int check_atoms_present(t_atoms *pdba, int nab[], t_hack *ab[], bool bMissing) { int i, j, k, d, rnr, nadd; nadd=0; for(i=0; i < pdba->nr; i++) { rnr = pdba->atom[i].resind; for(j=0; j<nab[i]; j++) if ( ab[i][j].oname==NULL ) { /* we're adding */ if (ab[i][j].nname == NULL) gmx_incons("ab[i][j].name not allocated"); /* check if the atom is already present */ k=pdbasearch_atom(ab[i][j].nname, rnr, pdba, "check", bMissing); if ( k != -1 ) { /* we found the added atom, so move the hack there: */ srenew(ab[k], nab[k]+1); ab[k][nab[k]] = ab[i][j]; ab[k][nab[k]].oname = strdup(ab[k][nab[k]].nname); /* reset any possible new coordinates: */ for(d=0; d<DIM; d++) ab[k][nab[k]].newx[d]=NOTSET; /* keep count */ nab[k]++; /* remove the hack from this atom: */ for(k=j+1; k<nab[i]; k++) ab[i][k-1] = ab[i][k]; /* keep count */ nab[i]--; j--; srenew(ab[i], nab[i]); } else /* count how many atoms we'll add */ nadd++; } else if ( ab[i][j].nname==NULL ) /* we're deleting */ nadd--; } return nadd; }