Beispiel #1
0
static void set_wall_atomtype(gpp_atomtype_t at,t_gromppopts *opts,
			      t_inputrec *ir)
{
  int i;

  if (ir->nwall > 0)
    fprintf(stderr,"Searching the wall atom type(s)\n");
  for(i=0; i<ir->nwall; i++)
    ir->wall_atomtype[i] = get_atomtype_type(opts->wall_atomtype[i],at);
}
Beispiel #2
0
static void read_atom(char *line, bool bAdd,
                      char **nname, t_atom *a, gpp_atomtype_t atype, int *cgnr)
{
    int    nr, i;
    char   buf[5][30];
    double m, q;

    /* This code is messy, because of support for different formats:
     * for replace: [new name] <atom type> <m> <q> [cgnr (old format)]
     * for add:                <atom type> <m> <q> [cgnr]
     */
    nr = sscanf(line, "%s %s %s %s %s", buf[0], buf[1], buf[2], buf[3], buf[4]);

    /* Here there an ambiguity due to the old replace format with cgnr,
     * which was read for years, but ignored in the rest of the code.
     * We have to assume that the atom type does not start with a digit
     * to make a line with 4 entries uniquely interpretable.
     */
    if (!bAdd && nr == 4 && isdigit(buf[1][0]))
    {
        nr = 3;
    }

    if (nr < 3 || nr > 4)
    {
        gmx_fatal(FARGS, "Reading Termini Database: expected %d or %d items of atom data in stead of %d on line\n%s", 3, 4, nr, line);
    }
    i = 0;
    if (!bAdd)
    {
        if (nr == 4)
        {
            *nname = gmx_strdup(buf[i++]);
        }
        else
        {
            *nname = nullptr;
        }
    }
    a->type = get_atomtype_type(buf[i++], atype);
    sscanf(buf[i++], "%lf", &m);
    a->m = m;
    sscanf(buf[i++], "%lf", &q);
    a->q = q;
    if (bAdd && nr == 4)
    {
        sscanf(buf[i++], "%d", cgnr);
    }
    else
    {
        *cgnr = NOTSET;
    }
}
Beispiel #3
0
static void read_atom(char *line, t_atom *a, gpp_atomtype_t atype, int *cgnr)
{
    int    i, n;
    char   type[12];
    double m, q;

    if ( (i=sscanf(line,"%s%lf%lf%n", type, &m, &q, &n)) != 3 )
        gmx_fatal(FARGS,"Reading Termini Database: expected %d items of atom data in stead of %d on line\n%s", 3, i, line);
    a->m=m;
    a->q=q;
    a->type=get_atomtype_type(type,atype);
    if ( sscanf(line+n,"%d", cgnr) != 1 )
        *cgnr = NOTSET;
}
Beispiel #4
0
static gmx_bool read_atoms(FILE *in, char *line,
                           t_restp *r0, t_symtab *tab, gpp_atomtype_t atype)
{
    int    i, j, cg, maxentries;
    char   buf[256], buf1[256];
    double q;

    /* Read Atoms */
    maxentries   = 0;
    r0->atom     =     NULL;
    r0->atomname = NULL;
    r0->cgnr     =     NULL;
    i            = 0;
    while (get_a_line(in, line, STRLEN) && (strchr(line, '[') == NULL))
    {
        if (sscanf(line, "%s%s%lf%d", buf, buf1, &q, &cg) != 4)
        {
            return FALSE;
        }
        if (i >= maxentries)
        {
            maxentries += 100;
            srenew(r0->atom,     maxentries);
            srenew(r0->atomname, maxentries);
            srenew(r0->cgnr,     maxentries);
        }
        r0->atomname[i] = put_symtab(tab, buf);
        r0->atom[i].q   = q;
        r0->cgnr[i]     = cg;
        j               = get_atomtype_type(buf1, atype);
        if (j == NOTSET)
        {
            gmx_fatal(FARGS, "Atom type %s (residue %s) not found in atomtype "
                      "database", buf1, r0->resname);
        }
        r0->atom[i].type = j;
        r0->atom[i].m    = get_atomtype_massA(j, atype);
        i++;
    }
    r0->natom = i;
    srenew(r0->atom, i);
    srenew(r0->atomname, i);
    srenew(r0->cgnr, i);

    return TRUE;
}
Beispiel #5
0
int nm2type(int nnm, t_nm2type nm2t[], t_symtab *tab, t_atoms *atoms,
            gpp_atomtype_t atype, int *nbonds, t_params *bonds)
{
    int      cur = 0;
#define prev (1-cur)
    int      i, j, k, m, n, nresolved, nb, maxbond, ai, aj, best, im, nqual[2][ematchNR];
    int     *bbb, *n_mask, *m_mask, **match, **quality;
    char    *aname_i, *aname_m, *aname_n, *type;
    double   qq, mm;
    t_param *param;

    snew(param, 1);
    maxbond = 0;
    for (i = 0; (i < atoms->nr); i++)
    {
        maxbond = max(maxbond, nbonds[i]);
    }
    if (debug)
    {
        fprintf(debug, "Max number of bonds per atom is %d\n", maxbond);
    }
    snew(bbb, maxbond);
    snew(n_mask, maxbond);
    snew(m_mask, maxbond);
    snew(match, maxbond);
    for (i = 0; (i < maxbond); i++)
    {
        snew(match[i], maxbond);
    }

    nresolved = 0;
    for (i = 0; (i < atoms->nr); i++)
    {
        aname_i = *atoms->atomname[i];
        nb      = 0;
        for (j = 0; (j < bonds->nr); j++)
        {
            ai = bonds->param[j].AI;
            aj = bonds->param[j].AJ;
            if (ai == i)
            {
                bbb[nb++] = aj;
            }
            else if (aj == i)
            {
                bbb[nb++] = ai;
            }
        }
        if (nb != nbonds[i])
        {
            gmx_fatal(FARGS, "Counting number of bonds nb = %d, nbonds[%d] = %d",
                      nb, i, nbonds[i]);
        }
        if (debug)
        {
            fprintf(debug, "%4s has bonds to", aname_i);
            for (j = 0; (j < nb); j++)
            {
                fprintf(debug, " %4s", *atoms->atomname[bbb[j]]);
            }
            fprintf(debug, "\n");
        }
        best = -1;
        for (k = 0; (k < ematchNR); k++)
        {
            nqual[prev][k] = 0;
        }

        /* First check for names */
        for (k = 0; (k < nnm); k++)
        {
            if (nm2t[k].nbonds == nb)
            {
                im = match_str(*atoms->atomname[i], nm2t[k].elem);
                if (im > ematchWild)
                {
                    for (j = 0; (j < ematchNR); j++)
                    {
                        nqual[cur][j] = 0;
                    }

                    /* Fill a matrix with matching quality */
                    for (m = 0; (m < nb); m++)
                    {
                        aname_m = *atoms->atomname[bbb[m]];
                        for (n = 0; (n < nb); n++)
                        {
                            aname_n     = nm2t[k].bond[n];
                            match[m][n] = match_str(aname_m, aname_n);
                        }
                    }
                    /* Now pick the best matches */
                    for (m = 0; (m < nb); m++)
                    {
                        n_mask[m] = 0;
                        m_mask[m] = 0;
                    }
                    for (j = ematchNR-1; (j > 0); j--)
                    {
                        for (m = 0; (m < nb); m++)
                        {
                            for (n = 0; (n < nb); n++)
                            {
                                if ((n_mask[n] == 0) &&
                                    (m_mask[m] == 0) &&
                                    (match[m][n] == j))
                                {
                                    n_mask[n] = 1;
                                    m_mask[m] = 1;
                                    nqual[cur][j]++;
                                }
                            }
                        }
                    }
                    if ((nqual[cur][ematchExact]+
                         nqual[cur][ematchElem]+
                         nqual[cur][ematchWild]) == nb)
                    {
                        if ((nqual[cur][ematchExact] > nqual[prev][ematchExact]) ||

                            ((nqual[cur][ematchExact] == nqual[prev][ematchExact]) &&
                             (nqual[cur][ematchElem] > nqual[prev][ematchElem])) ||

                            ((nqual[cur][ematchExact] == nqual[prev][ematchExact]) &&
                             (nqual[cur][ematchElem] == nqual[prev][ematchElem]) &&
                             (nqual[cur][ematchWild] > nqual[prev][ematchWild])))
                        {
                            best = k;
                            cur  = prev;
                        }
                    }
                }
            }
        }
        if (best != -1)
        {
            int  atomnr = 0;
            real alpha  = 0;

            qq   = nm2t[best].q;
            mm   = nm2t[best].m;
            type = nm2t[best].type;

            if ((k = get_atomtype_type(type, atype)) == NOTSET)
            {
                atoms->atom[i].qB = alpha;
                atoms->atom[i].m  = atoms->atom[i].mB = mm;
                k                 = add_atomtype(atype, tab, &(atoms->atom[i]), type, param,
                                                 atoms->atom[i].type, 0, 0, 0, atomnr, 0, 0);
            }
            atoms->atom[i].type  = k;
            atoms->atom[i].typeB = k;
            atoms->atom[i].q     = qq;
            atoms->atom[i].qB    = qq;
            atoms->atom[i].m     = mm;
            atoms->atom[i].mB    = mm;
            nresolved++;
        }
        else
        {
            fprintf(stderr, "Can not find forcefield for atom %s-%d with %d bonds\n",
                    *atoms->atomname[i], i+1, nb);
        }
    }
    sfree(bbb);
    sfree(n_mask);
    sfree(m_mask);
    sfree(param);

    return nresolved;
}