Exemplo n.º 1
0
static void get_dih(t_xrama *xr, t_atoms *atoms)
{
    int    found, ff[NPP];
    int    i;
    size_t j;

    for (i = 0; (i < atoms->nr); )
    {
        found = i;
        for (j = 0; (j < NPP); j++)
        {
            if ((ff[j] = find_atom(pp_pat[j], atoms->atomname, found, atoms->nr)) == -1)
            {
                break;
            }
            found = ff[j]+1;
        }
        if (j != NPP)
        {
            break;
        }
        add_xr(xr, ff, atoms);
        i = ff[0]+1;
    }
    fprintf(stderr, "Found %d phi-psi combinations\n", xr->npp);
}
Exemplo n.º 2
0
static void get_dih2(t_xrama *xr,t_functype functype[],
		     t_ilist *bondeds,t_atoms *atoms)
{
  int     found,**ff,thisff[NPP];
  int     i,j,k,type,ftype,nat,ai,aj,ak,al;
  char    *cai,*caj,*cak,*cal;
  int     ndih,maxdih;
  t_iatom *iatoms;

  ndih=0;
  maxdih=1+(bondeds->nr/5);
  snew(ff,maxdih);
  for(j=0; (j<maxdih); j++) {
    snew(ff[j],NPP);
  }
  fprintf(stderr,"There may be as many as %d dihedrals...\n",maxdih);
  
  iatoms=bondeds->iatoms;
  for(i=0; (i<bondeds->nr); ) {
    type=iatoms[0];
    ftype=functype[type];
    nat=interaction_function[ftype].nratoms+1;
    
    if (ftype == F_PDIHS) {
      ai=iatoms[1]; cai=*atoms->atomname[ai];
      aj=iatoms[2]; caj=*atoms->atomname[aj];
      ak=iatoms[3]; cak=*atoms->atomname[ak];
      al=iatoms[4]; cal=*atoms->atomname[al];
      
      for(j=0; (j<NPP); j++)
	thisff[j]=-1;
      if (strcasecmp(cai,"C") == 0) {
	/* May be a Phi angle */
	if ((strcasecmp(caj,"N") == 0) &&
	    (strcasecmp(cak,"CA") == 0) &&
	    (strcasecmp(cal,"C") == 0))
	  thisff[0]=ai,thisff[1]=aj,thisff[2]=ak,thisff[3]=al;
      }
      else if (strcasecmp(cai,"N") == 0) {
	/* May be a Psi angle */
	if ((strcasecmp(caj,"CA") == 0) &&
	    (strcasecmp(cak,"C") == 0) &&
	    (strcasecmp(cal,"N") == 0))
	  thisff[1]=ai,thisff[2]=aj,thisff[3]=ak,thisff[4]=al;
      }
      if (thisff[1] != -1) {
	ndih=search_ff(thisff,ndih,ff);
	if (ndih > maxdih)
	  fatal_error(0,"More than %n dihedrals found. SEGV?",maxdih);
      }
      else {
	fprintf(stderr,"No Phi or Psi, atoms: %s %s %s %s\n",
		cai,caj,cak,cal);
      }
    }
    i+=nat;
    iatoms+=nat;
  }
  for(j=0; (j<ndih); j++) {
    if ((ff[j][0] != -1) && (ff[j][4] != -1))
      add_xr(xr,ff[j],atoms);
    else {
      fprintf(stderr,"Incomplete dihedral(%d) atoms: ",j);
      for(k=0; (k<NPP); k++)
	fprintf(stderr,"%2s ",
		ff[j][k] == -1 ? "-1" : *atoms->atomname[ff[j][k]]);
      fprintf(stderr,"\n");
    }
  }
  fprintf(stderr,"Found %d phi-psi combinations\n",xr->npp);
}