added t_resinfo struct to t_atoms which contains the residue name, (original) residue...
authorhess <hess>
Fri, 6 Mar 2009 10:48:14 +0000 (10:48 +0000)
committerhess <hess>
Fri, 6 Mar 2009 10:48:14 +0000 (10:48 +0000)
68 files changed:
include/gmxfio.h
include/hackblock.h
include/pdbio.h
include/txtdump.h
include/typedefs.h
include/types/atoms.h
src/gmxlib/confio.c
src/gmxlib/gbutil.c
src/gmxlib/gmxfio.c
src/gmxlib/index.c
src/gmxlib/mtop_util.c
src/gmxlib/mvdata.c
src/gmxlib/nrama.c
src/gmxlib/pdbio.c
src/gmxlib/tpxio.c
src/gmxlib/txtdump.c
src/gmxlib/typedefs.c
src/kernel/gen_ad.c
src/kernel/gen_vsite.c
src/kernel/genhydro.c
src/kernel/gmxcheck.c
src/kernel/hizzie.c
src/kernel/pdb2gmx.c
src/kernel/pdb2top.c
src/kernel/pgutil.c
src/kernel/pgutil.h
src/kernel/protonate.c
src/kernel/specbond.c
src/kernel/topio.c
src/kernel/toppush.c
src/kernel/toputil.c
src/kernel/tpbcmp.c
src/kernel/tpbconv.c
src/kernel/x2top.c
src/kernel/xlate.c
src/mdlib/gmx_qhop_db.c
src/ngmx/manager.c
src/tools/addconf.c
src/tools/dlist.c
src/tools/do_dssp.c
src/tools/edittop.c
src/tools/gmx_anaeig.c
src/tools/gmx_bond.c
src/tools/gmx_bundle.c
src/tools/gmx_cluster.c
src/tools/gmx_confrms.c
src/tools/gmx_disre.c
src/tools/gmx_dist.c
src/tools/gmx_dyndom.c
src/tools/gmx_editconf.c
src/tools/gmx_genbox.c
src/tools/gmx_genconf.c
src/tools/gmx_genion.c
src/tools/gmx_hbond.c
src/tools/gmx_helix.c
src/tools/gmx_mdmat.c
src/tools/gmx_mindist.c
src/tools/gmx_rdf.c
src/tools/gmx_rmsdist.c
src/tools/gmx_rmsf.c
src/tools/gmx_saltbr.c
src/tools/gmx_sas.c
src/tools/gmx_sdf.c
src/tools/gmx_traj.c
src/tools/gmx_trjconv.c
src/tools/hxprops.c
src/tools/hxprops.h
src/tools/make_ndx.c

index 3be9f99a26ac204bc356942fd5963f909013f6f5..09be03c58815f5c785283dcf4bc14450ac1eea39 100644 (file)
@@ -54,7 +54,8 @@ enum { eitemHEADER, eitemIR, eitemBOX,
        eitemTOP, eitemX, eitemV, eitemF, eitemNR };
        
 /* Enumerated for data types in files */
-enum { eioREAL, eioDOUBLE, eioINT, eioGMX_STEP_T, eioNUCHAR, eioUSHORT,
+enum { eioREAL, eioDOUBLE, eioINT, eioGMX_STEP_T,
+       eioUCHAR, eioNUCHAR, eioUSHORT,
        eioRVEC, eioNRVEC, eioIVEC, eioSTRING, eioNR };
 
 /* Functions for reading and writing data */
@@ -215,6 +216,10 @@ extern void unset_comment(void);
   do_read ((void *)&(item),1,eioGMX_STEP_T,(#item),__FILE__,__LINE__) :\
   do_write((void *)&(item),1,eioGMX_STEP_T,(#item),__FILE__,__LINE__))
  
+#define do_uchar(item)        (bRead ?\
+  do_read ((void *)&(item),1,eioUCHAR,(#item),__FILE__,__LINE__) :\
+  do_write((void *)&(item),1,eioUCHAR,(#item),__FILE__,__LINE__))
+
 #define do_nuchar(item,n)     (bRead ?\
   do_read ((void *)(item),n,eioNUCHAR,(#item),__FILE__,__LINE__) :\
   do_write((void *)(item),n,eioNUCHAR,(#item),__FILE__,__LINE__))
index b4db7cf268f5e6ed6e9d8c3ee641e62feed6d922..ab0dc4e77c41bd343e1439f8adeaa4b9e11255c1 100644 (file)
@@ -117,6 +117,7 @@ typedef struct {
   t_hackblock **sel_ntdb, **sel_ctdb;
   int         nah;
   t_symtab    tab;
+  /* residue indices (not numbers!) of the N and C termini */
   int         *rN, *rC;
   t_atomtype  atype;
   /* protonated topology: */
index 10f628bafe446fffe905f252750f728cddeec907..ead5fd5f7c932ca9fb13a6c36de39ed5cddbe583 100644 (file)
@@ -49,8 +49,8 @@
 typedef struct gmx_conect_t *gmx_conect;
 
 /* THE pdb format (for ATOM/HETATOM lines) */
-static char *pdbformat ="%-6s%5u  %-4.4s%3.3s %c%4d    %8.3f%8.3f%8.3f";
-static char *pdbformat4="%-6s%5u %-4.4s %3.3s %c%4d    %8.3f%8.3f%8.3f";
+static char *pdbformat ="%-6s%5u  %-4.4s%3.3s %c%4d%c   %8.3f%8.3f%8.3f";
+static char *pdbformat4="%-6s%5u %-4.4s %3.3s %c%4d%c   %8.3f%8.3f%8.3f";
 
 /* Enumerated type for pdb records. The other entries are ignored
  * when reading a pdb file 
index 8ad0dcaf92feee05d28a495c957b18969bc3866d..831b4fbdad2f7f02df92d4ef3afcd13487c94256 100644 (file)
 #define        USE_WIDTH       ((LINE_WIDTH)-(RMARGIN))
 #define INDENT         3
 
-extern char *atomname(t_atoms *a,int i);
-/* Return pointer to a buffer which holds the atomname in the
- * form resname resnr atomname. Pointer can be freed afterwards.
- */
 int pr_indent(FILE *fp,int n);
 int available(FILE *fp,void *p,int indent,const char *title);
 int pr_title(FILE *fp,int indent,const char *title);
index 9ae13f88dbbdb96155f6854980d7f394fecfd2bf..ad1cd40ae7ee9f03e4c3a240e0eb88b8cbbb22a4 100644 (file)
@@ -169,6 +169,13 @@ void init_t_atoms(t_atoms *atoms, int natoms, bool bPdbinfo);
 /* allocate memory for the arrays, set nr to natoms and nres to 0
  * set pdbinfo to NULL or allocate memory for it */  
 
+extern void t_atoms_set_resinfo(t_atoms *atoms,int atom_ind,t_symtab *symtab,
+                               char *resname,int resnr,unsigned char ic,
+                               unsigned char chain);
+/* Set the residue name, number, insertion code and chain identifier
+ * of atom index atom_ind.
+ */
+
 void free_t_atoms(t_atoms *atoms,bool bFreeNames);
 /* free all the arrays and set the nr and nres to 0 */
 
index e8ddf281cd9bbce71ee4f8ba3ed74ed1a16bff33..de8cc0430c1a4388e2051107e6fd5a6a986833e9 100644 (file)
@@ -48,17 +48,22 @@ typedef struct {
   unsigned short type;         /* Atom type                            */
   unsigned short typeB;                /* Atom type for Free Energy calc       */
   int           ptype;         /* Particle type                        */
-  int          resnr;          /* Residue number                       */
+  int          resind;         /* Index into resinfo in t_atoms)       */
   int           atomnumber;     /* Atomic Number or NOTSET              */
-  unsigned char chain;          /* chain identifier                     */
 } t_atom;
 
+typedef struct {
+  char          **name;         /* Pointer to the residue name          */
+  int           nr;             /* Residue number                       */
+  unsigned char ic;             /* Code for insertion of residues       */
+  unsigned char chain;          /* Chain identifier                     */
+} t_resinfo;
+
 typedef struct {
   int  type;                    /* PDB record name                      */
   int  atomnr;                  /* PDB atom number                      */
   char altloc;                  /* Alternate location indicator         */
   char atomnm[6];               /* True atom name including spaces      */
-  char pdbresnr[6];             /* PDB res number                       */
   real occup;                   /* Occupancy                            */
   real bfac;                    /* B-factor                             */
   bool bAnisotropic;            /* (an)isotropic switch                 */
@@ -81,9 +86,8 @@ typedef struct {
                                /* use: (*(atomtype[i]))                */
   char         ***atomtypeB;   /* Array of pointers to B atom types    */
                                /* use: (*(atomtypeB[i]))               */
-  int          nres;           /* Nr of residue names                  */
-  char         ***resname;     /* Array of pointers to residue names   */
-                               /* use: (*(resname[i]))         */
+  int          nres;           /* The number of resinfo entries        */
+  t_resinfo     *resinfo;       /* Array of residue names and numbers   */
   t_pdbinfo     *pdbinfo;       /* PDB Information, such as aniso. Bfac */
 } t_atoms;
 
index cac5d28aaac86d1909c2b5045945c7955069fa66..91b594e649a9252d205e6bed23f81ac73d2046cb 100644 (file)
@@ -84,7 +84,7 @@ static int read_g96_pos(char line[],t_symtab *symtab,FILE *fp,char *infile,
       shift = CHAR_SHIFT;
     else
       shift = 0;
-    newres  = 0;
+    newres  = -1;
     oldres  = -666; /* Unlikely number for the first residue! */
     bEnd    = FALSE;
     while (!bEnd && fgets2(line,STRLEN,fp)) {
@@ -112,16 +112,18 @@ static int read_g96_pos(char line[],t_symtab *symtab,FILE *fp,char *infile,
          atoms->atomname[natoms]=put_symtab(symtab,anm);
          if (resnr != oldres) {
            oldres = resnr;
+           newres++;
            if (newres >= atoms->nr)
              gmx_fatal(FARGS,"More residues than atoms in %s (natoms = %d)",
                          infile,atoms->nr);
-           atoms->resname[newres] = put_symtab(symtab,resnm);
-           newres++;
-           if (newres > atoms->nres)
-             atoms->nres = newres;
+           atoms->atom[natoms].resind = newres;
+           if (newres+1 > atoms->nres) {
+             atoms->nres = newres+1;
+           }
+           t_atoms_set_resinfo(atoms,natoms,symtab,resnm,resnr,' ',' ');
+         } else {
+           atoms->atom[natoms].resind = newres;
          }
-         resnr = newres;
-         atoms->atom[natoms].resnr = resnr-1;
        }
        if (fr->x) {
          fr->x[natoms][0] = db1;
@@ -309,8 +311,8 @@ void write_g96_conf(FILE *out,t_trxframe *fr,
       for(i=0; i<nout; i++) {
        if (index) a = index[i]; else a = i;
        fprintf(out,"%5d %-5s %-5s%7d%15.9f%15.9f%15.9f\n",
-               (atoms->atom[a].resnr+1) % 100000,
-               *atoms->resname[atoms->atom[a].resnr],
+               (atoms->resinfo[atoms->atom[a].resind].nr) % 100000,
+               *atoms->resinfo[atoms->atom[a].resind].name,
                *atoms->atomname[a],(i+1) % 10000000,
                fr->x[a][XX],fr->x[a][YY],fr->x[a][ZZ]);
       }
@@ -330,8 +332,8 @@ void write_g96_conf(FILE *out,t_trxframe *fr,
       for(i=0; i<nout; i++) {
        if (index) a = index[i]; else a = i;
        fprintf(out,"%5d %-5s %-5s%7d%15.9f%15.9f%15.9f\n",
-               (atoms->atom[a].resnr+1) % 100000,
-               *atoms->resname[atoms->atom[a].resnr],
+               (atoms->resinfo[atoms->atom[a].resind].nr) % 100000,
+               *atoms->resinfo[atoms->atom[a].resind].name,
                *atoms->atomname[a],(i+1) % 10000000,
                fr->v[a][XX],fr->v[a][YY],fr->v[a][ZZ]);
       }
@@ -445,7 +447,7 @@ static void read_espresso_conf(char *infile,
   static t_symtab *symtab=NULL;
   FILE *fp;
   char word[STRLEN],buf[STRLEN];
-  int  natoms,level,npar,r,nprop,p,i,m;
+  int  natoms,level,npar,r,nprop,p,i,m,molnr;
   int  prop[32];
   double d;
   bool bFoundParticles,bFoundProp,bFoundVariable,bMol;
@@ -531,7 +533,17 @@ static void read_espresso_conf(char *infile,
              break;
            case espMOLECULE:
              r = get_espresso_word(fp,word);
-             atoms->atom[i].resnr = atoi(word);
+             molnr = atoi(word);
+             if (i == 0 ||
+                 atoms->resinfo[atoms->atom[i-1].resind].nr != molnr) {
+               atoms->atom[i].resind =
+                 (i == 0 ? 0 : atoms->atom[i-1].resind+1); 
+               atoms->resinfo[atoms->atom[i].resind].nr    = molnr;
+               atoms->resinfo[atoms->atom[i].resind].ic    = ' ';
+               atoms->resinfo[atoms->atom[i].resind].chain = ' ';
+             } else {
+               atoms->atom[i].resind = atoms->atom[i-1].resind;
+             }
              break;
            }
          }
@@ -539,12 +551,13 @@ static void read_espresso_conf(char *infile,
          sprintf(buf,"T%d",atoms->atom[i].type);
          atoms->atomname[i] = put_symtab(symtab,buf);
          if (bMol) {
-           if (i == 0 || atoms->atom[i].resnr != atoms->atom[i-1].resnr) {
-             atoms->resname[atoms->atom[i].resnr] = put_symtab(symtab,"MOL");
+           if (i == 0 || atoms->atom[i].resind != atoms->atom[i-1].resind) {
+             atoms->resinfo[atoms->atom[i].resind].name =
+               put_symtab(symtab,"MOL");
            }
          } else {
            /* Residue number is the atom number */
-           atoms->atom[i].resnr = i;
+           atoms->atom[i].resind = i;
            /* Generate an residue name from the particle type */
            if (atoms->atom[i].type < 26) {
              sprintf(buf,"T%c",'A'+atoms->atom[i].type);
@@ -552,7 +565,7 @@ static void read_espresso_conf(char *infile,
              sprintf(buf,"T%c%c",
                      'A'+atoms->atom[i].type/26,'A'+atoms->atom[i].type%26);
            }
-           atoms->resname[atoms->atom[i].resnr] = put_symtab(symtab,buf);
+           t_atoms_set_resinfo(atoms,i,symtab,buf,i,' ',' ');
          }       
 
          if (r == 3)
@@ -696,7 +709,7 @@ static bool get_w_conf(FILE *in, char *infile, char *title,
   bool   bFirst,bVel;
   char   *p1,*p2,*p3;
   
-  newres  = 0;
+  newres  = -1;
   oldres  = NOTSET; /* Unlikely number for the first residue! */
   ddist   = 0;
   
@@ -756,14 +769,15 @@ static bool get_w_conf(FILE *in, char *infile, char *title,
     name[5]='\0';
     if (resnr != oldres) {
       oldres = resnr;
+      newres++;
       if (newres >= natoms)
        gmx_fatal(FARGS,"More residues than atoms in %s (natoms = %d)",
                    infile,natoms);
-      atoms->resname[newres] = put_symtab(symtab,name);
-      newres++;
+      atoms->atom[i].resind = newres;
+      t_atoms_set_resinfo(atoms,i,symtab,name,i,' ',' ');
+    } else {
+      atoms->atom[i].resind = newres;
     }
-    resnr = newres;
-    atoms->atom[i].resnr = resnr-1;
 
     /* atomname */
     memcpy(name,line+10,5);
@@ -805,7 +819,7 @@ static bool get_w_conf(FILE *in, char *infile, char *title,
       }
     }
   }
-  atoms->nres=newres;
+  atoms->nres = newres + 1;
 
   /* box */
   fgets2 (line,STRLEN,in);
@@ -870,13 +884,13 @@ static void get_conf(FILE *in, char *title, int *natoms,
   atoms.nr=*natoms;
   snew(atoms.atom,*natoms);
   atoms.nres=*natoms;
-  snew(atoms.resname,*natoms);
+  snew(atoms.resinfo,*natoms);
   snew(atoms.atomname,*natoms);
   
   get_w_conf(in,title,title,&atoms,&ndec,x,v,box);
   
   sfree(atoms.atom);
-  sfree(atoms.resname);
+  sfree(atoms.resinfo);
   sfree(atoms.atomname);
 }
 
@@ -893,7 +907,7 @@ bool gro_next_x_or_v(FILE *status,t_trxframe *fr)
   atoms.nr=fr->natoms;
   snew(atoms.atom,fr->natoms);
   atoms.nres=fr->natoms;
-  snew(atoms.resname,fr->natoms);
+  snew(atoms.resinfo,fr->natoms);
   snew(atoms.atomname,fr->natoms);
   
   fr->bV = get_w_conf(status,title,title,&atoms,&ndec,fr->x,fr->v,fr->box);
@@ -908,7 +922,7 @@ bool gro_next_x_or_v(FILE *status,t_trxframe *fr)
   fr->bBox = TRUE;
 
   sfree(atoms.atom);
-  sfree(atoms.resname);
+  sfree(atoms.resinfo);
   sfree(atoms.atomname);
 
   if ((p=strstr(title,"t=")) != NULL) {
@@ -999,7 +1013,7 @@ void write_hconf_indexed_p(FILE *out,char *title,t_atoms *atoms,
                           rvec *x,rvec *v,matrix box)
 {
   char resnm[6],nm[6],format[100];
-  int  ai,i,resnr;
+  int  ai,i,resind,resnr;
 
   bromacs(format,99);
   fprintf (out,"%s\n",(title && title[0])?title:format);
@@ -1010,17 +1024,22 @@ void write_hconf_indexed_p(FILE *out,char *title,t_atoms *atoms,
   for (i=0; (i<nx); i++) {
     ai=index[i];
     
-    resnr=atoms->atom[ai].resnr;
+    resind = atoms->atom[ai].resind;
     strcpy(resnm," ??? ");
-    if (resnr < atoms->nres)
-      strcpy(resnm,*atoms->resname[resnr]);
+    if (resind < atoms->nres) {
+      strcpy(resnm,*atoms->resinfo[resind].name);
+      resnr = atoms->resinfo[resind].nr;
+    } else {
+      strcpy(resnm," ??? ");
+      resnr = resind + 1;
+    }
     
     if (atoms->atom)
       strcpy(nm,*atoms->atomname[ai]);
     else
       strcpy(nm," ??? ");
 
-    fprintf(out,"%5d%-5.5s%5.5s%5d",(resnr+1)%100000,resnm,nm,(ai+1)%100000);
+    fprintf(out,"%5d%-5.5s%5.5s%5d",resnr%100000,resnm,nm,(ai+1)%100000);
     /* next fprintf uses built format string */
     if (v)
       fprintf(out,format,
index 7298dd2b2c700018a08ff95845f5da96010f13e9..a161b9a8f06c2c5f233fa7c11a0cc2f4a52fd2cf 100644 (file)
@@ -193,9 +193,10 @@ void genconf(t_atoms *atoms,rvec *x,rvec *v,real *r,matrix box,ivec n_box)
     int offsres = i*atoms->nres;
     for (j=0;(j<atoms->nr);j++) {
       atoms->atomname[offs+j]  = atoms->atomname[j];
-      atoms->atom[offs+j].resnr = atoms->atom[j].resnr+offsres;
-      atoms->resname[atoms->atom[offs+j].resnr]=
-       atoms->resname[atoms->atom[j].resnr];
+      atoms->atom[offs+j].resind = atoms->atom[j].resind + offsres;
+      atoms->resinfo[atoms->atom[offs+j].resind] =
+       atoms->resinfo[atoms->atom[j].resind];
+      atoms->resinfo[atoms->atom[offs+j].resind].nr += offsres;
     }
   }
   atoms->nr*=nmol;
index 668b4a747ce87e0dd8f7768efc337aec6896403f..f0d623c021c8f6eaaea32ba5a29728a5e0a78f94 100644 (file)
@@ -124,7 +124,8 @@ char *comment_str[eitemNR] = {
 static t_fileio *FIO = NULL;
 static t_fileio *curfio = NULL;
 static int  nFIO = 0;
-static char *eioNames[eioNR] = { "REAL", "INT", "NUCHAR", "USHORT", 
+static char *eioNames[eioNR] = { "REAL", "INT", "GMX_STE_T",
+                                "UCHAR", "NUCHAR", "USHORT", 
                                 "RVEC", "NRVEC", "IVEC", "STRING" };
 static char *add_comment = NULL;
 
@@ -230,6 +231,9 @@ static bool do_ascwrite(void *item,int nitem,int eio,
     sprintf(strbuf,"%s%s%s","%",gmx_step_fmt,"\n");
     res = fprintf(curfio->fp,strbuf,*((gmx_step_t *)item),dbgstr(desc));
     break;
+  case eioUCHAR:
+    res = fprintf(curfio->fp,"%4d%s\n",*((unsigned char *)item),dbgstr(desc));
+    break;
   case eioNUCHAR:
     ucptr = (unsigned char *)item;
     for(i=0; (i<nitem); i++)
@@ -342,7 +346,7 @@ static bool do_ascread(void *item,int nitem,int eio,
   gmx_step_t s;
   double d,x;
   real   *ptr;
-  unsigned char *ucptr;
+  unsigned char uc,*ucptr;
   char   *cptr;
   
   check_nitem();  
@@ -358,7 +362,11 @@ static bool do_ascread(void *item,int nitem,int eio,
     break;
   case eioGMX_STEP_T:
     res = sscanf(next_item(fp),gmx_step_pfmt,&s);
-    if (item) *((int *)item) = s;
+    if (item) *((gmx_step_t *)item) = s;
+    break;
+  case eioUCHAR:
+    res = sscanf(next_item(fp),"%c",&uc);
+    if (item) *((unsigned char *)item) = uc;
     break;
   case eioNUCHAR:
     ucptr = (unsigned char *)item;
@@ -432,6 +440,9 @@ static bool do_binwrite(void *item,int nitem,int eio,
   case eioGMX_STEP_T:
     size = sizeof(gmx_step_t);
     break;
+  case eioUCHAR:
+    size = sizeof(unsigned char);
+    break;
   case eioNUCHAR:
     size = sizeof(unsigned char);
     break;
@@ -488,6 +499,9 @@ static bool do_binread(void *item,int nitem,int eio,
   case eioGMX_STEP_T:
     size = sizeof(gmx_step_t);
     break;
+  case eioUCHAR:
+    size = sizeof(unsigned char);
+    break;
   case eioNUCHAR:
     size = sizeof(unsigned char);
     break;
@@ -533,7 +547,7 @@ static bool do_binread(void *item,int nitem,int eio,
 static bool do_xdr(void *item,int nitem,int eio,
                   char *desc,char *srcfile,int line)
 {
-  unsigned char *ucptr;
+  unsigned char ucdum,*ucptr;
   bool_t res=0;
   float  fvec[DIM];
   double dvec[DIM];
@@ -576,13 +590,17 @@ static bool do_xdr(void *item,int nitem,int eio,
     res = xdr_gmx_step_t(curfio->xdr,&sdum,NULL);
     if (item) *(gmx_step_t *)item = sdum;
     break;
+  case eioUCHAR:
+    if (item && !curfio->bRead) idum = *(unsigned char *)item;
+    res = xdr_u_char(curfio->xdr,&ucdum);
+    if (item) *(unsigned char *)item = ucdum;
+    break;
   case eioNUCHAR:
     ucptr = (unsigned char *)item;
     res   = 1;
     for(j=0; (j<nitem) && res; j++) {
       res = xdr_u_char(curfio->xdr,&(ucptr[j]));
     }
-    
     break;
   case eioUSHORT:
     if (item && !curfio->bRead) us = *(unsigned short *)item;
index bd71453ce22066d6bc92df13e5a28bd860b042ed..73ff5192393a58bfa7eb9d933c4bd716bbb211d7 100644 (file)
@@ -167,7 +167,7 @@ atom_id *mk_aid(t_atoms *atoms,eRestp restp[],eRestp res,int *nra,
   snew(a,atoms->nr);
   *nra=0;
   for(i=0; (i<atoms->nr); i++) 
-    if ((restp[atoms->atom[i].resnr] == res) == bTrue)
+    if ((restp[atoms->atom[i].resind] == res) == bTrue)
       a[(*nra)++]=i;
   
   return a;
@@ -180,7 +180,7 @@ static void analyse_other(eRestp Restp[],t_atoms *atoms,
   char **attp=NULL;
   char *rname,*aname;
   atom_id *other_ndx,*aid,*aaid;
-  int  i,j,k,l,resnr,naid,naaid,natp,nrestp=0;
+  int  i,j,k,l,resind,naid,naaid,natp,nrestp=0;
   
   for(i=0; (i<atoms->nres); i++)
     if (Restp[i] == etOther)
@@ -191,9 +191,9 @@ static void analyse_other(eRestp Restp[],t_atoms *atoms,
       printf("Analysing Other...\n");
     snew(other_ndx,atoms->nr);
     for(k=0; (k<atoms->nr); k++) {
-      resnr=atoms->atom[k].resnr;
-      rname=*atoms->resname[resnr];
-      if (Restp[resnr] ==  etOther) {
+      resind = atoms->atom[k].resind;
+      rname = *atoms->resinfo[resind].name;
+      if (Restp[resind] == etOther) {
        for(l=0; (l<nrestp); l++)
          if (strcmp(restp[l],rname) == 0)
            break;
@@ -207,7 +207,7 @@ static void analyse_other(eRestp Restp[],t_atoms *atoms,
       snew(aid,atoms->nr);
       naid=0;
       for(j=0; (j<atoms->nr); j++) {
-       rname=*atoms->resname[atoms->atom[j].resnr];
+       rname = *atoms->resinfo[atoms->atom[j].resind].name;
        if (strcmp(restp[i],rname) == 0) 
          aid[naid++] = j;
       }
@@ -313,7 +313,7 @@ static void analyse_prot(eRestp restp[],t_atoms *atoms,
   for(i=0; (i<NCH); i++) {
     nra=0;
     for(n=0; (n<atoms->nr); n++) {
-      if (restp[atoms->atom[n].resnr] == etProt) {
+      if (restp[atoms->atom[n].resind] == etProt) {
        match=FALSE;
        for(j=0; (j<sizes[i]); j++) {
          /* skip digits at beginning of atomname, e.g. 1H */
@@ -342,11 +342,11 @@ static void analyse_prot(eRestp restp[],t_atoms *atoms,
     for(i=0; (i<NCH); i++) {
       printf("Split %12s into %5d residues (y/n) ? ",ch_name[i],npres);
       if (gmx_ask_yesno(bASK)) {
-       int resnr;
+       int resind;
        nra = 0;
-       for(n=0;((atoms->atom[n].resnr<npres) && (n<atoms->nr));) {
-         resnr = atoms->atom[n].resnr;
-         for(;((atoms->atom[n].resnr==resnr) && (n<atoms->nr));n++) {
+       for(n=0;((atoms->atom[n].resind < npres) && (n<atoms->nr));) {
+         resind = atoms->atom[n].resind;
+         for(;((atoms->atom[n].resind==resind) && (n<atoms->nr));n++) {
            match=FALSE;
            for(j=0;(j<sizes[i]); j++) 
              if (strcasecmp(chains[i][j],*atoms->atomname[n]) == 0)
@@ -356,8 +356,10 @@ static void analyse_prot(eRestp restp[],t_atoms *atoms,
          }
          /* copy the residuename to the tail of the groupname */
          if (nra > 0) {
-           sprintf(ndx_name,"%s_%s%d",
-                   ch_name[i],*atoms->resname[resnr],resnr+1);
+           t_resinfo *ri;
+           ri = &atoms->resinfo[resind];
+           sprintf(ndx_name,"%s_%s%d%c",
+                   ch_name[i],*ri->name,ri->nr,ri->ic==' ' ? '\0' : ri->ic);
            add_grp(gb,gn,nra,aid,ndx_name);
            nra = 0;
          }
@@ -367,12 +369,12 @@ static void analyse_prot(eRestp restp[],t_atoms *atoms,
     printf("Make group with sidechain and C=O swapped (y/n) ? ");
     if (gmx_ask_yesno(bASK)) {
       /* Make swap sidechain C=O index */
-      int resnr,hold;
+      int resind,hold;
       nra = 0;
-      for(n=0;((atoms->atom[n].resnr<npres) && (n<atoms->nr));) {
-       resnr = atoms->atom[n].resnr;
+      for(n=0;((atoms->atom[n].resind < npres) && (n<atoms->nr));) {
+       resind = atoms->atom[n].resind;
        hold  = -1;
-       for(;((atoms->atom[n].resnr==resnr) && (n<atoms->nr));n++)
+       for(;((atoms->atom[n].resind==resind) && (n<atoms->nr));n++)
          if (strcmp("CA",*atoms->atomname[n]) == 0) {
            aid[nra++]=n;
            hold=nra;
@@ -468,7 +470,7 @@ void analyse(t_atoms *atoms,t_blocka *gb,char ***gn,bool bASK,bool bVerb)
 
   aan = get_aa_names();
   for(i=0; (i<atoms->nres); i++) {
-    resnm=*atoms->resname[i];
+    resnm = *atoms->resinfo[i].name;
     if ((restp[i] == etOther) && is_protein(aan,resnm))
       restp[i] = etProt;
     if (restp[i] == etOther)
index 1588d958e01be79c74ded16f4ef8b4fde788dddd..d4817d950d177364c5061c4d0927a50c51ea5843 100644 (file)
@@ -128,7 +128,7 @@ void gmx_mtop_atomnr_to_molblock_ind(const gmx_mtop_t *mtop,int atnr_global,
 void gmx_mtop_atominfo_global(const gmx_mtop_t *mtop,int atnr_global,
                               char **atomname,int *resnr,char **resname)
 {
-    int mb,a_start,a_end,resnr_offset,at_loc;
+    int mb,a_start,a_end,resnr_last,at_loc;
     gmx_molblock_t *molb;
     t_atoms *atoms=NULL;
     
@@ -140,12 +140,21 @@ void gmx_mtop_atominfo_global(const gmx_mtop_t *mtop,int atnr_global,
     
     mb = -1;
     a_end = 0;
-    resnr_offset = 0;
+    resnr_last = 0;
     do
     {
         if (mb >= 0)
         {
-            resnr_offset += mtop->molblock[mb].nmol*atoms->nres;
+            if (atoms->nres > 1)
+            {
+                /* Multiple residue molecule, do not renumber the residues */
+                resnr_last = atoms->resinfo[atoms->nres-1].nr;
+            }
+            else
+            {
+                /* Single residue molecule, keep counting */
+                resnr_last += mtop->molblock[mb].nmol;
+            }
         }
         mb++;
         atoms = &mtop->moltype[mtop->molblock[mb].type].atoms;
@@ -156,8 +165,13 @@ void gmx_mtop_atominfo_global(const gmx_mtop_t *mtop,int atnr_global,
 
     at_loc = (atnr_global - a_start) % atoms->nr;
     *atomname = *(atoms->atomname[at_loc]);
-    *resnr    = resnr_offset + atoms->atom[at_loc].resnr;
-    *resname  = *(atoms->resname[atoms->atom[at_loc].resnr]);
+    *resnr    = atoms->resinfo[atoms->atom[at_loc].resind].nr;
+    if (atoms->nres == 1)
+    {
+        /* Single residue molecule, keep counting */
+        *resnr += resnr_last;
+    }
+    *resname  = *(atoms->resinfo[atoms->atom[at_loc].resind].name);
 }
 
 typedef struct gmx_mtop_atomloop_all
@@ -166,7 +180,7 @@ typedef struct gmx_mtop_atomloop_all
     int        mblock;
     t_atoms    *atoms;
     int        mol;
-    int        resnr_offset;
+    int        resnr_last;
     int        at_local;
     int        at_global;
 } t_gmx_mtop_atomloop_all;
@@ -183,7 +197,7 @@ gmx_mtop_atomloop_all_init(const gmx_mtop_t *mtop)
     aloop->atoms        =
         &mtop->moltype[mtop->molblock[aloop->mblock].type].atoms;
     aloop->mol          = 0;
-    aloop->resnr_offset = 0;
+    aloop->resnr_last   = 0;
     aloop->at_local     = -1;
     aloop->at_global    = -1;
 
@@ -208,7 +222,16 @@ bool gmx_mtop_atomloop_all_next(gmx_mtop_atomloop_all_t aloop,
 
     if (aloop->at_local >= aloop->atoms->nr)
     {
-        aloop->resnr_offset += aloop->atoms->nres;
+        if (aloop->atoms->nres > 1)
+        {
+            /* Multiple residue molecule, keep the residue numbers */
+            aloop->resnr_last = aloop->atoms->resinfo[aloop->atoms->nres-1].nr;
+        }
+        else
+        {
+            /* Single residue molecule, increase the count with one */
+            aloop->resnr_last++;
+        }
         aloop->mol++;
         aloop->at_local = 0;
         if (aloop->mol >= aloop->mtop->molblock[aloop->mblock].nmol)
@@ -233,12 +256,16 @@ bool gmx_mtop_atomloop_all_next(gmx_mtop_atomloop_all_t aloop,
 void gmx_mtop_atomloop_all_names(gmx_mtop_atomloop_all_t aloop,
                                  char **atomname,int *resnr,char **resname)
 {
-    int resnr_mol;
+    int resind_mol;
 
     *atomname = *(aloop->atoms->atomname[aloop->at_local]);
-    resnr_mol = aloop->atoms->atom[aloop->at_local].resnr;
-    *resnr    = aloop->resnr_offset + resnr_mol;
-    *resname  = *(aloop->atoms->resname[resnr_mol]);
+    resind_mol = aloop->atoms->atom[aloop->at_local].resind;
+    *resnr = aloop->atoms->resinfo[resind_mol].nr;
+    if (aloop->atoms->nres == 1)
+    {
+        *resnr += aloop->resnr_last;
+    }
+    *resname  = *(aloop->atoms->resinfo[resind_mol].name);
 }
 
 void gmx_mtop_atomloop_all_moltype(gmx_mtop_atomloop_all_t aloop,
@@ -480,14 +507,14 @@ static void atomcat(t_atoms *dest, t_atoms *src, int copies)
     if (src->nres)
     {
         size=dest->nres+copies*src->nres;
-        srenew(dest->resname,size);
+        srenew(dest->resinfo,size);
     }
     
     /* residue information */
     for (l=dest->nres,j=0; (j<copies); j++,l+=src->nres)
     {
-        memcpy((char *) &(dest->resname[l]),(char *) &(src->resname[0]),
-               (size_t)(src->nres*sizeof(src->resname[0])));
+        memcpy((char *) &(dest->resinfo[l]),(char *) &(src->resinfo[0]),
+               (size_t)(src->nres*sizeof(src->resinfo[0])));
     }
     
     for (l=destnr,j=0; (j<copies); j++,l+=srcnr)
@@ -502,12 +529,22 @@ static void atomcat(t_atoms *dest, t_atoms *src, int copies)
                (size_t)(srcnr*sizeof(src->atom[0])));
     }
     
-    /* Increment residue numbers */
+    /* Increment residue indices */
     for (l=destnr,j=0; (j<copies); j++)
     {
         for (i=0; (i<srcnr); i++,l++)
         {
-            dest->atom[l].resnr  = dest->nres+j*src->nres+src->atom[i].resnr;
+            dest->atom[l].resind = dest->nres+j*src->nres+src->atom[i].resind;
+        }
+    }    
+    
+    if (src->nres == 1)
+    {
+        /* Single residue molecule, continue counting residues */
+        for (j=0; (j<copies); j++)
+        {
+            dest->resinfo[dest->nres+j].nr =
+                dest->resinfo[dest->nres-1].nr + 1 + j;
         }
     }
     
index 8893395e052a65749ce9b53fbad34372923070aa..c6f21dcadbb01bda014c70da3a7adbcce0cdfff7 100644 (file)
@@ -92,6 +92,26 @@ static void bc_strings(const t_commrec *cr,t_symtab *symtab,int nr,char ****nm)
   sfree(handle);
 }
 
+static void bc_strings_resinfo(const t_commrec *cr,t_symtab *symtab,
+                              int nr,t_resinfo *resinfo)
+{
+  int  i;
+  int  *handle;
+
+  snew(handle,nr);
+  if (MASTER(cr)) {
+    for(i=0; (i<nr); i++)
+      handle[i] = lookup_symtab(symtab,resinfo[i].name);
+  }
+  nblock_bc(cr,nr,handle);
+
+  if (!MASTER(cr)) {
+    for (i=0; (i<nr); i++) 
+      resinfo[i].name = get_symtab_handle(symtab,handle[i]);
+  }
+  sfree(handle);
+}
+
 static void bc_symtab(const t_commrec *cr,t_symtab *symtab)
 {
   int i,nr,len;
@@ -151,7 +171,8 @@ static void bc_atoms(const t_commrec *cr,t_symtab *symtab,t_atoms *atoms)
   nblock_bc(cr,atoms->nr,atoms->atom);
   bc_strings(cr,symtab,atoms->nr,&atoms->atomname);
   block_bc(cr,atoms->nres);
-  bc_strings(cr,symtab,atoms->nres,&atoms->resname);
+  nblock_bc(cr,atoms->nres,atoms->resinfo);
+  bc_strings_resinfo(cr,symtab,atoms->nres,atoms->resinfo);
   /* QMMM requires atomtypes to be known on all nodes as well */
   bc_strings(cr,symtab,atoms->nr,&atoms->atomtype);
 }
index c9670193eaa2c87f169846c36588a4bfc1d4d361..fe4b39dd3be560ae8cfe801752873d5b1d477591 100644 (file)
@@ -122,8 +122,8 @@ static void add_xr(t_xrama *xr,int ff[5],t_atoms *atoms)
   xr->pp[xr->npp].iphi=xr->ndih-2;
   xr->pp[xr->npp].ipsi=xr->ndih-1;
   xr->pp[xr->npp].bShow=FALSE;
-  sprintf(buf,"%s-%d",*atoms->resname[atoms->atom[ff[1]].resnr],
-         atoms->atom[ff[1]].resnr+1);
+  sprintf(buf,"%s-%d",*atoms->resinfo[atoms->atom[ff[1]].resind].name,
+         atoms->resinfo[atoms->atom[ff[1]].resind].nr);
   xr->pp[xr->npp].label=strdup(buf);
   xr->npp++;
 } 
index 32065e788b1a756bb77b358c16e95d6c16a81458..9498d70958660ec3d28815dcf467e1b9b8c558f9 100644 (file)
@@ -225,9 +225,10 @@ void write_pdbfile_indexed(FILE *out,char *title,
                           int ePBC,matrix box,char chain,
                           int model_nr, atom_id nindex, atom_id index[])
 {
-  char resnm[6],nm[6],ch,pdbform[128],pukestring[100];
+  char resnm[6],nm[6],pdbform[128],pukestring[100];
   atom_id i,ii;
-  int  resnr,type;
+  int  resind,resnr,type;
+  unsigned char resic,ch;
   real occup,bfac;
   bool bOccup;
   int  nlongname=0;
@@ -258,21 +259,23 @@ void write_pdbfile_indexed(FILE *out,char *title,
     fprintf(out,"MODEL %8d\n",model_nr>=0 ? model_nr : 1);
   for (ii=0; ii<nindex; ii++) {
     i=index[ii];
-    resnr=atoms->atom[i].resnr;
-    strcpy(resnm,*atoms->resname[resnr]);
+    resind = atoms->atom[i].resind;
+    strcpy(resnm,*atoms->resinfo[resind].name);
     strcpy(nm,*atoms->atomname[i]);
        /* rename HG12 to 2HG1, etc. */
     xlate_atomname_gmx2pdb(nm);
-    resnr++;
+    resnr = atoms->resinfo[resind].nr;
+    resic = atoms->resinfo[resind].ic;
+    if (chain) {
+      ch = chain;
+    } else {
+      ch = atoms->resinfo[resind].chain;
+      if (ch == 0) {
+       ch = ' ';
+      }
+    }
     if (resnr>=10000)
       resnr = resnr % 10000;
-    if (chain)
-      ch=chain;
-    else
-      if (atoms->atom[i].chain)
-       ch=atoms->atom[i].chain;
-      else
-         ch=' ';
     if (atoms->pdbinfo) {
       type  = atoms->pdbinfo[i].type;
       occup = bOccup ? 1.0 : atoms->pdbinfo[i].occup;
@@ -284,7 +287,7 @@ void write_pdbfile_indexed(FILE *out,char *title,
       bfac  = 0.0;
     }
     if (bWideFormat)
-      strcpy(pdbform,"%-6s%5u %-4.4s %3.3s %c%4d    %10.5f%10.5f%10.5f%8.4f%8.4f\n");
+      strcpy(pdbform,"%-6s%5u %-4.4s %3.3s %c%4d%c   %10.5f%10.5f%10.5f%8.4f%8.4f\n");
     else {
       if ((strlen(nm)<4) && (atoms->atom[i].atomnumber < 10))
        strcpy(pdbform,pdbformat);
@@ -302,11 +305,11 @@ void write_pdbfile_indexed(FILE *out,char *title,
       }
       strcat(pdbform,"%6.2f%6.2f\n");
     }
-    fprintf(out,pdbform,pdbtp[type],(i+1)%100000,nm,resnm,ch,resnr,
+    fprintf(out,pdbform,pdbtp[type],(i+1)%100000,nm,resnm,ch,resnr,resic,
            10*x[i][XX],10*x[i][YY],10*x[i][ZZ],occup,bfac);
     if (atoms->pdbinfo && atoms->pdbinfo[i].bAnisotropic) {
-      fprintf(out,"ANISOU%5u  %-4.4s%3.3s %c%4d  %7d%7d%7d%7d%7d%7d\n",
-             (i+1)%100000,nm,resnm,ch,resnr,
+      fprintf(out,"ANISOU%5u  %-4.4s%3.3s %c%4d%c %7d%7d%7d%7d%7d%7d\n",
+             (i+1)%100000,nm,resnm,ch,resnr,resic,
              atoms->pdbinfo[i].uij[0],atoms->pdbinfo[i].uij[1],
              atoms->pdbinfo[i].uij[2],atoms->pdbinfo[i].uij[3],
              atoms->pdbinfo[i].uij[4],atoms->pdbinfo[i].uij[5]);
@@ -435,10 +438,10 @@ static int read_atom(t_symtab *symtab,
   t_atom *atomn;
   int  j,k;
   char nc='\0';
-  char anr[12],anm[12],anm_copy[12],altloc,resnm[12],chain[12],resnr[12];
-  char xc[12],yc[12],zc[12],occup[12],bfac[12],pdbresnr[12];
-  static char oldresnm[12],oldresnr[12];
-  int  newres,atomnumber;
+  char anr[12],anm[12],anm_copy[12],altloc,resnm[12],rnr[12];
+  char xc[12],yc[12],zc[12],occup[12],bfac[12];
+  unsigned char resic,chain;
+  int  resnr,atomnumber;
 
   if (natom>=atoms->nr)
     gmx_fatal(FARGS,"\nFound more atoms (%d) in pdb file than expected (%d)",
@@ -462,19 +465,16 @@ static int read_atom(t_symtab *symtab,
   resnm[k]=nc;
   trim(resnm);
 
-  for(k=0; (k<1); k++,j++)
-    chain[k]=line[j];
-  chain[k]=nc;
+  chain = line[j];
+  j++;
   
   for(k=0; (k<4); k++,j++) {
-    resnr[k]=line[j];
-    pdbresnr[k]=line[j];
+    rnr[k] = line[j];
   }
-  resnr[k]=nc;
-  trim(resnr);
-  pdbresnr[k]=line[j];
-  pdbresnr[k+1]=nc;
-  trim(pdbresnr);
+  rnr[k] = nc;
+  trim(rnr);
+  resnr = atoi(rnr);
+  resic = line[j];
   j+=4;
 
   /* X,Y,Z Coordinate */
@@ -495,24 +495,27 @@ static int read_atom(t_symtab *symtab,
 
   if (atoms->atom) {
     atomn=&(atoms->atom[natom]);
-    if ((natom==0) || (strcmp(oldresnr,pdbresnr)!=0) || 
-       (strcmp(oldresnm,resnm)!=0)) {
-      strcpy(oldresnr,pdbresnr);
-      strcpy(oldresnm,resnm);
-      if (natom==0)
-       newres=0;
-      else
-       newres=atoms->atom[natom-1].resnr+1;
-      atoms->nres=newres+1;
-      atoms->resname[newres]=put_symtab(symtab,resnm);
+    if ((natom==0) ||
+       atoms->resinfo[atoms->atom[natom-1].resind].nr != resnr ||
+       atoms->resinfo[atoms->atom[natom-1].resind].ic != resic ||
+       (strcmp(*atoms->resinfo[atoms->atom[natom-1].resind].name,resnm) != 0))
+    {
+      if (natom == 0) {
+       atomn->resind = 0;
+      } else {
+       atomn->resind = atoms->atom[natom-1].resind + 1;
+      }
+      atoms->nres = atomn->resind + 1;
+      t_atoms_set_resinfo(atoms,natom,symtab,resnm,resnr,resic,chain);
     }
     else
-      newres=atoms->atom[natom-1].resnr;
-    if (bChange)
+    {
+      atomn->resind = atoms->atom[natom-1].resind;
+    }
+    if (bChange) {
       xlate_atomname_pdb2gmx(anm); 
+    }
     atoms->atomname[natom]=put_symtab(symtab,anm);
-    atomn->chain=chain[0];
-    atomn->resnr=newres;
     atomn->m = 0.0;
     atomn->q = 0.0;
     atomn->atomnumber = atomnumber;
@@ -524,7 +527,6 @@ static int read_atom(t_symtab *symtab,
     atoms->pdbinfo[natom].type=type;
     atoms->pdbinfo[natom].atomnr=atoi(anr);
     atoms->pdbinfo[natom].altloc=altloc;
-    strcpy(atoms->pdbinfo[natom].pdbresnr,pdbresnr);
     strcpy(atoms->pdbinfo[natom].atomnm,anm_copy);
     atoms->pdbinfo[natom].bfac=atof(bfac);
     atoms->pdbinfo[natom].occup=atof(occup);
index 3eb588006db81cdc2c7fa6463f730d68e50605d6..7f43acc53ba52c655f5f1e1a0057739fcea0831f 100644 (file)
@@ -62,7 +62,7 @@
 #include "mtop_util.h"
 
 /* This number should be increased whenever the file format changes! */
-static const int tpx_version = 62;
+static const int tpx_version = 63;
 
 /* This number should only be increased when you edit the TOPOLOGY section
  * of the tpx format. This way we can maintain forward compatibility too
@@ -73,7 +73,7 @@ static const int tpx_version = 62;
  * to the end of the tpx file, so we can just skip it if we only
  * want the topology.
  */
-static const int tpx_generation = 18;
+static const int tpx_generation = 19;
 
 /* This number should be the most recent backwards incompatible version 
  * I.e., if this number is 9, we cannot read tpx version 9 with this code.
@@ -1200,7 +1200,7 @@ static void do_atom(t_atom *atom,int ngrp,bool bRead, int file_version,
   do_ushort(atom->type);
   do_ushort(atom->typeB);
   do_int (atom->ptype);
-  do_int (atom->resnr);
+  do_int (atom->resind);
   if (file_version >= 52)
     do_int(atom->atomnumber);
   else if (bRead)
@@ -1273,6 +1273,23 @@ static void do_strstr(int nstr,char ***nm,bool bRead,t_symtab *symtab)
     do_symstr(&(nm[j]),bRead,symtab);
 }
 
+static void do_resinfo(int n,t_resinfo *ri,bool bRead,t_symtab *symtab,
+                      int file_version)
+{
+  int  j;
+  
+  for (j=0; (j<n); j++) {
+    do_symstr(&(ri[j].name),bRead,symtab);
+    if (file_version >= 63) {
+      do_int  (ri[j].nr);
+      do_uchar(ri[j].ic);
+    } else {
+      ri[j].nr = j + 1;
+      ri[j].ic = ' ';
+    }
+  }
+}
+
 static void do_atoms(t_atoms *atoms,bool bRead,t_symtab *symtab,
                     int file_version,
                     gmx_groups_t *groups)
@@ -1293,7 +1310,7 @@ static void do_atoms(t_atoms *atoms,bool bRead,t_symtab *symtab,
     snew(atoms->atomname,atoms->nr);
     snew(atoms->atomtype,atoms->nr);
     snew(atoms->atomtypeB,atoms->nr);
-    snew(atoms->resname,atoms->nres);
+    snew(atoms->resinfo,atoms->nres);
     if (file_version < 57) {
       snew(groups->grpname,groups->ngrpname);
     }
@@ -1312,7 +1329,7 @@ static void do_atoms(t_atoms *atoms,bool bRead,t_symtab *symtab,
     do_strstr(atoms->nr,atoms->atomtype,bRead,symtab);
     do_strstr(atoms->nr,atoms->atomtypeB,bRead,symtab);
   }
-  do_strstr(atoms->nres,atoms->resname,bRead,symtab);
+  do_resinfo(atoms->nres,atoms->resinfo,bRead,symtab,file_version);
 
   if (file_version < 57) {
     do_strstr(groups->ngrpname,groups->grpname,bRead,symtab);
@@ -1426,8 +1443,8 @@ static void do_symtab(t_symtab *symtab,bool bRead)
 void 
 tpx_make_chain_identifiers(t_atoms *atoms,t_block *mols)
 {
-  int m,a,a0,a1;
-  char c,chain;
+  int m,a,a0,a1,r;
+  unsigned char c,chain;
 #define CHAIN_MIN_ATOMS 15
 
   chain='A';
@@ -1439,12 +1456,15 @@ tpx_make_chain_identifiers(t_atoms *atoms,t_block *mols)
       chain++;
     } else
       c=' ';
-    for(a=a0; a<a1; a++)
-      atoms->atom[a].chain=c;  
+    for(a=a0; a<a1; a++) {
+      atoms->resinfo[atoms->atom[a].resind].chain = c;
+    }
+  }
+  if (chain == 'B') {
+    for(r=0; r<atoms->nres; r++) {
+      atoms->resinfo[r].chain = ' ';
+    }
   }
-  if (chain == 'B')
-    for(a=0; a<atoms->nr; a++)
-      atoms->atom[a].chain=' ';
 }
   
 static void do_moltype(gmx_moltype_t *molt,bool bRead,t_symtab *symtab,
@@ -2102,13 +2122,13 @@ bool read_tps_conf(char *infile,char *title,t_topology *top,int *ePBC,
       aps = gmx_atomprop_init();
       for(i=0; (i<natoms); i++)
        if (!gmx_atomprop_query(aps,epropMass,
-                               *top->atoms.resname[top->atoms.atom[i].resnr],
+                               *top->atoms.resinfo[top->atoms.atom[i].resind].name,
                                *top->atoms.atomname[i],
                                &(top->atoms.atom[i].m))) {
          if (debug) 
            fprintf(debug,"Can not find mass for atom %s %d %s, setting to 1\n",
-                   *top->atoms.resname[top->atoms.atom[i].resnr],
-                   top->atoms.atom[i].resnr+1,
+                   *top->atoms.resinfo[top->atoms.atom[i].resind].name,
+                   top->atoms.resinfo[top->atoms.atom[i].resind].nr,
                    *top->atoms.atomname[i]);
        }
       gmx_atomprop_destroy(aps);
index b2bca3c7d83b3efe232fe2b96be4d3f0af1ae744..e4f62bed5fb2e5045b6f7cb3e29b2003479a02c6 100644 (file)
@@ -1117,6 +1117,23 @@ static void pr_strings2(FILE *fp,int indent,const char *title,
     }
 }
 
+static void pr_resinfo(FILE *fp,int indent,const char *title,t_resinfo *resinfo,int n, bool bShowNumbers)
+{
+    int i;
+    
+    if (available(fp,resinfo,indent,title))
+    {  
+        indent=pr_title_n(fp,indent,title,n);
+        for (i=0; i<n; i++)
+        {
+            (void) pr_indent(fp,indent);
+            (void) fprintf(fp,"%s[%d]={name=\"%s\", nr=%d, ic='%c'}\n",
+                           title,bShowNumbers?i:-1,
+                           *(resinfo[i].name),resinfo[i].nr,resinfo[i].ic);
+        }
+    }
+}
+
 static void pr_atom(FILE *fp,int indent,const char *title,t_atom *atom,int n)
 {
   int i,j;
@@ -1126,9 +1143,10 @@ static void pr_atom(FILE *fp,int indent,const char *title,t_atom *atom,int n)
     for (i=0; i<n; i++) {
       (void) pr_indent(fp,indent);
       fprintf(fp,"%s[%6d]={type=%3d, typeB=%3d, ptype=%8s, m=%12.5e, "
-             "q=%12.5e, mB=%12.5e, qB=%12.5e, resnr=%5d, atomnumber=%3d}\n",
-             title,i,atom[i].type,atom[i].typeB,ptype_str[atom[i].ptype],
-             atom[i].m,atom[i].q,atom[i].mB,atom[i].qB,atom[i].resnr,atom[i].atomnumber);
+              "q=%12.5e, mB=%12.5e, qB=%12.5e, resind=%5d, atomnumber=%3d}\n",
+              title,i,atom[i].type,atom[i].typeB,ptype_str[atom[i].ptype],
+              atom[i].m,atom[i].q,atom[i].mB,atom[i].qB,
+              atom[i].resind,atom[i].atomnumber);
     }
   }
 }
@@ -1209,7 +1227,7 @@ void pr_atoms(FILE *fp,int indent,const char *title,t_atoms *atoms,
       pr_atom(fp,indent,"atom",atoms->atom,atoms->nr);
       pr_strings(fp,indent,"atom",atoms->atomname,atoms->nr,bShownumbers);
       pr_strings2(fp,indent,"type",atoms->atomtype,atoms->atomtypeB,atoms->nr,bShownumbers);
-      pr_strings(fp,indent,"residue",atoms->resname,atoms->nres,bShownumbers);
+      pr_resinfo(fp,indent,"residue",atoms->resinfo,atoms->nres,bShownumbers);
     }
 }
 
@@ -1337,16 +1355,6 @@ void pr_header(FILE *fp,int indent,const char *title,t_tpxheader *sh)
     }
 }
 
-char *atomname(t_atoms *a,int i)
-{
-  char buf[32];
-  int resnr=a->atom[i].resnr;
-  
-  sprintf(buf,"%s%d-%s",*a->resname[resnr],resnr+1,*a->atomname[i]);
-  
-  return strdup(buf);
-}
-
 void pr_commrec(FILE *fp,int indent,t_commrec *cr)
 {
   pr_indent(fp,indent);
index bcf2d840560a37e13edad8fc7c88a523b003bc96..65f547f20552f1a57d5b38a05dc4b7625299330e 100644 (file)
@@ -112,7 +112,7 @@ void init_atom(t_atoms *at)
   at->nr       = 0;
   at->nres     = 0;
   at->atom     = NULL;
-  at->resname  = NULL;
+  at->resinfo  = NULL;
   at->atomname = NULL;
   at->atomtype = NULL;
   at->atomtypeB= NULL;
@@ -252,7 +252,7 @@ void done_atom (t_atoms *at)
   at->nr       = 0;
   at->nres     = 0;
   sfree(at->atom);
-  sfree(at->resname);
+  sfree(at->resinfo);
   sfree(at->atomname);
 }
 
@@ -513,7 +513,7 @@ void init_t_atoms(t_atoms *atoms, int natoms, bool bPdbinfo)
   snew(atoms->atomname,natoms);
   atoms->atomtype=NULL;
   atoms->atomtypeB=NULL;
-  snew(atoms->resname,natoms);
+  snew(atoms->resinfo,natoms);
   snew(atoms->atom,natoms);
   if (bPdbinfo)
     snew(atoms->pdbinfo,natoms);
@@ -521,6 +521,19 @@ void init_t_atoms(t_atoms *atoms, int natoms, bool bPdbinfo)
     atoms->pdbinfo=NULL;
 }
 
+void t_atoms_set_resinfo(t_atoms *atoms,int atom_ind,t_symtab *symtab,
+                        char *resname,int resnr,unsigned char ic,
+                        unsigned char chain)
+{
+  t_resinfo *ri;
+
+  ri = &atoms->resinfo[atoms->atom[atom_ind].resind];
+  ri->name  = put_symtab(symtab,resname);
+  ri->nr    = resnr;
+  ri->ic    = ic;
+  ri->chain = chain;
+}
+
 void free_t_atoms(t_atoms *atoms,bool bFreeNames)
 {
   int i;
@@ -531,13 +544,13 @@ void free_t_atoms(t_atoms *atoms,bool bFreeNames)
       *atoms->atomname[i]=NULL;
     }
     for(i=0; i<atoms->nres; i++) {
-      sfree(*atoms->resname[i]);
-      *atoms->resname[i]=NULL;
+      sfree(*atoms->resinfo[i].name);
+      *atoms->resinfo[i].name=NULL;
     }
   }
   sfree(atoms->atomname);
   /* Do we need to free atomtype and atomtypeB as well ? */
-  sfree(atoms->resname);
+  sfree(atoms->resinfo);
   sfree(atoms->atom);
   if (atoms->pdbinfo)
     sfree(atoms->pdbinfo);
index 4e39a69407f2419aa9c8cf78b0e38c8983927684..e1d5467db06b19d975106a4a7d07b0ca4258f90c 100644 (file)
@@ -467,7 +467,7 @@ static int get_impropers(t_atoms *atoms,t_hackblock hb[],t_param **idih,
          nidih++;
        }
       }
-      while ((start<atoms->nr) && (atoms->atom[start].resnr==i))
+      while ((start<atoms->nr) && (atoms->atom[start].resind == i))
        start++;
     }
   }
@@ -502,15 +502,15 @@ bool is_hydro(t_atoms *atoms,int ai)
 }
 
 static void get_atomnames_min(int n,char **anm,
-                             int res,t_atoms *atoms,atom_id *a)
+                             int resind,t_atoms *atoms,atom_id *a)
 {
   int m;
 
   /* Assume ascending residue numbering */
   for(m=0; m<n; m++) {
-    if (atoms->atom[a[m]].resnr < res)
+    if (atoms->atom[a[m]].resind < resind)
       strcpy(anm[m],"-");
-    else if (atoms->atom[a[m]].resnr > res)
+    else if (atoms->atom[a[m]].resind > resind)
       strcpy(anm[m],"+");
     else
       strcpy(anm[m],"");
@@ -529,8 +529,8 @@ static void gen_excls(t_atoms *atoms, t_excls *excls, t_hackblock hb[],
 
   astart = 0;
   for(a=0; a<atoms->nr; a++) {
-    r = atoms->atom[a].resnr;
-    if (a==atoms->nr-1 || atoms->atom[a+1].resnr!=r) {
+    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++) {
@@ -692,11 +692,11 @@ void gen_pad(t_nextnb *nnb, t_atoms *atoms, int nrexcl, bool bH14,
            ang[nang].C1=NOTSET;
            set_p_string(&(ang[nang]),"");
            if (hb) {
-             minres = atoms->atom[ang[nang].a[0]].resnr;
+             minres = atoms->atom[ang[nang].a[0]].resind;
              maxres = minres;
              for(m=1; m<3; m++) {
-               minres = min(minres,atoms->atom[ang[nang].a[m]].resnr);
-               maxres = max(maxres,atoms->atom[ang[nang].a[m]].resnr);
+               minres = min(minres,atoms->atom[ang[nang].a[m]].resind);
+               maxres = max(maxres,atoms->atom[ang[nang].a[m]].resind);
              }
              res = 2*minres-maxres;
              do {
@@ -739,11 +739,11 @@ void gen_pad(t_nextnb *nnb, t_atoms *atoms, int nrexcl, bool bH14,
                set_p_string(&(dih[ndih]),"");
                nFound = 0;
                if (hb) {
-                 minres = atoms->atom[dih[ndih].a[0]].resnr;
+                 minres = atoms->atom[dih[ndih].a[0]].resind;
                  maxres = minres;
                  for(m=1; m<4; m++) {
-                   minres = min(minres,atoms->atom[dih[ndih].a[m]].resnr);
-                   maxres = max(maxres,atoms->atom[dih[ndih].a[m]].resnr);
+                   minres = min(minres,atoms->atom[dih[ndih].a[m]].resind);
+                   maxres = max(maxres,atoms->atom[dih[ndih].a[m]].resind);
                  }
                  res = 2*minres-maxres;
                  do {
index 893c6542f5ac01bf53530bf5ea38ece45c0b2a66..76db8b39105e9f5f306ec899398926086d392964 100644 (file)
@@ -419,9 +419,9 @@ static int get_atype(int atom, t_atoms *at, int nrtp, t_restp rtp[],
     type=at->atom[atom].type;
   else {
     /* get type from rtp */
-    rtpp = search_rtp(*(at->resname[at->atom[atom].resnr]),nrtp,rtp);
-    bNterm = is_protein(aan,*(at->resname[at->atom[atom].resnr])) && 
-      (at->atom[atom].resnr == 0);
+    rtpp = search_rtp(*(at->resinfo[at->atom[atom].resind].name),nrtp,rtp);
+    bNterm = is_protein(aan,*(at->resinfo[at->atom[atom].resind].name)) && 
+      (at->atom[atom].resind == 0);
     j=search_jtype(rtpp,*(at->atomname[atom]),bNterm);
     type=rtpp->atom[j].type;
   }
@@ -452,9 +452,9 @@ static real get_amass(int atom, t_atoms *at, int nrtp, t_restp rtp[],
     mass=at->atom[atom].m;
   else {
     /* get mass from rtp */
-    rtpp = search_rtp(*(at->resname[at->atom[atom].resnr]),nrtp,rtp);
-    bNterm = is_protein(aan,*(at->resname[at->atom[atom].resnr])) && 
-      (at->atom[atom].resnr == 0);
+    rtpp = search_rtp(*(at->resinfo[at->atom[atom].resind].name),nrtp,rtp);
+    bNterm = is_protein(aan,*(at->resinfo[at->atom[atom].resind].name)) && 
+      (at->atom[atom].resind == 0);
     j=search_jtype(rtpp,*(at->atomname[atom]),bNterm);
     mass=rtpp->atom[j].m;
   }
@@ -914,8 +914,7 @@ static int gen_vsites_trp(t_atomtype atype, rvec *newx[],
     (*newatom)      [atM[j]].q     = (*newatom)[atM[j]].qB    = 0.0;
     (*newatom)      [atM[j]].type  = (*newatom)[atM[j]].typeB = tpM;
     (*newatom)      [atM[j]].ptype = eptAtom;
-    (*newatom)      [atM[j]].resnr = at->atom[i0].resnr;
-    (*newatom)      [atM[j]].chain = at->atom[i0].chain;
+    (*newatom)      [atM[j]].resind= at->atom[i0].resind;
     (*newvsite_type)[atM[j]]       = NOTSET;
     (*newcgnr)      [atM[j]]       = (*cgnr)[i0];
   }
@@ -1081,8 +1080,7 @@ static int gen_vsites_tyr(t_atomtype atype, rvec *newx[],
   (*newatom)      [atM].q     = (*newatom)[atM].qB    = 0.0;
   (*newatom)      [atM].type  = (*newatom)[atM].typeB = tpM;
   (*newatom)      [atM].ptype = eptAtom;
-  (*newatom)      [atM].resnr = at->atom[i0].resnr;
-  (*newatom)      [atM].chain = at->atom[i0].chain;
+  (*newatom)      [atM].resind= at->atom[i0].resind;
   (*newvsite_type)[atM]       = NOTSET;
   (*newcgnr)      [atM]       = (*cgnr)[i0]; 
   /* renumber cgnr: */
@@ -1326,7 +1324,7 @@ void do_vsites(int nrtp, t_restp rtp[], t_atomtype atype,
                real mHmult, bool bVsiteAromatics, char *ff)
 {
 #define MAXATOMSPERRESIDUE 16
-  int  i,j,k,i0,ni0,whatres,resnr,add_shift,ftype,nvsite,nadd;
+  int  i,j,k,i0,ni0,whatres,resind,add_shift,ftype,nvsite,nadd;
   int  ai,aj,ak,al;
   int  nrfound=0,needed,nrbonds,nrHatoms,Heavy,nrheavies,tpM,tpHeavy;
   int  Hatoms[4],heavies[4],bb;
@@ -1421,11 +1419,11 @@ void do_vsites(int nrtp, t_restp rtp[], t_atomtype atype,
     
   /* generate vsite constructions */
   /* loop over all atoms */
-  resnr=NOTSET;
+  resind = -1;
   for(i=0; (i<at->nr); i++) {
-    if (at->atom[i].resnr != resnr) {
-      resnr=at->atom[i].resnr;
-      resnm=*(at->resname[resnr]);
+    if (at->atom[i].resind != resind) {
+      resind = at->atom[i].resind;
+      resnm  = *(at->resinfo[resind].name);
     }
     /* first check for aromatics to virtualize */
     /* don't waste our effort on DNA, water etc. */
@@ -1433,28 +1431,30 @@ void do_vsites(int nrtp, t_restp rtp[], t_atomtype atype,
      * CA atom, since there might be an X2/X3 group on the
      * N-terminus that must be treated first.
      */
-    if ( bVsiteAromatics && !strcmp(*(at->atomname[i]),"CA") &&
-        !bResProcessed[resnr] && is_protein(aan,*(at->resname[resnr])) ) {
+    if ( bVsiteAromatics &&
+        !strcmp(*(at->atomname[i]),"CA") &&
+        !bResProcessed[resind] &&
+        is_protein(aan,*(at->resinfo[resind].name)) ) {
       /* mark this residue */
-      bResProcessed[resnr]=TRUE;
+      bResProcessed[resind] = TRUE;
       /* find out if this residue needs converting */
       whatres=NOTSET;
       for(j=0; j<resNR && whatres==NOTSET; j++) {
                  
-                 cmplength = bPartial ? strlen(resnm)-1 : strlen(resnm);
-                 
-                 bFound = ((strncasecmp(resnm,resnms[j], cmplength)==0) ||
-                                       (strncasecmp(resnm,resnmsN[j],cmplength)==0) ||
-                                       (strncasecmp(resnm,resnmsC[j],cmplength)==0));
-               
-                 if ( bFound ) {
-                         whatres=j;
+       cmplength = bPartial[j] ? strlen(resnm)-1 : strlen(resnm);
+       
+       bFound = ((strncasecmp(resnm,resnms[j], cmplength)==0) ||
+                 (strncasecmp(resnm,resnmsN[j],cmplength)==0) ||
+                 (strncasecmp(resnm,resnmsC[j],cmplength)==0));
+       
+       if ( bFound ) {
+         whatres=j;
          /* get atoms we will be needing for the conversion */
          nrfound=0;
          for (k=0; atnms[j][k]; k++) {
            ats[k]=NOTSET;
            i0=i;
-           while (i<at->nr && at->atom[i].resnr==resnr && ats[k]==NOTSET) {
+           while (i<at->nr && at->atom[i].resind==resind && ats[k]==NOTSET) {
              if (strcasecmp(*(at->atomname[i]),atnms[j][k])==0) {
                ats[k]=i;
                nrfound++;
@@ -1472,9 +1472,9 @@ void do_vsites(int nrtp, t_restp rtp[], t_atomtype atype,
            needed = k;
          if (nrfound<needed)
            gmx_fatal(FARGS,"not enough atoms found (%d, need %d) in "
-                       "residue %s %d while\n             "
-                       "generating aromatics virtual site construction",
-                       nrfound,needed,resnm,resnr+1);
+                     "residue %s %d while\n             "
+                     "generating aromatics virtual site construction",
+                     nrfound,needed,resnm,at->resinfo[resind].nr);
        }
       }
       /* the enums for every residue MUST correspond to atnms[residue] */
@@ -1507,7 +1507,7 @@ void do_vsites(int nrtp, t_restp rtp[], t_atomtype atype,
                    __FILE__,__LINE__);
       } /* switch whatres */
       /* skip back to beginning of residue */
-      while(i>0 && at->atom[i-1].resnr==resnr)
+      while(i>0 && at->atom[i-1].resind == resind)
        i--;
     } /* if bVsiteAromatics & is protein */
     
@@ -1676,8 +1676,7 @@ void do_vsites(int nrtp, t_restp rtp[], t_atomtype atype,
          newatom[ni0+j].q     = newatom[ni0+j].qB    = 0.0;
          newatom[ni0+j].type  = newatom[ni0+j].typeB = tpM;
          newatom[ni0+j].ptype = eptAtom;
-         newatom[ni0+j].resnr = at->atom[i0].resnr;
-         newatom[ni0+j].chain = at->atom[i0].chain;
+         newatom[ni0+j].resind= at->atom[i0].resind;
          newvsite_type[ni0+j] = NOTSET;
          newcgnr[ni0+j]       = (*cgnr)[i0];
        }
@@ -1736,9 +1735,9 @@ void do_vsites(int nrtp, t_restp rtp[], t_atomtype atype,
     for(i=0; i<at->nr; i++)
       fprintf(debug,"%4d %4d %4s %4d %4s %6d %-10s\n",i+1,o2n[i]+1,
              at->atomname[i]?*(at->atomname[i]):"(NULL)",
-             at->atom[i].resnr,
-             at->resname[at->atom[i].resnr]?
-             *(at->resname[at->atom[i].resnr]):"(NULL)",
+             at->resinfo[at->atom[i].resind].nr,
+             at->resinfo[at->atom[i].resind].name ?
+             *(at->resinfo[at->atom[i].resind].name):"(NULL)",
              (*cgnr)[i],
              ((*vsite_type)[i]==NOTSET) ? 
              "NOTSET" : interaction_function[(*vsite_type)[i]].name);
@@ -1747,7 +1746,7 @@ void do_vsites(int nrtp, t_restp rtp[], t_atomtype atype,
       if (newatomname[i])
        fprintf(debug,"%4d %4s %4d %6d %-10s\n",i+1,
                newatomname[i]?*(newatomname[i]):"(NULL)",
-               newatom[i].resnr,newcgnr[i],
+               newatom[i].resind,newcgnr[i],
                (newvsite_type[i]==NOTSET) ? 
                "NOTSET" : interaction_function[newvsite_type[i]].name);
   }
@@ -1782,9 +1781,9 @@ void do_vsites(int nrtp, t_restp rtp[], t_atomtype atype,
     for(i=0; i<at->nr; i++)
       fprintf(debug,"%4d %4s %4d %4s %6d %-10s\n",i+1,
              at->atomname[i]?*(at->atomname[i]):"(NULL)",
-             at->atom[i].resnr, 
-             at->resname[at->atom[i].resnr]?
-             *(at->resname[at->atom[i].resnr]):"(NULL)",
+             at->resinfo[at->atom[i].resind].nr, 
+             at->resinfo[at->atom[i].resind].name ?
+             *(at->resinfo[at->atom[i].resind].name):"(NULL)",
              (*cgnr)[i],
              ((*vsite_type)[i]==NOTSET) ? 
              "NOTSET" : interaction_function[(*vsite_type)[i]].name);
index 5d5fb29e7dbaba86d3b4aab0095378d864d0b886..114de3be8636ed572a3e44894014147c838bd6e2 100644 (file)
@@ -67,30 +67,32 @@ static void copy_atom(t_atoms *atoms1,int a1,t_atoms *atoms2,int a2)
   *atoms2->atomname[a2]=strdup(*atoms1->atomname[a1]);
 }
 
-atom_id pdbasearch_atom(char *name,int resnr,t_atoms *pdba, char *searchtype)
+static atom_id pdbasearch_atom(char *name,int resind,t_atoms *pdba,
+                              char *searchtype)
 {
   int  i;
   
-  for(i=0; (i<pdba->nr) && (pdba->atom[i].resnr != resnr); 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,TRUE);
 }
 
-void hacksearch_atom(int *ii, int *jj, char *name, int nab[], t_hack *ab[], 
-                    int resnr, t_atoms *pdba)
+static void hacksearch_atom(int *ii, int *jj, char *name,
+                           int nab[], t_hack *ab[], 
+                           int resind, t_atoms *pdba)
 {
   int  i,j;
   
   *ii=-1;
   if (name[0] == '-') {
     name++;
-    resnr--;
+    resind--;
   }
-  for(i=0; (i<pdba->nr) && (pdba->atom[i].resnr != resnr); i++)
+  for(i=0; (i<pdba->nr) && (pdba->atom[i].resind != resind); i++)
     ;
-  for(   ; (i<pdba->nr) && (pdba->atom[i].resnr == resnr) && (*ii<0); i++)
+  for(   ; (i<pdba->nr) && (pdba->atom[i].resind == resind) && (*ii<0); i++)
     for(j=0; (j < nab[i]) && (*ii<0); j++)
       if (ab[i][j].nname && strcmp(name,ab[i][j].nname) == 0) {
        *ii=i;
@@ -139,7 +141,7 @@ static t_hackblock *get_hackblocks(t_atoms *pdba, int nah, t_hackblock ah[],
   }
   /* then the whole hdb */
   for(rnr=0; rnr < pdba->nres; rnr++) {
-    ahptr=search_h_db(nah,ah,*pdba->resname[rnr]);
+    ahptr=search_h_db(nah,ah,*pdba->resinfo[rnr].name);
     if ( ahptr ) {
       if (hb[rnr].name==NULL)
        hb[rnr].name=strdup(ahptr->name);
@@ -227,13 +229,13 @@ static void expand_hackblocks(t_atoms *pdba, t_hackblock hb[],
   for(i=0; i < pdba->nr; i++) {
     bN = FALSE;
     for(j=0; j<nterpairs && !bN; j++)
-      bN = pdba->atom[i].resnr==rN[j];
+      bN = pdba->atom[i].resind==rN[j];
     bC = FALSE;
     for(j=0; j<nterpairs && !bC; j++)
-      bC = pdba->atom[i].resnr==rC[j];
+      bC = pdba->atom[i].resind==rC[j];
 
     /* add hacks to this atom */
-    expand_hackblocks_one(&hb[pdba->atom[i].resnr], *pdba->atomname[i], 
+    expand_hackblocks_one(&hb[pdba->atom[i].resind], *pdba->atomname[i], 
                          &nab[i], &ab[i], bN, bC);
   }
   if (debug) fprintf(debug,"\n");
@@ -245,7 +247,7 @@ static int check_atoms_present(t_atoms *pdba, int nab[], t_hack *ab[])
   
   nadd=0;
   for(i=0; i < pdba->nr; i++) {
-    rnr = pdba->atom[i].resnr;
+    rnr = pdba->atom[i].resind;
     for(j=0; j<nab[i]; j++)
       if ( ab[i][j].oname==NULL ) { 
        /* we're adding */
@@ -291,7 +293,7 @@ static void calc_all_pos(t_atoms *pdba, rvec x[], int nab[], t_hack *ab[])
   jj = 0;
   
   for(i=0; i < pdba->nr; i++) {
-    rnr   = pdba->atom[i].resnr;
+    rnr   = pdba->atom[i].resind;
     for(j=0; j < nab[i]; j+=ab[i][j].nr) {
       /* check if we're adding: */
       if (ab[i][j].oname==NULL && ab[i][j].tp > 0) {
@@ -302,8 +304,10 @@ static void calc_all_pos(t_atoms *pdba, rvec x[], int nab[], t_hack *ab[])
            hacksearch_atom(&ii, &jj, ab[i][j].a[m], nab, ab, rnr, pdba);
            if (ii < 0)
              gmx_fatal(FARGS,"Atom %s not found in residue %s%d"
-                         " while adding hydrogens",
-                         ab[i][j].a[m],*pdba->resname[rnr],rnr+1);
+                       " while adding hydrogens",
+                       ab[i][j].a[m],
+                       *pdba->resinfo[rnr].name,
+                       pdba->resinfo[rnr].nr);
            else
              copy_rvec(ab[ii][jj].newx, xa[m]);
          } else
@@ -399,8 +403,8 @@ int add_h(t_atoms **pdbaptr, rvec *xptr[],
     snew(newpdba,1);
     init_t_atoms(newpdba,natoms+nadd,FALSE);
     newpdba->nres    = pdba->nres;   
-    sfree(newpdba->resname);
-    newpdba->resname = pdba->resname;
+    sfree(newpdba->resinfo);
+    newpdba->resinfo = pdba->resinfo;
   } else {
     nadd = 0;
   }
@@ -423,8 +427,8 @@ int add_h(t_atoms **pdbaptr, rvec *xptr[],
       }
       if (debug) fprintf(debug,"(%3d) %3d %4s %4s%3d %3d",
                         i+1, newi+1, *pdba->atomname[i],
-                        *pdba->resname[pdba->atom[i].resnr],
-                        pdba->atom[i].resnr+1, nab[i]);
+                        *pdba->resinfo[pdba->atom[i].resind].name,
+                        pdba->resinfo[pdba->atom[i].resind].nr, nab[i]);
       if (bUpdate_pdba)
        copy_atom(pdba,i, newpdba,newi);
       copy_rvec((*xptr)[i],xn[newi]);
@@ -443,7 +447,7 @@ int add_h(t_atoms **pdbaptr, rvec *xptr[],
            debug_gmx();
          }
          if (bUpdate_pdba) {
-           newpdba->atom[newi].resnr=pdba->atom[i].resnr;
+           newpdba->atom[newi].resind=pdba->atom[i].resind;
          }
          if (debug) fprintf(debug," + %d",newi+1);
        }
@@ -553,7 +557,7 @@ int protonate(t_atoms **atomsptr,rvec **xptr,t_protonate *protdata)
 
     if (nntdb>=4 && nctdb>=2) {
       /* Yuk, yuk, hardcoded default termini selections !!! */
-      if (strncmp(*atoms->resname[atoms->atom[atoms->nr-1].resnr],"PRO",3)==0)
+      if (strncmp(*atoms->resinfo[atoms->atom[atoms->nr-1].resind].name,"PRO",3)==0)
        nt = 3;
       else
        nt = 1;
@@ -569,7 +573,7 @@ int protonate(t_atoms **atomsptr,rvec **xptr,t_protonate *protdata)
     snew(protdata->rN, NTERPAIRS);
     snew(protdata->rC, NTERPAIRS);
     protdata->rN[0]=0;
-    protdata->rC[0]=atoms->atom[atoms->nr-1].resnr;
+    protdata->rC[0]=atoms->atom[atoms->nr-1].resind;
     
     /* keep unprotonated topology: */
     protdata->upatoms = atoms;
index 32688c194918f410ed5af0f5b26abf41f02af690..1e863e12bb053d037c299fc1da2dd4be0d9f27c3 100644 (file)
@@ -429,10 +429,11 @@ void chk_tps(char *fn, real vdw_fac, real bon_lo, real bon_hi)
     snew(atom_vdw,natom);
     aps = gmx_atomprop_init();
     for (i=0; (i<natom); i++) {
-      gmx_atomprop_query(aps,epropVDW,*(atoms->resname[atoms->atom[i].resnr]),
+      gmx_atomprop_query(aps,epropVDW,
+                        *(atoms->resinfo[atoms->atom[i].resind].name),
                         *(atoms->atomname[i]),&(atom_vdw[i]));
       if (debug) fprintf(debug,"%5d %4s %4s %7g\n",i+1,
-                        *(atoms->resname[atoms->atom[i].resnr]),
+                        *(atoms->resinfo[atoms->atom[i].resind].name),
                         *(atoms->atomname[i]),
                         atom_vdw[i]);
     }
@@ -462,10 +463,12 @@ void chk_tps(char *fn, real vdw_fac, real bon_lo, real bon_hi)
          fprintf(stderr,
                  "\r%5d %4s %4s%4d %-5.3g  %5d %4s %4s%4d %-5.3g  %-6.4g\n",
                  i+1,*(atoms->atomname[i]),
-                 *(atoms->resname[atoms->atom[i].resnr]),atoms->atom[i].resnr+1,
+                 *(atoms->resinfo[atoms->atom[i].resind].name),
+                 atoms->resinfo[atoms->atom[i].resind].nr,
                  atom_vdw[i],
                  j+1,*(atoms->atomname[j]),
-                 *(atoms->resname[atoms->atom[j].resnr]),atoms->atom[j].resnr+1,
+                 *(atoms->resinfo[atoms->atom[j].resind].name),
+                 atoms->resinfo[atoms->atom[j].resind].nr,
                  atom_vdw[j],
                  sqrt(r2) );
        }
@@ -498,8 +501,8 @@ void chk_tps(char *fn, real vdw_fac, real bon_lo, real bon_hi)
          fprintf(stderr,
                  "%5d %4s %4s%4d %-5.3g",
                  i,*(atoms->atomname[i]),
-                 *(atoms->resname[atoms->atom[i].resnr]),
-                 atoms->atom[i].resnr,atom_vdw[i]);
+                 *(atoms->resinfo[atoms->atom[i].resind].name),
+                 atoms->resinfo[atoms->atom[i].resind].nr,atom_vdw[i]);
          for (j=0; (j<DIM); j++)
            fprintf(stderr," %6.3g",x[i][j]);
          fprintf(stderr,"\n");
index f92414a9e18c99ab41afcd13439908a0c2494a28..ca4d1f3bf4c8c1f202d7ac1fa5f6d30e26ddb599 100644 (file)
@@ -110,10 +110,10 @@ static void pr_hbonds(FILE *fp,t_blocka *hb,t_atoms *pdba)
     for(j=j0; (j<j1); j++) {
       k=hb->a[j];
       fprintf(fp,"%5s%4d%5s - %5s%4d%5s\n",
-             *pdba->resname[pdba->atom[i].resnr],
-             pdba->atom[i].resnr+1,*pdba->atomname[i],
-             *pdba->resname[pdba->atom[k].resnr],
-             pdba->atom[k].resnr+1,*pdba->atomname[k]);
+             *pdba->resinfo[pdba->atom[i].resind].name,
+             pdba->resinfo[pdba->atom[i].resind].nr,*pdba->atomname[i],
+             *pdba->resinfo[pdba->atom[k].resind].name,
+             pdba->resinfo[pdba->atom[k].resind].nr,*pdba->atomname[k]);
     }
   }
 }
@@ -129,13 +129,13 @@ static bool chk_hbonds(int i,t_atoms *pdba, rvec x[],
   
   natom=pdba->nr;
   bHB = FALSE;
-  ri = pdba->atom[i].resnr;
+  ri = pdba->atom[i].resind;
   dist2=sqr(dist);
   for(j=0; (j<natom); j++) {
     /* Check whether the other atom is a donor/acceptor and not i */
     if ((ad[j]) && (j != i)) {
       /* Check whether the other atom is on the same ring as well */
-      if ((pdba->atom[j].resnr != ri) ||
+      if ((pdba->atom[j].resind != ri) ||
          ((strcmp(*pdba->atomname[j],"ND1") != 0) &&
           (strcmp(*pdba->atomname[j],"NE2") != 0))) {
        aj = j;
@@ -147,10 +147,11 @@ static bool chk_hbonds(int i,t_atoms *pdba, rvec x[],
          if (debug)
            fprintf(debug,
                    "HBOND between %s%d-%s and %s%d-%s is %g nm, %g deg\n",
-                   *pdba->resname[pdba->atom[i].resnr], 
-                   pdba->atom[i].resnr+1, *pdba->atomname[i],
-                   *pdba->resname[pdba->atom[aj].resnr],
-                   pdba->atom[aj].resnr+1,*pdba->atomname[aj],sqrt(d2),a);
+                   *pdba->resinfo[pdba->atom[i].resind].name, 
+                   pdba->resinfo[pdba->atom[i].resind].nr,*pdba->atomname[i],
+                   *pdba->resinfo[pdba->atom[aj].resind].name,
+                   pdba->resinfo[pdba->atom[aj].resind].nr,*pdba->atomname[aj],
+                   sqrt(d2),a);
          hbond[i] = TRUE;
          bHB      = TRUE;
        }
@@ -189,7 +190,7 @@ void set_histp(t_atoms *pdba,rvec *x,real angle,real dist){
   bool bHDd,bHEd;
   rvec xh1,xh2;
   int  natom;
-  int  i,j,nd,na,aj,hisnr,his0,type=-1;
+  int  i,j,nd,na,aj,hisind,his0,type=-1;
   int  nd1,ne2,cg,cd2,ce1;
   t_blocka *hb;
   real d;
@@ -219,17 +220,17 @@ void set_histp(t_atoms *pdba,rvec *x,real angle,real dist){
   fprintf(stderr,"There are %d hydrogen bonds\n",hb->nra);
   
   /* Now do the HIS stuff */
-  hisnr=-1;
+  hisind=-1;
   for(i=0; (i<natom); ) {
-    if (strcasecmp(*pdba->resname[pdba->atom[i].resnr],"HIS") != 0) 
+    if (strcasecmp(*pdba->resinfo[pdba->atom[i].resind].name,"HIS") != 0) 
       i++;
     else {
-      if (pdba->atom[i].resnr != hisnr) {
-       hisnr=pdba->atom[i].resnr;
+      if (pdba->atom[i].resind != hisind) {
+       hisind=pdba->atom[i].resind;
        
        /* Find the  atoms in the ring */
        nd1=ne2=cg=cd2=ce1=-1;
-       for(j=i; (pdba->atom[j].resnr==hisnr) && (j<natom); j++) {
+       for(j=i; (pdba->atom[j].resind==hisind) && (j<natom); j++) {
          atomnm=*pdba->atomname[j];
          if (strcmp(atomnm,"CD2") == 0)
            cd2=j;
@@ -261,13 +262,15 @@ void set_histp(t_atoms *pdba,rvec *x,real angle,real dist){
          }
          else 
            type = ehisB;
-         fprintf(stderr,"Will use %s for residue %d\n",hh[type],hisnr+1);
+         fprintf(stderr,"Will use %s for residue %d\n",
+                 hh[type],pdba->resinfo[hisind].nr);
        }
        else 
-         gmx_fatal(FARGS,"Incomplete ring in HIS%d",hisnr+1);
+         gmx_fatal(FARGS,"Incomplete ring in HIS%d",
+                   pdba->resinfo[hisind].nr);
        
-       sfree(*pdba->resname[hisnr]);
-       *pdba->resname[hisnr]=strdup(hh[type]);
+       sfree(*pdba->resinfo[hisind].name);
+       *pdba->resinfo[hisind].name = strdup(hh[type]);
       }
     }
   }
index 68d237c8f6f5037b9f89f37ec1f9d77691bd4d7e..96e1fc77b0374ee7ef19e9b777f839622b748106 100644 (file)
@@ -178,10 +178,10 @@ static void rename_pdbres(t_atoms *pdba,char *oldnm,char *newnm,
   int i;
   
   for(i=0; (i<pdba->nres); i++) {
-    resnm=*pdba->resname[i];
+    resnm = *pdba->resinfo[i].name;
     if ((bFullCompare && (strcasecmp(resnm,oldnm) == 0)) ||
        (!bFullCompare && strstr(resnm,oldnm) != NULL)) {
-      pdba->resname[i] = put_symtab(symtab,newnm);
+      pdba->resinfo[i].name = put_symtab(symtab,newnm);
     }
   }
 }
@@ -195,11 +195,11 @@ static void rename_pdbresint(t_atoms *pdba,char *oldnm,
   char *resnm;
   
   for(i=0; i<pdba->nres; i++) {
-    resnm=*pdba->resname[i];
+    resnm = *pdba->resinfo[i].name;
     if ((bFullCompare && (strcmp(resnm,oldnm) == 0)) ||
        (!bFullCompare && strstr(resnm,oldnm) != NULL)) {
       ptr=gettp(i);
-      pdba->resname[i]=put_symtab(symtab,ptr);
+      pdba->resinfo[i].name = put_symtab(symtab,ptr);
     }
   }
 }
@@ -218,8 +218,8 @@ static void check_occupancy(t_atoms *atoms,char *filename,bool bVerbose)
       if (atoms->pdbinfo[i].occup != 1) {
        if (bVerbose)
          fprintf(stderr,"Occupancy for atom %s%d-%s is %f rather than 1\n",
-                 *atoms->resname[atoms->atom[i].resnr],
-                 atoms->atom[i].resnr+1,
+                 *atoms->resinfo[atoms->atom[i].resind].name,
+                 atoms->resinfo[ atoms->atom[i].resind].nr,
                  *atoms->atomname[i],
                  atoms->pdbinfo[i].occup);
        if (atoms->pdbinfo[i].occup == 0) 
@@ -403,15 +403,15 @@ static void sort_pdbatoms(int nrtp,t_restp restp[],
   snew(pdbi, natoms);
   
   for(i=0; i<natoms; i++) {
-    atomnm=*pdba->atomname[i];
-    resnm=*pdba->resname[pdba->atom[i].resnr];
+    atomnm = *pdba->atomname[i];
+    resnm = *pdba->resinfo[pdba->atom[i].resind].name;
     if ((rptr=search_rtp(resnm,nrtp,restp)) == NULL)
       gmx_fatal(FARGS,"Residue type %s not found",resnm);
     for(j=0; (j<rptr->natom); j++)
       if (strcasecmp(atomnm,*(rptr->atomname[j])) == 0)
        break;
     if (j==rptr->natom) {
-      if ( ( ( pdba->atom[i].resnr == 0) && (atomnm[0] == 'H') &&
+      if ( ( ( pdba->atom[i].resind == 0) && (atomnm[0] == 'H') &&
             ( (atomnm[1] == '1') || (atomnm[1] == '2') || 
               (atomnm[1] == '3') ) ) )
        j=1;
@@ -420,7 +420,9 @@ static void sort_pdbatoms(int nrtp,t_restp restp[],
        
        sprintf(buf,"Atom %s in residue %s %d not found in rtp entry with %d atoms\n"
                "             while sorting atoms%s",atomnm,
-               rptr->resname,pdba->atom[i].resnr+1,rptr->natom,
+               rptr->resname,
+               pdba->resinfo[pdba->atom[i].resind].nr,
+               rptr->natom,
                is_hydrogen(atomnm) ? ". Maybe different protonation state.\n"
                "             Remove this hydrogen or choose a different "
                "protonation state.\n"
@@ -430,7 +432,7 @@ static void sort_pdbatoms(int nrtp,t_restp restp[],
       }
     }
     /* make shadow array to be sorted into indexgroup */
-    pdbi[i].resnr  = pdba->atom[i].resnr;
+    pdbi[i].resnr  = pdba->atom[i].resind;
     pdbi[i].j      = j;
     pdbi[i].index  = i;
     pdbi[i].anm1   = atomnm[1];
@@ -445,8 +447,8 @@ static void sort_pdbatoms(int nrtp,t_restp restp[],
   snew(*xnew,natoms);
   pdbnew->nr=pdba->nr;
   pdbnew->nres=pdba->nres;
-  sfree(pdbnew->resname);
-  pdbnew->resname=pdba->resname;
+  sfree(pdbnew->resinfo);
+  pdbnew->resinfo=pdba->resinfo;
   for (i=0; i<natoms; i++) {
     pdbnew->atom[i]     = pdba->atom[pdbi[i].index];
     pdbnew->atomname[i] = pdba->atomname[pdbi[i].index];
@@ -473,6 +475,7 @@ static void sort_pdbatoms(int nrtp,t_restp restp[],
 static int remove_duplicate_atoms(t_atoms *pdba,rvec x[],bool bVerbose)
 {
   int     i,j,oldnatoms,ndel;
+  t_resinfo *ri;
   
   printf("Checking for duplicate atoms....\n");
   oldnatoms    = pdba->nr;
@@ -482,15 +485,15 @@ static int remove_duplicate_atoms(t_atoms *pdba,rvec x[],bool bVerbose)
     /* compare 'i' and 'i-1', throw away 'i' if they are identical 
        this is a 'while' because multiple alternate locations can be present */
     while ( (i < pdba->nr) &&
-           (pdba->atom[i-1].resnr == pdba->atom[i].resnr) &&
+           (pdba->atom[i-1].resind == pdba->atom[i].resind) &&
            (strcmp(*pdba->atomname[i-1],*pdba->atomname[i])==0) ) {
       ndel++;
       if (bVerbose) {
-       printf("deleting duplicate atom %4s  %s%4d",
-              *pdba->atomname[i], *pdba->resname[pdba->atom[i].resnr], 
-              pdba->atom[i].resnr+1);
-       if (pdba->atom[i].chain && (pdba->atom[i].chain!=' '))
-         printf(" ch %c", pdba->atom[i].chain);
+       ri = &pdba->resinfo[pdba->atom[i].resind];
+       printf("deleting duplicate atom %4s  %s%4d%c",
+              *pdba->atomname[i],*ri->name,ri->nr,ri->ic);
+       if (ri->chain && (ri->chain != ' '))
+         printf(" ch %c", ri->chain);
        if (pdba->pdbinfo) {
          if (pdba->pdbinfo[i].atomnr)
            printf("  pdb nr %4d",pdba->pdbinfo[i].atomnr);
@@ -526,9 +529,9 @@ void find_nc_ter(t_atoms *pdba,int r0,int r1,int *rn,int *rc,t_aa_names *aan)
   *rc=-1;
 
   for(rnr=r0; rnr<r1; rnr++) {
-    if ((*rn == -1) && (is_protein(aan,*pdba->resname[rnr])))
+    if ((*rn == -1) && (is_protein(aan,*pdba->resinfo[rnr].name)))
        *rn=rnr;
-    if ((*rc != rnr) && (is_protein(aan,*pdba->resname[rnr])))
+    if ((*rc != rnr) && (is_protein(aan,*pdba->resinfo[rnr].name)))
       *rc=rnr;
   }
 
@@ -648,6 +651,7 @@ int main(int argc, char *argv[])
   int        natom,nres;
   t_atoms    pdba_all,*pdba;
   t_atoms    *atoms;
+  t_resinfo  *ri;
   t_blocka   *block;
   int        chain,nch,maxch,nwaterchain;
   t_pdbchain *pdb_ch;
@@ -860,11 +864,12 @@ int main(int argc, char *argv[])
   pchain='?';
   pdb_ch=NULL;
   for (i=0; (i<natom); i++) {
-    bWat = strcasecmp(*pdba_all.resname[pdba_all.atom[i].resnr],watres) == 0;
-    if ((i==0) || (pdba_all.atom[i].chain!=pchain) || (bWat != bPrevWat)) {
+    ri = &pdba_all.resinfo[pdba_all.atom[i].resind];
+    bWat = strcasecmp(*ri->name,watres) == 0;
+    if ((i == 0) || (ri->chain != pchain) || (bWat != bPrevWat)) {
       if (bMerge && i>0 && !bWat) {
        printf("Merge chain '%c' and '%c'? (n/y) ",
-              pchain,pdba_all.atom[i].chain);
+              pchain,ri->chain);
        if(NULL==fgets(select,STRLEN-1,stdin))
         {
            gmx_fatal(FARGS,"Error reading from stdin");
@@ -872,10 +877,10 @@ int main(int argc, char *argv[])
       } 
       else
        select[0] = 'n';
-      pchain=pdba_all.atom[i].chain;
+      pchain = ri->chain;
       if (select[0] == 'y') {
        pdb_ch[nch-1].chainstart[pdb_ch[nch-1].nterpairs] = 
-         pdba_all.atom[i].resnr;
+         pdba_all.atom[i].resind;
        pdb_ch[nch-1].nterpairs++;
        srenew(pdb_ch[nch-1].chainstart,pdb_ch[nch-1].nterpairs+1);
       } else {
@@ -884,20 +889,20 @@ int main(int argc, char *argv[])
          pdb_ch[nch-1].natom=i-pdb_ch[nch-1].start;
        if (bWat) {
          nwaterchain++;
-         pdba_all.atom[i].chain='\0';
+         ri->chain = '\0';
        }
        /* check if chain identifier was used before */
        for (j=0; (j<nch); j++)
          if ((pdb_ch[j].chain != '\0') && (pdb_ch[j].chain != ' ') &&
-             (pdb_ch[j].chain == pdba_all.atom[i].chain))
+             (pdb_ch[j].chain == ri->chain))
            gmx_fatal(FARGS,"Chain identifier '%c' was used "
-                       "in two non-sequential blocks (residue %d, atom %d)",
-                       pdba_all.atom[i].chain,pdba_all.atom[i].resnr+1,i+1);
+                     "in two non-sequential blocks (residue %d, atom %d)",
+                     ri->chain,ri->nr,i+1);
        if (nch == maxch) {
          maxch += 16;
          srenew(pdb_ch,maxch);
        }
-       pdb_ch[nch].chain=pdba_all.atom[i].chain;
+       pdb_ch[nch].chain = ri->chain;
        pdb_ch[nch].start=i;
        pdb_ch[nch].bAllWat=bWat;
        if (bWat)
@@ -965,20 +970,22 @@ int main(int argc, char *argv[])
       *chains[i].pdba->atomname[j] = 
        strdup(*pdba_all.atomname[pdb_ch[si].start+j]);
       /* make all chain identifiers equal to that off the chain */
-      chains[i].pdba->atom[j].chain=pdb_ch[si].chain;
+      chains[i].pdba->resinfo[chains[i].pdba->atom[j].resind].chain =
+       pdb_ch[si].chain;
       chains[i].pdba->pdbinfo[j]=pdba_all.pdbinfo[pdb_ch[si].start+j];
       copy_rvec(pdbx[pdb_ch[si].start+j],chains[i].x[j]);
     }
     /* Renumber the residues assuming that the numbers are continuous */
-    k    = chains[i].pdba->atom[0].resnr;
-    nres = chains[i].pdba->atom[chains[i].pdba->nr-1].resnr - k + 1;
+    k    = chains[i].pdba->atom[0].resind;
+    nres = chains[i].pdba->atom[chains[i].pdba->nr-1].resind - k + 1;
     chains[i].pdba->nres = nres;
     for(j=0; j < chains[i].pdba->nr; j++)
-      chains[i].pdba->atom[j].resnr -= k;
-    srenew(chains[i].pdba->resname,nres);
+      chains[i].pdba->atom[j].resind -= k;
+    srenew(chains[i].pdba->resinfo,nres);
     for(j=0; j<nres; j++) {
-      snew(chains[i].pdba->resname[j],1);
-      *chains[i].pdba->resname[j] = strdup(*pdba_all.resname[k+j]);
+      chains[i].pdba->resinfo[j] = pdba_all.resinfo[k+j];
+      snew(chains[i].pdba->resinfo[j].name,1);
+      *chains[i].pdba->resinfo[j].name = strdup(*pdba_all.resinfo[k+j].name);
     }
   }
 
@@ -989,7 +996,7 @@ int main(int argc, char *argv[])
   printf("There are %d chains and %d blocks of water and "
         "%d residues with %d atoms\n",
         nch-nwaterchain,nwaterchain,
-        pdba_all.atom[natom-1].resnr+1,natom);
+        pdba_all.resinfo[pdba_all.atom[natom-1].resind].nr,natom);
          
   printf("\n  %5s  %4s %6s\n","chain","#res","#atoms");
   for (i=0; (i<nch); i++)
@@ -1102,7 +1109,7 @@ int main(int argc, char *argv[])
         * (or a generic terminus if no-residue specific is available).
         */
        /* First the N terminus */
-       strncpy(resname,*pdba->resname[cc->rN[i]],3);
+       strncpy(resname,*pdba->resinfo[cc->rN[i]].name,3);
        tdblist=filter_ter(nNtdb,ntdb,resname,&ntdblist);
        if(ntdblist==0)
          gmx_fatal(FARGS,"No suitable N-terminus found in database");
@@ -1115,7 +1122,7 @@ int main(int argc, char *argv[])
        sfree(tdblist);
        
        /* And the C terminus */
-       strncpy(resname,*pdba->resname[cc->rC[i]],3);
+       strncpy(resname,*pdba->resinfo[cc->rC[i]].name,3);
        tdblist=filter_ter(nCtdb,ctdb,resname,&ntdblist);
        if(ntdblist==0)
          gmx_fatal(FARGS,"No suitable C-terminus found in database");
@@ -1140,8 +1147,8 @@ int main(int argc, char *argv[])
     if (debug)
       for(i=0; (i<natom); i++)
        fprintf(debug,"Res %s%d atom %d %s\n",
-               *(pdba->resname[pdba->atom[i].resnr]),
-               pdba->atom[i].resnr+1,i+1,*pdba->atomname[i]);
+               *(pdba->resinfo[pdba->atom[i].resind].name),
+               pdba->resinfo[pdba->atom[i].resind].nr,i+1,*pdba->atomname[i]);
     
     strcpy(posre_fn,ftp2fn(efITP,NFILE,fnm));
     
@@ -1245,10 +1252,10 @@ int main(int argc, char *argv[])
   snew(atoms,1);
   init_t_atoms(atoms,natom,FALSE);
   for(i=0; i < atoms->nres; i++)
-    sfree(atoms->resname[i]);
-  sfree(atoms->resname);
+    sfree(atoms->resinfo[i].name);
+  sfree(atoms->resinfo);
   atoms->nres=nres;
-  snew(atoms->resname,nres);
+  snew(atoms->resinfo,nres);
   snew(x,natom);
   k=0;
   l=0;
@@ -1258,14 +1265,14 @@ int main(int argc, char *argv[])
             i+1,chains[i].pdba->nr,chains[i].pdba->nres);
     for (j=0; (j<chains[i].pdba->nr); j++) {
       atoms->atom[k]=chains[i].pdba->atom[j];
-      atoms->atom[k].resnr+=l; /* l is processed nr of residues */
+      atoms->atom[k].resind += l; /* l is processed nr of residues */
       atoms->atomname[k]=chains[i].pdba->atomname[j];
-      atoms->atom[k].chain=chains[i].chain;
+      atoms->resinfo[atoms->atom[k].resind].chain = chains[i].chain;
       copy_rvec(chains[i].x[j],x[k]);
       k++;
     }
     for (j=0; (j<chains[i].pdba->nres); j++) {
-      atoms->resname[l]=chains[i].pdba->resname[j];
+      atoms->resinfo[l] = chains[i].pdba->resinfo[j];
       l++;
     }
   }
index 0a9573c976559204c9bf20931506f4ffac4bcc58..3364aa75dddb71dfe7b3a935bbe625ade53e6785 100644 (file)
@@ -68,7 +68,7 @@
 /* this must correspond to enum in pdb2top.h */
 const char *hh[ehisNR]   = { "HISA", "HISB", "HISH", "HIS1" };
 
-static int missing_atoms(t_restp *rp, int resnr,
+static int missing_atoms(t_restp *rp, int resind,
                         t_atoms *at, int i0, int i, bool bCTer)
 {
   int  j,k,nmiss;
@@ -86,11 +86,11 @@ static int missing_atoms(t_restp *rp, int resnr,
       nmiss++;
       fprintf(stderr,"\nWARNING: "
              "atom %s is missing in residue %s %d in the pdb file\n",
-             name,*(at->resname[resnr]),resnr+1);
+             name,*(at->resinfo[resind].name),at->resinfo[resind].nr);
       if (name[0]=='H' || name[0]=='h')
        fprintf(stderr,"         You might need to add atom %s to the hydrogen database of residue %s\n"
                       "         in the file ff???.hdb (see the manual)\n",
-               name,*(at->resname[resnr]));
+               name,*(at->resinfo[resind].name));
       fprintf(stderr,"\n");
       }
       /* } */
@@ -164,7 +164,7 @@ choose_ff(char *forcefield, int maxlen)
 static int name2type(t_atoms *at, int **cgnr, t_atomtype atype, 
                     t_restp restp[])
 {
-  int     i,j,prevresnr,resnr,i0,prevcg,cg,curcg;
+  int     i,j,prevresind,resind,i0,prevcg,cg,curcg;
   char    *name;
   bool    bProt, bNterm;
   double  qt;
@@ -173,7 +173,7 @@ static int name2type(t_atoms *at, int **cgnr, t_atomtype atype,
   
   nmissat = 0;
 
-  resnr=-1;
+  resind=-1;
   bProt=FALSE;
   bNterm=FALSE;
   i0=0;
@@ -186,32 +186,32 @@ static int name2type(t_atoms *at, int **cgnr, t_atomtype atype,
   aan = get_aa_names();
   
   for(i=0; (i<at->nr); i++) {
-    prevresnr=resnr;
-    if (at->atom[i].resnr != resnr) {
-      resnr=at->atom[i].resnr;
-      bProt=is_protein(aan,*(at->resname[resnr]));
-      bNterm=bProt && (resnr == 0);
-      if (resnr>0)
+    prevresind=resind;
+    if (at->atom[i].resind != resind) {
+      resind = at->atom[i].resind;
+      bProt = is_protein(aan,*(at->resinfo[resind].name));
+      bNterm=bProt && (resind == 0);
+      if (resind > 0)
        nmissat += 
-         missing_atoms(&restp[prevresnr],prevresnr,at,i0,i,
-                       (!bProt && is_protein(aan,restp[prevresnr].resname)));
+         missing_atoms(&restp[prevresind],prevresind,at,i0,i,
+                       (!bProt && is_protein(aan,restp[prevresind].resname)));
       i0=i;
     }
     if (at->atom[i].m == 0) {
       if (debug)
        fprintf(debug,"atom %d%s: curcg=%d, prevcg=%d, cg=%d\n",
                i+1,*(at->atomname[i]),curcg,prevcg,
-               j==NOTSET ? NOTSET : restp[resnr].cgnr[j]);
+               j==NOTSET ? NOTSET : restp[resind].cgnr[j]);
       qt=0;
       prevcg=cg;
       name=*(at->atomname[i]);
-      j=search_jtype(&restp[resnr],name,bNterm);
-      at->atom[i].type = restp[resnr].atom[j].type;
-      at->atom[i].q    = restp[resnr].atom[j].q;
-      at->atom[i].m    = get_atomtype_massA(restp[resnr].atom[j].type,
+      j=search_jtype(&restp[resind],name,bNterm);
+      at->atom[i].type = restp[resind].atom[j].type;
+      at->atom[i].q    = restp[resind].atom[j].q;
+      at->atom[i].m    = get_atomtype_massA(restp[resind].atom[j].type,
                                            atype);
-      cg = restp[resnr].cgnr[j];
-      if ( (cg != prevcg) || (resnr != prevresnr) )
+      cg = restp[resind].cgnr[j];
+      if ( (cg != prevcg) || (resind != prevresind) )
        curcg++;
     } else {
       if (debug)
@@ -229,8 +229,8 @@ static int name2type(t_atoms *at, int **cgnr, t_atomtype atype,
     at->atom[i].qB    = at->atom[i].q;
     at->atom[i].mB    = at->atom[i].m;
   }
-  nmissat += missing_atoms(&restp[resnr],resnr,at,i0,i,
-                          (!bProt || is_protein(aan,restp[resnr].resname)));
+  nmissat += missing_atoms(&restp[resind],resind,at,i0,i,
+                          (!bProt || is_protein(aan,restp[resind].resname)));
   done_aa_names(&aan);
                           
   return nmissat;
@@ -357,14 +357,14 @@ void write_top(FILE *out, char *pr,char *molname,
   }
 }
 
-static atom_id search_res_atom(char *type,int resnr,
+static atom_id search_res_atom(char *type,int resind,
                               int natom,t_atom at[],char **aname[],
                               char *bondtype,bool bMissing)
 {
   int i;
 
   for(i=0; (i<natom); i++)
-    if (at[i].resnr == resnr)
+    if (at[i].resind == resind)
       return search_atom(type,i,natom,at,aname,bondtype,bMissing);
   
   return NO_ATID;
@@ -395,7 +395,7 @@ static void at2bonds(t_params *psb, t_hackblock *hb,
                     int nres, rvec x[], 
                     real long_bond_dist, real short_bond_dist)
 {
-  int     resnr,i,j,k;
+  int     resind,i,j,k;
   atom_id ai,aj;
   real    dist2, long_bond_dist2, short_bond_dist2;
   char    *ptr;
@@ -410,16 +410,16 @@ static void at2bonds(t_params *psb, t_hackblock *hb,
 
   fprintf(stderr,"Making bonds...\n");
   i=0;
-  for(resnr=0; (resnr < nres) && (i<natoms); resnr++) {
+  for(resind=0; (resind < nres) && (i<natoms); resind++) {
     /* add bonds from list of bonded interactions */
-    for(j=0; j < hb[resnr].rb[ebtsBONDS].nb; j++) {
+    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[resnr].rb[ebtsBONDS].b[j].AI,i,natoms,atom,aname,
+      ai=search_atom(hb[resind].rb[ebtsBONDS].b[j].AI,i,natoms,atom,aname,
                     ptr,TRUE);
-      aj=search_atom(hb[resnr].rb[ebtsBONDS].b[j].AJ,i,natoms,atom,aname,
+      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]);
@@ -429,23 +429,23 @@ static void at2bonds(t_params *psb, t_hackblock *hb,
        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[resnr].rb[ebtsBONDS].b[j].s);
+       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].resnr == resnr) ) {
-      for(j=0; j < hb[resnr].nhack; j++)
-       if ( ( hb[resnr].hack[j].tp > 0 ||
-              hb[resnr].hack[j].oname==NULL ) &&
-            strcmp(hb[resnr].hack[j].AI,*(aname[i])) == 0 ) {
-         switch(hb[resnr].hack[j].tp) {
+    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[resnr].hack[j].nr); k++)
+           for(k=0; (k<hb[resind].hack[j].nr); k++)
              add_param(psb,i,i+k+1,NULL,NULL);
          }
        }
@@ -526,10 +526,12 @@ void print_sums(t_atoms *atoms, bool bSystem)
   fprintf(stderr,"Total charge%s %.3f e\n",where,qtot);
 }
 
-void get_hackblocks_rtp(t_hackblock **hb, t_restp **restp, 
-                       int nrtp, t_restp rtp[], int nres, char **resname[], 
-                       int nterpairs, t_hackblock **ntdb, t_hackblock **ctdb,
-                       int *rn, int *rc)
+static void get_hackblocks_rtp(t_hackblock **hb, t_restp **restp, 
+                              int nrtp, t_restp rtp[],
+                              int nres, t_resinfo *resinfo, 
+                              int nterpairs,
+                              t_hackblock **ntdb, t_hackblock **ctdb,
+                              int *rn, int *rc)
 {
   int i, j, k, l;
   t_restp *res;
@@ -549,7 +551,7 @@ void get_hackblocks_rtp(t_hackblock **hb, t_restp **restp,
 
   /* then the whole rtp */
   for(i=0; i < nres; i++) {
-    res = search_rtp(*resname[i],nrtp,rtp);
+    res = search_rtp(*resinfo[i].name,nrtp,rtp);
     copy_t_restp(res, &(*restp)[i]);
     bN = FALSE;
     for(j=0; j<nterpairs && !bN; j++)
@@ -579,7 +581,7 @@ void get_hackblocks_rtp(t_hackblock **hb, t_restp **restp,
                      "while combining tdb and rtp",
                      (*hb)[i].hack[j].oname!=NULL ? 
                      (*hb)[i].hack[j].oname : (*hb)[i].hack[j].AI, 
-                     i+1,*resname[i]);
+                     i+1,*resinfo[i].name);
        if ( (*hb)[i].hack[j].oname==NULL ) {
          /* we're adding: */
          if (debug) 
@@ -673,7 +675,7 @@ void pdb2top(FILE *top_file, char *posre_fn, char *molname,
   init_plist(plist);
 
   /* lookup hackblocks and rtp for all residues */
-  get_hackblocks_rtp(&hb, &restp, nrtp, rtp, atoms->nres, atoms->resname
+  get_hackblocks_rtp(&hb, &restp, nrtp, rtp, atoms->nres, atoms->resinfo
                     nterpairs, ntdb, ctdb, rn, rc);
   /* ideally, now we would not need the rtp itself anymore, but do 
      everything using the hb and restp arrays. Unfortunately, that 
index 4b784c9d627a294cdeac12930c73a3af157a5943..292f4287876c78e97e67b78bc90930d34b0ef87c 100644 (file)
 #include "pgutil.h"
 #include "string.h"
 
-void atom_not_found(int fatal_errno,const char *file,int line,
-                   char *atomname,int resnr,
-                   char *bondtype,bool bDontQuit)
+static void atom_not_found(int fatal_errno,const char *file,int line,
+                          char *atomname,int resind,
+                          char *bondtype,bool bDontQuit)
 {
   if (strcmp(bondtype,"check") != 0) {
     if (bDontQuit) {
       fprintf(stderr,
-             "WARNING: atom %s not found in residue %d while adding %s\n",
-             atomname,resnr,bondtype);
+             "WARNING: atom %s not found in residue seq.nr. %d while adding %s\n",
+             atomname,resind+1,bondtype);
     } else {
       gmx_fatal(fatal_errno,file,line,
-               "Atom %s not found in residue %d while adding %s\n",
-               atomname,resnr,bondtype);
+               "Atom %s not found in residue seq.nr. %d while adding %s\n",
+               atomname,resind+1,bondtype);
     }
   }
 }
@@ -62,48 +62,48 @@ void atom_not_found(int fatal_errno,const char *file,int line,
 atom_id search_atom(char *type,int start,int natoms,t_atom at[],char **anm[],
                    char *bondtype,bool bDontQuit)
 {
-  int     i,resnr=-1;
+  int     i,resind=-1;
   bool    bPrevious,bNext;
 
   bPrevious = (strchr(type,'-') != NULL);
   bNext     = (strchr(type,'+') != NULL);
 
   if (!bPrevious) {
-    resnr = at[start].resnr;
+    resind = at[start].resind;
     if (bNext) {
       /* The next residue */
       type++;
-      while ((start<natoms) && (at[start].resnr == resnr))
+      while ((start<natoms) && (at[start].resind == resind))
        start++;
       if (start < natoms)
-       resnr = at[start].resnr;
+       resind = at[start].resind;
     }
     
-    for(i=start; (i<natoms) && (bNext || (at[i].resnr == resnr)); i++) {
+    for(i=start; (i<natoms) && (bNext || (at[i].resind == resind)); i++) {
       if (anm[i] && strcasecmp(type,*(anm[i]))==0)
        return (atom_id) i;
     }
-    if (!(bNext && at[start].resnr==at[natoms-1].resnr))
-      atom_not_found(FARGS,type,at[start].resnr+1,bondtype,bDontQuit);
+    if (!(bNext && at[start].resind==at[natoms-1].resind))
+      atom_not_found(FARGS,type,at[start].resind,bondtype,bDontQuit);
   }
   else {
     /* The previous residue */
     type++;
     if (start > 0)
-      resnr = at[start-1].resnr;
-    for(i=start-1; (i>=0) /*&& (at[i].resnr == resnr)*/; i--)
+      resind = at[start-1].resind;
+    for(i=start-1; (i>=0) /*&& (at[i].resind == resind)*/; i--)
       if (strcasecmp(type,*(anm[i]))==0)
        return (atom_id) i;
     if (start > 0)
-      atom_not_found(FARGS,type,at[start].resnr+1,bondtype,bDontQuit);
+      atom_not_found(FARGS,type,at[start].resind,bondtype,bDontQuit);
   }
   return NO_ATID;
 }
 
-void set_at(t_atom *at,real m,real q,int type,int resnr)
+void set_at(t_atom *at,real m,real q,int type,int resind)
 {
   at->m=m;
   at->q=q;
   at->type=type;
-  at->resnr=resnr;
+  at->resind=resind;
 }
index 5156c84dbc1e74a97a5a09f78d8062d48fb6a41e..62b9d1e81405e167b50b9021e191b7900fb47c57 100644 (file)
@@ -49,6 +49,6 @@ extern atom_id search_atom(char *type,int start,
  * When bDontQuit=FALSE an fatal error is issued, otherwise a warning.
  */
 
-extern void set_at(t_atom *at,real m,real q,int type,int resnr);
+extern void set_at(t_atom *at,real m,real q,int type,int resind);
 
 #endif /* _pgutil_h */
index 01ba4e79acdb39271a90e14a5a40805541e54b42..cc8416f0b11c5c9aad57481331cc8a47ea885079 100644 (file)
-/*\r
- * $Id$\r
- * \r
- *                This source code is part of\r
- * \r
- *                 G   R   O   M   A   C   S\r
- * \r
- *          GROningen MAchine for Chemical Simulations\r
- * \r
- *                        VERSION 3.2.0\r
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.\r
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.\r
- * Copyright (c) 2001-2004, The GROMACS development team,\r
- * check out http://www.gromacs.org for more information.\r
-\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- * \r
- * If you want to redistribute modifications, please consider that\r
- * scientific software is very special. Version control is crucial -\r
- * bugs must be traceable. We will be happy to consider code for\r
- * inclusion in the official distribution, but derived work must not\r
- * be called official GROMACS. Details are found in the README & COPYING\r
- * files - if they are missing, get the official version at www.gromacs.org.\r
- * \r
- * To help us fund GROMACS development, we humbly ask that you cite\r
- * the papers on the package - you can find them in the top README file.\r
- * \r
- * For more info, check our website at http://www.gromacs.org\r
- * \r
- * And Hey:\r
- * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon\r
- */\r
-#ifdef HAVE_CONFIG_H\r
-#include <config.h>\r
-#endif\r
-\r
-#include <math.h>\r
-#include "typedefs.h"\r
-#include "macros.h"\r
-#include "copyrite.h"\r
-#include "smalloc.h"\r
-#include "statutil.h"\r
-#include "confio.h"\r
-#include "genhydro.h"\r
-#include "tpxio.h"\r
-#include "index.h"\r
-#include "vec.h"\r
-#include "hackblock.h"\r
-\r
-int main (int argc,char *argv[])\r
-{\r
-  static char *desc[] = {\r
-    "[TT]protonate[tt] reads (a) conformation(s) and adds all missing",\r
-    "hydrogens as defined in [TT]ffgmx2.hdb[tt]. If only [TT]-s[tt] is",\r
-    "specified, this conformation will be protonated, if also [TT]-f[tt]",\r
-    "is specified, the conformation(s) will be read from this file",\r
-    "which can be either a single conformation or a trajectory.",\r
-    "[PAR]",\r
-    "If a pdb file is supplied, residue names might not correspond to",\r
-    "to the GROMACS naming conventions, in which case these residues will",\r
-    "probably not be properly protonated.",\r
-    "[PAR]",\r
-    "If an index file is specified, please note that the atom numbers",\r
-    "should correspond to the [BB]protonated[bb] state."\r
-  };\r
-  \r
-  char        title[STRLEN+1];  \r
-  char        *infile;\r
-  char        *grpnm;\r
-  t_topology  top;\r
-  int         ePBC;\r
-  t_atoms     *atoms,*iatoms;\r
-  t_protonate protdata;\r
-  atom_id     *index;\r
-  int         status,out;\r
-  t_trxframe  fr,frout;\r
-  rvec        *x,*ix;\r
-  int         nidx,natoms,natoms_out;\r
-  matrix      box;\r
-  int         i,frame,resnr;\r
-  bool        bReadMultiple;\r
-  \r
-  t_filenm fnm[] = {\r
-    { efTPS, NULL, NULL,         ffREAD  },\r
-    { efTRX, "-f", NULL,         ffOPTRD },\r
-    { efNDX, NULL, NULL,         ffOPTRD },\r
-    { efTRO, "-o", "protonated", ffWRITE }\r
-  };\r
-#define NFILE asize(fnm)\r
-  \r
-  CopyRight(stderr,argv[0]);\r
-  parse_common_args(&argc,argv,PCA_CAN_TIME,\r
-                   NFILE,fnm,0,NULL,asize(desc),desc,0,NULL);\r
-  \r
-  infile=opt2fn("-s",NFILE,fnm);\r
-  read_tps_conf(infile,title,&top,&ePBC,&x,NULL,box,FALSE);\r
-  atoms=&(top.atoms);\r
-  printf("Select group to process:\n");\r
-  get_index(atoms,ftp2fn_null(efNDX,NFILE,fnm),1,&nidx,&index,&grpnm);\r
-  bReadMultiple = opt2bSet("-f",NFILE,fnm);\r
-  if (bReadMultiple) {\r
-    infile = opt2fn("-f",NFILE,fnm);\r
-    if ( !read_first_frame(&status, infile, &fr, TRX_NEED_X ) )\r
-      gmx_fatal(FARGS,"cannot read coordinate file %s",infile);\r
-    natoms = fr.natoms;\r
-  } else {\r
-    clear_trxframe(&fr,TRUE);\r
-    fr.natoms = atoms->nr;\r
-    fr.bTitle = TRUE;\r
-    fr.title  = title;\r
-    fr.bX     = TRUE;\r
-    fr.x      = x;\r
-    fr.bBox   = TRUE;\r
-    copy_mat(box, fr.box);\r
-    natoms = fr.natoms;\r
-  }\r
-  \r
-  /* check input */\r
-  if ( natoms == 0 )\r
-    gmx_fatal(FARGS,"no atoms in coordinate file %s",infile);\r
-  if ( natoms > atoms->nr )\r
-    gmx_fatal(FARGS,"topology with %d atoms does not match "\r
-               "coordinates with %d atoms",atoms->nr,natoms);\r
-  for(i=0; i<nidx; i++)\r
-    if (index[i] > natoms)\r
-      gmx_fatal(FARGS,"An atom number in group %s is larger than the number of "\r
-                 "atoms (%d) in the coordinate file %s",grpnm,natoms,infile);\r
-  \r
-  /* get indexed copy of atoms */\r
-  snew(iatoms,1);\r
-  init_t_atoms(iatoms,nidx,FALSE);\r
-  snew(iatoms->atom, iatoms->nr);\r
-  resnr = 0;\r
-  for(i=0; i<nidx; i++) {\r
-    iatoms->atom[i] = atoms->atom[index[i]];\r
-    iatoms->atomname[i] = atoms->atomname[index[i]];\r
-    if ( i>0 && (atoms->atom[index[i]].resnr!=atoms->atom[index[i-1]].resnr) )\r
-      resnr++;\r
-    iatoms->atom[i].resnr = resnr;\r
-    iatoms->resname[resnr] = atoms->resname[atoms->atom[index[i]].resnr];\r
-    iatoms->nres = max(iatoms->nres, iatoms->atom[i].resnr+1);\r
-  }\r
-  \r
-  init_t_protonate(&protdata);\r
-  \r
-  out = open_trx(opt2fn("-o",NFILE,fnm),"w");\r
-  snew(ix, nidx);\r
-  frame=0;\r
-  do {\r
-    if (debug) fprintf(debug,"FRAME %d (%d %g)\n",frame,fr.step,fr.time);\r
-    /* get indexed copy of x */\r
-    for(i=0; i<nidx; i++)\r
-      copy_rvec(fr.x[index[i]], ix[i]);\r
-    /* protonate */\r
-    natoms_out = protonate(&iatoms, &ix, &protdata);\r
-    \r
-    /* setup output frame */\r
-    frout = fr;\r
-    frout.natoms = natoms_out;\r
-    frout.bAtoms = TRUE;\r
-    frout.atoms  = iatoms;\r
-    frout.bV     = FALSE;\r
-    frout.bF     = FALSE;\r
-    frout.x      = ix;\r
-\r
-    /* write output */\r
-    write_trxframe(out,&frout);\r
-    frame++;\r
-  } while ( bReadMultiple && read_next_frame(status, &fr) );\r
-  \r
-  thanx(stderr);\r
-\r
-  return 0;\r
-}\r
-\r
+/*
+ * $Id$
+ * 
+ *                This source code is part of
+ * 
+ *                 G   R   O   M   A   C   S
+ * 
+ *          GROningen MAchine for Chemical Simulations
+ * 
+ *                        VERSION 3.2.0
+ * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2004, The GROMACS development team,
+ * check out http://www.gromacs.org for more information.
+
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * If you want to redistribute modifications, please consider that
+ * scientific software is very special. Version control is crucial -
+ * bugs must be traceable. We will be happy to consider code for
+ * inclusion in the official distribution, but derived work must not
+ * be called official GROMACS. Details are found in the README & COPYING
+ * files - if they are missing, get the official version at www.gromacs.org.
+ * 
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the papers on the package - you can find them in the top README file.
+ * 
+ * For more info, check our website at http://www.gromacs.org
+ * 
+ * And Hey:
+ * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <math.h>
+#include "typedefs.h"
+#include "macros.h"
+#include "copyrite.h"
+#include "smalloc.h"
+#include "statutil.h"
+#include "confio.h"
+#include "genhydro.h"
+#include "tpxio.h"
+#include "index.h"
+#include "vec.h"
+#include "hackblock.h"
+
+int main (int argc,char *argv[])
+{
+  static char *desc[] = {
+    "[TT]protonate[tt] reads (a) conformation(s) and adds all missing",
+    "hydrogens as defined in [TT]ffgmx2.hdb[tt]. If only [TT]-s[tt] is",
+    "specified, this conformation will be protonated, if also [TT]-f[tt]",
+    "is specified, the conformation(s) will be read from this file",
+    "which can be either a single conformation or a trajectory.",
+    "[PAR]",
+    "If a pdb file is supplied, residue names might not correspond to",
+    "to the GROMACS naming conventions, in which case these residues will",
+    "probably not be properly protonated.",
+    "[PAR]",
+    "If an index file is specified, please note that the atom numbers",
+    "should correspond to the [BB]protonated[bb] state."
+  };
+  
+  char        title[STRLEN+1];  
+  char        *infile;
+  char        *grpnm;
+  t_topology  top;
+  int         ePBC;
+  t_atoms     *atoms,*iatoms;
+  t_protonate protdata;
+  atom_id     *index;
+  int         status,out;
+  t_trxframe  fr,frout;
+  rvec        *x,*ix;
+  int         nidx,natoms,natoms_out;
+  matrix      box;
+  int         i,frame,resind;
+  bool        bReadMultiple;
+  
+  t_filenm fnm[] = {
+    { efTPS, NULL, NULL,         ffREAD  },
+    { efTRX, "-f", NULL,         ffOPTRD },
+    { efNDX, NULL, NULL,         ffOPTRD },
+    { efTRO, "-o", "protonated", ffWRITE }
+  };
+#define NFILE asize(fnm)
+  
+  CopyRight(stderr,argv[0]);
+  parse_common_args(&argc,argv,PCA_CAN_TIME,
+                   NFILE,fnm,0,NULL,asize(desc),desc,0,NULL);
+  
+  infile=opt2fn("-s",NFILE,fnm);
+  read_tps_conf(infile,title,&top,&ePBC,&x,NULL,box,FALSE);
+  atoms=&(top.atoms);
+  printf("Select group to process:\n");
+  get_index(atoms,ftp2fn_null(efNDX,NFILE,fnm),1,&nidx,&index,&grpnm);
+  bReadMultiple = opt2bSet("-f",NFILE,fnm);
+  if (bReadMultiple) {
+    infile = opt2fn("-f",NFILE,fnm);
+    if ( !read_first_frame(&status, infile, &fr, TRX_NEED_X ) )
+      gmx_fatal(FARGS,"cannot read coordinate file %s",infile);
+    natoms = fr.natoms;
+  } else {
+    clear_trxframe(&fr,TRUE);
+    fr.natoms = atoms->nr;
+    fr.bTitle = TRUE;
+    fr.title  = title;
+    fr.bX     = TRUE;
+    fr.x      = x;
+    fr.bBox   = TRUE;
+    copy_mat(box, fr.box);
+    natoms = fr.natoms;
+  }
+  
+  /* check input */
+  if ( natoms == 0 )
+    gmx_fatal(FARGS,"no atoms in coordinate file %s",infile);
+  if ( natoms > atoms->nr )
+    gmx_fatal(FARGS,"topology with %d atoms does not match "
+               "coordinates with %d atoms",atoms->nr,natoms);
+  for(i=0; i<nidx; i++)
+    if (index[i] > natoms)
+      gmx_fatal(FARGS,"An atom number in group %s is larger than the number of "
+                 "atoms (%d) in the coordinate file %s",grpnm,natoms,infile);
+  
+  /* get indexed copy of atoms */
+  snew(iatoms,1);
+  init_t_atoms(iatoms,nidx,FALSE);
+  snew(iatoms->atom, iatoms->nr);
+  resind = 0;
+  for(i=0; i<nidx; i++) {
+    iatoms->atom[i] = atoms->atom[index[i]];
+    iatoms->atomname[i] = atoms->atomname[index[i]];
+    if ( i>0 && (atoms->atom[index[i]].resind!=atoms->atom[index[i-1]].resind) )
+      resind++;
+    iatoms->atom[i].resind = resind;
+    iatoms->resinfo[resind] = atoms->resinfo[atoms->atom[index[i]].resind];
+    iatoms->nres = max(iatoms->nres, iatoms->atom[i].resind+1);
+  }
+  
+  init_t_protonate(&protdata);
+  
+  out = open_trx(opt2fn("-o",NFILE,fnm),"w");
+  snew(ix, nidx);
+  frame=0;
+  do {
+    if (debug) fprintf(debug,"FRAME %d (%d %g)\n",frame,fr.step,fr.time);
+    /* get indexed copy of x */
+    for(i=0; i<nidx; i++)
+      copy_rvec(fr.x[index[i]], ix[i]);
+    /* protonate */
+    natoms_out = protonate(&iatoms, &ix, &protdata);
+    
+    /* setup output frame */
+    frout = fr;
+    frout.natoms = natoms_out;
+    frout.bAtoms = TRUE;
+    frout.atoms  = iatoms;
+    frout.bV     = FALSE;
+    frout.bF     = FALSE;
+    frout.x      = ix;
+
+    /* write output */
+    write_trxframe(out,&frout);
+    frame++;
+  } while ( bReadMultiple && read_next_frame(status, &fr) );
+  
+  thanx(stderr);
+
+  return 0;
+}
+
index 5ebb156643f1f582c536081fdd59fa62de04630d..15a51500882366f4ac8f2dd2b905dd0272847105 100644 (file)
@@ -139,13 +139,13 @@ static bool is_bond(int nsb,t_specbond sb[],t_atoms *pdba,int a1,int a2,
   
   at1=*pdba->atomname[a1];
   at2=*pdba->atomname[a2];
-  res1=*pdba->resname[pdba->atom[a1].resnr];
-  res2=*pdba->resname[pdba->atom[a2].resnr];
+  res1=*pdba->resinfo[pdba->atom[a1].resind].name;
+  res2=*pdba->resinfo[pdba->atom[a2].resind].name;
   
   if (debug) 
     fprintf(stderr,"Checking %s-%d %s-%d and %s-%d %s-%d: %g ",
-           res1, pdba->atom[a1].resnr+1, at1, a1+1,
-           res2, pdba->atom[a2].resnr+1, at2, a2+1, d);
+           res1, pdba->resinfo[pdba->atom[a1].resind].nr, at1, a1+1,
+           res2, pdba->resinfo[pdba->atom[a2].resind].nr, at2, a2+1, d);
                    
   for(i=0; (i<nsb); i++) {
     *index_sb = i;
@@ -174,13 +174,15 @@ static bool is_bond(int nsb,t_specbond sb[],t_atoms *pdba,int a1,int a2,
   return FALSE;
 }
 
-static void rename_1res(t_atoms *pdba,int resnr,char *newres)
+static void rename_1res(t_atoms *pdba,int resind,char *newres)
 {
   if(debug) fprintf(stderr,"Renaming %s-%d to %s\n", 
-                   *pdba->resname[resnr], resnr+1, newres);
+                   *pdba->resinfo[resind].name,
+                   pdba->resinfo[resind].nr,
+                   newres);
   /* this used to free *resname, which fucks up the symtab! */
-  snew(pdba->resname[resnr],1);
-  *pdba->resname[resnr]=strdup(newres);
+  snew(pdba->resinfo[resind].name,1);
+  *pdba->resinfo[resind].name = strdup(newres);
 }
 
 int mk_specbonds(t_atoms *pdba,rvec x[],bool bInteractive,
@@ -206,9 +208,9 @@ int mk_specbonds(t_atoms *pdba,rvec x[],bool bInteractive,
     
     nspec = 0;
     for(i=0;(i<pdba->nr);i++) {
-      if (is_special(nsb,sb,*pdba->resname[pdba->atom[i].resnr],
+      if (is_special(nsb,sb,*pdba->resinfo[pdba->atom[i].resind].name,
                     *pdba->atomname[i])) {
-       specp[nspec] = pdba->atom[i].resnr;
+       specp[nspec] = pdba->atom[i].resind;
        sgp[nspec] = i;
        nspec++;
       }
@@ -233,8 +235,8 @@ int mk_specbonds(t_atoms *pdba,rvec x[],bool bInteractive,
        fprintf(stderr,"%8s%8s","","");
        e=min(b+MAXCOL, nspec-1);
        for(i=b; (i<e); i++) {
-         sprintf(buf,"%s%d",*pdba->resname[pdba->atom[sgp[i]].resnr],
-                 specp[i]+1);
+         sprintf(buf,"%s%d",*pdba->resinfo[pdba->atom[sgp[i]].resind].name,
+                 pdba->resinfo[specp[i]].nr);
          fprintf(stderr,"%8s",buf);
        }
        fprintf(stderr,"\n");
@@ -249,8 +251,8 @@ int mk_specbonds(t_atoms *pdba,rvec x[],bool bInteractive,
        /* print matrix */
        e=min(b+MAXCOL, nspec);
        for(i=b+1; (i<nspec); i++) {
-         sprintf(buf,"%s%d",*pdba->resname[pdba->atom[sgp[i]].resnr],
-                 specp[i]+1);
+         sprintf(buf,"%s%d",*pdba->resinfo[pdba->atom[sgp[i]].resind].name,
+                 pdba->resinfo[specp[i]].nr);
          fprintf(stderr,"%8s",buf);
          sprintf(buf,"%s%d", *pdba->atomname[sgp[i]], sgp[i]+1);
          fprintf(stderr,"%8s",buf);
@@ -271,9 +273,11 @@ int mk_specbonds(t_atoms *pdba,rvec x[],bool bInteractive,
        if (is_bond(nsb,sb,pdba,ai,aj,d[i][j],&index_sb,&bSwap)) {
          fprintf(stderr,"%s %s-%d %s-%d and %s-%d %s-%d%s",
                  bInteractive ? "Link" : "Linking",
-                 *pdba->resname[pdba->atom[ai].resnr], specp[i]+1, 
+                 *pdba->resinfo[pdba->atom[ai].resind].name,
+                 pdba->resinfo[specp[i]].nr, 
                  *pdba->atomname[ai], ai+1,
-                 *pdba->resname[pdba->atom[aj].resnr], specp[j]+1, 
+                 *pdba->resinfo[pdba->atom[aj].resind].name,
+                 pdba->resinfo[specp[j]].nr, 
                  *pdba->atomname[aj], aj+1,
                  bInteractive ? " (y/n) ?" : "...\n");
          bDoit=bInteractive ? yesno() : TRUE;
index 5342a3415eb8a78f9afec633bc776c2fb7d85d85..7ed9d272f708d822aa25fab06d2f7f146466678f 100644 (file)
@@ -153,7 +153,7 @@ static void gen_pairs(t_params *nbs,t_params *pairs,real fudge, int comb, bool b
 double check_mol(gmx_mtop_t *mtop)
 {
   char    buf[256];
-  int     i,mb,nmol,rn,pt;
+  int     i,mb,nmol,ri,pt;
   double  q;
   real    m;
   t_atoms *atoms;
@@ -172,16 +172,22 @@ double check_mol(gmx_mtop_t *mtop)
        * else, if it is a shell, a vsite or a bondshell it can have mass zero
        */
       if ((m <= 0.0) && ((pt == eptAtom) || (pt == eptNucleus))) {
-       rn=atoms->atom[i].resnr;
+       ri = atoms->atom[i].resind;
        sprintf(buf,"atom %s (Res %s-%d) has mass %g\n",
-               *(atoms->atomname[i]),*(atoms->resname[rn]),rn+1,m);
+               *(atoms->atomname[i]),
+               *(atoms->resinfo[ri].name),
+               atoms->resinfo[ri].nr,
+               m);
        warning_error(buf);
       } else 
        if ((m!=0) && (pt == eptVSite)) {
-         rn=atoms->atom[i].resnr;
+         ri = atoms->atom[i].resind;
          sprintf(buf,"virtual site %s (Res %s-%d) has non-zero mass %g\n"
                  "     Check your topology.\n",
-                 *(atoms->atomname[i]),*(atoms->resname[rn]),rn+1,m);
+                 *(atoms->atomname[i]),
+                 *(atoms->resinfo[ri].name),
+                 atoms->resinfo[ri].nr,
+                 m);
          warning_error(buf);
          /* The following statements make LINCS break! */
          /* atoms->atom[i].m=0; */
index 3db2eb193caff971c1d3e513216cc3601c0497af..1595643abfc2be8fd766eafc8ad0e0811f45f4aa 100644 (file)
@@ -905,21 +905,45 @@ push_gb_params (t_atomtype at, char *line)
 static void push_atom_now(t_symtab *symtab,t_atoms *at,int atomnr,
                          int atomicnumber,
                          int type,char *ctype,int ptype,
-                         int resnumber,int cgnumber,
+                         char *resnumberic,int cgnumber,
                          char *resname,char *name,real m0,real q0,
                          int typeB,char *ctypeB,real mB,real qB)
 {
-  int j,resnr_diff=-1;
+  int j,resind,resnr;
+  unsigned char ric;
   int nr = at->nr;
 
   if (((nr==0) && (atomnr != 1)) || (nr && (atomnr != at->nr+1)))
     gmx_fatal(FARGS,"Atoms in the .top are not numbered consecutively from 1 (rather, atomnr = %d, while at->nr = %d)",atomnr,at->nr);
-  if (nr)
-    resnr_diff = resnumber - (at->atom[at->nr-1].resnr+1);
-  if (((nr==0) && (resnumber != 1)) || 
-      (nr && (resnr_diff != 0) && (resnr_diff != 1))) 
-    gmx_fatal(FARGS,"Residue numbers in the .top are not numbered consecutively from 1 (rather, resnumber = %d and resnr_diff = %d)",resnumber,resnr_diff);
-  
+
+  j = strlen(resnumberic) - 1;
+  if (isdigit(resnumberic[j])) {
+    ric = ' ';
+  } else {
+    ric = resnumberic[j];
+    if (j == 0 || !isdigit(resnumberic[j-1])) {
+      gmx_fatal(FARGS,"Invalid residue number '%s' for atom %d",
+               resnumberic,atomnr);
+    }
+  }
+  resnr = atoi(resnumberic);
+
+  if (nr == 0) {
+    resind = 0;
+  } else {
+    resind = at->atom[at->nr-1].resind;
+    if (strcmp(resname,*at->resinfo[resind].name) != 0 ||
+       resnr != at->resinfo[resind].nr ||
+       ric   != at->resinfo[resind].ic) {
+      resind++;
+      at->nres = resind + 1;
+      srenew(at->resinfo,at->nres);
+      at->resinfo[resind].name = put_symtab(symtab,resname);
+      at->resinfo[resind].nr   = resnr;
+      at->resinfo[resind].ic   = ric;
+    }
+  }
+
   /* New atom instance
    * get new space for arrays 
    */
@@ -928,11 +952,6 @@ static void push_atom_now(t_symtab *symtab,t_atoms *at,int atomnr,
   srenew(at->atomtype,nr+1);
   srenew(at->atomtypeB,nr+1);
 
-  if (resnumber > at->nres) {
-    at->nres=resnumber;
-    srenew(at->resname,resnumber);
-    at->resname[resnumber-1] = put_symtab(symtab,resname);
-  }
   /* fill the list */
   at->atom[nr].type  = type;
   at->atom[nr].ptype = ptype;
@@ -942,7 +961,7 @@ static void push_atom_now(t_symtab *symtab,t_atoms *at,int atomnr,
   at->atom[nr].qB    = qB;
   at->atom[nr].mB    = mB;
   
-  at->atom[nr].resnr = resnumber-1;
+  at->atom[nr].resind = resind;
   at->atom[nr].atomnumber = atomicnumber;
   at->atomname[nr] = put_symtab(symtab,name);
   at->atomtype[nr] = put_symtab(symtab,ctype);
@@ -968,9 +987,9 @@ void push_atom(t_symtab *symtab,t_block *cgs,
               t_atoms *at,t_atomtype atype,char *line,int *lastcg)
 {
   int          nr,ptype;
-  int          resnumber,cgnumber,atomnr,type,typeB,nscan;
+  int          cgnumber,atomnr,type,typeB,nscan;
   char                 id[STRLEN],ctype[STRLEN],ctypeB[STRLEN],
-                       resname[STRLEN],name[STRLEN],check[STRLEN];
+                resnumberic[STRLEN],resname[STRLEN],name[STRLEN],check[STRLEN];
   double        m,q,mb,qb;
   real          m0,q0,mB,qB;
 
@@ -978,8 +997,8 @@ void push_atom(t_symtab *symtab,t_block *cgs,
   nr = at->nr;
 
   /* Fixed parameters */
-  if (sscanf(line,"%s%s%d%s%s%d",
-            id,ctype,&resnumber,resname,name,&cgnumber) != 6) {
+  if (sscanf(line,"%s%s%s%s%s%d",
+            id,ctype,resnumberic,resname,name,&cgnumber) != 6) {
     too_few();
     return;
   }
@@ -1025,7 +1044,7 @@ void push_atom(t_symtab *symtab,t_block *cgs,
   push_cg(cgs,lastcg,cgnumber,nr);
 
   push_atom_now(symtab,at,atomnr,get_atomtype_atomnumber(type,atype),
-               type,ctype,ptype,resnumber,cgnumber,
+               type,ctype,ptype,resnumberic,cgnumber,
                resname,name,m0,q0,typeB,
                typeB==type ? ctype : ctypeB,mB,qB);
 }
index 3af2b1c70091c5323d15b34570cfe800466a06f6..bd1ff07a64515e29acbb9673ee400999f5bde8fd 100644 (file)
@@ -393,9 +393,11 @@ void print_atoms(FILE *out,t_atomtype atype,t_atoms *at,int *cgnr)
       if ((tpnmA = get_atomtype_name(tpA,atype)) == NULL)
        gmx_fatal(FARGS,"tpA = %d, i= %d in print_atoms",tpA,i);
       
-      fprintf(out,"%6d %10s %6d %6s %6s %6d %10g %10g",
-             i+1,tpnmA,at->atom[i].resnr+1,  
-             *(at->resname[at->atom[i].resnr]),
+      fprintf(out,"%6d %10s %6d%c %5s %6s %6d %10g %10g",
+             i+1,tpnmA,
+             at->resinfo[at->atom[i].resind].nr,
+             at->resinfo[at->atom[i].resind].ic,
+             *(at->resinfo[at->atom[i].resind].name),
              *(at->atomname[i]),cgnr[i],
              at->atom[i].q,at->atom[i].m);
       if (PERTURBED(at->atom[i])) {
index 9d71b366c25e9ec462ada12103dd81fe5df0bd4b..cd34774284f96978658707970a793baae04ea524 100644 (file)
@@ -293,7 +293,7 @@ static void cmp_atom(FILE *fp,int index,t_atom *a1,t_atom *a2,real ftol)
   if (a2) {
     cmp_us(fp,"atom.type",index,a1->type,a2->type);
     cmp_us(fp,"atom.ptype",index,a1->ptype,a2->ptype);
-    cmp_int(fp,"atom.resnr",index,a1->resnr,a2->resnr);
+    cmp_int(fp,"atom.resind",index,a1->resind,a2->resind);
     cmp_int(fp,"atom.atomnumber",index,a1->atomnumber,a2->atomnumber);
     cmp_real(fp,"atom.m",index,a1->m,a2->m,ftol);
     cmp_real(fp,"atom.q",index,a1->q,a2->q,ftol);
index df733eb922903eba015cefc57c7030e062f2bc73..0444861bd1a8e0b234f596b3ec66339fbe3e3968 100644 (file)
@@ -160,15 +160,16 @@ static void reduce_rvec(int gnx,atom_id index[],rvec vv[])
 }
 
 static void reduce_atom(int gnx,atom_id index[],t_atom atom[],char ***atomname,
-                       int *nres, char ***resname)
+                       int *nres,t_resinfo *resinfo)
 {
   t_atom *ptr;
-  char   ***aname,***rname;
+  char   ***aname;
+  t_resinfo *rinfo;
   int    i,nr;
   
   snew(ptr,gnx);
   snew(aname,gnx);
-  snew(rname,atom[index[gnx-1]].resnr+1);
+  snew(rinfo,atom[index[gnx-1]].resind+1);
   for(i=0; (i<gnx); i++) {
     ptr[i]   = atom[index[i]];
     aname[i] = atomname[index[i]];
@@ -177,20 +178,21 @@ static void reduce_atom(int gnx,atom_id index[],t_atom atom[],char ***atomname,
   for(i=0; (i<gnx); i++) {
     atom[i]     = ptr[i];
     atomname[i] = aname[i];
-    if ((i==0) || (atom[i].resnr != atom[i-1].resnr)) {
+    if ((i==0) || (atom[i].resind != atom[i-1].resind)) {
       nr++;
-      rname[nr]=resname[atom[i].resnr];
+      rinfo[nr] = resinfo[atom[i].resind];
     }
-    atom[i].resnr=nr;
+    atom[i].resind = nr;
   }
   nr++;
-  for(i=0; (i<nr); i++)
-    resname[i]=rname[i];
+  for(i=0; (i<nr); i++) {
+    resinfo[i] = rinfo[i];
+  }
   *nres=nr;
 
   sfree(aname);
   sfree(ptr);
-  sfree(rname);
+  sfree(rinfo);
 }
 
 static void reduce_ilist(atom_id invindex[],bool bKeep[],
@@ -244,7 +246,7 @@ static void reduce_topology_x(int gnx,atom_id index[],
   reduce_rvec(gnx,index,x);
   reduce_rvec(gnx,index,v);
   reduce_atom(gnx,index,top.atoms.atom,top.atoms.atomname,
-             &(top.atoms.nres),top.atoms.resname);
+             &(top.atoms.nres),top.atoms.resinfo);
 
   for(i=0; (i<F_NRE); i++) {
     reduce_ilist(invindex,bKeep,&(top.idef.il[i]),
index 3d2c670f05c846dba6b24899f3c8088a0de07cb8..67d3b0156c8ab45fc701331caac118c183b8c591 100644 (file)
@@ -344,7 +344,7 @@ static void print_rtp(char *filenm,char *title,t_atoms *atoms,
   fp = gmx_fio_fopen(filenm,"w");
   fprintf(fp,"; %s\n",title);
   fprintf(fp,"\n");
-  fprintf(fp,"[ %s ]\n",*atoms->resname[0]);
+  fprintf(fp,"[ %s ]\n",*atoms->resinfo[0].name);
   fprintf(fp,"\n");
   fprintf(fp,"[ atoms ]\n");
   for(i=0; (i<atoms->nr); i++) {
index 450a839dcc4d95297f5a14299b2ce8f02e10d388..00d0b124c98f598c08a842bfeb2065619ccce407 100644 (file)
@@ -122,7 +122,7 @@ void rename_atoms(t_atoms *atoms,t_symtab *symtab,t_aa_names *aan)
   xlatom = get_xlatoms(&nxlate);
 
   for(a=0; (a<atoms->nr); a++) {
-    res  = *(atoms->resname[atoms->atom[a].resnr]);
+    res = *(atoms->resinfo[atoms->atom[a].resind].name);
     strcpy(atombuf,*(atoms->atomname[a]));
     if (isdigit(atombuf[0])) {
       c = atombuf[0];
index 4f9a935d6e07ba5bbe6dffd3fa21fe742cb110bf..d325ac42a992157e195fb8ada64daf647112365d 100644 (file)
 typedef struct {
   int id,charge,natom;
   int ndonor,*donor,nacceptor,*acceptor;
-} t_resinfo;
+} qhop_resinfo_t;
   
 typedef struct {
-  int        nrtp;
-  t_restp    *rtp;
-  t_resinfo  *resinfo;
-  int        bts[4];
-  int        nrexcl;
-  bool       bAllDih,bHH14,bRemoveDih;
-  t_atomtype atype;
-  t_symtab   tab;
-  int        ngqh;
-  gmx_qhop   *gqh;
+  int               nrtp;
+  t_restp           *rtp;
+  qhop_resinfo_t    *resinfo;
+  int               bts[4];
+  int               nrexcl;
+  bool              bAllDih,bHH14,bRemoveDih;
+  t_atomtype        atype;
+  t_symtab          tab;
+  int               ngqh;
+  gmx_qhop          *gqh;
   t_qhop_parameters *qhop_param;
 } gmx_qhop_db_t;
 
-static void fill_resinfo(t_restp *rtp,t_resinfo *ri)
+static void fill_resinfo(t_restp *rtp,qhop_resinfo_t *ri)
 {
   int    j,k,m;
   bool   bDonor;
index d7d19e982cca877ba424dcfe1d59d2cdb8be0848..95ca72eb1777293f057ade1ceb82e0892999fe42 100644 (file)
@@ -215,17 +215,19 @@ void set_file(t_x11 *x11,t_manager *man,char *trajectory,char *status)
   aps = gmx_atomprop_init();
   for(i=0; (i<man->natom); i++) {
     char *aname=*(at->atomname[i]);
-    int  resnr=at->atom[i].resnr;
+    t_resinfo *ri=&at->resinfo[at->atom[i].resind];
 
     man->col[i]=Type2Color(aname);
     snew(man->szLab[i],20);
-    sprintf(man->szLab[i],"%s%d, %s",*(at->resname[resnr]),resnr+1,aname);
+    if (ri->ic != ' ') {
+      sprintf(man->szLab[i],"%s%d%c, %s",*ri->name,ri->nr,ri->ic,aname);
+    } else {
+      sprintf(man->szLab[i],"%s%d, %s",*ri->name,ri->nr,aname);
+    }
     man->bHydro[i]=(toupper(aname[0])=='H');
     if ( man->bHydro[i] )
       man->vdw[i]=0;
-    else if (!gmx_atomprop_query(aps,epropVDW,
-                                *(at->resname[resnr]),aname,
-                                &(man->vdw[i])))
+    else if (!gmx_atomprop_query(aps,epropVDW,*ri->name,aname,&(man->vdw[i])))
       man->vdw[i] = 0;
   }
   gmx_atomprop_destroy(aps);
index e65eb1a27c76df68b3b0704c9fc966a596859d5e..b1005125b16370c9015e46e7c23c4c241624d8f9 100644 (file)
@@ -76,11 +76,11 @@ static void set_margin(t_atoms *atoms, rvec *x, real *r)
   start=0;
   for(i=0; i < atoms->nr; i++) {
     if ( (i+1 == atoms->nr) || 
-        (atoms->atom[i+1].resnr != atoms->atom[i].resnr) ) {
+        (atoms->atom[i+1].resind != atoms->atom[i].resind) ) {
       d=max_dist(x,r,start,i+1);
       if (debug && d>box_margin)
        fprintf(debug,"getting margin from %s: %g\n",
-               *(atoms->resname[atoms->atom[i].resnr]),box_margin);
+               *(atoms->resinfo[atoms->atom[i].resind].name),box_margin);
       box_margin=max(box_margin,d);
       start=i+1;
     }
@@ -104,12 +104,12 @@ static bool outside_box_plus_margin(rvec x,matrix box)
 
 static int mark_res(int at, bool *mark, int natoms, t_atom *atom,int *nmark)
 {
-  int resnr;
+  int resind;
   
-  resnr = atom[at].resnr;
-  while( (at > 0) && (resnr==atom[at-1].resnr) )
+  resind = atom[at].resind;
+  while( (at > 0) && (resind==atom[at-1].resind) )
     at--;
-  while( (at < natoms) && (resnr==atom[at].resnr) ) {
+  while( (at < natoms) && (resind==atom[at].resind) ) {
     if (!mark[at]) {
       mark[at]=TRUE;
       (*nmark)++;
@@ -163,11 +163,11 @@ static void combine_atoms(t_atoms *ap,t_atoms *as,
     copy_rvec(xs[i],xc[j]);
     if (vc) copy_rvec(vs[i],vc[j]);
     memcpy(&(ac->atom[j]),&(as->atom[i]),sizeof(as->atom[i]));
-    ac->atom[j].type   = 0;
-    ac->atom[j].resnr += res0;
+    ac->atom[j].type    = 0;
+    ac->atom[j].resind += res0;
   }
   ac->nr   = j;
-  ac->nres = ac->atom[j-1].resnr+1;
+  ac->nres = ac->atom[j-1].resind+1;
   /* Fill all elements to prevent uninitialized memory */
   for(i=0; i<ac->nr; i++) {
     ac->atom[i].m     = 1;
@@ -411,8 +411,8 @@ void add_conf(t_atoms *atoms, rvec **x, rvec **v, real **r, bool bSrenew,
              (outside_box_minus_margin2(x_solvt[is1],box) && /* is1 on edge */
               outside_box_minus_margin2(x_solvt[is2],box))   /* is2 on edge */
              ) &&
-            (atoms_solvt->atom[is1].resnr !=  /* Not the same residue */
-             atoms_solvt->atom[is2].resnr))) {
+            (atoms_solvt->atom[is1].resind !=  /* Not the same residue */
+             atoms_solvt->atom[is2].resind))) {
          
          ntest++;
          rvec_sub(xi,xj,dx);
@@ -481,22 +481,22 @@ void add_conf(t_atoms *atoms, rvec **x, rvec **v, real **r, bool bSrenew,
     if (!remove[i]) {
       j++;
       if ((i == 0) || 
-         (atoms_solvt->atom[i].resnr != atoms_solvt->atom[i-1].resnr))
+         (atoms_solvt->atom[i].resind != atoms_solvt->atom[i-1].resind))
        jnres++;
     }
   }
   if (debug)
     fprintf(debug,"Will add %d atoms in %d residues\n",j,jnres);
   /* Flag the remaing solvent atoms to be removed */
-  jjj = atoms_solvt->atom[i-1].resnr;
+  jjj = atoms_solvt->atom[i-1].resind;
   for ( ; (i<atoms_solvt->nr); i++) 
-    if (atoms_solvt->atom[i].resnr > jjj)
+    if (atoms_solvt->atom[i].resind > jjj)
       remove[i] = TRUE;
     else
       j++;
 
   if (bSrenew) {
-    srenew(atoms->resname,  atoms->nres+atoms_solvt->nres);
+    srenew(atoms->resinfo,  atoms->nres+atoms_solvt->nres);
     srenew(atoms->atomname, atoms->nr+j);
     srenew(atoms->atom,     atoms->nr+j);
     srenew(*x,              atoms->nr+j);
@@ -510,7 +510,7 @@ void add_conf(t_atoms *atoms, rvec **x, rvec **v, real **r, bool bSrenew,
   for (i=0; i<atoms_solvt->nr; i++)
     if (!remove[i]) {
       if (prev==NOTSET || 
-         atoms_solvt->atom[i].resnr != atoms_solvt->atom[prev].resnr) {
+         atoms_solvt->atom[i].resind != atoms_solvt->atom[prev].resind) {
        nresadd ++;
        atoms->nres++;
        /* calculate shift of the solvent molecule using the first atom */
@@ -523,14 +523,16 @@ void add_conf(t_atoms *atoms, rvec **x, rvec **v, real **r, bool bSrenew,
       rvec_add(x_solvt[i],dx,(*x)[atoms->nr]);
       if (v) copy_rvec(v_solvt[i],(*v)[atoms->nr]);
       (*r)[atoms->nr]   = r_solvt[i];
-      atoms->atom[atoms->nr].resnr = atoms->nres-1;
-      atoms->resname[atoms->nres-1] =
-       atoms_solvt->resname[atoms_solvt->atom[i].resnr];
+      atoms->atom[atoms->nr].resind = atoms->nres-1;
+      atoms->resinfo[atoms->nres-1] =
+       atoms_solvt->resinfo[atoms_solvt->atom[i].resind];
+      atoms->resinfo[atoms->nres-1].nr =
+       (atoms->nres == 1 ? 1 : atoms->resinfo[atoms->nres-2].nr + 1);
       atoms->nr++;
       prev=i;
     }
   if (bSrenew)
-    srenew(atoms->resname,  atoms->nres+nresadd);
+    srenew(atoms->resinfo,  atoms->nres+nresadd);
   
   if (bVerbose)
     fprintf(stderr,"Added %d molecules\n",nresadd);
index 2de6ac374168eb8cd92b0c9a34d762d2fd34f5c2..1dc15f12eafb2242adad5d58a1994c581f0f077e 100644 (file)
@@ -61,7 +61,7 @@ t_dlist *mk_dlist(FILE *log,
   ires = -1;
   i    =  0;
   while (i<atoms->nr) {
-    ires=atoms->atom[i].resnr;
+    ires = atoms->atom[i].resind;
     
     /* Initiate all atom numbers to -1 */
     atm.minC=atm.H=atm.N=atm.C=atm.O=atm.minO=-1;
@@ -70,7 +70,7 @@ t_dlist *mk_dlist(FILE *log,
       
     /* Look for atoms in this residue */
     /* maybe should allow for chis to hydrogens? */
-    while ((i<atoms->nr) && (atoms->atom[i].resnr == ires)) {
+    while ((i<atoms->nr) && (atoms->atom[i].resind == ires)) {
       if ((strcmp(*(atoms->atomname[i]),"H") == 0) ||
          (strcmp(*(atoms->atomname[i]),"H1") == 0) )
        atm.H=i;
@@ -114,23 +114,25 @@ t_dlist *mk_dlist(FILE *log,
        atm.Cn[7]=i;
       i++;
     }
+
+    thisres = *(atoms->resinfo[ires].name);    
     
     /* added by grs - special case for aromatics, whose chis above 2 are 
        not real and produce rubbish output - so set back to -1 */ 
-    if (strcmp(*(atoms->resname[ires]),"PHE") == 0 ||
-       strcmp(*(atoms->resname[ires]),"TYR") == 0 ||
-       strcmp(*(atoms->resname[ires]),"PTR") == 0 ||
-       strcmp(*(atoms->resname[ires]),"TRP") == 0 ||
-       strcmp(*(atoms->resname[ires]),"HIS") == 0 ||
-       strcmp(*(atoms->resname[ires]),"HISA") == 0 ||
-       strcmp(*(atoms->resname[ires]),"HISB") == 0 )  {
+    if (strcmp(thisres,"PHE") == 0 ||
+       strcmp(thisres,"TYR") == 0 ||
+       strcmp(thisres,"PTR") == 0 ||
+       strcmp(thisres,"TRP") == 0 ||
+       strcmp(thisres,"HIS") == 0 ||
+       strcmp(thisres,"HISA") == 0 ||
+       strcmp(thisres,"HISB") == 0 )  {
       for (ii=5 ; ii<=7 ; ii++) 
        atm.Cn[ii]=-1; 
     }
     /* end fixing aromatics */ 
 
     /* Special case for Pro, has no H */
-    if (strcmp(*(atoms->resname[ires]),"PRO") == 0) 
+    if (strcmp(thisres,"PRO") == 0) 
       atm.H=atm.Cn[4];
     /* Carbon from previous residue */
     if (prev.C != -1)
@@ -139,8 +141,6 @@ t_dlist *mk_dlist(FILE *log,
       atm.minO = prev.O;
     prev = atm;
       
-    thisres=*(atoms->resname[ires]);   
-    
     /* Check how many dihedrals we have */
     if ((atm.N != -1) && (atm.Cn[1] != -1) && (atm.C != -1) &&
       (atm.O != -1) && ((atm.H != -1) || (atm.minC != -1))) {
index 7a058db0d72eabc82a7b37233cbb06f93a2d32cb..0f132822506ea8a1e8f95ee0be4a2377042f240b 100644 (file)
@@ -142,7 +142,7 @@ bool *bPhobics(t_atoms *atoms)
   snew(bb,atoms->nres);
   
   for(i=0; (i<atoms->nres); i++) {
-    if (search_str(nb,cb,*atoms->resname[i]) != -1)
+    if (search_str(nb,cb,*atoms->resinfo[i].name) != -1)
       bb[i]=TRUE;
   }
   return bb;
@@ -179,12 +179,12 @@ static void norm_acc(t_atoms *atoms, int nres,
   }
   
   for(i=0; (i<nres); i++) {
-    n = search_str(n_surf,surf_res,*atoms->resname[i]);
+    n = search_str(n_surf,surf_res,*atoms->resinfo[i].name);
     if ( n != -1)
       norm_av_area[i] = av_area[i] / surf[n];
     else 
       fprintf(stderr,"Residue %s not found in surface database (%s)\n",
-             *atoms->resname[i],surffn);
+             *atoms->resinfo[i].name,surffn);
   }
 }
 
@@ -387,8 +387,8 @@ int main(int argc,char *argv[])
   nres=0;
   nr0=-1;
   for(i=0; (i<gnx); i++) {
-    if (atoms->atom[index[i]].resnr != nr0) {
-      nr0=atoms->atom[index[i]].resnr;
+    if (atoms->atom[index[i]].resind != nr0) {
+      nr0=atoms->atom[index[i]].resind;
       nres++;
     }
   }
index 9d78addace28afaadc192038f06ea228b33b65e2..64ab577afede154e6f6e81896803e50c6cc05d2a 100644 (file)
@@ -60,7 +60,7 @@ void replace_atom(t_topology *top,int inr,char *anm,char *resnm,
   atoms->atom[inr].type = atoms->atom[inr].typeB = type;
   
   /* Residue name */
-  atoms->resname[atoms->atom[inr].resnr] = put_symtab(&top->symtab,resnm);
+  atoms->resinfo[atoms->atom[inr].resind].name = put_symtab(&top->symtab,resnm);
   /* Atom name */
   atoms->atomname[inr] = put_symtab(&top->symtab,anm);
   if (debug)
index 270202781481df96ba1c5d51e40413bce11fd46c..29c56f5898a3f61ae253168169f39829f1d9b44a 100644 (file)
@@ -554,9 +554,11 @@ static void project(char *trajfile,t_topology *top,int ePBC,matrix topbox,
       fact=1.0;
 
     for(i=0; i<nframes; i++) {
-      atoms.resname[i]=&resnm;
-      atoms.atomname[i]=&atnm;
-      atoms.atom[i].resnr=ceil(i*fact);
+      atoms.atomname[i] = &atnm;
+      atoms.atom[i].resind = i;
+      atoms.resinfo[i].name = &resnm;
+      atoms.resinfo[i].nr   = ceil(i*fact);
+      atoms.resinfo[i].ic   = ' ';
       x[i][XX]=inprod[0][i];
       x[i][YY]=inprod[1][i];
       x[i][ZZ]=inprod[2][i];
@@ -631,8 +633,9 @@ static void project(char *trajfile,t_topology *top,int ePBC,matrix topbox,
       out=open_trx(str2,"w");
       for(frame=0; frame<nextr; frame++) {
        if ((extreme==0) && (nextr<=3))
-         for(i=0; i<natoms; i++)
-           atoms->atom[index[i]].chain='A'+frame;
+         for(i=0; i<natoms; i++) {
+           atoms->resinfo[atoms->atom[index[i]].resind].chain = 'A' + frame;
+         }
        for(i=0; i<natoms; i++)
          for(d=0; d<DIM; d++) 
            xread[index[i]][d] = 
index d5843b399383efcee206646c85414ddb25f316b7..6ac5436eb73dc51502645f86618a2c46e499ddfc 100644 (file)
@@ -63,11 +63,11 @@ static void make_dist_leg(FILE *fp,int gnx,atom_id index[],t_atoms *atoms)
     snew(leg[i/2],256);
     sprintf(leg[i/2],"%s %s%d - %s %s%d",
            *(atoms->atomname[index[i]]),
-           *(atoms->resname[atoms->atom[index[i]].resnr]),
-            atoms->atom[index[i]].resnr+1,
+           *(atoms->resinfo[atoms->atom[index[i]].resind].name),
+            atoms->resinfo[atoms->atom[index[i]].resind].nr,
            *(atoms->atomname[index[i+1]]),
-           *(atoms->resname[atoms->atom[index[i+1]].resnr]),
-            atoms->atom[index[i+1]].resnr+1);
+           *(atoms->resinfo[atoms->atom[index[i+1]].resind].name),
+            atoms->resinfo[atoms->atom[index[i+1]].resind].nr);
   }
   xvgr_legend(fp,gnx/2,leg);
   for(i=0; i<gnx/2; i++)
index b31d7ad4341aabb7d3746f6d801cedddd86c2da4..e5f0569b7793eede856a484c9034abb50c585c83 100644 (file)
@@ -291,8 +291,10 @@ int gmx_bundle(int argc,char *argv[])
     outatoms.nr = 3*n;
     for(i=0; i<3*n; i++) {
       outatoms.atomname[i] = &anm;
-      outatoms.atom[i].resnr = i/3;
-      outatoms.resname[i/3] = &rnm;
+      outatoms.atom[i].resind = i/3;
+      outatoms.resinfo[i/3].name = &rnm;
+      outatoms.resinfo[i/3].nr   = i/3 + 1;
+      outatoms.resinfo[i/3].ic   = ' ';
     }
     fpdb = open_trx(opt2fn("-oa",NFILE,fnm),"w");
   } else
index bf7bfe3384fdbebee9ea2e1b121f295f6b22df8d..47a3345fe322f305f621c7583caf3cad40b20c9a 100644 (file)
@@ -1369,11 +1369,11 @@ int gmx_cluster(int argc,char *argv[])
     }
     init_t_atoms(&useatoms,isize,FALSE);
     snew(usextps, isize);
-    useatoms.resname=top.atoms.resname;
+    useatoms.resinfo = top.atoms.resinfo;
     for(i=0; i<isize; i++) {
       useatoms.atomname[i]=top.atoms.atomname[index[i]];
-      useatoms.atom[i].resnr=top.atoms.atom[index[i]].resnr;
-      useatoms.nres=max(useatoms.nres,useatoms.atom[i].resnr+1);
+      useatoms.atom[i].resind = top.atoms.atom[index[i]].resind;
+      useatoms.nres = max(useatoms.nres,useatoms.atom[i].resind+1);
       copy_rvec(xtps[index[i]],usextps[i]);
     }
     useatoms.nr=isize;
index da55874fe98ec475ff42d7ba341b4978bfe29b7c..1b970609f7ec4f4323e41e746af330b336aef3d4 100644 (file)
@@ -83,11 +83,11 @@ int build_res_index(int isize, atom_id index[], t_atom atom[], int rindex[])
   int i, r;
   
   r=0;
-  rindex[r] = atom[index[0]].resnr;
+  rindex[r] = atom[index[0]].resind;
   r++;
   for(i=1; i<isize; i++)
-    if (atom[index[i]].resnr != rindex[r-1]) {
-      rindex[r] = atom[index[i]].resnr;
+    if (atom[index[i]].resind != rindex[r-1]) {
+      rindex[r] = atom[index[i]].resind;
       r++;
     }
   
@@ -98,8 +98,8 @@ int find_res_end(int i, int isize, atom_id index[], t_atoms *atoms)
 {
   int rnr;
   
-  rnr = atoms->atom[index[i]].resnr;
-  while(i<isize && atoms->atom[index[i]].resnr==rnr)
+  rnr = atoms->atom[index[i]].resind;
+  while(i<isize && atoms->atom[index[i]].resind==rnr)
     i++;
   return i;
 }
@@ -157,8 +157,10 @@ int find_next_match_atoms_in_res(int *i1,int isize1,atom_id index1[],
   return cmp;
 }
 
-int find_next_match_res(int *rnr1, int isize1, int index1[], char **resnms1[],
-                       int *rnr2, int isize2, int index2[], char **resnms2[])
+static int find_next_match_res(int *rnr1, int isize1,
+                              int index1[], t_resinfo *resinfo1,
+                              int *rnr2, int isize2,
+                              int index2[], t_resinfo *resinfo2)
 {
   int dx, dy, dmax, cmp, rr1, rr2;
   bool bFW=FALSE,bFF=FALSE;
@@ -181,17 +183,20 @@ int find_next_match_res(int *rnr1, int isize1, int index1[], char **resnms1[],
        cmp=NOTSET;
        if ( rr1+dx<isize1 && rr2+dy<isize2 ) {
          bFW=TRUE;
-         cmp=debug_strcmp(*resnms1[index1[rr1+dx]],*resnms2[index2[rr2+dy]]);
+         cmp=debug_strcmp(*resinfo1[index1[rr1+dx]].name,
+                          *resinfo2[index2[rr2+dy]].name);
          if (debug) fprintf(debug,"(%d %d)", rr1+dx, rr2+dy);
        }
        if ( cmp!=0 && rr1+dy<isize1 && rr2+dx<isize2 ) {
          bFW=FALSE;
-         cmp=debug_strcmp(*resnms1[index1[rr1+dy]],*resnms2[index2[rr2+dx]]);
+         cmp=debug_strcmp(*resinfo1[index1[rr1+dy]].name,
+                          *resinfo2[index2[rr2+dx]].name);
          if (debug) fprintf(debug,"(%d %d)", rr1+dy, rr2+dx);
        }
        if ( dx!=0 && cmp!=0 && rr1+dx<isize1 && rr2+dx<isize2 ) {
          bFF=TRUE;
-         cmp=debug_strcmp(*resnms1[index1[rr1+dx]],*resnms2[index2[rr2+dx]]);
+         cmp=debug_strcmp(*resinfo1[index1[rr1+dx]].name,
+                          *resinfo2[index2[rr2+dx]].name);
          if (debug) fprintf(debug,"(%d %d)", rr1+dx, rr2+dx);
        } else
          bFF=FALSE;
@@ -204,7 +209,8 @@ int find_next_match_res(int *rnr1, int isize1, int index1[], char **resnms1[],
      to allow for single mutations of residues... */
   if (bFF) {
     if (debug) fprintf(debug, "%d.%d.%dX%sX%s",dx,rr1,rr2,
-                      *resnms1[index1[rr1+1]],*resnms2[index2[rr2+1]]);
+                      *resinfo1[index1[rr1+1]].name,
+                      *resinfo2[index2[rr2+1]].name);
     dx=1;
   }
   if (cmp==0) {
@@ -232,10 +238,10 @@ int find_first_atom_in_res(int rnr, int isize, atom_id index[], t_atom atom[])
   int i;
   
   i=0;
-  while(i<isize && atom[index[i]].resnr!=rnr)
+  while(i<isize && atom[index[i]].resind!=rnr)
     i++;
   
-  if (atom[index[i]].resnr==rnr)
+  if (atom[index[i]].resind==rnr)
     return i;
   else
     return NOTSET;
@@ -250,13 +256,14 @@ void find_matching_names(int *isize1, atom_id index1[], t_atoms *atoms1,
   int rsize1, rsize2;
   int *rindex1, *rindex2;
   char *resnm1, *resnm2, *atnm1, *atnm2;
-  char ***resnms1,***resnms2,***atnms1,***atnms2;
+  char ***atnms1,***atnms2;
+  t_resinfo *resinfo1,*resinfo2;
   
   /* set some handy shortcuts */  
-  resnms1 = atoms1->resname;
-  atnms1  = atoms1->atomname;
-  resnms2 = atoms2->resname;
-  atnms2  = atoms2->atomname;
+  resinfo1 = atoms1->resinfo;
+  atnms1   = atoms1->atomname;
+  resinfo2 = atoms2->resinfo;
+  atnms2   = atoms2->atomname;
   
   /* build indexes of selected residues */
   snew(rindex1,atoms1->nres);
@@ -271,12 +278,12 @@ void find_matching_names(int *isize1, atom_id index1[], t_atoms *atoms1,
   if (debug) fprintf(debug, "Find matching names: %d, %d\n", *isize1, *isize2);
   while ( atcmp==0 && i1<*isize1 && i2<*isize2 ) {
     /* prologue */
-    rnr1 = atoms1->atom[index1[i1]].resnr;
-    rnr2 = atoms2->atom[index2[i2]].resnr;
+    rnr1 = atoms1->atom[index1[i1]].resind;
+    rnr2 = atoms2->atom[index2[i2]].resind;
     if (rnr1!=prnr1 || rnr2!=prnr2) {
       if (debug) fprintf(debug, "R: %s%d %s%d\n", 
-                        *resnms1[rnr1],rnr1,*resnms2[rnr2],rnr2);
-      rescmp=strcmp(*resnms1[rnr1], *resnms2[rnr2]);
+                        *resinfo1[rnr1].name,rnr1,*resinfo2[rnr2].name,rnr2);
+      rescmp=strcmp(*resinfo1[rnr1].name, *resinfo2[rnr2].name);
     }
     if (debug) fprintf(debug, "comparing %d %d", i1, i2);
     atcmp=debug_strcmp(*atnms1[index1[i1]], *atnms2[index2[i2]]);
@@ -295,15 +302,17 @@ void find_matching_names(int *isize1, atom_id index1[], t_atoms *atoms1,
     if (atcmp!=0) { /* still no match -> next residue(s) */
       prnr1=rnr1;
       prnr2=rnr2;
-      rescmp = find_next_match_res(&rnr1,rsize1,rindex1,resnms1,
-                                  &rnr2,rsize2,rindex2,resnms2);
+      rescmp = find_next_match_res(&rnr1,rsize1,rindex1,resinfo1,
+                                  &rnr2,rsize2,rindex2,resinfo2);
       if (rnr1!=prnr1) 
        i1 = find_first_atom_in_res(rnr1, *isize1, index1, atoms1->atom);
       if (rnr2!=prnr2) 
        i2 = find_first_atom_in_res(rnr2, *isize2, index2, atoms2->atom);
       if (debug) fprintf(debug, " -> %s%d-%s%d %s%d-%s%d",
-                        *resnms1[rnr1],rnr1, *atnms1[index1[i1]],index1[i1],
-                        *resnms2[rnr2],rnr2, *atnms2[index2[i2]],index2[i2]);
+                        *resinfo1[rnr1].name,rnr1,
+                        *atnms1[index1[i1]],index1[i1],
+                        *resinfo2[rnr2].name,rnr2,
+                        *atnms2[index2[i2]],index2[i2]);
       m1 = find_res_end(i1, *isize1, index1, atoms1);
       m2 = find_res_end(i2, *isize2, index2, atoms2);
       if (debug) fprintf(debug, " [%d<%d %d<%d]", i1,m1, i2,m2);
@@ -564,7 +573,7 @@ int gmx_confrms(int argc,char *argv[])
        if (bBfac)
          atoms1->pdbinfo[index1[i]].bfac = 800*M_PI*M_PI/3.0*msds[i]/100;
        if (bLabel)
-         atoms1->atom[index1[i]].chain = 'A';
+         atoms1->resinfo[atoms1->atom[index1[i]].resind].chain = 'A';
       }
       snew(atoms2->pdbinfo, atoms2->nr);
       snew(atoms2->atom, atoms2->nr);
@@ -574,7 +583,7 @@ int gmx_confrms(int argc,char *argv[])
        if (bBfac)
          atoms2->pdbinfo[index2[i]].bfac = 800*M_PI*M_PI/3.0*msds[i]/100;
        if (bLabel)
-         atoms2->atom[index2[i]].chain = 'B';
+         atoms2->resinfo[atoms2->atom[index2[i]].resind].chain = 'B';
       }
     }
     fp=ffopen(outfile,"w");
index a8187f92d23f2cfcac8afdd70127cf741e56b840..fd19f3674693ce4efa82012822df6f958ccaa908 100644 (file)
@@ -461,7 +461,7 @@ static void dump_disre_matrix(char *fn,t_dr_result *dr,int ndr,
     atoms = &mtop->moltype[mtop->molblock[mb].type].atoms;
     for(mol=0; mol<mtop->molblock[mb].nmol; mol++) {
       for(a=0; a<atoms->nr; a++) {
-       resnr[a_offset+a] = n_res + atoms->atom[a].resnr;
+       resnr[a_offset+a] = n_res + atoms->atom[a].resind;
       }
       n_res    += atoms->nres;
       a_offset += atoms->nr;
index 25ef798b8975d4e10507e140faa39bfa1fafb4ed..3e1214fb597f8288d79e6331543bf386c8744bc4 100644 (file)
@@ -221,9 +221,9 @@ int gmx_dist(int argc,char *argv[])
        dist2 = norm2(dx);
        if (dist2<cut2) {
          if (bPrintDist) {
-           res=top->atoms.atom[j].resnr;
+           res=top->atoms.atom[j].resind;
            fprintf(stdout,"\rt: %g  %d %s %d %s  %g (nm)\n",
-                   t,res+1,*top->atoms.resname[res],
+                   t,top->atoms.resinfo[res].nr,*top->atoms.resinfo[res].name,
                    j+1,*top->atoms.atomname[j],sqrt(dist2));
          }
          if (bLifeTime)
index 9ef6eae48f8493a44dd7667f263d5b82ce5a57a3..c556c888a08033e31ba6595c4dcea0d42f4387d2 100644 (file)
@@ -215,7 +215,7 @@ int gmx_dyndom(int argc,char *argv[])
     if (label > 'Z')
       label-=26;
     for(j=0; (j<atoms.nr); j++)
-      atoms.atom[j].chain = label;
+      atoms.resinfo[atoms.atom[j].resind].chain = label;
     
     write_trx(status,atoms.nr,index_all,&atoms,i,angle,box,xout,vout);  
   }
index 610ee1bede8b22861e8e37b6569b05f4beadef82..706b3d2a0b1742168d11f7a6806e597850f11320 100644 (file)
@@ -87,7 +87,7 @@ real calc_mass(t_atoms *atoms,bool bGetMass,gmx_atomprop_t aps)
   for(i=0; (i<atoms->nr); i++) {
     if (bGetMass) {
       gmx_atomprop_query(aps,epropMass,
-                        *atoms->resname[atoms->atom[i].resnr]
+                        *atoms->resinfo[atoms->atom[i].resind].name
                         *atoms->atomname[i],&(atoms->atom[i].m));
     }
     tmass += atoms->atom[i].m;
@@ -237,7 +237,7 @@ void set_pdb_conf_bfac(int natoms,int nres,t_atoms *atoms,
     for(i=0; (i<n_bfac); i++) {
       found=FALSE;
       for(n=0; (n<natoms); n++)
-       if ( bfac_nr[i] == (atoms->atom[n].resnr+1) ) {
+       if ( bfac_nr[i] == atoms->resinfo[atoms->atom[n].resind].nr ) {
          atoms->pdbinfo[n].bfac=bfac[i];
          found=TRUE;
        }
@@ -294,9 +294,10 @@ void visualize_images(char *fn,int ePBC,matrix box)
   ala = "ALA";
   for(i=0; i<nat; i++) {
     atoms.atomname[i] = &c;
-    atoms.atom[i].resnr = i;
-    atoms.resname[i] = &ala;
-    atoms.atom[i].chain = 'A'+i/NCUCVERT;
+    atoms.atom[i].resind = i;
+    atoms.resinfo[i].name  = &ala;
+    atoms.resinfo[i].nr    = i + 1;
+    atoms.resinfo[i].chain = 'A'+i/NCUCVERT;
   }
   calc_triclinic_images(box,img+1);
 
@@ -604,7 +605,7 @@ int gmx_editconf(int argc, char *argv[])
       /* Determine the Van der Waals radius from the force field */
       if (bReadVDW) {
        if (!gmx_atomprop_query(aps,epropVDW,
-                               *top->atoms.resname[top->atoms.atom[i].resnr],
+                               *top->atoms.resinfo[top->atoms.atom[i].resind].name,
                                *top->atoms.atomname[i],&vdw))
          vdw = rvdw;
       }
@@ -893,7 +894,7 @@ int gmx_editconf(int argc, char *argv[])
       }
       if (opt2parg_bSet("-label",NPA,pa)) {
        for(i=0; (i<atoms.nr); i++) 
-         atoms.atom[i].chain=label[0];
+         atoms.resinfo[atoms.atom[i].resind].chain=label[0];
       }
       write_pdbfile(out,title,&atoms,x,ePBC,box,0,-1);
       if (bLegend)
index 2048e83cac73c6674360d8c387ef59d1c89ddabd..7b57a5b003f87d316d58aa1e12881236d78a4168 100644 (file)
@@ -103,7 +103,7 @@ static void mk_vdw(t_atoms *a,real rvdw[],gmx_atomprop_t aps,
   fprintf(stderr,"Initialising van der waals distances...\n");
   for(i=0; (i < a->nr); i++)
     if (!gmx_atomprop_query(aps,epropVDW,
-                           *(a->resname[a->atom[i].resnr]), 
+                           *(a->resinfo[a->atom[i].resind].name), 
                            *(a->atomname[i]),&(rvdw[i])))
       rvdw[i] =        r_distance;
 }
@@ -135,21 +135,21 @@ void sort_molecule(t_atoms **atoms_solvt,rvec *x,rvec *v,real *r)
   nrmoltypes=0;
   atnr=0;
   for (i=0; i<atoms->nr; i++) {
-    if ( (i==0) || (atoms->atom[i].resnr != atoms->atom[i-1].resnr) ) {
+    if ( (i==0) || (atoms->atom[i].resind != atoms->atom[i-1].resind) ) {
       /* see if this was a molecule type we haven't had yet: */
       moltp=NOTSET;
       for (j=0; (j<nrmoltypes) && (moltp==NOTSET); j++)
-       if (strcmp(*(atoms->resname[atoms->atom[i].resnr]),
+       if (strcmp(*(atoms->resinfo[atoms->atom[i].resind].name),
                   moltypes[j].name)==0)
          moltp=j;
       if (moltp==NOTSET) {
        moltp=nrmoltypes;
        nrmoltypes++;
        srenew(moltypes,nrmoltypes);
-       moltypes[moltp].name=*(atoms->resname[atoms->atom[i].resnr]);
+       moltypes[moltp].name=*(atoms->resinfo[atoms->atom[i].resind].name);
        atnr = 0;
        while ((i+atnr<atoms->nr) && 
-              (atoms->atom[i].resnr == atoms->atom[i+atnr].resnr))
+              (atoms->atom[i].resind == atoms->atom[i+atnr].resind))
          atnr++;
        moltypes[moltp].natoms=atnr;
        moltypes[moltp].nmol=0;
@@ -184,7 +184,7 @@ void sort_molecule(t_atoms **atoms_solvt,rvec *x,rvec *v,real *r)
     snew(newatoms,1);
     init_t_atoms(newatoms,atoms->nr,FALSE);
     newatoms->nres=atoms->nres;
-    snew(newatoms->resname,atoms->nres);
+    snew(newatoms->resinfo,atoms->nres);
     snew(newx,atoms->nr);
     if (v) snew(newv,atoms->nr);
     snew(newr,atoms->nr);
@@ -192,10 +192,11 @@ void sort_molecule(t_atoms **atoms_solvt,rvec *x,rvec *v,real *r)
     for (i=0; i<atoms->nr; i++) {
       resnr = moltypes[tps[i]].res0 +
        (moltypes[tps[i]].i-moltypes[tps[i]].i0) / moltypes[tps[i]].natoms;
-      newatoms->resname[resnr] = atoms->resname[atoms->atom[i].resnr];
+      newatoms->atom[moltypes[tps[i]].i].resind = resnr;
+      newatoms->resinfo[resnr] = atoms->resinfo[atoms->atom[i].resind];
+      newatoms->resinfo[resnr].nr = resnr + 1;
       newatoms->atomname[moltypes[tps[i]].i] = atoms->atomname[i];
       newatoms->atom[moltypes[tps[i]].i] = atoms->atom[i];
-      newatoms->atom[moltypes[tps[i]].i].resnr = resnr;
       copy_rvec(x[i],newx[moltypes[tps[i]].i]);
       if (v) copy_rvec(v[i],newv[moltypes[tps[i]].i]);
       newr[moltypes[tps[i]].i] = r[i];
@@ -204,7 +205,7 @@ void sort_molecule(t_atoms **atoms_solvt,rvec *x,rvec *v,real *r)
     
     /* put them back into the original arrays and throw away temporary arrays */
     sfree(atoms->atomname);
-    sfree(atoms->resname);
+    sfree(atoms->resinfo);
     sfree(atoms->atom);
     sfree(atoms);
     *atoms_solvt = newatoms;
@@ -234,7 +235,7 @@ void rm_res_pbc(t_atoms *atoms, rvec *x, matrix box)
       rvec_inc(xcg,x[n]);
     }
     if ( (n+1 == atoms->nr) || 
-        (atoms->atom[n+1].resnr != atoms->atom[n].resnr) ) {
+        (atoms->atom[n+1].resind != atoms->atom[n].resind) ) {
       /* if nat==0 we have only hydrogens in the solvent, 
         we take last coordinate as cg */
       if (nat==0) {
@@ -286,7 +287,7 @@ static char *insert_mols(char *mol_insrt,int nmol_insrt,int ntry,int seed,
   /* allocate memory for atom coordinates of insert molecules */
   snew(x_insrt,atoms_insrt.nr);
   snew(r_insrt,atoms_insrt.nr);
-  snew(atoms_insrt.resname,atoms_insrt.nr);
+  snew(atoms_insrt.resinfo,atoms_insrt.nr);
   snew(atoms_insrt.atomname,atoms_insrt.nr);
   snew(atoms_insrt.atom,atoms_insrt.nr);
   atoms_insrt.pdbinfo = NULL;
@@ -299,12 +300,12 @@ static char *insert_mols(char *mol_insrt,int nmol_insrt,int ntry,int seed,
                &ePBC_insrt,box_insrt);
   fprintf(stderr,"%s\nContaining %d atoms in %d residue\n",
          title_insrt,atoms_insrt.nr,atoms_insrt.nres);
-  srenew(atoms_insrt.resname,atoms_insrt.nres);  
+  srenew(atoms_insrt.resinfo,atoms_insrt.nres);  
     
   /* initialise van der waals arrays of insert molecules */
   mk_vdw(&atoms_insrt,r_insrt,aps,r_distance);
 
-  srenew(atoms->resname,(atoms->nres+nmol_insrt));
+  srenew(atoms->resinfo,(atoms->nres+nmol_insrt));
   srenew(atoms->atomname,(atoms->nr+atoms_insrt.nr*nmol_insrt));
   srenew(atoms->atom,(atoms->nr+atoms_insrt.nr*nmol_insrt));
   srenew(*x,(atoms->nr+atoms_insrt.nr*nmol_insrt));
@@ -314,7 +315,7 @@ static char *insert_mols(char *mol_insrt,int nmol_insrt,int ntry,int seed,
   while ((mol < nmol_insrt) && (try < ntry*nmol_insrt)) {
     fprintf(stderr,"\rTry %d",try++);
     for (i=0;(i<atoms_insrt.nr);i++) {
-      if (atoms_insrt.atom[i].resnr!=0) 
+      if (atoms_insrt.atom[i].resind!=0) 
        gmx_fatal(FARGS,"more then one residue in insert molecules\n"
                    "program terminated\n");
       copy_rvec(x_insrt[i],x_n[i]);
@@ -339,7 +340,7 @@ static char *insert_mols(char *mol_insrt,int nmol_insrt,int ntry,int seed,
       fprintf(stderr," success (now %d atoms)!",atoms->nr);
     }
   }
-  srenew(atoms->resname,  atoms->nres);
+  srenew(atoms->resinfo,  atoms->nres);
   srenew(atoms->atomname, atoms->nr);
   srenew(atoms->atom,     atoms->nr);
   srenew(*x,              atoms->nr);
@@ -348,7 +349,7 @@ static char *insert_mols(char *mol_insrt,int nmol_insrt,int ntry,int seed,
   fprintf(stderr,"\n");
   /* print number of molecules added */
   fprintf(stderr,"Added %d molecules (out of %d requested) of %s\n",
-         mol,nmol_insrt,*atoms_insrt.resname[0]); 
+         mol,nmol_insrt,*atoms_insrt.resinfo[0].name); 
     
   return title_insrt;
 }
@@ -377,7 +378,7 @@ static void add_solv(char *fn,t_atoms *atoms,rvec **x,rvec **v,real **r,
   snew(x_solvt,atoms_solvt->nr);
   if (v) snew(v_solvt,atoms_solvt->nr);
   snew(r_solvt,atoms_solvt->nr);
-  snew(atoms_solvt->resname,atoms_solvt->nr);
+  snew(atoms_solvt->resinfo,atoms_solvt->nr);
   snew(atoms_solvt->atomname,atoms_solvt->nr);
   snew(atoms_solvt->atom,atoms_solvt->nr);
   atoms_solvt->pdbinfo = NULL;
@@ -408,7 +409,7 @@ static void add_solv(char *fn,t_atoms *atoms,rvec **x,rvec **v,real **r,
          n_box[XX],n_box[YY],n_box[ZZ]);
   
   /* realloc atoms_solvt for the new solvent configuration */
-  srenew(atoms_solvt->resname,atoms_solvt->nres*nmol);
+  srenew(atoms_solvt->resinfo,atoms_solvt->nres*nmol);
   srenew(atoms_solvt->atomname,atoms_solvt->nr*nmol);
   srenew(atoms_solvt->atom,atoms_solvt->nr*nmol);
   srenew(x_solvt,atoms_solvt->nr*nmol);
@@ -484,15 +485,15 @@ static void update_top(t_atoms *atoms,matrix box,int NFILE,t_filenm fnm[],
   
   for(i=0; (i<atoms->nres); i++) {
     /* calculate number of SOLvent molecules */
-    if ( (strcmp(*atoms->resname[i],"SOL")==0) ||
-        (strcmp(*atoms->resname[i],"WAT")==0) ||
-        (strcmp(*atoms->resname[i],"HOH")==0) )
+    if ( (strcmp(*atoms->resinfo[i].name,"SOL")==0) ||
+        (strcmp(*atoms->resinfo[i].name,"WAT")==0) ||
+        (strcmp(*atoms->resinfo[i].name,"HOH")==0) )
       nsol++;
   }
   mtot = 0;
   for(i=0; (i<atoms->nr); i++) {
     gmx_atomprop_query(aps,epropMass,
-                      *atoms->resname[atoms->atom[i].resnr],
+                      *atoms->resinfo[atoms->atom[i].resind].name,
                       *atoms->atomname[i],&mm);
     mtot += mm;
   }
@@ -734,7 +735,7 @@ int gmx_genbox(int argc,char *argv[])
   if (!bProt) {
     atoms.nr=0;
     atoms.nres=0;
-    atoms.resname=NULL;
+    atoms.resinfo=NULL;
     atoms.atomname=NULL;
     atoms.atom=NULL;
     atoms.pdbinfo=NULL;
index 6fc29e78a7c26f80558c9b54c2abdd19f126c68b..aa9c31a81c598eb5fa4c300ba3aabcbbc2c19a63 100644 (file)
@@ -257,12 +257,15 @@ int gmx_genconf(int argc, char *argv[])
          for(m=0; (m<DIM); m++) {
            x[ndx+l][m] += shift[m];
          }
-         atoms->atom[ndx+l].resnr=(bRenum ? nrdx:0) + atoms->atom[l].resnr;
+         atoms->atom[ndx+l].resind = nrdx + atoms->atom[l].resind;
          atoms->atomname[ndx+l]=atoms->atomname[l];
        }
 
-       for(l=0; (l<nres); l++)
-         atoms->resname[nrdx+l]=atoms->resname[l];
+       for(l=0; (l<nres); l++) {
+         atoms->resinfo[nrdx+l] = atoms->resinfo[l];
+         if (bRenum)
+           atoms->resinfo[nrdx+l].nr += nrdx;
+       }
        if (bTRX)
          if (!read_next_x(status,&t,natoms,xx,boxx) && 
              ((i+1)*(j+1)*(k+1) < vol))
index 3e318776212ea2af16b737cef629af57a5304e28..7a8b73b0e56be52daf6a44de13dcd688f7185f82 100644 (file)
@@ -175,7 +175,7 @@ void sort_ions(int nsa,int nw,int repl[],atom_id index[],
   if (np+nn > 0) {
     /* Put the positive and negative ions at the end */
     starta = index[nsa*(nw - np - nn)];
-    startr = atoms->atom[starta].resnr;
+    startr = atoms->atom[starta].resind;
 
     if (np) {
       snew(pptr,1);
@@ -198,16 +198,16 @@ void sort_ions(int nsa,int nw,int repl[],atom_id index[],
        k = startr+npi;
        copy_rvec(x[index[nsa*i]],xt[j]);
        atoms->atomname[j] = paptr;
-       atoms->atom[j].resnr = k ;
-       atoms->resname[k] = pptr;
+       atoms->atom[j].resind = k ;
+       atoms->resinfo[k].name = pptr;
        npi++;
       } else if (r < 0) {
        j = starta+np+nni;
        k = startr+np+nni;
        copy_rvec(x[index[nsa*i]],xt[j]);
        atoms->atomname[j] = naptr;
-       atoms->atom[j].resnr = k;
-       atoms->resname[k] = nptr;
+       atoms->atom[j].resind = k;
+       atoms->resinfo[k].name = nptr;
        nni++;
       }
     }
@@ -436,8 +436,8 @@ int gmx_genion(int argc, char *argv[])
                  grpname,i,index[i-1]+1,i+1,index[i]+1);
     nsa = 1;
     while ((nsa<nwa) &&
-          (atoms.atom[index[nsa]].resnr ==
-           atoms.atom[index[nsa-1]].resnr))
+          (atoms.atom[index[nsa]].resind ==
+           atoms.atom[index[nsa-1]].resind))
       nsa++;
     if (nwa % nsa)
       gmx_fatal(FARGS,"Your solvent group size (%d) is not a multiple of %d",
index e922fe09c61b5c9baea4649144345fa5390c71b9..b2acbb66f79106ad728c5fb1c362b03116151821 100644 (file)
@@ -387,8 +387,9 @@ static char *mkatomname(t_atoms *atoms,int i)
   static char buf[32];
   int rnr;
   
-  rnr = atoms->atom[i].resnr;
-  sprintf(buf,"%4s%d%-4s",*atoms->resname[rnr],rnr+1,*atoms->atomname[i]);
+  rnr = atoms->atom[i].resind;
+  sprintf(buf,"%4s%d%-4s",
+         *atoms->resinfo[rnr].name,atoms->resinfo[rnr].nr,*atoms->atomname[i]);
   
   return buf;
 }
@@ -2351,8 +2352,8 @@ int gmx_hbond(int argc,char *argv[])
                            gmx_fatal(FARGS,"Invalid donor %d",i);
                          if ((ia = acceptor_index(&hb->a,ogrp,j)) == NOTSET)
                            gmx_fatal(FARGS,"Invalid acceptor %d",j);
-                         resdist=abs(top.atoms.atom[i].resnr-
-                                     top.atoms.atom[j].resnr);
+                         resdist=abs(top.atoms.atom[i].resind-
+                                     top.atoms.atom[j].resind);
                          if (resdist >= max_hx) 
                            resdist = max_hx-1;
                          hb->nhx[nframes][resdist]++;
index e4859b8ff5eddbff96207fce70f1d11d99e66869..a1ff3f1c80a43d5f5a76809399ffeafb39618c98 100644 (file)
@@ -255,7 +255,7 @@ int gmx_helix(int argc,char *argv[])
            top->atoms.nr,natoms);
            
   bb=mkbbind(ftp2fn(efNDX,NFILE,fnm),&nres,&nbb,r0,&nall,&allindex,
-            top->atoms.atomname,top->atoms.atom,top->atoms.resname);
+            top->atoms.atomname,top->atoms.atom,top->atoms.resinfo);
   snew(bbindex,natoms);
   snew(caindex,nres);
   
index 81d1ec00f2fc83612c92c448da9c4dceaf551ae7..792a00d023eeb14fb51d3c89f52d713df0eafd13 100644 (file)
@@ -67,9 +67,9 @@ int *res_ndx(t_atoms *atoms)
   if (atoms->nr <= 0)
     return NULL;
   snew(rndx,atoms->nr);
-  r0=atoms->atom[0].resnr;
+  r0=atoms->atom[0].resind;
   for(i=0; (i<atoms->nr); i++)
-    rndx[i]=atoms->atom[i].resnr-r0;
+    rndx[i]=atoms->atom[i].resind-r0;
   
   return rndx;
 }
@@ -82,10 +82,10 @@ int *res_natm(t_atoms *atoms)
   if (atoms->nr <= 0)
     return NULL;
   snew(natm,atoms->nres);
-  r0=atoms->atom[0].resnr;
+  r0=atoms->atom[0].resind;
   j=0;
   for(i=0; (i<atoms->nres); i++) {
-    while ((atoms->atom[j].resnr)-r0 == i) {
+    while ((atoms->atom[j].resind)-r0 == i) {
       natm[i]++;
       j++;
     }
@@ -223,25 +223,25 @@ int gmx_mdmat(int argc,char *argv[])
   snew(useatoms.atomname,natoms);
     
   useatoms.nres = 0;
-  snew(useatoms.resname,natoms);
+  snew(useatoms.resinfo,natoms);
   
-  prevres = top.atoms.atom[index[0]].resnr;
+  prevres = top.atoms.atom[index[0]].resind;
   newres  = 0;
   for(i=0;(i<isize);i++) {
     int ii = index[i];
     useatoms.atomname[i]=top.atoms.atomname[ii];
-    if (top.atoms.atom[ii].resnr != prevres) {
-      prevres = top.atoms.atom[ii].resnr;
+    if (top.atoms.atom[ii].resind != prevres) {
+      prevres = top.atoms.atom[ii].resind;
       newres++;
-      useatoms.resname[i] = top.atoms.resname[prevres];
+      useatoms.resinfo[i] = top.atoms.resinfo[prevres];
       if (debug) {
        fprintf(debug,"New residue: atom %5s %5s %6d, index entry %5d, newres %5d\n",
-               *(top.atoms.resname[top.atoms.atom[ii].resnr]),
+               *(top.atoms.resinfo[top.atoms.atom[ii].resind].name),
                *(top.atoms.atomname[ii]),
                ii,i,newres);
       }
     }
-    useatoms.atom[i].resnr = newres;
+    useatoms.atom[i].resind = newres;
   }
   useatoms.nres = newres+1;
   useatoms.nr = isize;
index 496e6a009d068e2baa26edeca33950234437b911..ba305c58c552d6ce7089118e92e1d80672d6e25e 100644 (file)
@@ -391,7 +391,7 @@ int find_residues(t_atoms *atoms, int n, atom_id index[], atom_id **resindex)
   presnr = NOTSET;
   snew(residx, atoms->nres);
   for(i=0; i<n; i++) {
-    resnr = atoms->atom[index[i]].resnr;
+    resnr = atoms->atom[index[i]].resind;
     if (resnr != presnr) {
       residx[nres]=i;
       nres++;
index b03654b13be379b7bc78f10e081f415f268bfd4a..97576724346e7cff207b96cb9dfa840996cc2640 100644 (file)
@@ -190,8 +190,8 @@ static void split_group(int isize,int *index,char *grpname,
        cur = mol;
       }
     } else if (type == 'r') {
-      /* Check if the residue number has changed */
-      res = atom[a].resnr;
+      /* Check if the residue index has changed */
+      res = atom[a].resind;
       if (res != cur) {
        coi[is++] = i;
        cur = res;
index 13a3159cbd6bc412157cff10d56d8496292dca19..5f8cfafeaec4260cd124b1c0c5a6b42db1485b0c 100644 (file)
@@ -268,12 +268,12 @@ static int analyze_noe_equivalent(char *eq_fn,
        /* check explicit list of equivalent atoms */
        do {
          j=i+1;
-         rnri=atoms->atom[index[i]].resnr;
-         rnrj=atoms->atom[index[j]].resnr;
+         rnri=atoms->atom[index[i]].resind;
+         rnrj=atoms->atom[index[j]].resind;
          bEquiv = 
            is_equiv(neq, equiv, &nnm[i], 
-                    rnri, *atoms->resname[rnri], *atoms->atomname[index[i]],
-                    rnrj, *atoms->resname[rnrj], *atoms->atomname[index[j]]);
+                    rnri,*atoms->resinfo[rnri].name,*atoms->atomname[index[i]],
+                    rnrj,*atoms->resinfo[rnrj].name,*atoms->atomname[index[j]]);
          if(nnm[i] && bEquiv)
            nnm[j]=strdup(nnm[i]);
          if (bEquiv) {
@@ -322,9 +322,9 @@ static int analyze_noe_equivalent(char *eq_fn,
   if (debug)
     /* dump new names */
     for(i=0; i<isize; i++) {
-      rnri=atoms->atom[index[i]].resnr;
+      rnri=atoms->atom[index[i]].resind;
       fprintf(debug,"%s %s %d -> %s\n",*atoms->atomname[index[i]],
-             *atoms->resname[rnri],rnri,nnm[i]?nnm[i]:"");
+             *atoms->resinfo[rnri].name,rnri,nnm[i]?nnm[i]:"");
     }
     
   for(i=0; i<isize; i++) {
@@ -339,8 +339,8 @@ static int analyze_noe_equivalent(char *eq_fn,
        if ( noe_index[i]==noe_index[i+1] )
          noe_gr[gi].aname[strlen(noe_gr[gi].aname)-1]='*';
       }
-      noe_gr[gi].rnr=atoms->atom[index[i]].resnr;
-      noe_gr[gi].rname=strdup(*atoms->resname[noe_gr[gi].rnr]);
+      noe_gr[gi].rnr=atoms->atom[index[i]].resind;
+      noe_gr[gi].rname=strdup(*atoms->resinfo[noe_gr[gi].rnr].name);
       /* dump group definitions */
       if (debug) fprintf(debug,"%d %d %d %d %s %s %d\n",i,gi,
                         noe_gr[gi].ianr,noe_gr[gi].anr,noe_gr[gi].aname,
index 85a34e21ce6d038caba3e01b1acff922fccbb580..69a0c1113bb94a6bb9d2193bfcaf51cbd1c8c212 100644 (file)
 #include "confio.h"
 #include "eigensolver.h"
 
-static real find_pdb_bfac(t_atoms *atoms,char *resnm,int resnr,char *atomnm)
+static real find_pdb_bfac(t_atoms *atoms,t_resinfo *ri,char *atomnm)
 {
   char rresnm[8];
   int i;
   
-  strcpy(rresnm,resnm);
+  strcpy(rresnm,*ri->name);
   rresnm[3]='\0';
   for(i=0; (i<atoms->nr); i++) {
-    if ((resnr == atoms->atom[i].resnr) &&
-       (strcmp(*atoms->resname[resnr],rresnm) == 0) &&
+    if ((ri->nr == atoms->resinfo[atoms->atom[i].resind].nr) &&
+       (ri->ic == atoms->resinfo[atoms->atom[i].resind].ic) &&
+       (strcmp(*atoms->resinfo[atoms->atom[i].resind].name,rresnm) == 0) &&
        (strstr(*atoms->atomname[i],atomnm) != NULL))
       break;
   }
   if (i == atoms->nr) {
     fprintf(stderr,"\rCan not find %s%d-%s in pdbfile\n",
-           rresnm,resnr,atomnm);
+           rresnm,ri->nr,atomnm);
     return 0.0;
   }
     
@@ -108,7 +109,7 @@ void average_residues(real f[],int isize,atom_id index[],real w_rls[],
     av += w_rls[index[i]]*f[i];
     m += w_rls[index[i]];
     if (i+1==isize || 
-       atoms->atom[index[i]].resnr!=atoms->atom[index[i+1]].resnr) {
+       atoms->atom[index[i]].resind!=atoms->atom[index[i+1]].resind) {
       av /= m;
       for(j=start; j<=i; j++)
        f[j] = av;
@@ -207,7 +208,7 @@ int gmx_rmsf(int argc,char *argv[])
   
   FILE         *fp;               /* the graphics file */
   char         *devfn,*dirfn;
-  int          resnr;
+  int          resind;
 
   bool         bReadPDB;  
   atom_id      *index;
@@ -386,13 +387,13 @@ int gmx_rmsf(int argc,char *argv[])
     xvgr_legend(fp,2,leg);
     for(i=0;(i<isize);i++) {
       if (!bRes || i+1==isize ||
-         top.atoms.atom[index[i]].resnr!=top.atoms.atom[index[i+1]].resnr) {
-       resnr    = top.atoms.atom[index[i]].resnr;
-       pdb_bfac = find_pdb_bfac(pdbatoms,*(top.atoms.resname[resnr]),resnr,
+         top.atoms.atom[index[i]].resind!=top.atoms.atom[index[i+1]].resind) {
+       resind    = top.atoms.atom[index[i]].resind;
+       pdb_bfac = find_pdb_bfac(pdbatoms,&top.atoms.resinfo[resind],
                                 *(top.atoms.atomname[index[i]]));
        
        fprintf(fp,"%5d  %10.5f  %10.5f\n",
-               bRes ? top.atoms.atom[index[i]].resnr+1 : i+1,rmsf[i]*bfac,
+               bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : i+1,rmsf[i]*bfac,
                pdb_bfac);
       }
     }
@@ -401,9 +402,9 @@ int gmx_rmsf(int argc,char *argv[])
     fp = xvgropen(ftp2fn(efXVG,NFILE,fnm),"RMS fluctuation",label,"(nm)");
     for(i=0; i<isize; i++)
       if (!bRes || i+1==isize ||
-         top.atoms.atom[index[i]].resnr!=top.atoms.atom[index[i+1]].resnr)
+         top.atoms.atom[index[i]].resind!=top.atoms.atom[index[i+1]].resind)
        fprintf(fp,"%5d %8.4f\n",
-               bRes ? top.atoms.atom[index[i]].resnr+1 : i+1,sqrt(rmsf[i]));
+               bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : i+1,sqrt(rmsf[i]));
     fclose(fp);
   }
   
@@ -419,9 +420,9 @@ int gmx_rmsf(int argc,char *argv[])
     fp = xvgropen(devfn,"RMS Deviation",label,"(nm)");
     for(i=0; i<isize; i++)
       if (!bRes || i+1==isize ||
-         top.atoms.atom[index[i]].resnr!=top.atoms.atom[index[i+1]].resnr)
+         top.atoms.atom[index[i]].resind!=top.atoms.atom[index[i+1]].resind)
        fprintf(fp,"%5d %8.4f\n",
-               bRes ? top.atoms.atom[index[i]].resnr+1 : i+1,sqrt(rmsf[i]));
+               bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : i+1,sqrt(rmsf[i]));
     fclose(fp);
   }
 
index 4f2b3d2379c611d2ada8ffddf56391526d7051e3..0fa4801d70b36164df45a5a511e13d2422eaab24 100644 (file)
@@ -77,8 +77,10 @@ static t_charge *mk_charge(t_atoms *atoms,t_block *cgs,int *nncg)
       cg[ncg].q=qq;
       cg[ncg].cg=i;
       anr=cgs->index[i];
-      resnr=atoms->atom[anr].resnr;
-      sprintf(buf,"%s%d",*(atoms->resname[resnr]),resnr+1);
+      resnr=atoms->atom[anr].resind;
+      sprintf(buf,"%s%d",
+             *(atoms->resinfo[resnr].name),
+             atoms->resinfo[resnr].nr);
       cg[ncg].label=strdup(buf);
       ncg++;
     }
index 64ad03b893d13d3f99d7f61479c0a87df0c302c2..c598b51dd08044e06b683a12d22c3554e2b843c2 100644 (file)
@@ -140,8 +140,9 @@ void connelly_plot(char *fn,int ndots,real dots[],rvec x[],t_atoms *atoms,
     r0 = atoms->nres;
     srenew(atoms->atom,atoms->nr+ndots);
     srenew(atoms->atomname,atoms->nr+ndots);
-    srenew(atoms->resname,r0+1);
-    atoms->resname[r0]  = put_symtab(symtab,resnm);
+    srenew(atoms->resinfo,r0+1);
+    atoms->atom[i0].resind = r0;
+    t_atoms_set_resinfo(atoms,i0,symtab,resnm,r0+1,' ',' ');
     srenew(atoms->pdbinfo,atoms->nr+ndots);
     snew(xnew,atoms->nr+ndots);
     for(i=0; (i<atoms->nr); i++)
@@ -149,11 +150,9 @@ void connelly_plot(char *fn,int ndots,real dots[],rvec x[],t_atoms *atoms,
     for(i=k=0; (i<ndots); i++) {
       ii0 = i0+i;
       atoms->atomname[ii0] = put_symtab(symtab,atomnm);
-      sprintf(atoms->pdbinfo[ii0].pdbresnr,"%d",r0+1);
       atoms->pdbinfo[ii0].type = epdbATOM;
-      atoms->atom[ii0].chain = ' ';
       atoms->pdbinfo[ii0].atomnr= ii0;
-      atoms->atom[ii0].resnr = r0;
+      atoms->atom[ii0].resind = r0;
       xnew[ii0][XX] = dots[k++];
       xnew[ii0][YY] = dots[k++];
       xnew[ii0][ZZ] = dots[k++];
@@ -168,16 +167,15 @@ void connelly_plot(char *fn,int ndots,real dots[],rvec x[],t_atoms *atoms,
   }
   else {
     init_t_atoms(&aaa,ndots,TRUE);
+    aaa.atom[0].resind = 0;
+    t_atoms_set_resinfo(&aaa,0,symtab,resnm,1,' ',' ');
     snew(xnew,ndots);
     for(i=k=0; (i<ndots); i++) {
       ii0 = i;
-      aaa.resname[ii0]  = put_symtab(symtab,resnm);
       aaa.atomname[ii0] = put_symtab(symtab,atomnm);
-      strcpy(aaa.pdbinfo[ii0].pdbresnr,"1");
       aaa.pdbinfo[ii0].type = epdbATOM;
-      aaa.atom[ii0].chain = ' ';
       aaa.pdbinfo[ii0].atomnr= ii0;
-      aaa.atom[ii0].resnr = 0;
+      aaa.atom[ii0].resind = 0;
       xnew[ii0][XX] = dots[k++];
       xnew[ii0][YY] = dots[k++];
       xnew[ii0][ZZ] = dots[k++];
@@ -305,7 +303,7 @@ void sas_plot(int nfile,t_filenm fnm[],real solsize,int ndots,
   ndefault = 0;
   for(i=0; (i<natoms); i++) {
     if (!gmx_atomprop_query(aps,epropVDW,
-                           *(top->atoms.resname[top->atoms.atom[i].resnr]),
+                           *(top->atoms.resinfo[top->atoms.atom[i].resind].name),
                            *(top->atoms.atomname[i]),&radius[i]))
       ndefault++;
     /* radius[i] = calc_radius(*(top->atoms.atomname[i])); */
@@ -342,12 +340,12 @@ void sas_plot(int nfile,t_filenm fnm[],real solsize,int ndots,
     }
     if (bDGsol)
       if (!gmx_atomprop_query(aps,epropDGsol,
-                             *(atoms->resname[atoms->atom[ii].resnr]),
+                             *(atoms->resinfo[atoms->atom[ii].resind].name),
                              *(atoms->atomtype[ii]),&(dgs_factor[i])))
        dgs_factor[i] = dgs_default;
     if (debug)
       fprintf(debug,"Atom %5d %5s-%5s: q= %6.3f, r= %6.3f, dgsol= %6.3f, hydrophobic= %s\n",
-             ii+1,*(atoms->resname[atoms->atom[ii].resnr]),
+             ii+1,*(atoms->resinfo[atoms->atom[ii].resind].name),
              *(atoms->atomname[ii]),
              atoms->atom[ii].q,radius[ii]-solsize,dgs_factor[i],
              BOOL(bPhobic[i]));
@@ -423,7 +421,7 @@ void sas_plot(int nfile,t_filenm fnm[],real solsize,int ndots,
        if (bResAt) {
          atom_area[i] += at_area;
          atom_area2[i] += sqr(at_area);
-         res_a[atoms->atom[ii].resnr] += at_area;
+         res_a[atoms->atom[ii].resind] += at_area;
        }
        tarea += at_area;
        if (bDGsol)
@@ -490,12 +488,13 @@ void sas_plot(int nfile,t_filenm fnm[],real solsize,int ndots,
     }
     for(i=0; i<nx[0]; i++) {
       ii = index[0][i];
-      res = atoms->atom[ii].resnr;
-      if (i==nx[0]-1 || res!=atoms->atom[index[0][i+1]].resnr) {
+      res = atoms->atom[ii].resind;
+      if (i==nx[0]-1 || res!=atoms->atom[index[0][i+1]].resind) {
        fluc2 = res_area2[res]-sqr(res_area[res]);
        if (fluc2 < 0)
          fluc2 = 0;
-       fprintf(fp,"%10d  %10g %10g\n",res+1,res_area[res],sqrt(fluc2));
+       fprintf(fp,"%10d  %10g %10g\n",
+               atoms->resinfo[res].nr,res_area[res],sqrt(fluc2));
       }
       fluc2 = atom_area2[i]-sqr(atom_area[i]);
       if (fluc2 < 0)
index f9ec64f95b6dd421860c30b2606b61b3ac533273..185edb850e14c7492f14be6c7f4127e9604508a1 100644 (file)
@@ -81,7 +81,7 @@ static void do_sdf(char *fnNDX,char *fnTPS,char *fnTRX, char *fnSDF,
   int        *isize;
   int        isize_cg=0;
   int        isize_ref=3;
-  int        ref_resnr[3];
+  int        ref_resind[3];
   int        nrefmol=0,refc=0;
   atom_id    **index;
   atom_id    *index_cg=NULL;
@@ -187,16 +187,16 @@ structure if needed */
         {
           /* check if all three atoms come from the same molecule */
           for (j=G_REF1; j<=G_REF3; j++)
-            ref_resnr[j] = top.atoms.atom[index[j][i]].resnr;
+            ref_resind[j] = top.atoms.atom[index[j][i]].resind;
 
 
-          if ( ref_resnr[G_REF1] != ref_resnr[G_REF2] ||
-                 ref_resnr[G_REF2] != ref_resnr[G_REF3] ||
-                 ref_resnr[G_REF3] != ref_resnr[G_REF1] )
+          if ( ref_resind[G_REF1] != ref_resind[G_REF2] ||
+                 ref_resind[G_REF2] != ref_resind[G_REF3] ||
+                 ref_resind[G_REF3] != ref_resind[G_REF1] )
               {
                 fprintf(stderr,"\nWarning: reference triple (%d) will be skipped.\n",i);
                 fprintf(stderr,  "         resnr[1]: %d, resnr[2]: %d, resnr[3]: %d\n",
-                        ref_resnr[G_REF1],ref_resnr[G_REF2], ref_resnr[G_REF3]);
+                        ref_resind[G_REF1],ref_resind[G_REF2], ref_resind[G_REF3]);
                 isize[NDX_REF1]--;
                 for (j=NDX_REF1; j<=NDX_REF3; j++)
                   srenew(index[j],isize[NDX_REF1]);
@@ -232,18 +232,18 @@ structure if needed */
         {
           /* check consistency for atoms 1 and 2 */
           for (j=G_REF1; j<=G_REF2; j++)
-            ref_resnr[j] = top.atoms.atom[index[j][i]].resnr;
+            ref_resind[j] = top.atoms.atom[index[j][i]].resind;
 
 
-          if ( ref_resnr[G_REF1] != ref_resnr[G_REF2] ||
+          if ( ref_resind[G_REF1] != ref_resind[G_REF2] ||
                index[G_REF1][i] == index[G_REF2][i] )
             {
-              if ( ref_resnr[G_REF1] != ref_resnr[G_REF2] )
+              if ( ref_resind[G_REF1] != ref_resind[G_REF2] )
                 {
                   fprintf(stderr,"\nWarning: bond (%d) not from one molecule."
                           "Will not be used for SDF.\n",i);
                   fprintf(stderr,  "         resnr[1]: %d, resnr[2]: %d\n",
-                          ref_resnr[G_REF1],ref_resnr[G_REF2]);
+                          ref_resind[G_REF1],ref_resind[G_REF2]);
                 }
               else
                 {
@@ -271,14 +271,14 @@ structure if needed */
 
 
       for (i=G_REF1; i<=G_REF3; i++)
-        ref_resnr[i] = top.atoms.atom[index[i][0]].resnr;
+        ref_resind[i] = top.atoms.atom[index[i][0]].resind;
 
 
       for (i=0; i<natoms; i++)
         {
-          if (  ref_resnr[G_REF1] == top.atoms.atom[i].resnr ||
-                ref_resnr[G_REF2] == top.atoms.atom[i].resnr ||
-                ref_resnr[G_REF3] == top.atoms.atom[i].resnr )
+          if (  ref_resind[G_REF1] == top.atoms.atom[i].resind ||
+                ref_resind[G_REF2] == top.atoms.atom[i].resind ||
+                ref_resind[G_REF3] == top.atoms.atom[i].resind )
             nrefmol++;
         }
       srenew(index[G_REFMOL],nrefmol);
@@ -288,9 +288,9 @@ structure if needed */
 
       for (i=0; i<natoms; i++)
         {
-          if (  ref_resnr[G_REF1] == top.atoms.atom[i].resnr ||
-                ref_resnr[G_REF2] == top.atoms.atom[i].resnr ||
-                ref_resnr[G_REF3] == top.atoms.atom[i].resnr )
+          if (  ref_resind[G_REF1] == top.atoms.atom[i].resind ||
+                ref_resind[G_REF2] == top.atoms.atom[i].resind ||
+                ref_resind[G_REF3] == top.atoms.atom[i].resind )
             {
               index[G_REFMOL][nrefmol] = i;
               nrefmol++;
@@ -360,8 +360,8 @@ structure if needed */
             for (j=0; j<isize[G_REF3]; j++)
               {
                 /* Avoid expensive stuff if possible */
-                if ( top.atoms.atom[index[G_REF1][i]].resnr != 
-                     top.atoms.atom[index[G_REF3][j]].resnr &&
+                if ( top.atoms.atom[index[G_REF1][i]].resind != 
+                     top.atoms.atom[index[G_REF3][j]].resind &&
                      index[G_REF1][i] != index[G_REF3][j] &&
                      index[G_REF2][i] != index[G_REF3][j] )
                   {
@@ -405,8 +405,8 @@ structure if needed */
             for (j=0; j<isize[G_REF2]; j++)
               {
                 /* Avoid expensive stuff if possible */
-                if ( top.atoms.atom[index[G_REF1][i]].resnr != 
-                     top.atoms.atom[index[G_REF2][j]].resnr &&
+                if ( top.atoms.atom[index[G_REF1][i]].resind != 
+                     top.atoms.atom[index[G_REF2][j]].resind &&
                      index[G_REF1][i] != index[G_REF2][j] )
                   {
                     pbc_dx(&pbc,x[index[G_REF1][i]],x[index[G_REF2][j]],dx);
@@ -416,10 +416,10 @@ structure if needed */
                       {
                         for (k=0; k<isize[G_REF3]; k++)
                           {
-                            if ( top.atoms.atom[index[G_REF1][i]].resnr != 
-                                 top.atoms.atom[index[G_REF3][k]].resnr &&
-                                 top.atoms.atom[index[G_REF2][j]].resnr != 
-                                 top.atoms.atom[index[G_REF3][k]].resnr &&
+                            if ( top.atoms.atom[index[G_REF1][i]].resind != 
+                                 top.atoms.atom[index[G_REF3][k]].resind &&
+                                 top.atoms.atom[index[G_REF2][j]].resind != 
+                                 top.atoms.atom[index[G_REF3][k]].resind &&
                                  index[G_REF1][i] != index[G_REF3][k] &&
                                  index[G_REF2][j] != index[G_REF3][k])
                               {
@@ -551,8 +551,8 @@ structure if needed */
 
       for (i=0; i<isize[G_REFMOL]; i++)
         fprintf(fp,"%5d%5s%5s%5d%8.3f%8.3f%8.3f\n",
-                top.atoms.atom[index[G_REFMOL][i]].resnr+1,
-                *(top.atoms.resname[top.atoms.atom[index[G_REFMOL][i]].resnr]),
+                top.atoms.resinfo[top.atoms.atom[index[G_REFMOL][i]].resind].nr,
+                *(top.atoms.resinfo[top.atoms.atom[index[G_REFMOL][i]].resind].name),
                 *(top.atoms.atomname[index[G_REFMOL][i]]),i+1,
                 -1*x_refmol[i][XX],-1*x_refmol[i][YY],-1*x_refmol[i][ZZ]);
       /* Inserted -1* on the line above three times */
index e62a14bfa8777de1f6ff37f5d8abb971ccf3bbb0..93e652273c37d040953705ce3a5454fbea227500 100644 (file)
@@ -387,8 +387,8 @@ static void write_pdb_bfac(char *fname,char *xname,
     
     printf("Maximum %s is %g on atom %d %s, res. %s %d\n",
           title,sqrt(max)/nfr_v,maxi+1,*(atoms->atomname[maxi]),
-          *(atoms->resname[atoms->atom[maxi].resnr]),
-          atoms->atom[maxi].resnr+1);
+          *(atoms->resinfo[atoms->atom[maxi].resind].name),
+          atoms->resinfo[atoms->atom[maxi].resind].nr);
     
     if (atoms->pdbinfo == NULL)
       snew(atoms->pdbinfo,atoms->nr);
index 35277a290d69b28104515b6c0452afb079372299..07a92ce1f69400f943696eed40dabcee232d7c40 100644 (file)
@@ -313,7 +313,7 @@ static void put_residue_com_in_box(int unitcell_enum,int ecenter,
   clear_rvec(com);
   mtot = 0;
   for(i=0; i<natoms+1; i++) {
-    if (i == natoms || (presnr != atom[i].resnr && presnr != NOTSET)) {
+    if (i == natoms || (presnr != atom[i].resind && presnr != NOTSET)) {
       /* calculate final COM */
       res_end = i;
       res_nat = res_end - res_start;
@@ -336,7 +336,7 @@ static void put_residue_com_in_box(int unitcell_enum,int ecenter,
       if (norm2(shift)) {
        if (debug)
          fprintf (debug,"\nShifting position of residue %d (atoms %u-%u) "
-                  "by %g,%g,%g\n", atom[res_start].resnr+1, 
+                  "by %g,%g,%g\n", atom[res_start].resind+1, 
                   res_start+1, res_end+1, PR_VEC(shift));
        for(j=res_start; j<res_end; j++)
          rvec_inc(x[j],shift);
@@ -354,7 +354,7 @@ static void put_residue_com_in_box(int unitcell_enum,int ecenter,
        com[d] += m*x[i][d];
       mtot += m;
 
-      presnr = atom[i].resnr;
+      presnr = atom[i].resind;
     }
   }
 }
@@ -966,12 +966,12 @@ int gmx_trjconv(int argc,char *argv[])
     if ((ftp == efGRO) || ((ftp == efG96) && bTPS) || (ftp == efPDB)) {
       /* get memory for stuff to go in pdb file */
       init_t_atoms(&useatoms,atoms->nr,FALSE);
-      sfree(useatoms.resname);
-      useatoms.resname=atoms->resname;
+      sfree(useatoms.resinfo);
+      useatoms.resinfo = atoms->resinfo;
       for(i=0;(i<nout);i++) {
        useatoms.atomname[i]=atoms->atomname[index[i]];
        useatoms.atom[i]=atoms->atom[index[i]];
-       useatoms.nres=max(useatoms.nres,useatoms.atom[i].resnr+1);
+       useatoms.nres=max(useatoms.nres,useatoms.atom[i].resind+1);
       }
       useatoms.nr=nout;
     }
index defe3c1b312633597b4f4c9754624fe3e8aecc8c..4274c5095e8fcc7e9418dcdb3c1c46bdb82404c7 100644 (file)
@@ -305,7 +305,7 @@ static void set_ahcity(int nbb,t_bb bb[])
 t_bb *mkbbind(char *fn,int *nres,int *nbb,int res0,
              int *nall,atom_id **index,
              char ***atomname,t_atom atom[],
-             char ***resname)
+             t_resinfo *resinfo)
 {
   static char * bb_nm[] = { "N", "H", "CA", "C", "O" };
 #define NBB asize(bb_nm)
@@ -317,10 +317,10 @@ t_bb *mkbbind(char *fn,int *nres,int *nbb,int res0,
   rd_index(fn,1,&gnx,index,&grpname);
   *nall=gnx;
   fprintf(stderr,"Checking group %s\n",grpname);
-  r0=r1=atom[(*index)[0]].resnr;
+  r0=r1=atom[(*index)[0]].resind;
   for(i=1; (i<gnx); i++) {
-    r0=min(r0,atom[(*index)[i]].resnr);
-    r1=max(r1,atom[(*index)[i]].resnr);
+    r0=min(r0,atom[(*index)[i]].resind);
+    r1=max(r1,atom[(*index)[i]].resind);
   }    
   rnr=r1-r0+1;
   fprintf(stderr,"There are %d residues\n",rnr);
@@ -330,8 +330,8 @@ t_bb *mkbbind(char *fn,int *nres,int *nbb,int res0,
     
   for(i=j=0; (i<gnx); i++) {
     ai=(*index)[i];
-    ri=atom[ai].resnr-r0;
-    if (strcmp(*(resname[ri]),"PRO") == 0) {
+    ri=atom[ai].resind-r0;
+    if (strcmp(*(resinfo[ri].name),"PRO") == 0) {
       if (strcmp(*(atomname[ai]),"CD") == 0)
        bb[ri].H=ai;
     }
@@ -392,8 +392,8 @@ t_bb *mkbbind(char *fn,int *nres,int *nbb,int res0,
   
   /* Set the labels */
   for(i=0; (i<rnr); i++) {
-    ri=atom[bb[i].CA].resnr;
-    sprintf(bb[i].label,"%s%d",*(resname[ri]),ri+res0);
+    ri=atom[bb[i].CA].resind;
+    sprintf(bb[i].label,"%s%d",*(resinfo[ri].name),ri+res0);
   }
   
   *nres=rnr;
index 2c6ae1e0e91aeeb31c3edaa7d46489f703cc0509..b94cae309a29fce96a3c64e8a385eebfdf9f0082 100644 (file)
@@ -99,7 +99,7 @@ extern void av_phipsi(FILE *fphi,FILE *fpsi,FILE *fphi2,FILE *fpsi2,
 extern t_bb *mkbbind(char *fn,int *nres,int *nbb,int res0,
                     int *nall,atom_id **index,
                     char ***atomname,t_atom atom[],
-                    char ***resname);
+                    t_resinfo *resinfo);
                     
 extern void do_start_end(int nres,t_bb bb[],rvec x[],int *nbb,
                         atom_id bbindex[],int *nca,atom_id caindex[],
index 5d2252d89fc3af3b25c1911ced71624ae2b1fbb7..6a57d3e8ce5fa45988576e09a8a3243ed30d1474 100644 (file)
@@ -276,9 +276,9 @@ static int select_residuenumbers(char **string,t_atoms *atoms,atom_id n1,
     parse_int(string,&up);
 
     for(i=0; i<atoms->nr; i++) {
-      resnr=atoms->atom[i].resnr;
+      resnr = atoms->resinfo[atoms->atom[i].resind].nr;
       for(j=n1; (j<=up); j++) {
-       if (resnr==j-1) {
+       if (resnr == j) {
          index[*nr]=i;
          (*nr)++;
        }
@@ -297,7 +297,7 @@ static int select_residuenumbers(char **string,t_atoms *atoms,atom_id n1,
     sprintf(gname,"r");
     do {
       for(i=0; i<atoms->nr; i++) {
-       if (atoms->atom[i].resnr==j-1) {
+       if (atoms->resinfo[atoms->atom[i].resind].nr == j) {
        index[*nr]=i;
        (*nr)++;
        }
@@ -325,9 +325,9 @@ static bool atoms_from_residuenumbers(t_atoms *atoms,int group,t_blocka *block,
       return FALSE;
     }
   for(i=0; i<atoms->nr; i++) {
-    resnr=atoms->atom[i].resnr;
+    resnr = atoms->resinfo[atoms->atom[i].resind].nr;
     for (j=j0; j<j1; j++)
-      if (block->a[j]==resnr) {
+      if (block->a[j]+1 == resnr) {
        index[*nr]=i;
        (*nr)++;
        break;
@@ -377,7 +377,7 @@ static int select_chainnames(t_atoms *atoms,int n_names,char **names,
   name[1]=0;
   *nr=0;
   for(i=0; i<atoms->nr; i++) {
-    name[0]=atoms->atom[i].chain;
+    name[0] = atoms->resinfo[atoms->atom[i].resind].chain;
     j=0; 
     while (j<n_names && !comp_name(name,names[j])) 
       j++;
@@ -434,7 +434,7 @@ static int select_residuenames(t_atoms *atoms,int n_names,char **names,
 
   *nr=0;
   for(i=0; i<atoms->nr; i++) {
-    name=*(atoms->resname[atoms->atom[i].resnr]);
+    name = *(atoms->resinfo[atoms->atom[i].resind].name);
     j=0; 
     while (j<n_names && !comp_name(name,names[j])) 
       j++;
@@ -521,7 +521,7 @@ static void split_group(t_atoms *atoms,int sel_nr,t_blocka *block,char ***gn,
                        bool bAtom)
 {
   char buf[STRLEN],*name;
-  int i,nr;
+  int i,resind;
   atom_id a,n0,n1;
 
   printf("Splitting group %d '%s' into %s\n",sel_nr,(*gn)[sel_nr],
@@ -532,9 +532,9 @@ static void split_group(t_atoms *atoms,int sel_nr,t_blocka *block,char ***gn,
   srenew(block->a,block->nra+n1-n0);
   for (i=n0; i<n1; i++) {
     a=block->a[i];
-    nr=atoms->atom[a].resnr;
-    name=*(atoms->resname[nr]);
-    if (bAtom || (i==n0) || (atoms->atom[block->a[i-1]].resnr!=nr)) { 
+    resind = atoms->atom[a].resind;
+    name = *(atoms->resinfo[resind].name);
+    if (bAtom || (i==n0) || (atoms->atom[block->a[i-1]].resind!=resind)) { 
       if (i>n0)
        block->index[block->nr]=block->nra;
       block->nr++;
@@ -543,7 +543,7 @@ static void split_group(t_atoms *atoms,int sel_nr,t_blocka *block,char ***gn,
       if (bAtom)
        sprintf(buf,"%s_%s_%u",(*gn)[sel_nr],*atoms->atomname[a],a+1);
       else
-       sprintf(buf,"%s_%s_%d",(*gn)[sel_nr],name,nr+1);
+       sprintf(buf,"%s_%s_%d",(*gn)[sel_nr],name,atoms->resinfo[resind].nr);
       (*gn)[block->nr-1]=strdup(buf);
     }
     block->a[block->nra]=a;
@@ -572,7 +572,8 @@ static int split_chain(t_atoms *atoms,rvec *x,
       srenew(end,nchain+1);
       start[nchain]=ca_start;
       while ((start[nchain]>0) && 
-            (atoms->atom[start[nchain]-1].resnr==atoms->atom[ca_start].resnr))
+            (atoms->atom[start[nchain]-1].resind ==
+             atoms->atom[ca_start].resind))
        start[nchain]--;
 
       i=ca_start;
@@ -587,7 +588,7 @@ static int split_chain(t_atoms *atoms,rvec *x,
       
       end[nchain]=ca_end;
       while ((end[nchain]+1<natoms) && 
-           (atoms->atom[end[nchain]+1].resnr==atoms->atom[ca_end].resnr)) 
+           (atoms->atom[end[nchain]+1].resind==atoms->atom[ca_end].resind)) 
        end[nchain]++;
       ca_start=end[nchain]+1;
       nchain++;
@@ -767,30 +768,33 @@ static bool parse_entry(char **string,int natoms,t_atoms *atoms,
 
 static void list_residues(t_atoms *atoms)
 {
-  int i,j,start,end,prev_resnr,resnr;
+  int i,j,start,end,prev_resind,resind;
   bool bDiff;
 
   /* Print all the residues, assuming continuous resnr count */ 
-  start = atoms->atom[0].resnr;
-  prev_resnr = start;
+  start = atoms->atom[0].resind;
+  prev_resind = start;
   for(i=0; i<atoms->nr; i++) {
-    resnr = atoms->atom[i].resnr;
-    if ((resnr != prev_resnr) || (i==atoms->nr-1)) {
-      if ((bDiff=strcmp(*atoms->resname[resnr],*atoms->resname[start])) || 
+    resind = atoms->atom[i].resind;
+    if ((resind != prev_resind) || (i==atoms->nr-1)) {
+      if ((bDiff=strcmp(*atoms->resinfo[resind].name,
+                       *atoms->resinfo[start].name)) || 
          (i==atoms->nr-1)) {
        if (bDiff)
-         end = prev_resnr;
+         end = prev_resind;
        else
-         end = resnr;
+         end = resind;
        if (end < start+3)
          for(j=start; j<=end; j++)
-           printf("%4d %-5s",j+1,*(atoms->resname[j]));
+           printf("%4d %-5s",
+                  j+1,*(atoms->resinfo[j].name));
        else
-         printf(" %4d - %4d %-5s  ",start+1,end+1,*(atoms->resname[start]));
-       start = resnr;
+         printf(" %4d - %4d %-5s  ",
+                start+1,end+1,*(atoms->resinfo[start].name));
+       start = resind;
       }
     }
-    prev_resnr = resnr;
+    prev_resind = resind;
   }   
   printf("\n");
 }