Пример #1
0
int read_ter_db(const char *ffdir, char ter,
                t_hackblock **tbptr, gpp_atomtype_t atype)
{
    char   ext[STRLEN];
    int    ntb;

    sprintf(ext, ".%c.tdb", ter);

    /* Search for termini database files.
     * Do not generate an error when none are found.
     */
    std::vector<std::string> tdbf  = fflib_search_file_end(ffdir, ext, FALSE);
    ntb    = 0;
    *tbptr = nullptr;
    for (const auto &filename : tdbf)
    {
        read_ter_db_file(filename.c_str(), &ntb, tbptr, atype);
    }

    if (debug)
    {
        print_ter_db("new", ter, ntb, *tbptr, atype);
    }

    return ntb;
}
Пример #2
0
t_nm2type *rd_nm2type(const char *ffdir, int *nnm)
{
    std::vector<std::string> ff  = fflib_search_file_end(ffdir, ".n2t", FALSE);
    *nnm = 0;
    t_nm2type               *nm = nullptr;
    for (const auto &filename : ff)
    {
        rd_nm2type_file(filename, nnm, &nm);
    }
    return nm;
}
Пример #3
0
gpp_atomtype_t read_atype(const char *ffdir, t_symtab *tab)
{
    int            nfile, f;
    char         **file;
    FILE          *in;
    char           buf[STRLEN], name[STRLEN];
    double         m;
    int            nratt = 0;
    gpp_atomtype_t at;
    t_atom        *a;
    t_param       *nb;

    nfile = fflib_search_file_end(ffdir, ".atp", TRUE, &file);
    at    = init_atomtype();
    snew(a, 1);
    snew(nb, 1);

    for (f = 0; f < nfile; f++)
    {
        in = fflib_open(file[f]);
        while (!feof(in))
        {
            /* Skip blank or comment-only lines */
            do
            {
                if (fgets2(buf, STRLEN, in) != NULL)
                {
                    strip_comment(buf);
                    trim(buf);
                }
            }
            while (!feof(in) && strlen(buf) == 0);

            if (sscanf(buf, "%s%lf", name, &m) == 2)
            {
                a->m = m;
                add_atomtype(at, tab, a, name, nb, 0, 0.0, 0.0, 0.0, 0, 0.0, 0.0 );
                fprintf(stderr, "\rAtomtype %d", ++nratt);
                fflush(stderr);
            }
            else
            {
                fprintf(stderr, "\nInvalid format: %s\n", buf);
            }
        }
        gmx_ffclose(in);
        sfree(file[f]);
    }
    fprintf(stderr, "\n");
    sfree(file);

    return at;
}
Пример #4
0
t_nm2type *rd_nm2type(const char *ffdir,int *nnm)
{
  int  nff,f;
  char **ff;
  t_nm2type *nm;

  nff = fflib_search_file_end(ffdir,".n2t",FALSE,&ff);
  *nnm = 0;
  nm   = NULL;
  for(f=0; f<nff; f++) {
    rd_nm2type_file(ff[f],nnm,&nm);
    sfree(ff[f]);
  }
  sfree(ff);

  return nm;
}
Пример #5
0
int read_h_db(const char *ffdir,t_hackblock **ah)
{
  int  nhdbf,f;
  char **hdbf;
  int  nah;
  FILE *fp;

  /* Read the hydrogen database file(s).
   * Do not generate an error when no files are found.
   */
  nhdbf = fflib_search_file_end(ffdir,".hdb",FALSE,&hdbf);
  nah = 0;
  *ah = NULL;
  for(f=0; f<nhdbf; f++) {
    read_h_db_file(hdbf[f],&nah,ah);
    sfree(hdbf[f]);
  }
  sfree(hdbf);

  return nah;
}
Пример #6
0
void rename_atoms(const char *xlfile,const char *ffdir,
                  t_atoms *atoms,t_symtab *symtab,const t_restp *restp,
                  gmx_bool bResname,gmx_residuetype_t rt,gmx_bool bReorderNum,
                  gmx_bool bVerbose)
{
    FILE *fp;
    int nxlate,a,i,resind;
    t_xlate_atom *xlatom;
    int  nf;
    char **f;
    char c,*rnm,atombuf[32],*ptr0,*ptr1;
    gmx_bool bReorderedNum,bRenamed,bMatch;

    nxlate = 0;
    xlatom = NULL;
    if (xlfile != NULL)
    {
        fp = libopen(xlfile);
        get_xlatoms(xlfile,fp,&nxlate,&xlatom);
        fclose(fp);
    }
    else
    {
        nf = fflib_search_file_end(ffdir,".arn",FALSE,&f);
        for(i=0; i<nf; i++)
        {
            fp = fflib_open(f[i]);
            get_xlatoms(f[i],fp,&nxlate,&xlatom);
            fclose(fp);
            sfree(f[i]);
        }
        sfree(f);
    }

    for(a=0; (a<atoms->nr); a++)
    {
        resind = atoms->atom[a].resind;
        if (bResname)
        {
            rnm = *(atoms->resinfo[resind].name);
        }
        else
        {
            rnm = *(atoms->resinfo[resind].rtp);
        }
               
        strcpy(atombuf,*(atoms->atomname[a]));
        bReorderedNum = FALSE;
        if (bReorderNum)
        {
            if (isdigit(atombuf[0]))
            {
                c = atombuf[0];
                for (i=0; ((size_t)i<strlen(atombuf)-1); i++)
                {
                    atombuf[i] = atombuf[i+1];
                }
                atombuf[i] = c;
                bReorderedNum = TRUE;
            }
        }
        bRenamed = FALSE;
        for(i=0; (i<nxlate) && !bRenamed; i++) {
            /* Check if the base file name of the rtp and arn entry match */
            if (restp == NULL ||
                gmx_strcasecmp(restp[resind].filebase,xlatom[i].filebase) == 0)
            {
                /* Match the residue name */
                bMatch = (xlatom[i].res == NULL ||
                          (gmx_strcasecmp("protein",xlatom[i].res) == 0 &&
                           gmx_residuetype_is_protein(rt,rnm)) ||
                          (gmx_strcasecmp("DNA",xlatom[i].res) == 0 &&
                           gmx_residuetype_is_dna(rt,rnm)) ||
                          (gmx_strcasecmp("RNA",xlatom[i].res) == 0 &&
                           gmx_residuetype_is_rna(rt,rnm)));
                if (!bMatch)
                {
                    ptr0 = rnm;
                    ptr1 = xlatom[i].res;
                    while (ptr0[0] != '\0' && ptr1[0] != '\0' &&
                           (ptr0[0] == ptr1[0] || ptr1[0] == '?'))
                    {
                        ptr0++;
                        ptr1++;
                    }
                    bMatch = (ptr0[0] == '\0' && ptr1[0] == '\0');
                }
                if (bMatch && strcmp(atombuf,xlatom[i].atom) == 0)
                {
                    /* We have a match. */
                    /* Don't free the old atomname,
                     * since it might be in the symtab.
                     */
                    ptr0 = strdup(xlatom[i].replace);
                    if (bVerbose)
                    {
                        printf("Renaming atom '%s' in residue %d %s to '%s'\n",
                               *atoms->atomname[a],
                               atoms->resinfo[resind].nr,
                               *atoms->resinfo[resind].name,
                               ptr0);
                    }
                    atoms->atomname[a] = put_symtab(symtab,ptr0);
                    bRenamed = TRUE;
                }
            }
        }
        if (bReorderedNum && !bRenamed)
        {
            atoms->atomname[a] = put_symtab(symtab,atombuf);
        }
    }

    done_xlatom(nxlate,xlatom);
}