Beispiel #1
0
gmx_bool gmx_atomprop_query(gmx_atomprop_t aps,
                            int eprop, const char *resnm, const char *atomnm,
                            real *value)
{
    gmx_atomprop *ap = (gmx_atomprop*) aps;
    int           j;
#define MAXQ 32
    char          atomname[MAXQ], resname[MAXQ];
    gmx_bool      bExact;

    set_prop(aps, eprop);
    if ((strlen(atomnm) > MAXQ-1) || (strlen(resnm) > MAXQ-1))
    {
        if (debug)
        {
            fprintf(debug, "WARNING: will only compare first %d characters\n",
                    MAXQ-1);
        }
    }
    if (isdigit(atomnm[0]))
    {
        int i;
        /* put digit after atomname */
        for (i = 1; i < MAXQ-1 && atomnm[i] != '\0'; i++)
        {
            atomname[i-1] = atomnm[i];
        }
        atomname[i-1] = atomnm[0];
        atomname[i]   = '\0';
    }
    else
    {
        strncpy(atomname, atomnm, MAXQ-1);
    }
    strncpy(resname, resnm, MAXQ-1);

    j = get_prop_index(&(ap->prop[eprop]), ap->restype, resname,
                       atomname, &bExact);

    if (eprop == epropVDW && !ap->bWarnVDW)
    {
        vdw_warning(stdout);
        ap->bWarnVDW = TRUE;
    }
    if (j >= 0)
    {
        *value = ap->prop[eprop].value[j];
        return TRUE;
    }
    else
    {
        *value = ap->prop[eprop].def;
        return FALSE;
    }
}
Beispiel #2
0
static void add_prop(aprop_t *ap, gmx_residuetype_t *restype,
                     char *resnm, char *atomnm,
                     real p, int line)
{
    int      i, j;
    gmx_bool bExact;

    j = get_prop_index(ap, restype, resnm, atomnm, &bExact);

    if (!bExact)
    {
        if (ap->nprop >= ap->maxprop)
        {
            ap->maxprop += 10;
            srenew(ap->resnm, ap->maxprop);
            srenew(ap->atomnm, ap->maxprop);
            srenew(ap->value, ap->maxprop);
            srenew(ap->bAvail, ap->maxprop);
            for (i = ap->nprop; (i < ap->maxprop); i++)
            {
                ap->atomnm[i] = NULL;
                ap->resnm[i]  = NULL;
                ap->value[i]  = 0;
                ap->bAvail[i] = FALSE;
            }
        }
        ap->atomnm[ap->nprop] = gmx_strdup(atomnm);
        ap->resnm[ap->nprop]  = gmx_strdup(resnm);
        j                     = ap->nprop;
        ap->nprop++;
    }
    if (ap->bAvail[j])
    {
        if (ap->value[j] == p)
        {
            fprintf(stderr, "Warning double identical entries for %s %s %g on line %d in file %s\n",
                    resnm, atomnm, p, line, ap->db);
        }
        else
        {
            fprintf(stderr, "Warning double different entries %s %s %g and %g on line %d in file %s\n"
                    "Using last entry (%g)\n",
                    resnm, atomnm, p, ap->value[j], line, ap->db, p);
            ap->value[j] = p;
        }
    }
    else
    {
        ap->bAvail[j] = TRUE;
        ap->value[j]  = p;
    }
}
Beispiel #3
0
gmx_bool gmx_atomprop_query(gmx_atomprop_t aps,
			int eprop,const char *resnm,const char *atomnm,
			real *value)
{
  gmx_atomprop *ap = (gmx_atomprop*) aps;
  size_t i;
  int  j;
#define MAXQ 32
  char atomname[MAXQ],resname[MAXQ];
  gmx_bool bExact;

  set_prop(aps,eprop);
  if ((strlen(atomnm) > MAXQ-1) || (strlen(resnm) > MAXQ-1)) {
    if (debug)
      fprintf(debug,"WARNING: will only compare first %d characters\n",
	      MAXQ-1);
  }
  if (isdigit(atomnm[0])) {
    /* put digit after atomname */
    for (i=1; (i<min(MAXQ-1,strlen(atomnm))); i++)
      atomname[i-1] = atomnm[i];
    atomname[i-1] = atomnm[0];
    atomname[i]   = '\0';
  } 
  else { 
    strncpy(atomname,atomnm,MAXQ-1);
  }
  upstring(atomname);
  strncpy(resname,resnm,MAXQ-1);
  upstring(resname);
  
  j = get_prop_index(&(ap->prop[eprop]),ap->restype,resname,
		     atomname,&bExact);
  
  if (j >= 0) {
    *value = ap->prop[eprop].value[j];
    return TRUE;
  }
  else {
    *value = ap->prop[eprop].def;
    return FALSE;
  }
}