Пример #1
0
static void gen_excls(t_atoms *atoms, t_excls *excls, t_hackblock hb[],
                      gmx_bool bAllowMissing)
{
    int         r;
    atom_id     a, astart, i1, i2, itmp;
    t_rbondeds *hbexcl;
    int         e;
    char       *anm;

    astart = 0;
    for (a = 0; a < atoms->nr; a++)
    {
        r = atoms->atom[a].resind;
        if (a == atoms->nr-1 || atoms->atom[a+1].resind != r)
        {
            hbexcl = &hb[r].rb[ebtsEXCLS];

            for (e = 0; e < hbexcl->nb; e++)
            {
                anm = hbexcl->b[e].a[0];
                i1  = search_atom(anm, astart, atoms,
                                  "exclusion", bAllowMissing);
                anm = hbexcl->b[e].a[1];
                i2  = search_atom(anm, astart, atoms,
                                  "exclusion", bAllowMissing);
                if (i1 != NO_ATID && i2 != NO_ATID)
                {
                    if (i1 > i2)
                    {
                        itmp = i1;
                        i1   = i2;
                        i2   = itmp;
                    }
                    srenew(excls[i1].e, excls[i1].nr+1);
                    excls[i1].e[excls[i1].nr] = i2;
                    excls[i1].nr++;
                }
            }

            astart = a+1;
        }
    }

    for (a = 0; a < atoms->nr; a++)
    {
        if (excls[a].nr > 1)
        {
            qsort(excls[a].e, excls[a].nr, (size_t)sizeof(atom_id), atom_id_comp);
        }
    }
}
Пример #2
0
void gen_cmap(t_params *psb, t_restp *restp, int natoms, t_atom atom[], char **aname[], int nres)
{
	int     residx,i,ii,j,k;
	atom_id ai,aj,ak,al,am;
	const char *ptr;
	
	if (debug)
		ptr = "cmap";
	else
		ptr = "check";
	
	fprintf(stderr,"Making cmap torsions...");
	i=0;
	/* End loop at nres-1, since the very last residue does not have a +N atom, and
	 * therefore we get a valgrind invalid 4 byte read error with atom am */
	for(residx=0; residx<nres-1; residx++)
	{
		/* Add CMAP terms from the list of CMAP interactions */
		for(j=0;j<restp[residx].rb[ebtsCMAP].nb; j++)
		{
			ai=search_atom(restp[residx].rb[ebtsCMAP].b[j].a[0],i,natoms,atom,aname,
						   ptr,TRUE);
			aj=search_atom(restp[residx].rb[ebtsCMAP].b[j].a[1],i,natoms,atom,aname,
						   ptr,TRUE);
			ak=search_atom(restp[residx].rb[ebtsCMAP].b[j].a[2],i,natoms,atom,aname,
						   ptr,TRUE);
			al=search_atom(restp[residx].rb[ebtsCMAP].b[j].a[3],i,natoms,atom,aname,
						   ptr,TRUE);
			am=search_atom(restp[residx].rb[ebtsCMAP].b[j].a[4],i,natoms,atom,aname,
						   ptr,TRUE);
			
			/* The first and last residues no not have cmap torsions */
			if(ai!=NO_ATID && aj!=NO_ATID && ak!=NO_ATID && al!=NO_ATID && am!=NO_ATID)
			{
				add_cmap_param(psb,ai,aj,ak,al,am,restp[residx].rb[ebtsCMAP].b[j].s);
			}
		}
		
		if(residx<nres-1)
		{
			while(atom[i].resind<residx+1)
			{
				i++;
			}
		}
	}
	
	/* Start the next residue */
}
Пример #3
0
static int get_impropers(t_atoms *atoms, t_hackblock hb[], t_param **improper,
                         gmx_bool bAllowMissing)
{
    t_rbondeds   *impropers;
    int           nimproper, i, j, k, start, ninc, nalloc;
    atom_id       ai[MAXATOMLIST];
    gmx_bool      bStop;

    ninc   = 500;
    nalloc = ninc;
    snew(*improper, nalloc);

    /* Add all the impropers from the residue database to the list. */
    nimproper = 0;
    start     = 0;
    if (hb != NULL)
    {
        for (i = 0; (i < atoms->nres); i++)
        {
            impropers = &hb[i].rb[ebtsIDIHS];
            for (j = 0; (j < impropers->nb); j++)
            {
                bStop = FALSE;
                for (k = 0; (k < 4) && !bStop; k++)
                {
                    ai[k] = search_atom(impropers->b[j].a[k], start,
                                        atoms,
                                        "improper", bAllowMissing);
                    if (ai[k] == NO_ATID)
                    {
                        bStop = TRUE;
                    }
                }
                if (!bStop)
                {
                    if (nimproper == nalloc)
                    {
                        nalloc += ninc;
                        srenew(*improper, nalloc);
                    }
                    /* Not broken out */
                    set_p(&((*improper)[nimproper]), ai, NULL, impropers->b[j].s);
                    nimproper++;
                }
            }
            while ((start < atoms->nr) && (atoms->atom[start].resind == i))
            {
                start++;
            }
        }
    }

    return nimproper;
}
Пример #4
0
static atom_id pdbasearch_atom(const char *name,int resind,t_atoms *pdba,
			       const char *searchtype,gmx_bool bAllowMissing)
{
  int  i;
  
  for(i=0; (i<pdba->nr) && (pdba->atom[i].resind != resind); i++)
    ;
    
  return search_atom(name,i,pdba->nr,pdba->atom,pdba->atomname,
		     searchtype,bAllowMissing);
}
Пример #5
0
atom_id pdbasearch_atom(char *name,int resnr,t_atoms *pdba, char *searchtype,
			bool bMissing)
{
  int  i;
  
  for(i=0; (i<pdba->nr) && (pdba->atom[i].resnr != resnr); i++)
    ;
    
  return search_atom(name,i,pdba->nr,pdba->atom,pdba->atomname,
		     searchtype,bMissing);
}
Пример #6
0
static atom_id search_res_atom(const char *type,int resind,
			       int natom,t_atom at[],
			       char ** const *aname,
			       const char *bondtype,gmx_bool bAllowMissing)
{
  int i;

  for(i=0; (i<natom); i++)
    if (at[i].resind == resind)
      return search_atom(type,i,natom,at,aname,bondtype,bAllowMissing);
  
  return NO_ATID;
}
Пример #7
0
static int get_impropers(t_atoms *atoms,t_hackblock hb[],t_param **idih,
			 bool bMissing)
{
  char      *a0;
  t_rbondeds *idihs;
  t_rbonded  *hbidih;
  int       nidih,i,j,k,r,start,ninc,nalloc;
  atom_id   ai[MAXATOMLIST];
  bool      bStop;
  
  ninc = 500;
  nalloc = ninc;
  snew(*idih,nalloc);

  /* Add all the impropers from the residue database to the list. */
  nidih = 0;
  start = 0;
  if (hb != NULL) {
    for(i=0; (i<atoms->nres); i++) {
      idihs=&hb[i].rb[ebtsIDIHS];
      for(j=0; (j<idihs->nb); j++) {
	bStop=FALSE;
	for(k=0; (k<4) && !bStop; k++) {
	  ai[k] = search_atom(idihs->b[j].a[k],start,
			      atoms->nr,atoms->atom,atoms->atomname,
			      "improper",bMissing);
	  if (ai[k] == NO_ATID)
	    bStop = TRUE;
	}
	if (!bStop) {
	  if (nidih == nalloc) {
	    nalloc += ninc;
	    srenew(*idih,nalloc);
	  }
	  /* Not broken out */
	  set_p(&((*idih)[nidih]),ai,NULL,idihs->b[j].s);
	  nidih++;
	}
      }
      while ((start<atoms->nr) && (atoms->atom[start].resind == i))
	start++;
    }
  }
  
  return nidih;
}
Пример #8
0
int
search_res_atom(const char *type, int resind,
                t_atoms *atoms,
                const char *bondtype, bool bAllowMissing)
{
    int i;

    for (i = 0; (i < atoms->nr); i++)
    {
        if (atoms->atom[i].resind == resind)
        {
            return search_atom(type, i, atoms, bondtype, bAllowMissing);
        }
    }

    return -1;
}
Пример #9
0
static void at2bonds(t_params *psb, t_hackblock *hb,
                     int natoms, t_atom atom[], char **aname[], 
                     int nres, rvec x[], 
                     real long_bond_dist, real short_bond_dist,
                     gmx_bool bAllowMissing)
{
  int     resind,i,j,k;
  atom_id ai,aj;
  real    dist2, long_bond_dist2, short_bond_dist2;
  const char *ptr;

  long_bond_dist2  = sqr(long_bond_dist);
  short_bond_dist2 = sqr(short_bond_dist);

  if (debug)
    ptr = "bond";
  else
    ptr = "check";

  fprintf(stderr,"Making bonds...\n");
  i=0;
  for(resind=0; (resind < nres) && (i<natoms); resind++) {
    /* add bonds from list of bonded interactions */
    for(j=0; j < hb[resind].rb[ebtsBONDS].nb; j++) {
      /* Unfortunately we can not issue errors or warnings
       * for missing atoms in bonds, as the hydrogens and terminal atoms
       * have not been added yet.
       */
      ai=search_atom(hb[resind].rb[ebtsBONDS].b[j].AI,i,natoms,atom,aname,
		     ptr,TRUE);
      aj=search_atom(hb[resind].rb[ebtsBONDS].b[j].AJ,i,natoms,atom,aname,
		     ptr,TRUE);
      if (ai != NO_ATID && aj != NO_ATID) {
          dist2 = distance2(x[ai],x[aj]);
          if (dist2 > long_bond_dist2 )
          {
              fprintf(stderr,"Warning: Long Bond (%d-%d = %g nm)\n",
                      ai+1,aj+1,sqrt(dist2));
          }
          else if (dist2 < short_bond_dist2 )
          {
              fprintf(stderr,"Warning: Short Bond (%d-%d = %g nm)\n",
                      ai+1,aj+1,sqrt(dist2));
          }
          add_param(psb,ai,aj,NULL,hb[resind].rb[ebtsBONDS].b[j].s);
      }
    }
    /* add bonds from list of hacks (each added atom gets a bond) */
    while( (i<natoms) && (atom[i].resind == resind) ) {
      for(j=0; j < hb[resind].nhack; j++)
	if ( ( hb[resind].hack[j].tp > 0 ||
	       hb[resind].hack[j].oname==NULL ) &&
	     strcmp(hb[resind].hack[j].AI,*(aname[i])) == 0 ) {
	  switch(hb[resind].hack[j].tp) {
	  case 9:          /* COOH terminus */
	    add_param(psb,i,i+1,NULL,NULL);     /* C-O  */
	    add_param(psb,i,i+2,NULL,NULL);     /* C-OA */
	    add_param(psb,i+2,i+3,NULL,NULL);   /* OA-H */
	    break;
	  default:
	    for(k=0; (k<hb[resind].hack[j].nr); k++)
	      add_param(psb,i,i+k+1,NULL,NULL);
	  }
	}
      i++;
    }
    /* we're now at the start of the next residue */
  }
}