static void analyse_prot(const char ** restype,t_atoms *atoms, t_blocka *gb,char ***gn,gmx_bool bASK,gmx_bool bVerb) { /* atomnames to be used in constructing index groups: */ static const char *pnoh[] = { "H" }; static const char *pnodum[] = { "MN1", "MN2", "MCB1", "MCB2", "MCG1", "MCG2", "MCD1", "MCD2", "MCE1", "MCE2", "MNZ1", "MNZ2" }; static const char *calpha[] = { "CA" }; static const char *bb[] = { "N","CA","C" }; static const char *mc[] = { "N","CA","C","O","O1","O2","OC1","OC2","OT","OXT" }; static const char *mcb[] = { "N","CA","CB","C","O","O1","O2","OC1","OC2","OT","OXT" }; static const char *mch[] = { "N","CA","C","O","O1","O2","OC1","OC2","OT","OXT", "H1","H2","H3","H" }; /* array of arrays of atomnames: */ static const char **chains[] = { NULL,pnoh,calpha,bb,mc,mcb,mch,mch,mch,pnodum }; #define NCH asize(chains) /* array of sizes of arrays of atomnames: */ const int sizes[NCH] = { 0, asize(pnoh), asize(calpha), asize(bb), asize(mc), asize(mcb), asize(mch), asize(mch), asize(mch), asize(pnodum) }; /* descriptive names of index groups */ const char *ch_name[NCH] = { "Protein", "Protein-H", "C-alpha", "Backbone", "MainChain", "MainChain+Cb", "MainChain+H", "SideChain", "SideChain-H", "Prot-Masses" }; /* construct index group containing (TRUE) or excluding (FALSE) given atom names */ const gmx_bool complement[NCH] = { TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }; const int wholename[NCH] = { -1, 0,-1,-1,-1,-1,-1,-1, 11,-1 }; /* the index in wholename gives the first item in the arrays of * atomtypes that should be tested with 'gmx_strncasecmp' in stead of * gmx_strcasecmp, or -1 if all items should be tested with strcasecmp * This is comparable to using a '*' wildcard at the end of specific * atom names, but that is more involved to implement... */ /* only add index group if it differs from the specified one, specify -1 to always add group */ const int compareto[NCH] = { -1,-1,-1,-1,-1,-1,-1,-1,-1, 0 }; int n,j; atom_id *aid; int nra,nnpres,npres; gmx_bool match; char ndx_name[STRLEN],*atnm; int i; if (bVerb) { printf("Analysing Protein...\n"); } snew(aid,atoms->nr); /* calculate the number of protein residues */ npres=0; for(i=0; (i<atoms->nres); i++) if (!gmx_strcasecmp(restype[i],"Protein")) { npres++; } /* find matching or complement atoms */ for(i=0; (i<(int)NCH); i++) { nra=0; for(n=0; (n<atoms->nr); n++) { if (!gmx_strcasecmp(restype[atoms->atom[n].resind],"Protein")) { match=FALSE; for(j=0; (j<sizes[i]); j++) { /* skip digits at beginning of atomname, e.g. 1H */ atnm=*atoms->atomname[n]; while (isdigit(atnm[0])) atnm++; if ( (wholename[i]==-1) || (j<wholename[i]) ) { if (gmx_strcasecmp(chains[i][j],atnm) == 0) match=TRUE; } else { if (gmx_strncasecmp(chains[i][j],atnm,strlen(chains[i][j])) == 0) match=TRUE; } } if (match != complement[i]) aid[nra++]=n; } } /* if we want to add this group always or it differs from previous group, add it: */ if ( compareto[i] == -1 || !grp_cmp(gb,nra,aid,compareto[i]-i) ) add_grp(gb,gn,nra,aid,ch_name[i]); } if (bASK) { for(i=0; (i<(int)NCH); i++) { printf("Split %12s into %5d residues (y/n) ? ",ch_name[i],npres); if (gmx_ask_yesno(bASK)) { int resind; nra = 0; 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 (gmx_strcasecmp(chains[i][j],*atoms->atomname[n]) == 0) match=TRUE; if (match != complement[i]) aid[nra++]=n; } /* copy the residuename to the tail of the groupname */ if (nra > 0) { 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 resind,hold; nra = 0; for(n=0;((atoms->atom[n].resind < npres) && (n<atoms->nr));) { resind = atoms->atom[n].resind; hold = -1; for(;((atoms->atom[n].resind==resind) && (n<atoms->nr));n++) if (strcmp("CA",*atoms->atomname[n]) == 0) { aid[nra++]=n; hold=nra; nra+=2; } else if (strcmp("C",*atoms->atomname[n]) == 0) { if (hold == -1) gmx_incons("Atom naming problem"); aid[hold]=n; } else if (strcmp("O",*atoms->atomname[n]) == 0) { if (hold == -1) gmx_incons("Atom naming problem"); aid[hold+1]=n; } else if (strcmp("O1",*atoms->atomname[n]) == 0) { if (hold == -1) gmx_incons("Atom naming problem"); aid[hold+1]=n; } else aid[nra++]=n; } /* copy the residuename to the tail of the groupname */ if (nra > 0) { add_grp(gb,gn,nra,aid,"SwapSC-CO"); nra = 0; } } } sfree(aid); }
static void analyse_prot(const char ** restype, t_atoms *atoms, t_blocka *gb, char ***gn, gmx_bool bASK, gmx_bool bVerb) { /* lists of atomnames to be used in constructing index groups: */ static const char *pnoh[] = { "H", "HN" }; static const char *pnodum[] = { "MN1", "MN2", "MCB1", "MCB2", "MCG1", "MCG2", "MCD1", "MCD2", "MCE1", "MCE2", "MNZ1", "MNZ2" }; static const char *calpha[] = { "CA" }; static const char *bb[] = { "N", "CA", "C" }; static const char *mc[] = { "N", "CA", "C", "O", "O1", "O2", "OC1", "OC2", "OT", "OXT" }; static const char *mcb[] = { "N", "CA", "CB", "C", "O", "O1", "O2", "OC1", "OC2", "OT", "OXT" }; static const char *mch[] = { "N", "CA", "C", "O", "O1", "O2", "OC1", "OC2", "OT", "OXT", "H1", "H2", "H3", "H", "HN" }; static const t_gmx_help_make_index_group constructing_data[] = {{ NULL, 0, "Protein", TRUE, -1, -1}, { pnoh, asize(pnoh), "Protein-H", TRUE, 0, -1}, { calpha, asize(calpha), "C-alpha", FALSE, -1, -1}, { bb, asize(bb), "Backbone", FALSE, -1, -1}, { mc, asize(mc), "MainChain", FALSE, -1, -1}, { mcb, asize(mcb), "MainChain+Cb", FALSE, -1, -1}, { mch, asize(mch), "MainChain+H", FALSE, -1, -1}, { mch, asize(mch), "SideChain", TRUE, -1, -1}, { mch, asize(mch), "SideChain-H", TRUE, 11, -1}, { pnodum, asize(pnodum), "Prot-Masses", TRUE, -1, 0}, }; const int num_index_groups = asize(constructing_data); int n, j; atom_id *aid; int nra, nnpres, npres; gmx_bool match; char ndx_name[STRLEN], *atnm; int i; if (bVerb) { printf("Analysing Protein...\n"); } snew(aid, atoms->nr); /* calculate the number of protein residues */ npres = 0; for (i = 0; (i < atoms->nres); i++) { if (0 == gmx_strcasecmp(restype[i], "Protein")) { npres++; } } /* find matching or complement atoms */ for (i = 0; (i < (int)num_index_groups); i++) { nra = 0; for (n = 0; (n < atoms->nr); n++) { if (0 == gmx_strcasecmp(restype[atoms->atom[n].resind], "Protein")) { match = FALSE; for (j = 0; (j < constructing_data[i].num_defining_atomnames); j++) { /* skip digits at beginning of atomname, e.g. 1H */ atnm = *atoms->atomname[n]; while (isdigit(atnm[0])) { atnm++; } if ( (constructing_data[i].wholename == -1) || (j < constructing_data[i].wholename) ) { if (0 == gmx_strcasecmp(constructing_data[i].defining_atomnames[j], atnm)) { match = TRUE; } } else { if (0 == gmx_strncasecmp(constructing_data[i].defining_atomnames[j], atnm, strlen(constructing_data[i].defining_atomnames[j]))) { match = TRUE; } } } if (constructing_data[i].bTakeComplement != match) { aid[nra++] = n; } } } /* if we want to add this group always or it differs from previous group, add it: */ if (-1 == constructing_data[i].compareto || !grp_cmp(gb, nra, aid, constructing_data[i].compareto-i) ) { add_grp(gb, gn, nra, aid, constructing_data[i].group_name); } } if (bASK) { for (i = 0; (i < (int)num_index_groups); i++) { printf("Split %12s into %5d residues (y/n) ? ", constructing_data[i].group_name, npres); if (gmx_ask_yesno(bASK)) { int resind; nra = 0; 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 < constructing_data[i].num_defining_atomnames); j++) { if (0 == gmx_strcasecmp(constructing_data[i].defining_atomnames[j], *atoms->atomname[n])) { match = TRUE; } } if (constructing_data[i].bTakeComplement != match) { aid[nra++] = n; } } /* copy the residuename to the tail of the groupname */ if (nra > 0) { t_resinfo *ri; ri = &atoms->resinfo[resind]; sprintf(ndx_name, "%s_%s%d%c", constructing_data[i].group_name, *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 resind, hold; nra = 0; for (n = 0; ((atoms->atom[n].resind < npres) && (n < atoms->nr)); ) { resind = atoms->atom[n].resind; hold = -1; for (; ((atoms->atom[n].resind == resind) && (n < atoms->nr)); n++) { if (strcmp("CA", *atoms->atomname[n]) == 0) { aid[nra++] = n; hold = nra; nra += 2; } else if (strcmp("C", *atoms->atomname[n]) == 0) { if (hold == -1) { gmx_incons("Atom naming problem"); } aid[hold] = n; } else if (strcmp("O", *atoms->atomname[n]) == 0) { if (hold == -1) { gmx_incons("Atom naming problem"); } aid[hold+1] = n; } else if (strcmp("O1", *atoms->atomname[n]) == 0) { if (hold == -1) { gmx_incons("Atom naming problem"); } aid[hold+1] = n; } else { aid[nra++] = n; } } } /* copy the residuename to the tail of the groupname */ if (nra > 0) { add_grp(gb, gn, nra, aid, "SwapSC-CO"); nra = 0; } } } sfree(aid); }