예제 #1
0
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;
	  }
	}
      }
    }
  }
}
예제 #2
0
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);
      }
    }
  }
}