Exemplo n.º 1
0
void merge_hacks_lo(int ns, t_hack *s, int *nd, t_hack **d)
{
    int i;

    if (ns)
    {
        srenew(*d, *nd + ns);
        for (i = 0; i < ns; i++)
        {
            copy_t_hack(&s[i], &(*d)[*nd + i]);
        }
        (*nd) += ns;
    }
}
Exemplo n.º 2
0
static void expand_hackblocks_one(t_hackblock *hbr, char *atomname,
                                  int *nabi, t_hack **abi, gmx_bool bN, gmx_bool bC)
{
    int      j, k, l, d;
    gmx_bool bIgnore;

    /* we'll recursively add atoms to atoms */
    for (j = 0; j < hbr->nhack; j++)
    {
        /* first check if we're in the N- or C-terminus, then we should ignore
           all hacks involving atoms from resp. previous or next residue
           (i.e. which name begins with '-' (N) or '+' (C) */
        bIgnore = FALSE;
        if (bN) /* N-terminus: ignore '-' */
        {
            for (k = 0; k < 4 && hbr->hack[j].a[k] && !bIgnore; k++)
            {
                bIgnore = hbr->hack[j].a[k][0] == '-';
            }
        }
        if (bC) /* C-terminus: ignore '+' */
        {
            for (k = 0; k < 4 && hbr->hack[j].a[k] && !bIgnore; k++)
            {
                bIgnore = hbr->hack[j].a[k][0] == '+';
            }
        }
        /* must be either hdb entry (tp>0) or add from tdb (oname==NULL)
           and first control aton (AI) matches this atom or
           delete/replace from tdb (oname!=NULL) and oname matches this atom */
        if (debug)
        {
            fprintf(debug, " %s", hbr->hack[j].oname ? hbr->hack[j].oname : hbr->hack[j].AI);
        }

        if (!bIgnore &&
            ( ( ( hbr->hack[j].tp > 0 || hbr->hack[j].oname == NULL ) &&
                strcmp(atomname, hbr->hack[j].AI) == 0 ) ||
              ( hbr->hack[j].oname != NULL &&
                strcmp(atomname, hbr->hack[j].oname) == 0) ) )
        {
            /* now expand all hacks for this atom */
            if (debug)
            {
                fprintf(debug, " +%dh", hbr->hack[j].nr);
            }
            srenew(*abi, *nabi + hbr->hack[j].nr);
            for (k = 0; k < hbr->hack[j].nr; k++)
            {
                copy_t_hack(&hbr->hack[j], &(*abi)[*nabi + k]);
                (*abi)[*nabi + k].bXSet = FALSE;
                /* if we're adding (oname==NULL) and don't have a new name (nname)
                   yet, build it from atomname */
                if ( (*abi)[*nabi + k].nname == NULL)
                {
                    if ( (*abi)[*nabi + k].oname == NULL)
                    {
                        (*abi)[*nabi + k].nname    = strdup(atomname);
                        (*abi)[*nabi + k].nname[0] = 'H';
                    }
                }
                else
                {
                    if (gmx_debug_at)
                    {
                        fprintf(debug, "Hack '%s' %d, replacing nname '%s' with '%s' (old name '%s')\n",
                                atomname, j,
                                (*abi)[*nabi + k].nname, hbr->hack[j].nname,
                                (*abi)[*nabi + k].oname ? (*abi)[*nabi + k].oname : "");
                    }
                    sfree((*abi)[*nabi + k].nname);
                    (*abi)[*nabi + k].nname = strdup(hbr->hack[j].nname);
                }

                if (hbr->hack[j].tp == 10 && k == 2)
                {
                    /* This is a water virtual site, not a hydrogen */
                    /* Ugly hardcoded name hack */
                    (*abi)[*nabi + k].nname[0] = 'M';
                }
                else if (hbr->hack[j].tp == 11 && k >= 2)
                {
                    /* This is a water lone pair, not a hydrogen */
                    /* Ugly hardcoded name hack */
                    srenew((*abi)[*nabi + k].nname, 4);
                    (*abi)[*nabi + k].nname[0] = 'L';
                    (*abi)[*nabi + k].nname[1] = 'P';
                    (*abi)[*nabi + k].nname[2] = '1' + k - 2;
                    (*abi)[*nabi + k].nname[3] = '\0';
                }
                else if (hbr->hack[j].nr > 1)
                {
                    /* adding more than one atom, number them */
                    l = strlen((*abi)[*nabi + k].nname);
                    srenew((*abi)[*nabi + k].nname, l+2);
                    (*abi)[*nabi + k].nname[l]   = '1' + k;
                    (*abi)[*nabi + k].nname[l+1] = '\0';
                }
            }
            (*nabi) += hbr->hack[j].nr;

            /* add hacks to atoms we've just added */
            if (hbr->hack[j].tp > 0 || hbr->hack[j].oname == NULL)
            {
                for (k = 0; k < hbr->hack[j].nr; k++)
                {
                    expand_hackblocks_one(hbr, (*abi)[*nabi-hbr->hack[j].nr+k].nname,
                                          nabi, abi, bN, bC);
                }
            }
        }
    }
}
Exemplo n.º 3
0
static void expand_hackblocks_one(t_hackblock *hbr, char *atomname, 
				  int *nabi, t_hack **abi, bool bN, bool bC)
{
  int j, k, l, d;
  bool bIgnore;
  
  /* we'll recursively add atoms to atoms */
  for(j=0; j < hbr->nhack; j++) {
    /* first check if we're in the N- or C-terminus, then we should ignore 
       all hacks involving atoms from resp. previous or next residue
       (i.e. which name begins with '-' (N) or '+' (C) */
    bIgnore = FALSE;
    if ( bN ) /* N-terminus: ignore '-' */
      for(k=0; k<4 && hbr->hack[j].a[k] && !bIgnore; k++)
	bIgnore = hbr->hack[j].a[k][0]=='-';
    if ( bC ) /* C-terminus: ignore '+' */
      for(k=0; k<4 && hbr->hack[j].a[k] && !bIgnore; k++)
	bIgnore = hbr->hack[j].a[k][0]=='+';
    /* must be either hdb entry (tp>0) or add from tdb (oname==NULL)
       and first control aton (AI) matches this atom or
       delete/replace from tdb (oname!=NULL) and oname matches this atom */
    if (debug) fprintf(debug," %s",
		       hbr->hack[j].oname?hbr->hack[j].oname:hbr->hack[j].AI);

    if ( !bIgnore &&
         ( ( ( hbr->hack[j].tp > 0 || hbr->hack[j].oname==NULL ) &&
             strcmp(atomname, hbr->hack[j].AI) == 0 ) ||
           ( hbr->hack[j].oname!=NULL &&
             strcmp(atomname, hbr->hack[j].oname) == 0) ) ) {
      /* now expand all hacks for this atom */
      if (debug) fprintf(debug," +%dh",hbr->hack[j].nr);
      srenew(*abi,*nabi + hbr->hack[j].nr);
      for(k=0; k < hbr->hack[j].nr; k++) {
	copy_t_hack(&hbr->hack[j], &(*abi)[*nabi + k]);
	for(d=0; d<DIM; d++)
	  (*abi)[*nabi + k].newx[d]=NOTSET;
	/* if we're adding (oname==NULL) and don't have a new name (nname) 
	   yet, build it from atomname */
	if ( (*abi)[*nabi + k].nname==NULL ) {
	  if ( (*abi)[*nabi + k].oname==NULL ) {
	    (*abi)[*nabi + k].nname=strdup(atomname);
	    (*abi)[*nabi + k].nname[0]='H';
	  }
	} else {
	  sfree((*abi)[*nabi + k].nname);
	  (*abi)[*nabi + k].nname=strdup(hbr->hack[j].nname);
	}
	/* if adding more than one atom, number them */
	if ( hbr->hack[j].nr > 1 ) {
	  l = strlen((*abi)[*nabi + k].nname);
	  srenew((*abi)[*nabi + k].nname, l+2);
	  (*abi)[*nabi + k].nname[l] = Hnum[k]; /* 1, 2, 3 .... */
	  (*abi)[*nabi + k].nname[l+1] = '\0';
	}
      }
      (*nabi) += hbr->hack[j].nr;
      
      /* add hacks to atoms we've just added */
      if ( hbr->hack[j].tp > 0 || hbr->hack[j].oname==NULL )
	for(k=0; k < hbr->hack[j].nr; k++)
	  expand_hackblocks_one(hbr, (*abi)[*nabi-hbr->hack[j].nr+k].nname, 
				nabi, abi, bN, bC);
    }
  }
}