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 */
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__))
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: */
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
#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);
/* 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 */
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 */
/* 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;
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)) {
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;
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]);
}
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]);
}
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;
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;
}
}
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);
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)
bool bFirst,bVel;
char *p1,*p2,*p3;
- newres = 0;
+ newres = -1;
oldres = NOTSET; /* Unlikely number for the first residue! */
ddist = 0;
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);
}
}
}
- atoms->nres=newres;
+ atoms->nres = newres + 1;
/* box */
fgets2 (line,STRLEN,in);
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);
}
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);
fr->bBox = TRUE;
sfree(atoms.atom);
- sfree(atoms.resname);
+ sfree(atoms.resinfo);
sfree(atoms.atomname);
if ((p=strstr(title,"t=")) != NULL) {
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);
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,
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;
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;
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++)
gmx_step_t s;
double d,x;
real *ptr;
- unsigned char *ucptr;
+ unsigned char uc,*ucptr;
char *cptr;
check_nitem();
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;
case eioGMX_STEP_T:
size = sizeof(gmx_step_t);
break;
+ case eioUCHAR:
+ size = sizeof(unsigned char);
+ break;
case eioNUCHAR:
size = sizeof(unsigned char);
break;
case eioGMX_STEP_T:
size = sizeof(gmx_step_t);
break;
+ case eioUCHAR:
+ size = sizeof(unsigned char);
+ break;
case eioNUCHAR:
size = sizeof(unsigned char);
break;
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];
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;
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;
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)
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;
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;
}
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 */
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)
}
/* 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;
}
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;
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)
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;
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;
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
int mblock;
t_atoms *atoms;
int mol;
- int resnr_offset;
+ int resnr_last;
int at_local;
int at_global;
} t_gmx_mtop_atomloop_all;
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;
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)
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,
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)
(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;
}
}
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;
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);
}
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++;
}
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;
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;
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);
}
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]);
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)",
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 */
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;
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);
#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
* 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.
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)
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)
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);
}
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);
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';
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,
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);
}
}
+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;
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);
}
}
}
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);
}
}
}
}
-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);
at->nr = 0;
at->nres = 0;
at->atom = NULL;
- at->resname = NULL;
+ at->resinfo = NULL;
at->atomname = NULL;
at->atomtype = NULL;
at->atomtypeB= NULL;
at->nr = 0;
at->nres = 0;
sfree(at->atom);
- sfree(at->resname);
+ sfree(at->resinfo);
sfree(at->atomname);
}
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);
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;
*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);
nidih++;
}
}
- while ((start<atoms->nr) && (atoms->atom[start].resnr==i))
+ while ((start<atoms->nr) && (atoms->atom[start].resind == i))
start++;
}
}
}
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],"");
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++) {
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 {
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 {
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;
}
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;
}
(*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];
}
(*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: */
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;
/* 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. */
* 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++;
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] */
__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 */
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];
}
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);
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);
}
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);
*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;
}
/* 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);
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");
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 */
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) {
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
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;
}
}
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]);
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);
}
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;
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;
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]);
}
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) );
}
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");
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]);
}
}
}
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;
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;
}
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;
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;
}
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]);
}
}
}
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);
}
}
}
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);
}
}
}
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)
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;
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"
}
}
/* 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];
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];
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;
/* 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);
*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;
}
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;
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");
}
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 {
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)
*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);
}
}
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++)
* (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");
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");
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));
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;
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++;
}
}
/* 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;
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");
}
/* } */
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;
nmissat = 0;
- resnr=-1;
+ resind=-1;
bProt=FALSE;
bNterm=FALSE;
i0=0;
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)
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;
}
}
-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;
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;
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]);
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);
}
}
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;
/* 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++)
"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)
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
#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);
}
}
}
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;
}
* 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 */
-/*\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;
+}
+
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;
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,
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++;
}
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");
/* 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);
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;
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;
* 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; */
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
*/
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;
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);
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;
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;
}
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);
}
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])) {
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);
}
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]];
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[],
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]),
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++) {
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];
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;
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);
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;
}
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)++;
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;
(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);
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);
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 */
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);
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;
/* 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;
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)
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))) {
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;
}
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);
}
}
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++;
}
}
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)
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];
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] =
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++)
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
}
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;
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++;
}
{
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;
}
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;
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;
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) {
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;
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);
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]]);
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);
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);
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");
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;
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)
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);
}
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;
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;
}
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);
/* 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;
}
}
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)
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;
}
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;
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);
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];
/* 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;
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) {
/* 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;
&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));
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]);
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);
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;
}
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;
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);
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;
}
if (!bProt) {
atoms.nr=0;
atoms.nres=0;
- atoms.resname=NULL;
+ atoms.resinfo=NULL;
atoms.atomname=NULL;
atoms.atom=NULL;
atoms.pdbinfo=NULL;
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))
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);
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++;
}
}
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",
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;
}
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]++;
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);
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;
}
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++;
}
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;
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++;
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;
/* 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) {
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++) {
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,
#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;
}
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;
FILE *fp; /* the graphics file */
char *devfn,*dirfn;
- int resnr;
+ int resind;
bool bReadPDB;
atom_id *index;
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);
}
}
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);
}
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);
}
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++;
}
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++)
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++];
}
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++];
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])); */
}
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]));
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)
}
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)
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;
{
/* 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]);
{
/* 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
{
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);
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++;
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] )
{
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);
{
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])
{
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 */
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);
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;
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);
com[d] += m*x[i][d];
mtot += m;
- presnr = atom[i].resnr;
+ presnr = atom[i].resind;
}
}
}
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;
}
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)
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);
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;
}
/* 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;
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[],
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)++;
}
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)++;
}
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;
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++;
*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++;
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],
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++;
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;
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;
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++;
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");
}