diff --git a/proflex/prog/first/src/c++/fixbabel.cpp b/proflex/prog/first/src/c++/fixbabel.cpp index a55b84b..94a6c46 100755 --- a/proflex/prog/first/src/c++/fixbabel.cpp +++ b/proflex/prog/first/src/c++/fixbabel.cpp @@ -1,24 +1,23 @@ /******************************************************************************* -* MSU ProFlex, formerly called FIRST, is a software developed to predict and * -* analyze protein flexibility. * -* This source file is a part of MSU ProFlex. * -* * -* Copyright (C) 1997 - 2008, Michigan State University. * -* * -* This program is free software; you can redistribute to academic users only, * -* it and/or modify it under the terms of the GNU General Public License, * -* version 2, as published by the Free Software Foundation. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, * -* or see http://www.gnu.org/licenses/gpl.txt * -*******************************************************************************/ + * MSU ProFlex, formerly called FIRST, is a software developed to predict and * + * analyze protein flexibility. * This source file is a part of MSU ProFlex. * + * * + * Copyright (C) 1997 - 2008, Michigan State University. * + * * + * This program is free software; you can redistribute to academic users only, + ** it and/or modify it under the terms of the GNU General Public License, * + * version 2, as published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * but + *WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General + *Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * along + *with this program; if not, write to the Free Software * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, * + * or see http://www.gnu.org/licenses/gpl.txt * + *******************************************************************************/ /**********************************************************************/ /* THIS IS A C++ CODE FOR FIX_BABEL */ @@ -28,199 +27,198 @@ /* Dec 31 2003, Sameer : A temporary fix to prevent debug msgs */ /* on stdout using DEBUG define */ /* arrays) of a protein, based on the chemistry of the covalent, salt */ -/* and hydrogen bonds present. */ -/* Last revision 6.27.00 by AJR */ +/* and hydrogen bonds present. */ +/* Last revision 6.27.00 by AJR */ /* PorousCity aka FIRSTweb version, revised AJR 4.10.01 */ /* modified 03.20.02 by AJR --added search for hydrophobics */ /**********************************************************************/ /**********************************************************************/ void residue::get_residue(char *temp_res) { - int i,j; + int i, j; - strcpy( rname, temp_res ); + strcpy(rname, temp_res); ifil >> natom_sum; - occu[0] =- 1; + occu[0] = -1; - for( i = 1; i <= natom_sum; i++ ) { - occu[i] =- 1; + for (i = 1; i <= natom_sum; i++) { + occu[i] = -1; ifil >> A_type[i]; - if( strlen(A_type[i]) == 1 ) { - A_type[i][1] = ' '; + if (strlen(A_type[i]) == 1) { + A_type[i][1] = ' '; A_type[i][2] = ' '; A_type[i][3] = '\0'; - } - else { - if( strlen(A_type[i]) == 2 ) { - A_type[i][2] = ' '; - A_type[i][3] = '\0'; + } else { + if (strlen(A_type[i]) == 2) { + A_type[i][2] = ' '; + A_type[i][3] = '\0'; } - } + } ifil >> A_mult[i]; - for( j = 1; j <= A_mult[i]; j++ ) { + for (j = 1; j <= A_mult[i]; j++) { ifil >> A_link[i][j]; } } - } /**********************************************************************/ - /**********************************************************************/ void list::make_connectivity(int usage) { - int natom = 0, i, j, k, flag = 0, xh_count = 0, atom_found = 0; - int ma_count = 0, rnumber, nsulfur = 0, ns_bond, nhydro = 0; - int flag8 = 0, **temp_link,loop_flag=1,flag17=0, oxtflag=0; - int so,sf,prev_occu=-1,bond_oxt[500][2],n_oxt=0,oflag[chaincount]; - int flag7=0,iix,iiy,iiz,ix,iy,iz,ua_count=0,count=0; - int label[1000], m,a,jx,jy,jz,flag9=0,flag10,kx,ky,kz,flag12=0; - int **u_nrot_bond,u_nrot_bond_count=0,ret_val=0,q,**chk_bond; - int chk_bond_count=0,**poor_bond,poor_bond_count=0; - int *skip_nhydro,skip_nhydro_count=0,*skip_hydro,skip_hydro_count=0; - int *missing,all_iso=0,O_iso=0,n; - float temp,dist[1000],**sxyz,no_bonds=0,*chk_bond_dist,*poor_bond_dist,factor; - char name[4],type[3],**atype,ans, line[80], **missing_atoms; - std::string dash1 ="------------------------------------------------------------"; - std::string dash2 ="-----------"; - std::string dash3 ="--------------------"; - - node *tempo,*res_ptr,*A_ptr[1000],*unknown_atom[100000],*x_hydro[10000]; - - ofstream xofil,yofil,zofil,vofil,wofil,uofil,test_file; + int natom = 0, i, j, k, flag = 0, xh_count = 0, atom_found = 0; + int ma_count = 0, rnumber, nsulfur = 0, ns_bond, nhydro = 0; + int flag8 = 0, **temp_link, loop_flag = 1, flag17 = 0, oxtflag = 0; + int so, sf, prev_occu = -1, bond_oxt[500][2], n_oxt = 0, oflag[chaincount]; + int flag7 = 0, iix, iiy, iiz, ix, iy, iz, ua_count = 0, count = 0; + int label[1000], m, a, jx, jy, jz, flag9 = 0, flag10, kx, ky, kz, flag12 = 0; + int **u_nrot_bond, u_nrot_bond_count = 0, ret_val = 0, q, **chk_bond; + int chk_bond_count = 0, **poor_bond, poor_bond_count = 0; + int *skip_nhydro, skip_nhydro_count = 0, *skip_hydro, skip_hydro_count = 0; + int *missing, all_iso = 0, O_iso = 0, n; + float temp, dist[1000], **sxyz, no_bonds = 0, *chk_bond_dist, *poor_bond_dist, + factor; + char name[4], type[3], **atype, ans, line[80], **missing_atoms; + std::string dash1 = + "------------------------------------------------------------"; + std::string dash2 = "-----------"; + std::string dash3 = "--------------------"; + + node *tempo, *res_ptr, *A_ptr[1000], *unknown_atom[100000], *x_hydro[10000]; + + ofstream xofil, yofil, zofil, vofil, wofil, uofil, test_file; ifstream sofil; - - ofil<<"*********** "<> line; - for( j = 0; j < lookup_atoms; j++) { - sofil >> distance[k][j].d[i]; + for (j = 0; j < lookup_atoms; j++) { + sofil >> distance[k][j].d[i]; } } } /************************************************************/ /* Setting the resolution for the distances. */ - for( k = 0; k < lookup_atoms; k++) { - for( j = 0; j < lookup_atoms; j++) { - factor = (resolution/100)*(distance[k][j].d[2]-distance[k][j].d[1]); - distance[k][j].d[0] -= 1.1*factor; + for (k = 0; k < lookup_atoms; k++) { + for (j = 0; j < lookup_atoms; j++) { + factor = (resolution / 100) * (distance[k][j].d[2] - distance[k][j].d[1]); + distance[k][j].d[0] -= 1.1 * factor; distance[k][j].d[1] -= factor; distance[k][j].d[2] += factor; - distance[k][j].d[3] += 1.1*factor; + distance[k][j].d[3] += 1.1 * factor; } } /************************************************************/ /* Start processing each group. */ /************************************************************/ - tempo = last; //reset the linked list of atom records to the beginning + tempo = last; // reset the linked list of atom records to the beginning - while(1) { + while (1) { - if( strncmp(tempo->r1.field1,"TER",3) == 0 ) { - if( tempo == start ) { - loop_flag = 0; - break; + if (strncmp(tempo->r1.field1, "TER", 3) == 0) { + if (tempo == start) { + loop_flag = 0; + break; } tempo = tempo->prior; - if( tempo == start ) { - loop_flag = 0; - break; + if (tempo == start) { + loop_flag = 0; + break; } } - if( loop_flag == 0 ) + if (loop_flag == 0) break; flag17 = 0; @@ -234,1587 +232,1444 @@ void list::make_connectivity(int usage) { /* Compare the current atom's residue type to see if it is */ /* one of the "standard" residue types stored in */ /* /lib/residue.lib */ - for(size_t III = 0; III < res_count; III++) { - if( strcmp(res_ptr->r1.rname,res[III].rname) == 0 ) { - flag = 1; - rnumber = III; - break; + for (size_t III = 0; III < res_count; III++) { + if (strcmp(res_ptr->r1.rname, res[III].rname) == 0) { + flag = 1; + rnumber = III; + break; } - } + } /************************************************************/ - + /************************************************************/ /* If the atom belongs to a residue type listed in /lib/ */ /* residue.lib . */ /************************************************************/ - if( flag == 1 ) { - if( prev_occu == 1 ) { - res[rnumber].occu[0] = 1; + if (flag == 1) { + if (prev_occu == 1) { + res[rnumber].occu[0] = 1; } - while(tempo->r1.mod_res_no == res_ptr->r1.mod_res_no && - strcmp(tempo->r1.chain,res_ptr->r1.chain) == 0 ) { - - //------------------------------------------------proces record of KNOWN group - //--------------------------------------------------for non-hyro - strcpy( atype[tempo->r1.ri_sr_no], tempo->r1.aname ); - p[tempo->r1.ri_sr_no] = tempo; - for( i = 1; i < 4; i++) { - sxyz[tempo->r1.ri_sr_no][i] = tempo->r1.coord[i]; - } - - /************************************************************/ - /* Initialize the linked-list hash table for searching for */ - /* nearby atoms in 3D. */ - /************************************************************/ - iix = (int)((tempo->r1.coord[1]-xmin)/grdlen); - iiy = (int)((tempo->r1.coord[2]-ymin)/grdlen); - iiz = (int)((tempo->r1.coord[3]-zmin)/grdlen); - ix = iix%32; - iy = iiy%32; - iz = iiz%32; - chain[tempo->r1.ri_sr_no] = grid[ix][iy][iz]; - grid[ix][iy][iz] = tempo->r1.ri_sr_no; - - if( tempo->r1.aname[2] != 'H' && - tempo->r1.aname[2] != 'D') { - // AJR 05.13.02 deal with labeling of known amino acid residue as O' instead of O: relabel - if( strcmp(tempo->r1.aname," O' ") == 0 && - tempo->r1.field1[0] == 'A') { - strcpy(p[tempo->r1.ri_sr_no]->r1.aname," O "); - strcpy(atype[tempo->r1.ri_sr_no],tempo->r1.aname); - } - name[0] = tempo->r1.aname[2]; - name[1] = tempo->r1.aname[3]; - name[2] = tempo->r1.aname[4]; - name[3] = '\0'; - - for( i = 1; i <= res[rnumber].natom_sum; i++) { - if(strcmp( name, res[rnumber].A_type[i]) == 0 && - res[rnumber].occu[i] != 1) { - flag17 = 1; - A_ptr[i] = tempo; - atom_found = 1; //---------known non-hydrogen atom - res[rnumber].occu[i] = 1; - natom++; - if(tempo->r1.aname[2]=='S') { //identify sulfur atoms - nsulfur++; - if( nsulfur > 1000 ) { - cout<<"Number of S atoms greater than 1000"<r1.aname[2] == 'S') { //identify sulfur atoms - nsulfur++; - if( nsulfur > 1000 ) { - cout<<"Number of S atoms greater than 1000"<r1.aname," OT1") == 0 || - strcmp(tempo->r1.aname," OT2") == 0 || - strcmp(tempo->r1.aname," O''") == 0) { // AJR 05.13.02 just rewrite as OXT - strcpy(p[tempo->r1.ri_sr_no]->r1.aname," OXT"); - } - if(strcmp(tempo->r1.aname," OXT")!=0 ) { - /*if(strcmp(tempo->r1.aname," OXT")!=0 && - strcmp(tempo->r1.aname," OT1")!=0 && - strcmp(tempo->r1.aname," OT2")!=0)*/ - ua_count++; - unknown_atom[ua_count]=tempo; - } - else { - n_oxt++; - so = tempo->r1.ri_sr_no; - for( j = 1; j <= res[rnumber].natom_sum; j++) { - if( strcmp(res[rnumber].A_type[j],"C ") == 0 ) { - sf = A_ptr[j]->r1.ri_sr_no; - } - } - if( n_oxt > 500 ) { - cout<<"No. of OXT atoms greater than 500"<prior; - if( strcmp(tempo->r1.field1,"TER ") == 0 ) { - if( tempo == start ) { - loop_flag = 0; - break; - } - tempo = tempo->prior; - if( tempo == start ) { - loop_flag = 0; - break; - } - } - } - else { - loop_flag = 0; - break; - } + while (tempo->r1.mod_res_no == res_ptr->r1.mod_res_no && + strcmp(tempo->r1.chain, res_ptr->r1.chain) == 0) { + + //------------------------------------------------proces record of KNOWN + //group + //--------------------------------------------------for non-hyro + strcpy(atype[tempo->r1.ri_sr_no], tempo->r1.aname); + p[tempo->r1.ri_sr_no] = tempo; + for (i = 1; i < 4; i++) { + sxyz[tempo->r1.ri_sr_no][i] = tempo->r1.coord[i]; + } + + /************************************************************/ + /* Initialize the linked-list hash table for searching for */ + /* nearby atoms in 3D. */ + /************************************************************/ + iix = (int)((tempo->r1.coord[1] - xmin) / grdlen); + iiy = (int)((tempo->r1.coord[2] - ymin) / grdlen); + iiz = (int)((tempo->r1.coord[3] - zmin) / grdlen); + ix = iix % 32; + iy = iiy % 32; + iz = iiz % 32; + chain[tempo->r1.ri_sr_no] = grid[ix][iy][iz]; + grid[ix][iy][iz] = tempo->r1.ri_sr_no; + + if (tempo->r1.aname[2] != 'H' && tempo->r1.aname[2] != 'D') { + // AJR 05.13.02 deal with labeling of known amino acid residue as O' + // instead of O: relabel + if (strcmp(tempo->r1.aname, " O' ") == 0 && + tempo->r1.field1[0] == 'A') { + strcpy(p[tempo->r1.ri_sr_no]->r1.aname, " O "); + strcpy(atype[tempo->r1.ri_sr_no], tempo->r1.aname); + } + name[0] = tempo->r1.aname[2]; + name[1] = tempo->r1.aname[3]; + name[2] = tempo->r1.aname[4]; + name[3] = '\0'; + + for (i = 1; i <= res[rnumber].natom_sum; i++) { + if (strcmp(name, res[rnumber].A_type[i]) == 0 && + res[rnumber].occu[i] != 1) { + flag17 = 1; + A_ptr[i] = tempo; + atom_found = 1; //---------known non-hydrogen atom + res[rnumber].occu[i] = 1; + natom++; + if (tempo->r1.aname[2] == 'S') { // identify sulfur atoms + nsulfur++; + if (nsulfur > 1000) { + cout << "Number of S atoms greater than 1000" << endl; + exit(-1); + } + s_ptr[nsulfur] = tempo; + } + break; + } + } + + if (flag17 != 1) { + for (i = 1; i <= res[rnumber].natom_sum; i++) { + type[0] = res[rnumber].A_type[i][0]; + type[1] = res[rnumber].A_type[i][1]; + type[2] = '\0'; + if (strncmp(name, type, 2) == 0 && res[rnumber].occu[i] != 1) { + A_ptr[i] = tempo; + atom_found = 1; //---------known non-hydrogen atom + res[rnumber].occu[i] = 1; + natom++; + if (tempo->r1.aname[2] == 'S') { // identify sulfur atoms + nsulfur++; + if (nsulfur > 1000) { + cout << "Number of S atoms greater than 1000" << endl; + exit(-1); + } + s_ptr[nsulfur] = tempo; + } + break; + } + } + } + flag17 = 0; + + if (atom_found != 1) { //-------------------extra atoms + if (strcmp(tempo->r1.aname, " OT1") == 0 || + strcmp(tempo->r1.aname, " OT2") == 0 || + strcmp(tempo->r1.aname, " O''") == + 0) { // AJR 05.13.02 just rewrite as OXT + strcpy(p[tempo->r1.ri_sr_no]->r1.aname, " OXT"); + } + if (strcmp(tempo->r1.aname, " OXT") != 0) { + /*if(strcmp(tempo->r1.aname," OXT")!=0 && + strcmp(tempo->r1.aname," OT1")!=0 && + strcmp(tempo->r1.aname," OT2")!=0)*/ + ua_count++; + unknown_atom[ua_count] = tempo; + } else { + n_oxt++; + so = tempo->r1.ri_sr_no; + for (j = 1; j <= res[rnumber].natom_sum; j++) { + if (strcmp(res[rnumber].A_type[j], "C ") == 0) { + sf = A_ptr[j]->r1.ri_sr_no; + } + } + if (n_oxt > 500) { + cout << "No. of OXT atoms greater than 500" << endl; + exit(12); + } + bond_oxt[n_oxt][0] = so; + bond_oxt[n_oxt][1] = sf; + } + } + atom_found = 0; + } else { + nhydro++; + h_ptr[nhydro] = tempo; + } + if (tempo != start) { + tempo = tempo->prior; + if (strcmp(tempo->r1.field1, "TER ") == 0) { + if (tempo == start) { + loop_flag = 0; + break; + } + tempo = tempo->prior; + if (tempo == start) { + loop_flag = 0; + break; + } + } + } else { + loop_flag = 0; + break; + } } -//------------------End of group - Now work with known group------------------// - -//--------------------------------------connectivity table for NON-Hydrogen atoms - for( i = 1; i <= res[rnumber].natom_sum; i++) { - if( res[rnumber].occu[i] == 1 ) { - for( j = 1; j <= res[rnumber].A_mult[i]; j++) { - if( res[rnumber].occu[res[rnumber].A_link[i][j]] == 1 ) { - so = A_ptr[i]->r1.ri_sr_no; - sf = A_ptr[res[rnumber].A_link[i][j]]->r1.ri_sr_no; - temp = 0; - for( k = 1; k < 4; k++) { - temp += pow((sxyz[so][k]-sxyz[sf][k]),2); - } - temp = sqrt(temp); - - // check distance criteria before connecting 2 residues - if( i == 1 ) { - if( strcmp(p[so]->r1.chain, p[sf]->r1.chain) == 0 ) { - ret_val=check_dist(so,sf,temp,atype[so],atype[sf],1,p[so]->r1.rname, - p[so]->r1.res_no,p[so]->r1.code,p[so]->r1.chain, - p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code, - p[sf]->r1.chain,usage); - if( ret_val == 1 ) { - make_connection(mult,temp_link,so,sf); - // record N=C Non-rotating bond between consecutive residues - no_bonds += 1; - nrot_bond_count++; - nrot_bond[nrot_bond_count][1]=so; - nrot_bond[nrot_bond_count][2]=sf; - } - else { - poor_bond_count++; - poor_bond[poor_bond_count][1]=so; - poor_bond[poor_bond_count][2]=sf; - poor_bond_dist[poor_bond_count]=temp; - } - } - else { - ret_val=check_dist(so,sf,temp,atype[so],atype[sf],3,p[so]->r1.rname, - p[so]->r1.res_no,p[so]->r1.code,p[so]->r1.chain, - p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code, - p[sf]->r1.chain,usage); - if( ret_val == 1 ) { - make_connection(mult,temp_link,so,sf); - // record N=C Non-rotating bond between consecutive residues - no_bonds += 1; - nrot_bond_count++; - nrot_bond[nrot_bond_count][1]=so; - nrot_bond[nrot_bond_count][2]=sf; - } - else { - poor_bond_count++; - poor_bond[poor_bond_count][1]=so; - poor_bond[poor_bond_count][2]=sf; - poor_bond_dist[poor_bond_count]=temp; - } - } - - } - else { - ret_val=check_dist(so,sf,temp,atype[so],atype[sf],1,p[so]->r1.rname, - p[so]->r1.res_no,p[so]->r1.code,p[so]->r1.chain, - p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code, - p[sf]->r1.chain,usage); - - if( ret_val == 1 ) { - // Special case: ARG for non-rotating bonds - if( strcmp( res[rnumber].rname, "ARG" ) == 0 ) { - if( strcmp(atype[so]," CZ ") == 0 ) { - if(strcmp(atype[sf]," NH1") == 0 || strcmp(atype[sf]," NH2") == 0 || - strcmp(atype[sf]," NE ") == 0) { - nrot_bond_count++; - nrot_bond[nrot_bond_count][1] = so; - nrot_bond[nrot_bond_count][2] = sf; - } - } - if( strcmp(atype[sf]," CZ ") == 0 ) { - if(strcmp(atype[so]," NH1") == 0 || - strcmp(atype[so]," NH2") == 0 || - strcmp(atype[so]," NE ") == 0) { - nrot_bond_count++; - nrot_bond[nrot_bond_count][1]=so; - nrot_bond[nrot_bond_count][2]=sf; - } - } - } - // End Special case: ARG for non-rotating bonds - - make_connection( mult, temp_link, so, sf ); - no_bonds += 1; - } - else { - poor_bond_count++; - poor_bond[poor_bond_count][1] = so; - poor_bond[poor_bond_count][2]=sf; - poor_bond_dist[poor_bond_count]=temp; - } - } - } - } - } - else { - ma_count++; //---------------missing atoms - missing[ma_count] = res_ptr->r1.ri_sr_no; - strcpy( missing_atoms[ma_count], res[rnumber].A_type[i] ); - } + //------------------End of group - Now work with known + //group------------------// + + //--------------------------------------connectivity table for + //NON-Hydrogen atoms + for (i = 1; i <= res[rnumber].natom_sum; i++) { + if (res[rnumber].occu[i] == 1) { + for (j = 1; j <= res[rnumber].A_mult[i]; j++) { + if (res[rnumber].occu[res[rnumber].A_link[i][j]] == 1) { + so = A_ptr[i]->r1.ri_sr_no; + sf = A_ptr[res[rnumber].A_link[i][j]]->r1.ri_sr_no; + temp = 0; + for (k = 1; k < 4; k++) { + temp += pow((sxyz[so][k] - sxyz[sf][k]), 2); + } + temp = sqrt(temp); + + // check distance criteria before connecting 2 residues + if (i == 1) { + if (strcmp(p[so]->r1.chain, p[sf]->r1.chain) == 0) { + ret_val = check_dist(so, sf, temp, atype[so], atype[sf], 1, + p[so]->r1.rname, p[so]->r1.res_no, + p[so]->r1.code, p[so]->r1.chain, + p[sf]->r1.rname, p[sf]->r1.res_no, + p[sf]->r1.code, p[sf]->r1.chain, usage); + if (ret_val == 1) { + make_connection(mult, temp_link, so, sf); + // record N=C Non-rotating bond between consecutive residues + no_bonds += 1; + nrot_bond_count++; + nrot_bond[nrot_bond_count][1] = so; + nrot_bond[nrot_bond_count][2] = sf; + } else { + poor_bond_count++; + poor_bond[poor_bond_count][1] = so; + poor_bond[poor_bond_count][2] = sf; + poor_bond_dist[poor_bond_count] = temp; + } + } else { + ret_val = check_dist(so, sf, temp, atype[so], atype[sf], 3, + p[so]->r1.rname, p[so]->r1.res_no, + p[so]->r1.code, p[so]->r1.chain, + p[sf]->r1.rname, p[sf]->r1.res_no, + p[sf]->r1.code, p[sf]->r1.chain, usage); + if (ret_val == 1) { + make_connection(mult, temp_link, so, sf); + // record N=C Non-rotating bond between consecutive residues + no_bonds += 1; + nrot_bond_count++; + nrot_bond[nrot_bond_count][1] = so; + nrot_bond[nrot_bond_count][2] = sf; + } else { + poor_bond_count++; + poor_bond[poor_bond_count][1] = so; + poor_bond[poor_bond_count][2] = sf; + poor_bond_dist[poor_bond_count] = temp; + } + } + + } else { + ret_val = check_dist(so, sf, temp, atype[so], atype[sf], 1, + p[so]->r1.rname, p[so]->r1.res_no, + p[so]->r1.code, p[so]->r1.chain, + p[sf]->r1.rname, p[sf]->r1.res_no, + p[sf]->r1.code, p[sf]->r1.chain, usage); + + if (ret_val == 1) { + // Special case: ARG for non-rotating bonds + if (strcmp(res[rnumber].rname, "ARG") == 0) { + if (strcmp(atype[so], " CZ ") == 0) { + if (strcmp(atype[sf], " NH1") == 0 || + strcmp(atype[sf], " NH2") == 0 || + strcmp(atype[sf], " NE ") == 0) { + nrot_bond_count++; + nrot_bond[nrot_bond_count][1] = so; + nrot_bond[nrot_bond_count][2] = sf; + } + } + if (strcmp(atype[sf], " CZ ") == 0) { + if (strcmp(atype[so], " NH1") == 0 || + strcmp(atype[so], " NH2") == 0 || + strcmp(atype[so], " NE ") == 0) { + nrot_bond_count++; + nrot_bond[nrot_bond_count][1] = so; + nrot_bond[nrot_bond_count][2] = sf; + } + } + } + // End Special case: ARG for non-rotating bonds + + make_connection(mult, temp_link, so, sf); + no_bonds += 1; + } else { + poor_bond_count++; + poor_bond[poor_bond_count][1] = so; + poor_bond[poor_bond_count][2] = sf; + poor_bond_dist[poor_bond_count] = temp; + } + } + } + } + } else { + ma_count++; //---------------missing atoms + missing[ma_count] = res_ptr->r1.ri_sr_no; + strcpy(missing_atoms[ma_count], res[rnumber].A_type[i]); + } } - + /************************************************************/ /* Place Hydrogen atoms. */ /************************************************************/ - for( i = 1; i <= nhydro; i++ ) { - mult[h_ptr[i]->r1.ri_sr_no] = 0; + for (i = 1; i <= nhydro; i++) { + mult[h_ptr[i]->r1.ri_sr_no] = 0; } - for( i = 1; i <= nhydro; i++) { - flag9 = 0; - so = h_ptr[i]->r1.ri_sr_no; - count = 0; - for( j = 1; j <= res[rnumber].natom_sum; j++) { - if( res[rnumber].occu[j] == 1 ) { - sf = A_ptr[j]->r1.ri_sr_no; - temp = 0; - for( k = 1; k < 4; k++) { - temp += pow((h_ptr[i]->r1.coord[k] - A_ptr[j]->r1.coord[k]),2); - } - temp = sqrt(temp); - -// 2008:10 SN Add a diagnostic message to the user if bond length < 1.0 - if( temp >= 0.85 && temp < 0.995 && \ - strncmp(A_ptr[j]->r1.aname," C",3)==0) { - cout<< "\nWARNING: Distance between "<r1.rname, - p[so]->r1.res_no,p[so]->r1.code,p[so]->r1.chain, - p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code, - p[sf]->r1.chain,usage); - - if( ret_val == 1 ) { - count++; - dist[count]=temp; - label[count]=sf; - } - } - } - for( j = 1; j <= 2; j++) { - for( k = j+1; k <= count; k++) { - if( dist[j] > dist[k] ) { - temp = dist[j]; - dist[j] = dist[k]; - dist[k] = temp; - a = label[j]; - label[j] = label[k]; - label[k] = a; - } - } - } - sf = label[1]; - if( count > 1 ) { - flag9 = 1; - } - else { - if( count == 1 ) { - make_connection( mult, temp_link, so, sf ); - no_bonds++; - } - } - if( flag9 == 1 || - count == 0) { - xh_count++; - x_hydro[xh_count] = h_ptr[i]; - } + for (i = 1; i <= nhydro; i++) { + flag9 = 0; + so = h_ptr[i]->r1.ri_sr_no; + count = 0; + for (j = 1; j <= res[rnumber].natom_sum; j++) { + if (res[rnumber].occu[j] == 1) { + sf = A_ptr[j]->r1.ri_sr_no; + temp = 0; + for (k = 1; k < 4; k++) { + temp += pow((h_ptr[i]->r1.coord[k] - A_ptr[j]->r1.coord[k]), 2); + } + temp = sqrt(temp); + + // 2008:10 SN Add a diagnostic message to the user if bond length + // < 1.0 + if (temp >= 0.85 && temp < 0.995 && + strncmp(A_ptr[j]->r1.aname, " C", 3) == 0) { + cout << "\nWARNING: Distance between " << so << " and " << sf + << " is"; + cout << temp << " A (between 0.85 and 1.0 A)!"; + cout << "\n ProFlex will still include the hydrogen"; + cout << " atom, " << so << " in its analysis." << endl; + } + + ret_val = + check_dist(so, sf, temp, atype[so], atype[sf], 2, + p[so]->r1.rname, p[so]->r1.res_no, p[so]->r1.code, + p[so]->r1.chain, p[sf]->r1.rname, p[sf]->r1.res_no, + p[sf]->r1.code, p[sf]->r1.chain, usage); + + if (ret_val == 1) { + count++; + dist[count] = temp; + label[count] = sf; + } + } + } + for (j = 1; j <= 2; j++) { + for (k = j + 1; k <= count; k++) { + if (dist[j] > dist[k]) { + temp = dist[j]; + dist[j] = dist[k]; + dist[k] = temp; + a = label[j]; + label[j] = label[k]; + label[k] = a; + } + } + } + sf = label[1]; + if (count > 1) { + flag9 = 1; + } else { + if (count == 1) { + make_connection(mult, temp_link, so, sf); + no_bonds++; + } + } + if (flag9 == 1 || count == 0) { + xh_count++; + x_hydro[xh_count] = h_ptr[i]; + } } - if( (res[rnumber].occu[3]) == 1 ) { - A_ptr[0] = A_ptr[3]; - prev_occu=1; + if ((res[rnumber].occu[3]) == 1) { + A_ptr[0] = A_ptr[3]; + prev_occu = 1; } - for( i = 0; i <= res[rnumber].natom_sum; i++) { - res[rnumber].occu[i]=-1; + for (i = 0; i <= res[rnumber].natom_sum; i++) { + res[rnumber].occu[i] = -1; } - } - else { // Process record of UNKNOWN group - while( tempo->r1.mod_res_no == res_ptr->r1.mod_res_no && - strcmp( tempo->r1.chain,res_ptr->r1.chain) == 0 ) { - p[tempo->r1.ri_sr_no] = tempo; - strcpy(atype[tempo->r1.ri_sr_no],tempo->r1.aname); - for( i = 1; i < 4; i++ ) { - sxyz[tempo->r1.ri_sr_no][i]=tempo->r1.coord[i]; - } - iix=(int)((tempo->r1.coord[1]-xmin)/grdlen); - iiy=(int)((tempo->r1.coord[2]-ymin)/grdlen); - iiz=(int)((tempo->r1.coord[3]-zmin)/grdlen); - ix=iix%32; - iy=iiy%32; - iz=iiz%32; - chain[tempo->r1.ri_sr_no]=grid[ix][iy][iz]; - grid[ix][iy][iz]=tempo->r1.ri_sr_no; - if(tempo->r1.aname[2]=='H' || tempo->r1.aname[2]=='D') { - nhydro++; - h_ptr[nhydro]=tempo; - xh_count++; - x_hydro[xh_count]=tempo; - } - else { - natom++; - A_ptr[natom]=tempo; - ua_count++; - unknown_atom[ua_count]=tempo; - } - if( tempo != start ) { - tempo=tempo->prior; - } - else { - loop_flag = 0; - break; - } + } else { // Process record of UNKNOWN group + while (tempo->r1.mod_res_no == res_ptr->r1.mod_res_no && + strcmp(tempo->r1.chain, res_ptr->r1.chain) == 0) { + p[tempo->r1.ri_sr_no] = tempo; + strcpy(atype[tempo->r1.ri_sr_no], tempo->r1.aname); + for (i = 1; i < 4; i++) { + sxyz[tempo->r1.ri_sr_no][i] = tempo->r1.coord[i]; + } + iix = (int)((tempo->r1.coord[1] - xmin) / grdlen); + iiy = (int)((tempo->r1.coord[2] - ymin) / grdlen); + iiz = (int)((tempo->r1.coord[3] - zmin) / grdlen); + ix = iix % 32; + iy = iiy % 32; + iz = iiz % 32; + chain[tempo->r1.ri_sr_no] = grid[ix][iy][iz]; + grid[ix][iy][iz] = tempo->r1.ri_sr_no; + if (tempo->r1.aname[2] == 'H' || tempo->r1.aname[2] == 'D') { + nhydro++; + h_ptr[nhydro] = tempo; + xh_count++; + x_hydro[xh_count] = tempo; + } else { + natom++; + A_ptr[natom] = tempo; + ua_count++; + unknown_atom[ua_count] = tempo; + } + if (tempo != start) { + tempo = tempo->prior; + } else { + loop_flag = 0; + break; + } } - for( i = 1; i <= natom; i++ ) { - if(A_ptr[i]->r1.aname[2] == 'S' ) { - nsulfur++; - if( nsulfur > 1000 ) { - cout<<"Number of S atoms greater than 1000"<r1.aname[2] == 'S') { + nsulfur++; + if (nsulfur > 1000) { + cout << "Number of S atoms greater than 1000" << endl; + exit(-1); + } + s_ptr[nsulfur] = A_ptr[i]; + } } - prev_occu=-1; + prev_occu = -1; } } - + // Unknown Non-hydrogen atom connectivity using "Hash code data structure" - for( i = 1; i <= ua_count; i++) { - so=unknown_atom[i]->r1.ri_sr_no; - iix=(int)((unknown_atom[i]->r1.coord[1]-xmin)/grdlen); - iiy=(int)((unknown_atom[i]->r1.coord[2]-ymin)/grdlen); - iiz=(int)((unknown_atom[i]->r1.coord[3]-zmin)/grdlen); - + for (i = 1; i <= ua_count; i++) { + so = unknown_atom[i]->r1.ri_sr_no; + iix = (int)((unknown_atom[i]->r1.coord[1] - xmin) / grdlen); + iiy = (int)((unknown_atom[i]->r1.coord[2] - ymin) / grdlen); + iiz = (int)((unknown_atom[i]->r1.coord[3] - zmin) / grdlen); + //---------------------------------------go to the beginning of the residue flag9 = 0; - for( jx = -1; jx <= 1; jx++) { - for( jy = -1; jy <= 1; jy++) { - for( jz = -1; jz <= 1; jz++) { - kx = (iix+jx)%32; - ky = (iiy+jy)%32; - kz = (iiz+jz)%32; - - sf = grid[kx][ky][kz]; - - while( sf != 0 ) { - if( atype[sf][2] != 'H' && - atype[sf][2] != 'D') { - for( j = 1; j <= mult[so]; j++) { - if( temp_link[so][j] == sf ) { - flag12 = 1; - flag9 = 1; - break; - } - } - if( flag12 != 1 ) { - temp = 0; - for( k = 1; k < 4; k++) { - temp += pow((sxyz[so][k]-sxyz[sf][k]),2); - } - temp = sqrt(temp); - ret_val=check_dist(so,sf,temp,atype[so],atype[sf],0,p[so]->r1.rname, - p[so]->r1.res_no,p[so]->r1.code,p[so]->r1.chain, - p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code, - p[sf]->r1.chain,usage); - - if( ret_val == 1 ) { - /************************************************************/ - /* Check for non rotating Note: Bonds are non rotating if */ - /* the 2 atoms belong to diff. groups */ - if(p[so]->r1.mod_res_no != p[sf]->r1.mod_res_no) { - u_nrot_bond_count++; - u_nrot_bond[u_nrot_bond_count][1] = so; - u_nrot_bond[u_nrot_bond_count][2] = sf; - } - make_connection(mult,temp_link,so,sf); - no_bonds+=1; - flag12=0; - chk_bond_count++; + for (jx = -1; jx <= 1; jx++) { + for (jy = -1; jy <= 1; jy++) { + for (jz = -1; jz <= 1; jz++) { + kx = (iix + jx) % 32; + ky = (iiy + jy) % 32; + kz = (iiz + jz) % 32; + + sf = grid[kx][ky][kz]; + + while (sf != 0) { + if (atype[sf][2] != 'H' && atype[sf][2] != 'D') { + for (j = 1; j <= mult[so]; j++) { + if (temp_link[so][j] == sf) { + flag12 = 1; + flag9 = 1; + break; + } + } + if (flag12 != 1) { + temp = 0; + for (k = 1; k < 4; k++) { + temp += pow((sxyz[so][k] - sxyz[sf][k]), 2); + } + temp = sqrt(temp); + ret_val = check_dist(so, sf, temp, atype[so], atype[sf], 0, + p[so]->r1.rname, p[so]->r1.res_no, + p[so]->r1.code, p[so]->r1.chain, + p[sf]->r1.rname, p[sf]->r1.res_no, + p[sf]->r1.code, p[sf]->r1.chain, usage); + + if (ret_val == 1) { + /************************************************************/ + /* Check for non rotating Note: Bonds are non rotating if */ + /* the 2 atoms belong to diff. groups */ + if (p[so]->r1.mod_res_no != p[sf]->r1.mod_res_no) { + u_nrot_bond_count++; + u_nrot_bond[u_nrot_bond_count][1] = so; + u_nrot_bond[u_nrot_bond_count][2] = sf; + } + make_connection(mult, temp_link, so, sf); + no_bonds += 1; + flag12 = 0; + chk_bond_count++; #ifdef DEBUG -printf("1. chk_bond_count =%d so %d sf %d dist %f\n",chk_bond_count,so,sf,temp); + printf("1. chk_bond_count =%d so %d sf %d dist %f\n", + chk_bond_count, so, sf, temp); #endif - chk_bond[chk_bond_count][1]=so; - chk_bond[chk_bond_count][2]=sf; - chk_bond_dist[chk_bond_count]=temp; - - flag9=1; - sf=chain[sf]; - } - else { - sf=chain[sf]; - } - } - else { - sf=chain[sf]; - flag12=0; - } - } - else { - sf=chain[sf]; - } - } - } + chk_bond[chk_bond_count][1] = so; + chk_bond[chk_bond_count][2] = sf; + chk_bond_dist[chk_bond_count] = temp; + + flag9 = 1; + sf = chain[sf]; + } else { + sf = chain[sf]; + } + } else { + sf = chain[sf]; + flag12 = 0; + } + } else { + sf = chain[sf]; + } + } + } } } - - if( flag9 != 1 ) { + + if (flag9 != 1) { skip_nhydro_count++; - skip_nhydro[skip_nhydro_count]=so; + skip_nhydro[skip_nhydro_count] = so; } - } - + } + // Sulfur-Sulfur atom connectivity using "Hash code data structure" ns_bond = 0; - for( i = 1; i <= nsulfur; i++ ) { + for (i = 1; i <= nsulfur; i++) { so = s_ptr[i]->r1.ri_sr_no; - iix=(int)((s_ptr[i]->r1.coord[1]-xmin)/grdlen); - iiy=(int)((s_ptr[i]->r1.coord[2]-ymin)/grdlen); - iiz=(int)((s_ptr[i]->r1.coord[3]-zmin)/grdlen); - + iix = (int)((s_ptr[i]->r1.coord[1] - xmin) / grdlen); + iiy = (int)((s_ptr[i]->r1.coord[2] - ymin) / grdlen); + iiz = (int)((s_ptr[i]->r1.coord[3] - zmin) / grdlen); + //---------------------------------------go to the beginning of the residue - for( jx = -1; jx <= 1; jx++) { - for( jy = -1; jy <= 1; jy++) { - for( jz = -1; jz <= 1; jz++) { - kx = (iix+jx)%32; - ky = (iiy+jy)%32; - kz = (iiz+jz)%32; - - sf = grid[kx][ky][kz]; - while( sf != 0 ) { - if( atype[sf][2] == 'S' && - so != sf) { - for( j = 1; j <= mult[so]; j++) { - if( temp_link[so][j] == sf ) { - flag12 = 1; - break; - } - } - if( flag12 != 1 ) { - temp = 0; - for( k = 1; k < 4; k++) { - temp+=pow((sxyz[so][k]-sxyz[sf][k]),2); - } - temp=sqrt(temp); - ret_val=check_dist(so,sf,temp,atype[so],atype[sf],0,p[so]->r1.rname, - p[so]->r1.res_no,p[so]->r1.code,p[so]->r1.chain, - p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code, - p[sf]->r1.chain,usage); - - if( ret_val == 1 ) { - /************************************************************/ - /* Check for non rotating. Note: Bonds are non rotating if */ - /* the 2 atoms belong to diff. groups */ - /************************************************************/ - if(p[so]->r1.mod_res_no != p[sf]->r1.mod_res_no) { - u_nrot_bond_count++; - u_nrot_bond[u_nrot_bond_count][1]=so; - u_nrot_bond[u_nrot_bond_count][2]=sf; - } - make_connection(mult,temp_link,so,sf); - no_bonds+=1; - ns_bond++; - flag12=0; - chk_bond_count++; + for (jx = -1; jx <= 1; jx++) { + for (jy = -1; jy <= 1; jy++) { + for (jz = -1; jz <= 1; jz++) { + kx = (iix + jx) % 32; + ky = (iiy + jy) % 32; + kz = (iiz + jz) % 32; + + sf = grid[kx][ky][kz]; + while (sf != 0) { + if (atype[sf][2] == 'S' && so != sf) { + for (j = 1; j <= mult[so]; j++) { + if (temp_link[so][j] == sf) { + flag12 = 1; + break; + } + } + if (flag12 != 1) { + temp = 0; + for (k = 1; k < 4; k++) { + temp += pow((sxyz[so][k] - sxyz[sf][k]), 2); + } + temp = sqrt(temp); + ret_val = check_dist(so, sf, temp, atype[so], atype[sf], 0, + p[so]->r1.rname, p[so]->r1.res_no, + p[so]->r1.code, p[so]->r1.chain, + p[sf]->r1.rname, p[sf]->r1.res_no, + p[sf]->r1.code, p[sf]->r1.chain, usage); + + if (ret_val == 1) { + /************************************************************/ + /* Check for non rotating. Note: Bonds are non rotating if */ + /* the 2 atoms belong to diff. groups */ + /************************************************************/ + if (p[so]->r1.mod_res_no != p[sf]->r1.mod_res_no) { + u_nrot_bond_count++; + u_nrot_bond[u_nrot_bond_count][1] = so; + u_nrot_bond[u_nrot_bond_count][2] = sf; + } + make_connection(mult, temp_link, so, sf); + no_bonds += 1; + ns_bond++; + flag12 = 0; + chk_bond_count++; #ifdef DEBUG -printf("1. chk_bond_count =%d so %d sf %d dist %f\n",chk_bond_count,so,sf,temp); + printf("1. chk_bond_count =%d so %d sf %d dist %f\n", + chk_bond_count, so, sf, temp); #endif - chk_bond[chk_bond_count][1]=so; - chk_bond[chk_bond_count][2]=sf; - chk_bond_dist[chk_bond_count]=temp; - sf=chain[sf]; - } - else { - sf = chain[sf]; - } - } - else { - sf = chain[sf]; - flag12 = 0; - } - } - else { - sf = chain[sf]; - } - } - } + chk_bond[chk_bond_count][1] = so; + chk_bond[chk_bond_count][2] = sf; + chk_bond_dist[chk_bond_count] = temp; + sf = chain[sf]; + } else { + sf = chain[sf]; + } + } else { + sf = chain[sf]; + flag12 = 0; + } + } else { + sf = chain[sf]; + } + } + } } } } - + // Extra & unknown hydrogen atom connectivity using "Hash code data structure" - for(i=1;i<=xh_count;i++) - { - so=x_hydro[i]->r1.ri_sr_no; - - iix=(int)((x_hydro[i]->r1.coord[1]-xmin)/grdlen); - iiy=(int)((x_hydro[i]->r1.coord[2]-ymin)/grdlen); - iiz=(int)((x_hydro[i]->r1.coord[3]-zmin)/grdlen); - count=0; - flag9=0; - for(jx=-1;jx<=1;jx++) - { - for(jy=-1;jy<=1;jy++) - { - for(jz=-1;jz<=1;jz++) - { - kx=(iix+jx)%32; - ky=(iiy+jy)%32; - kz=(iiz+jz)%32; - - sf=grid[kx][ky][kz]; - - while(sf!=0) - { - if(atype[sf][2]!='H' && atype[sf][2]!='D') - { - temp=0; - for(k=1;k<4;k++) - { - temp+=pow((sxyz[so][k]-sxyz[sf][k]),2); - } - temp=sqrt(temp); - ret_val=check_dist(so,sf,temp,atype[so],atype[sf],0,p[so]->r1.rname, - p[so]->r1.res_no,p[so]->r1.code,p[so]->r1.chain, - p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code, - p[sf]->r1.chain,usage); - - if(ret_val==1) { - count++; - dist[count]=temp; - label[count]=sf; - } - sf=chain[sf]; - } - else - { - sf=chain[sf]; - } - } - - } - } - } - for(j=1;j<=2;j++) - { - for(k=j+1;k<=count;k++) - { - if(dist[j]>dist[k]) - { - temp=dist[j]; - dist[j]=dist[k]; - dist[k]=temp; - a=label[j]; - label[j]=label[k]; - label[k]=a; - } - } - } - sf=label[1]; - if(count>1) - { - { - if(flag7==0) - { - cout<r1.rname,p[so]->r1.res_no, - p[so]->r1.code,p[so]->r1.chain,atype[so],atype[so], - atype[so],atype[so],atype[so]); - flag9=1; - } - } - else - { - if(count==1) - { - /*---------------------------------------------check for non rotating - Note: Bonds are non rotating if the 2 atoms belong to diff. groups */ - - if(p[so]->r1.mod_res_no != p[sf]->r1.mod_res_no) - { - u_nrot_bond_count++; - u_nrot_bond[u_nrot_bond_count][1]=so; - u_nrot_bond[u_nrot_bond_count][2]=sf; - } - make_connection(mult,temp_link,so,sf); - no_bonds+=1; - } - } - if(flag9==1 || count==0) - { - skip_hydro_count++; - skip_hydro[skip_hydro_count]=so; - } - } -//--------------------------------------------------------------Add in OXT atoms - - for( i = 1; i <= n_oxt; i++) { + for (i = 1; i <= xh_count; i++) { + so = x_hydro[i]->r1.ri_sr_no; + + iix = (int)((x_hydro[i]->r1.coord[1] - xmin) / grdlen); + iiy = (int)((x_hydro[i]->r1.coord[2] - ymin) / grdlen); + iiz = (int)((x_hydro[i]->r1.coord[3] - zmin) / grdlen); + count = 0; + flag9 = 0; + for (jx = -1; jx <= 1; jx++) { + for (jy = -1; jy <= 1; jy++) { + for (jz = -1; jz <= 1; jz++) { + kx = (iix + jx) % 32; + ky = (iiy + jy) % 32; + kz = (iiz + jz) % 32; + + sf = grid[kx][ky][kz]; + + while (sf != 0) { + if (atype[sf][2] != 'H' && atype[sf][2] != 'D') { + temp = 0; + for (k = 1; k < 4; k++) { + temp += pow((sxyz[so][k] - sxyz[sf][k]), 2); + } + temp = sqrt(temp); + ret_val = + check_dist(so, sf, temp, atype[so], atype[sf], 0, + p[so]->r1.rname, p[so]->r1.res_no, p[so]->r1.code, + p[so]->r1.chain, p[sf]->r1.rname, p[sf]->r1.res_no, + p[sf]->r1.code, p[sf]->r1.chain, usage); + + if (ret_val == 1) { + count++; + dist[count] = temp; + label[count] = sf; + } + sf = chain[sf]; + } else { + sf = chain[sf]; + } + } + } + } + } + for (j = 1; j <= 2; j++) { + for (k = j + 1; k <= count; k++) { + if (dist[j] > dist[k]) { + temp = dist[j]; + dist[j] = dist[k]; + dist[k] = temp; + a = label[j]; + label[j] = label[k]; + label[k] = a; + } + } + } + sf = label[1]; + if (count > 1) { + { + if (flag7 == 0) { + cout << endl << dash1 << dash3 << endl; + cout << endl << "\tHydrogen Atom Connectivity" << endl; + cout << endl + << "Warning: The following hydrogen atoms can be" + << " connected to more than 1 atom" << endl; + cout << endl << "\t Atom# Atom Res Res# Chain" << endl; + flag7 = 1; + } + write_output(1, so, 0, atype[so], p[so]->r1.rname, p[so]->r1.res_no, + p[so]->r1.code, p[so]->r1.chain, atype[so], atype[so], + atype[so], atype[so], atype[so]); + flag9 = 1; + } + } else { + if (count == 1) { + /*---------------------------------------------check for non rotating + Note: Bonds are non rotating if the 2 atoms belong to diff. groups */ + + if (p[so]->r1.mod_res_no != p[sf]->r1.mod_res_no) { + u_nrot_bond_count++; + u_nrot_bond[u_nrot_bond_count][1] = so; + u_nrot_bond[u_nrot_bond_count][2] = sf; + } + make_connection(mult, temp_link, so, sf); + no_bonds += 1; + } + } + if (flag9 == 1 || count == 0) { + skip_hydro_count++; + skip_hydro[skip_hydro_count] = so; + } + } + //--------------------------------------------------------------Add in OXT + //atoms + + for (i = 1; i <= n_oxt; i++) { so = bond_oxt[i][0]; sf = bond_oxt[i][1]; - make_connection(mult,temp_link,so,sf); + make_connection(mult, temp_link, so, sf); no_bonds++; } - - if(usage == 0) { -//----------------------------------------------------------------Check valencies - flag7=0; - for(i=1;i<=no_atoms;i++) - { - flag10=0; - flag9=0; - if(atype[i][2]=='H' || atype[i][2]=='D') - { - if(mult[i]>1) - { - flag10 = -1; - so=i; - if(flag7==0) - { - //system("clear"); - cout<r1.rname,p[so]->r1.res_no, - p[so]->r1.code,p[so]->r1.chain,atype[so],atype[so], - atype[so],atype[so],atype[so]); - for(j=1;j<=mult[i];j++) - { - if(strcmp(p[i]->r1.res_no,p[temp_link[i][j]]->r1.res_no)!=0) - { - if(flag9==0) - { - cout<r1.rname,p[sf]->r1.res_no, - p[sf]->r1.code,p[sf]->r1.chain,atype[sf],atype[sf], - atype[sf],atype[sf],atype[sf]); - ans = '@'; - while( ans != 'Y' && - ans != 'y' && - ans != 'N' && - ans != 'n') { - cout<<"Do you want to keep the bond? (y/n): "; - ans = cin.get(); - if( ans == '\n' ) - cout << "Please enter \"y\" or \"n\"." << endl; - else - cin.ignore(80, '\n'); - } - - if(ans=='N' || ans=='n') - { - for(k=j;k<=mult[so]-1;k++) - { - temp_link[so][k]=temp_link[so][k+1]; - } - temp_link[so][mult[so]]=-1; - mult[so]--; - for(m=1;m<=mult[sf];m++) - { - if(temp_link[sf][m]==so) - { - for(q=m;q<=mult[sf]-1;q++) - { - temp_link[sf][q]=temp_link[sf][q+1]; - } - temp_link[sf][mult[sf]]=-1; - } - } - mult[sf]--; - no_bonds--; - for(k=1;k<=chk_bond_count;k++) - { - if(chk_bond[k][1]==so || chk_bond[k][1]==sf) - { - chk_bond[k][1]=-1; - } - } - for(k=1;k<=u_nrot_bond_count;k++) - { - if(u_nrot_bond[k][1]==so || u_nrot_bond[k][1]==sf) - { - u_nrot_bond[k][1]=0; - } - } - flag10=1; - j--; - } - } - } - if( mult[i] > 1 ) - { - for(j=1;j<=mult[i];j++) - { - if(strcmp(p[i]->r1.res_no,p[temp_link[i][j]]->r1.res_no)==0) - { - if(flag9==0) - { - cout<r1.rname,p[sf]->r1.res_no, - p[sf]->r1.code,p[sf]->r1.chain,atype[sf],atype[sf], - atype[sf],atype[sf],atype[sf]); - ans = '@'; - while( ans != 'Y' && - ans != 'y' && - ans != 'N' && - ans != 'n') { - cout<<"Do you want to keep the bond? (y/n): "; - ans = cin.get(); - if( ans == '\n' ) - cout << "Please enter \"y\" or \"n\"." << endl; - else - cin.ignore(80, '\n'); - } - if(ans=='N' || ans=='n') - { - for(k=j;k<=mult[so]-1;k++) - { - temp_link[so][k]=temp_link[so][k+1]; - } - temp_link[so][mult[so]]=-1; - mult[so]--; - for(m=1;m<=mult[sf];m++) - { - if(temp_link[sf][m]==so) - { - for(q=m;q<=mult[sf]-1;q++) - { - temp_link[sf][q]=temp_link[sf][q+1]; - } - temp_link[sf][mult[sf]]=-1; - } - } - mult[sf]--; - no_bonds--; - for(k=1;k<=chk_bond_count;k++) - { - if(chk_bond[k][1]==so || chk_bond[k][1]==sf) - { - chk_bond[k][1]=-1; - } - } - for(k=1;k<=u_nrot_bond_count;k++) - { - if(u_nrot_bond[k][1]==so || u_nrot_bond[k][1]==sf) - { - u_nrot_bond[k][1]=0; - } - } - flag10=1; - j--; - } - } - } - } - } - } -// else if(atype[i][2]=='O' && atype[i][3] == ' ') -// --- 2007:06 SN --- Discrepancy in valency checks between v4 and v5 - else if(atype[i][2]=='O') - { - if(mult[i]>2) - { - flag10 = -1; - so=i; - if(flag7==0) - { - //system("clear"); - cout<r1.rname,p[so]->r1.res_no, - p[so]->r1.code,p[so]->r1.chain,atype[so],atype[so], - atype[so],atype[so],atype[so]); - for(j=1;j<=mult[i];j++) - { - if(strcmp(p[i]->r1.res_no,p[temp_link[i][j]]->r1.res_no)!=0) - { - if(flag9==0) - { - cout<r1.rname,p[sf]->r1.res_no, - p[sf]->r1.code,p[sf]->r1.chain,atype[sf],atype[sf], - atype[sf],atype[sf],atype[sf]); - ans = '@'; - while( ans != 'Y' && - ans != 'y' && - ans != 'N' && - ans != 'n') { - cout<<"Do you want to keep the bond? (y/n): "; - ans = cin.get(); - if( ans == '\n' ) - cout << "Please enter \"y\" or \"n\"." << endl; - else - cin.ignore(80, '\n'); - } - if(ans=='N' || ans=='n') - { - for(k=j;k<=mult[so]-1;k++) - { - temp_link[i][k]=temp_link[i][k+1]; - } - temp_link[i][mult[i]]=-1; - mult[i]--; - for(m=1;m<=mult[sf];m++) - { - if(temp_link[sf][m]==so) - { - for(q=m;q<=mult[sf]-1;q++) - { - temp_link[sf][q]=temp_link[sf][q+1]; - } - temp_link[sf][mult[sf]]=-1; - } - } - mult[sf]--; - no_bonds--; - for(k=1;k<=chk_bond_count;k++) - { - if(chk_bond[k][1]==so || chk_bond[k][1]==sf) - { - chk_bond[k][1]=-1; - } - } - for(k=1;k<=u_nrot_bond_count;k++) - { - if(u_nrot_bond[k][1]==so || u_nrot_bond[k][1]==sf) - { - u_nrot_bond[k][1]=0; - } - } - flag10=1; - j--; - } - } - } - if( mult[i] > 2 ) - { - for(j=1;j<=mult[i];j++) - { - if(strcmp(p[i]->r1.res_no,p[temp_link[i][j]]->r1.res_no)==0) - { - if(flag9==0) - { - cout<r1.rname,p[sf]->r1.res_no, - p[sf]->r1.code,p[sf]->r1.chain,atype[sf],atype[sf], - atype[sf],atype[sf],atype[sf]); - ans = '@'; - while( ans != 'Y' && - ans != 'y' && - ans != 'N' && - ans != 'n') { - cout<<"Do you want to keep the bond? (y/n): "; - ans = cin.get(); - if( ans == '\n' ) - cout << "Please enter \"y\" or \"n\"." << endl; - else - cin.ignore(80, '\n'); - } - if(ans=='N' || ans=='n') - { - for(k=j;k<=mult[so]-1;k++) - { - temp_link[i][k]=temp_link[i][k+1]; - } - temp_link[i][mult[i]]=-1; - mult[i]--; - for(m=1;m<=mult[sf];m++) - { - if(temp_link[sf][m]==so) - { - for(q=m;q<=mult[sf]-1;q++) - { - temp_link[sf][q]=temp_link[sf][q+1]; - } - temp_link[sf][mult[sf]]=-1; - } - } - mult[sf]--; - no_bonds--; - for(k=1;k<=chk_bond_count;k++) - { - if(chk_bond[k][1]==so || chk_bond[k][1]==sf) - { - chk_bond[k][1]=-1; - } - } - for(k=1;k<=u_nrot_bond_count;k++) - { - if(u_nrot_bond[k][1]==so || u_nrot_bond[k][1]==sf) - { - u_nrot_bond[k][1]=0; - } - } - flag10=1; - j--; - } - } - } - } - } - } -// else if( (atype[i][2]=='N' && atype[i][3] == ' ') && -// --- 2007:06 SN --- Discrepancy in valency checks between v4 and v5 - else if( atype[i][2]=='N' && - ( p[i]->r1.mod_res_no != 1 || ( p[i]->r1.mod_res_no == 1 && - strncmp(p[i]->r1.aname+1," N ",4)!=0 ) ) && - !(strcmp(p[i]->r1.rname,"LYS")==0 && - strncmp(p[i]->r1.aname+1," NZ ",4)==0) ) - { - if(mult[i]>3) - { - flag10 = -1; - so=i; - if(flag7==0) - { - //system("clear"); - cout<r1.rname,p[so]->r1.res_no, - p[so]->r1.code,p[so]->r1.chain,atype[so],atype[so], - atype[so],atype[so],atype[so]); - for(j=1;j<=mult[i];j++) - { - if(strcmp(p[i]->r1.res_no,p[temp_link[i][j]]->r1.res_no)!=0) - { - if(flag9==0) - { - cout<r1.rname,p[sf]->r1.res_no, - p[sf]->r1.code,p[sf]->r1.chain,atype[sf],atype[sf], - atype[sf],atype[sf],atype[sf]); - ans = '@'; - while( ans != 'Y' && - ans != 'y' && - ans != 'N' && - ans != 'n') { - cout<<"Do you want to keep the bond? (y/n): "; - ans = cin.get(); - if( ans == '\n' ) - cout << "Please enter \"y\" or \"n\"." << endl; - else - cin.ignore(80, '\n'); - } - if(ans=='N' || ans=='n') - { - for(k=j;k<=mult[so]-1;k++) - { - temp_link[i][k]=temp_link[i][k+1]; - } - temp_link[i][mult[i]]=-1; - mult[i]--; - for(m=1;m<=mult[sf];m++) - { - if(temp_link[sf][m]==so) - { - for(q=m;q<=mult[sf]-1;q++) - { - temp_link[sf][q]=temp_link[sf][q+1]; - } - temp_link[sf][mult[sf]]=-1; - } - } - mult[sf]--; - no_bonds--; - for(k=1;k<=chk_bond_count;k++) - { - if(chk_bond[k][1]==so || chk_bond[k][1]==sf) - { - chk_bond[k][1]=-1; - } - } - for(k=1;k<=u_nrot_bond_count;k++) - { - if(u_nrot_bond[k][1]==so || u_nrot_bond[k][1]==sf) - { - u_nrot_bond[k][1]=0; - } - } - flag10=1; - j--; - } - } - } - if( mult[i] > 3 ) - { - for(j=1;j<=mult[i];j++) - { - if(strcmp(p[i]->r1.res_no,p[temp_link[i][j]]->r1.res_no)==0) - { - if(flag9==0) - { - cout<r1.rname,p[sf]->r1.res_no, - p[sf]->r1.code,p[sf]->r1.chain,atype[sf],atype[sf], - atype[sf],atype[sf],atype[sf]); - ans = '@'; - while( ans != 'Y' && - ans != 'y' && - ans != 'N' && - ans != 'n') { - cout<<"Do you want to keep the bond? (y/n): "; - ans = cin.get(); - if( ans == '\n' ) - cout << "Please enter \"y\" or \"n\"." << endl; - else - cin.ignore(80, '\n'); - } - if(ans=='N' || ans=='n') - { - for(k=j;k<=mult[so]-1;k++) - { - temp_link[i][k]=temp_link[i][k+1]; - } - temp_link[i][mult[i]]=-1; - mult[i]--; - for(m=1;m<=mult[sf];m++) - { - if(temp_link[sf][m]==so) - { - for(q=m;q<=mult[sf]-1;q++) - { - temp_link[sf][q]=temp_link[sf][q+1]; - } - temp_link[sf][mult[sf]]=-1; - } - } - mult[sf]--; - no_bonds--; - for(k=1;k<=chk_bond_count;k++) - { - if(chk_bond[k][1]==so || chk_bond[k][1]==sf) - { - chk_bond[k][1]=-1; - } - } - for(k=1;k<=u_nrot_bond_count;k++) - { - if(u_nrot_bond[k][1]==so || u_nrot_bond[k][1]==sf) - { - u_nrot_bond[k][1]=0; - } - } - flag10=1; - j--; - } - } - } - } - } - } - else /* If Not 'C' 'N' 'O' 'H' Then ( metals! ligand! )*/ - { - if(mult[i]>4) - { - flag10 = -1; - so=i; - if(flag7==0) - { - //system("clear"); - cout<r1.rname,p[so]->r1.res_no, - p[so]->r1.code,p[so]->r1.chain,atype[so],atype[so], - atype[so],atype[so],atype[so]); - for(j=1;j<=mult[i];j++) - { - if(strcmp(p[i]->r1.res_no,p[temp_link[i][j]]->r1.res_no)!=0) - { - if(flag9==0) { - cout<r1.rname,p[sf]->r1.res_no, - p[sf]->r1.code,p[sf]->r1.chain,atype[sf],atype[sf], - atype[sf],atype[sf],atype[sf]); - ans = '@'; - while( ans != 'Y' && - ans != 'y' && - ans != 'N' && - ans != 'n') { - cout<<"Do you want to keep the bond? (y/n): "; - ans = cin.get(); - if( ans == '\n' ) - cout << "Please enter \"y\" or \"n\"." << endl; - else - cin.ignore(80, '\n'); - } - if( ans == 'N' || ans == 'n' ) - { - for(k=j;k<=mult[i]-1;k++) - { - temp_link[i][k]=temp_link[i][k+1]; - } - temp_link[i][mult[i]]=-1; - mult[i]--; - for(m=1;m<=mult[sf];m++) - { - if(temp_link[sf][m]==so) - { - for(q=m;q<=mult[sf]-1;q++) - { - temp_link[sf][q]=temp_link[sf][q+1]; - } - temp_link[sf][mult[sf]]=-1; - } - } - mult[sf]--; - no_bonds--; - for(k=1;k<=chk_bond_count;k++) - { - if(chk_bond[k][1]==so || chk_bond[k][1]==sf) - { - chk_bond[k][1]=-1; - } - } - for(k=1;k<=u_nrot_bond_count;k++) - { - if(u_nrot_bond[k][1]==so || u_nrot_bond[k][1]==sf) - { - u_nrot_bond[k][1]=0; - } - } - flag10=1; - j--; - } - } - } - if( mult[i] > 4 ) - { - for(j=1;j<=mult[i];j++) - { - if(strcmp(p[i]->r1.res_no,p[temp_link[i][j]]->r1.res_no)==0) - { - if( flag9 == 0) { - cout<r1.rname,p[sf]->r1.res_no, - p[sf]->r1.code,p[sf]->r1.chain,atype[sf],atype[sf], - atype[sf],atype[sf],atype[sf]); - ans = '@'; - while( ans != 'Y' && - ans != 'y' && - ans != 'N' && - ans != 'n') { - cout<<"Do you want to keep the bond? (y/n): "; - ans = cin.get(); - if( ans == '\n' ) - cout << "Please enter \"y\" or \"n\"." << endl; - else - cin.ignore(80, '\n'); - } - if( ans == 'N' || ans == 'n' ) - { - - for(k=j;k<=mult[i]-1;k++) - { - temp_link[i][k]=temp_link[i][k+1]; - } - temp_link[i][mult[i]]=-1; - mult[i]--; - for(m=1;m<=mult[sf];m++) - { - if(temp_link[sf][m]==so) - { - for(q=m;q<=mult[sf]-1;q++) - { - temp_link[sf][q]=temp_link[sf][q+1]; - } - temp_link[sf][mult[sf]]=-1; - } - } - mult[sf]--; - no_bonds--; - for(k=1;k<=chk_bond_count;k++) - { - if(chk_bond[k][1]==so || chk_bond[k][1]==sf) - { - chk_bond[k][1]=-1; - } - } - for(k=1;k<=u_nrot_bond_count;k++) - { - if(u_nrot_bond[k][1]==so || u_nrot_bond[k][1]==sf) - { - u_nrot_bond[k][1]=0; - } - } - flag10=1; - j--; - } - } - } - } - } - } - if(flag10==1) - { - cout< 1) { + flag10 = -1; + so = i; + if (flag7 == 0) { + // system("clear"); + cout << endl << endl << "\t\t Checking valencies" << endl; + cout << dash1 << dash3 << endl; + flag7 = 1; + } + cout << endl + << "Valency of atom " << i << " is " << mult[i] + << ", greater than its maximum valency (1)" << endl; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, so, 0, atype[so], p[so]->r1.rname, p[so]->r1.res_no, + p[so]->r1.code, p[so]->r1.chain, atype[so], atype[so], + atype[so], atype[so], atype[so]); + for (j = 1; j <= mult[i]; j++) { + if (strcmp(p[i]->r1.res_no, p[temp_link[i][j]]->r1.res_no) != 0) { + if (flag9 == 0) { + cout << endl + << "Possible incorrect bond(s) with atom(s):" << endl; + flag9 = 1; + } + sf = temp_link[i][j]; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, sf, 0, atype[sf], p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + atype[sf], atype[sf], atype[sf], atype[sf], + atype[sf]); + ans = '@'; + while (ans != 'Y' && ans != 'y' && ans != 'N' && ans != 'n') { + cout << "Do you want to keep the bond? (y/n): "; + ans = cin.get(); + if (ans == '\n') + cout << "Please enter \"y\" or \"n\"." << endl; + else + cin.ignore(80, '\n'); + } + + if (ans == 'N' || ans == 'n') { + for (k = j; k <= mult[so] - 1; k++) { + temp_link[so][k] = temp_link[so][k + 1]; + } + temp_link[so][mult[so]] = -1; + mult[so]--; + for (m = 1; m <= mult[sf]; m++) { + if (temp_link[sf][m] == so) { + for (q = m; q <= mult[sf] - 1; q++) { + temp_link[sf][q] = temp_link[sf][q + 1]; + } + temp_link[sf][mult[sf]] = -1; + } + } + mult[sf]--; + no_bonds--; + for (k = 1; k <= chk_bond_count; k++) { + if (chk_bond[k][1] == so || chk_bond[k][1] == sf) { + chk_bond[k][1] = -1; + } + } + for (k = 1; k <= u_nrot_bond_count; k++) { + if (u_nrot_bond[k][1] == so || u_nrot_bond[k][1] == sf) { + u_nrot_bond[k][1] = 0; + } + } + flag10 = 1; + j--; + } + } + } + if (mult[i] > 1) { + for (j = 1; j <= mult[i]; j++) { + if (strcmp(p[i]->r1.res_no, p[temp_link[i][j]]->r1.res_no) == 0) { + if (flag9 == 0) { + cout << endl + << "Possible incorrect bond(s) with atom(s):" << endl; + flag9 = 1; + } + sf = temp_link[i][j]; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, sf, 0, atype[sf], p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + atype[sf], atype[sf], atype[sf], atype[sf], + atype[sf]); + ans = '@'; + while (ans != 'Y' && ans != 'y' && ans != 'N' && ans != 'n') { + cout << "Do you want to keep the bond? (y/n): "; + ans = cin.get(); + if (ans == '\n') + cout << "Please enter \"y\" or \"n\"." << endl; + else + cin.ignore(80, '\n'); + } + if (ans == 'N' || ans == 'n') { + for (k = j; k <= mult[so] - 1; k++) { + temp_link[so][k] = temp_link[so][k + 1]; + } + temp_link[so][mult[so]] = -1; + mult[so]--; + for (m = 1; m <= mult[sf]; m++) { + if (temp_link[sf][m] == so) { + for (q = m; q <= mult[sf] - 1; q++) { + temp_link[sf][q] = temp_link[sf][q + 1]; + } + temp_link[sf][mult[sf]] = -1; + } + } + mult[sf]--; + no_bonds--; + for (k = 1; k <= chk_bond_count; k++) { + if (chk_bond[k][1] == so || chk_bond[k][1] == sf) { + chk_bond[k][1] = -1; + } + } + for (k = 1; k <= u_nrot_bond_count; k++) { + if (u_nrot_bond[k][1] == so || u_nrot_bond[k][1] == sf) { + u_nrot_bond[k][1] = 0; + } + } + flag10 = 1; + j--; + } + } + } + } + } + } + // else if(atype[i][2]=='O' && atype[i][3] == ' ') + // --- 2007:06 SN --- Discrepancy in valency checks between v4 + //and v5 + else if (atype[i][2] == 'O') { + if (mult[i] > 2) { + flag10 = -1; + so = i; + if (flag7 == 0) { + // system("clear"); + cout << endl << endl << "\t\t Checking valencies" << endl; + cout << dash1 << dash3 << endl; + flag7 = 1; + } + cout << endl + << "Valency of atom " << i << " is " << mult[i] + << ", greater than its maximum valency (2)" << endl; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, so, 0, atype[so], p[so]->r1.rname, p[so]->r1.res_no, + p[so]->r1.code, p[so]->r1.chain, atype[so], atype[so], + atype[so], atype[so], atype[so]); + for (j = 1; j <= mult[i]; j++) { + if (strcmp(p[i]->r1.res_no, p[temp_link[i][j]]->r1.res_no) != 0) { + if (flag9 == 0) { + cout << endl + << "Possible incorrect bond(s) with atom(s):" << endl; + flag9 = 1; + } + sf = temp_link[i][j]; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, sf, 0, atype[sf], p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + atype[sf], atype[sf], atype[sf], atype[sf], + atype[sf]); + ans = '@'; + while (ans != 'Y' && ans != 'y' && ans != 'N' && ans != 'n') { + cout << "Do you want to keep the bond? (y/n): "; + ans = cin.get(); + if (ans == '\n') + cout << "Please enter \"y\" or \"n\"." << endl; + else + cin.ignore(80, '\n'); + } + if (ans == 'N' || ans == 'n') { + for (k = j; k <= mult[so] - 1; k++) { + temp_link[i][k] = temp_link[i][k + 1]; + } + temp_link[i][mult[i]] = -1; + mult[i]--; + for (m = 1; m <= mult[sf]; m++) { + if (temp_link[sf][m] == so) { + for (q = m; q <= mult[sf] - 1; q++) { + temp_link[sf][q] = temp_link[sf][q + 1]; + } + temp_link[sf][mult[sf]] = -1; + } + } + mult[sf]--; + no_bonds--; + for (k = 1; k <= chk_bond_count; k++) { + if (chk_bond[k][1] == so || chk_bond[k][1] == sf) { + chk_bond[k][1] = -1; + } + } + for (k = 1; k <= u_nrot_bond_count; k++) { + if (u_nrot_bond[k][1] == so || u_nrot_bond[k][1] == sf) { + u_nrot_bond[k][1] = 0; + } + } + flag10 = 1; + j--; + } + } + } + if (mult[i] > 2) { + for (j = 1; j <= mult[i]; j++) { + if (strcmp(p[i]->r1.res_no, p[temp_link[i][j]]->r1.res_no) == 0) { + if (flag9 == 0) { + cout << endl + << "Possible incorrect bond(s) with atom(s):" << endl; + flag9 = 1; + } + sf = temp_link[i][j]; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, sf, 0, atype[sf], p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + atype[sf], atype[sf], atype[sf], atype[sf], + atype[sf]); + ans = '@'; + while (ans != 'Y' && ans != 'y' && ans != 'N' && ans != 'n') { + cout << "Do you want to keep the bond? (y/n): "; + ans = cin.get(); + if (ans == '\n') + cout << "Please enter \"y\" or \"n\"." << endl; + else + cin.ignore(80, '\n'); + } + if (ans == 'N' || ans == 'n') { + for (k = j; k <= mult[so] - 1; k++) { + temp_link[i][k] = temp_link[i][k + 1]; + } + temp_link[i][mult[i]] = -1; + mult[i]--; + for (m = 1; m <= mult[sf]; m++) { + if (temp_link[sf][m] == so) { + for (q = m; q <= mult[sf] - 1; q++) { + temp_link[sf][q] = temp_link[sf][q + 1]; + } + temp_link[sf][mult[sf]] = -1; + } + } + mult[sf]--; + no_bonds--; + for (k = 1; k <= chk_bond_count; k++) { + if (chk_bond[k][1] == so || chk_bond[k][1] == sf) { + chk_bond[k][1] = -1; + } + } + for (k = 1; k <= u_nrot_bond_count; k++) { + if (u_nrot_bond[k][1] == so || u_nrot_bond[k][1] == sf) { + u_nrot_bond[k][1] = 0; + } + } + flag10 = 1; + j--; + } + } + } + } + } + } + // else if( (atype[i][2]=='N' && atype[i][3] == ' ') && + // --- 2007:06 SN --- Discrepancy in valency checks between v4 + //and v5 + else if (atype[i][2] == 'N' && + (p[i]->r1.mod_res_no != 1 || + (p[i]->r1.mod_res_no == 1 && + strncmp(p[i]->r1.aname + 1, " N ", 4) != 0)) && + !(strcmp(p[i]->r1.rname, "LYS") == 0 && + strncmp(p[i]->r1.aname + 1, " NZ ", 4) == 0)) { + if (mult[i] > 3) { + flag10 = -1; + so = i; + if (flag7 == 0) { + // system("clear"); + cout << endl << endl << "\t\t Checking valencies" << endl; + cout << dash1 << dash3 << endl; + flag7 = 1; + } + cout << endl + << "Valency of atom " << i << " is " << mult[i] + << ", greater than its maximum valency (3)" << endl; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, so, 0, atype[so], p[so]->r1.rname, p[so]->r1.res_no, + p[so]->r1.code, p[so]->r1.chain, atype[so], atype[so], + atype[so], atype[so], atype[so]); + for (j = 1; j <= mult[i]; j++) { + if (strcmp(p[i]->r1.res_no, p[temp_link[i][j]]->r1.res_no) != 0) { + if (flag9 == 0) { + cout << endl + << "Possible incorrect bond(s) with atom(s):" << endl; + flag9 = 1; + } + sf = temp_link[i][j]; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, sf, 0, atype[sf], p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + atype[sf], atype[sf], atype[sf], atype[sf], + atype[sf]); + ans = '@'; + while (ans != 'Y' && ans != 'y' && ans != 'N' && ans != 'n') { + cout << "Do you want to keep the bond? (y/n): "; + ans = cin.get(); + if (ans == '\n') + cout << "Please enter \"y\" or \"n\"." << endl; + else + cin.ignore(80, '\n'); + } + if (ans == 'N' || ans == 'n') { + for (k = j; k <= mult[so] - 1; k++) { + temp_link[i][k] = temp_link[i][k + 1]; + } + temp_link[i][mult[i]] = -1; + mult[i]--; + for (m = 1; m <= mult[sf]; m++) { + if (temp_link[sf][m] == so) { + for (q = m; q <= mult[sf] - 1; q++) { + temp_link[sf][q] = temp_link[sf][q + 1]; + } + temp_link[sf][mult[sf]] = -1; + } + } + mult[sf]--; + no_bonds--; + for (k = 1; k <= chk_bond_count; k++) { + if (chk_bond[k][1] == so || chk_bond[k][1] == sf) { + chk_bond[k][1] = -1; + } + } + for (k = 1; k <= u_nrot_bond_count; k++) { + if (u_nrot_bond[k][1] == so || u_nrot_bond[k][1] == sf) { + u_nrot_bond[k][1] = 0; + } + } + flag10 = 1; + j--; + } + } + } + if (mult[i] > 3) { + for (j = 1; j <= mult[i]; j++) { + if (strcmp(p[i]->r1.res_no, p[temp_link[i][j]]->r1.res_no) == 0) { + if (flag9 == 0) { + cout << endl + << "Possible incorrect bond(s) with atom(s):" << endl; + flag9 = 1; + } + sf = temp_link[i][j]; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, sf, 0, atype[sf], p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + atype[sf], atype[sf], atype[sf], atype[sf], + atype[sf]); + ans = '@'; + while (ans != 'Y' && ans != 'y' && ans != 'N' && ans != 'n') { + cout << "Do you want to keep the bond? (y/n): "; + ans = cin.get(); + if (ans == '\n') + cout << "Please enter \"y\" or \"n\"." << endl; + else + cin.ignore(80, '\n'); + } + if (ans == 'N' || ans == 'n') { + for (k = j; k <= mult[so] - 1; k++) { + temp_link[i][k] = temp_link[i][k + 1]; + } + temp_link[i][mult[i]] = -1; + mult[i]--; + for (m = 1; m <= mult[sf]; m++) { + if (temp_link[sf][m] == so) { + for (q = m; q <= mult[sf] - 1; q++) { + temp_link[sf][q] = temp_link[sf][q + 1]; + } + temp_link[sf][mult[sf]] = -1; + } + } + mult[sf]--; + no_bonds--; + for (k = 1; k <= chk_bond_count; k++) { + if (chk_bond[k][1] == so || chk_bond[k][1] == sf) { + chk_bond[k][1] = -1; + } + } + for (k = 1; k <= u_nrot_bond_count; k++) { + if (u_nrot_bond[k][1] == so || u_nrot_bond[k][1] == sf) { + u_nrot_bond[k][1] = 0; + } + } + flag10 = 1; + j--; + } + } + } + } + } + } else /* If Not 'C' 'N' 'O' 'H' Then ( metals! ligand! )*/ + { + if (mult[i] > 4) { + flag10 = -1; + so = i; + if (flag7 == 0) { + // system("clear"); + cout << endl << endl << "\t\t Checking valencies" << endl; + cout << dash1 << dash3 << endl; + flag7 = 1; + } + cout << endl + << "Valency of atom " << i << " is " << mult[i] + << ", greater than its maximum valency (4)" << endl; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, so, 0, atype[so], p[so]->r1.rname, p[so]->r1.res_no, + p[so]->r1.code, p[so]->r1.chain, atype[so], atype[so], + atype[so], atype[so], atype[so]); + for (j = 1; j <= mult[i]; j++) { + if (strcmp(p[i]->r1.res_no, p[temp_link[i][j]]->r1.res_no) != 0) { + if (flag9 == 0) { + cout << endl + << "Possible incorrect bond(s) with atom(s):" << endl; + flag9 = 1; + } + sf = temp_link[i][j]; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, sf, 0, atype[sf], p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + atype[sf], atype[sf], atype[sf], atype[sf], + atype[sf]); + ans = '@'; + while (ans != 'Y' && ans != 'y' && ans != 'N' && ans != 'n') { + cout << "Do you want to keep the bond? (y/n): "; + ans = cin.get(); + if (ans == '\n') + cout << "Please enter \"y\" or \"n\"." << endl; + else + cin.ignore(80, '\n'); + } + if (ans == 'N' || ans == 'n') { + for (k = j; k <= mult[i] - 1; k++) { + temp_link[i][k] = temp_link[i][k + 1]; + } + temp_link[i][mult[i]] = -1; + mult[i]--; + for (m = 1; m <= mult[sf]; m++) { + if (temp_link[sf][m] == so) { + for (q = m; q <= mult[sf] - 1; q++) { + temp_link[sf][q] = temp_link[sf][q + 1]; + } + temp_link[sf][mult[sf]] = -1; + } + } + mult[sf]--; + no_bonds--; + for (k = 1; k <= chk_bond_count; k++) { + if (chk_bond[k][1] == so || chk_bond[k][1] == sf) { + chk_bond[k][1] = -1; + } + } + for (k = 1; k <= u_nrot_bond_count; k++) { + if (u_nrot_bond[k][1] == so || u_nrot_bond[k][1] == sf) { + u_nrot_bond[k][1] = 0; + } + } + flag10 = 1; + j--; + } + } + } + if (mult[i] > 4) { + for (j = 1; j <= mult[i]; j++) { + if (strcmp(p[i]->r1.res_no, p[temp_link[i][j]]->r1.res_no) == 0) { + if (flag9 == 0) { + cout << endl + << "Possible incorrect bond(s) with atom(s):" << endl; + flag9 = 1; + } + sf = temp_link[i][j]; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, sf, 0, atype[sf], p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + atype[sf], atype[sf], atype[sf], atype[sf], + atype[sf]); + ans = '@'; + while (ans != 'Y' && ans != 'y' && ans != 'N' && ans != 'n') { + cout << "Do you want to keep the bond? (y/n): "; + ans = cin.get(); + if (ans == '\n') + cout << "Please enter \"y\" or \"n\"." << endl; + else + cin.ignore(80, '\n'); + } + if (ans == 'N' || ans == 'n') { + + for (k = j; k <= mult[i] - 1; k++) { + temp_link[i][k] = temp_link[i][k + 1]; + } + temp_link[i][mult[i]] = -1; + mult[i]--; + for (m = 1; m <= mult[sf]; m++) { + if (temp_link[sf][m] == so) { + for (q = m; q <= mult[sf] - 1; q++) { + temp_link[sf][q] = temp_link[sf][q + 1]; + } + temp_link[sf][mult[sf]] = -1; + } + } + mult[sf]--; + no_bonds--; + for (k = 1; k <= chk_bond_count; k++) { + if (chk_bond[k][1] == so || chk_bond[k][1] == sf) { + chk_bond[k][1] = -1; + } + } + for (k = 1; k <= u_nrot_bond_count; k++) { + if (u_nrot_bond[k][1] == so || u_nrot_bond[k][1] == sf) { + u_nrot_bond[k][1] = 0; + } + } + flag10 = 1; + j--; + } + } + } + } + } + } + if (flag10 == 1) { + cout << endl << "New valency = " << mult[i] << endl; + } else if (flag10 == -1) { + cout << endl << "Unchanged valency = " << mult[i] << endl; + } + } + if (flag7 == 1) { + cout << endl << endl << "\t\tValency check is finished! " << endl; + cout << "---------------------------------------------------------------" + << endl; + cout << "Type \"s\" to stop or \"c\" to continue: "; ans = cin.get(); - if( ans == 's' || ans == 'S' ) { - cout << "proflex process killed by user.\n" << endl; - exit(-1); + if (ans == 's' || ans == 'S') { + cout << "proflex process killed by user.\n" << endl; + exit(-1); } - if( ans != '\n' ) - cin.ignore(80,'\n'); + if (ans != '\n') + cin.ignore(80, '\n'); cout << endl << endl; } } // ends the if(usage == 0) condition -//-------------copy the temp. connectivety table to new memory optimized table. -//------------------------------allocating memory for the new connectivity table - link_noHB=(int**)new int*[no_atoms+1]; - for(i=0;i<=no_atoms;i++) - { - *(link_noHB+i)=(int*) new int[mult[i]+1]; - } -//---------------------------------copying the temp. table to the new one - for(i=1;i<=no_atoms;i++) - { - for(j=1;j<=mult[i];j++) - { - link_noHB[i][j]=temp_link[i][j]; - } + //-------------copy the temp. connectivety table to new memory optimized + //table. + //------------------------------allocating memory for the new connectivity + //table + link_noHB = (int **)new int *[no_atoms + 1]; + for (i = 0; i <= no_atoms; i++) { + *(link_noHB + i) = (int *)new int[mult[i] + 1]; + } + //---------------------------------copying the temp. table to the new one + for (i = 1; i <= no_atoms; i++) { + for (j = 1; j <= mult[i]; j++) { + link_noHB[i][j] = temp_link[i][j]; } - -//--------------------------------------------------Unknown Non Rotating Bonds + } + + //--------------------------------------------------Unknown Non Rotating Bonds flag9 = 0; - if( usage == 0 ) { - if( u_nrot_bond_count > 0 ) { - for( i = 1; i <= u_nrot_bond_count; i++) { - if( u_nrot_bond[i][1] != 0) { - // changed 11.02.01 AJR to only prompt for this double bond lock if a peptide bond. - if( (atype[u_nrot_bond[i][1]][2] == 'C' && atype[u_nrot_bond[i][2]][2] != 'N') || - (atype[u_nrot_bond[i][1]][2] == 'N' && atype[u_nrot_bond[i][2]][2] != 'C') ) { - so = u_nrot_bond[i][1]; - sf = u_nrot_bond[i][2]; - - /************************************************************/ - /* Print the warning message title only once. */ - if( flag9 == 0 ) { - cout<r1.rname,p[so]->r1.res_no, - p[so]->r1.code,p[so]->r1.chain,atype[sf],p[sf]->r1.rname, - p[sf]->r1.res_no,p[sf]->r1.code,p[sf]->r1.chain); - cout<<"\tType y to LOCK the dihedral angle or any key to keep unlocked: "; - - ans = cin.get(); - if(ans == 'y' || ans == 'Y' ) { - nrot_bond_count++; - nrot_bond[nrot_bond_count][1]=u_nrot_bond[i][1]; - nrot_bond[nrot_bond_count][2]=u_nrot_bond[i][2]; - } - if( ans != '\n' ) - cin.ignore( 80, '\n' ); - - } - } + if (usage == 0) { + if (u_nrot_bond_count > 0) { + for (i = 1; i <= u_nrot_bond_count; i++) { + if (u_nrot_bond[i][1] != 0) { + // changed 11.02.01 AJR to only prompt for this double bond lock if a + // peptide bond. + if ((atype[u_nrot_bond[i][1]][2] == 'C' && + atype[u_nrot_bond[i][2]][2] != 'N') || + (atype[u_nrot_bond[i][1]][2] == 'N' && + atype[u_nrot_bond[i][2]][2] != 'C')) { + so = u_nrot_bond[i][1]; + sf = u_nrot_bond[i][2]; + + /************************************************************/ + /* Print the warning message title only once. */ + if (flag9 == 0) { + cout << endl << "\tDihedral Angle Constraints:" << endl; + cout << endl + << "Should the following bond be considered as " + << "Non-Rotating?" << endl; + flag9 = 1; + } + + cout << endl << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, so, sf, atype[so], p[so]->r1.rname, + p[so]->r1.res_no, p[so]->r1.code, p[so]->r1.chain, + atype[sf], p[sf]->r1.rname, p[sf]->r1.res_no, + p[sf]->r1.code, p[sf]->r1.chain); + cout << "\tType y to LOCK the dihedral angle or any key to keep " + "unlocked: "; + + ans = cin.get(); + if (ans == 'y' || ans == 'Y') { + nrot_bond_count++; + nrot_bond[nrot_bond_count][1] = u_nrot_bond[i][1]; + nrot_bond[nrot_bond_count][2] = u_nrot_bond[i][2]; + } + if (ans != '\n') + cin.ignore(80, '\n'); + } + } } - } + } } // ends the if(usage == 0) condition - - //---count no. of isolated water atoms, isolated Hydrogens and all isolated atoms - for(i=1;i<=no_atoms;i++) - { - if(mult[i]==0) - { - all_iso++; - if( (strcmp(p[i]->r1.rname,"HOH")==0 || - strcmp(p[i]->r1.rname,"DOD")==0) && p[i]->r1.aname[2]=='O') - { - O_iso++; - } - } + + //---count no. of isolated water atoms, isolated Hydrogens and all isolated + //atoms + for (i = 1; i <= no_atoms; i++) { + if (mult[i] == 0) { + all_iso++; + if ((strcmp(p[i]->r1.rname, "HOH") == 0 || + strcmp(p[i]->r1.rname, "DOD") == 0) && + p[i]->r1.aname[2] == 'O') { + O_iso++; + } } -//------------------------------------Set DAH_type------------------------------- - + } + //------------------------------------Set + //DAH_type------------------------------- + h_list_count = 0; set_DAH_type(usage, mult); flag8 = 0; - #ifdef DEBUG +#ifdef DEBUG cout << "do i get here " << endl; - #endif - for( i = 0; i < chaincount; i++) { +#endif + for (i = 0; i < chaincount; i++) { tempo = chainptr[i]; - while( strcmp( tempo->r1.aname," N ") != 0 ) { // catches end of ATOM records - if( tempo == start ) { - flag8 = 1; - break; + while (strcmp(tempo->r1.aname, " N ") != + 0) { // catches end of ATOM records + if (tempo == start) { + flag8 = 1; + break; } tempo = tempo->prior; } - + // modify C-terminus - if( flag8 != 1 ) { + if (flag8 != 1) { #ifdef DEBUG cout << "in flag8 != 1" << endl; #endif tempo->r1.DAH_type = 'C'; tempo = chainptr[i]; - if( i != 0 ) { - tempo = tempo->next; - oxtflag = 0; - // Check whether the residue is known or unknown - for( j = 0; j < 20; j++ ) { - if(strcmp(tempo->r1.rname,res[j].rname)==0) { - n = tempo->r1.mod_res_no; - while(tempo->r1.mod_res_no==n) { - if(strcmp(tempo->r1.aname," OXT")==0 || - strcmp(tempo->r1.aname," OT ")==0 || - strcmp(tempo->r1.aname," OT1")==0 || - strcmp(tempo->r1.aname," OT2")==0) { - tempo->r1.DAH_type='E'; - oxtflag=n; + if (i != 0) { + tempo = tempo->next; + oxtflag = 0; + // Check whether the residue is known or unknown + for (j = 0; j < 20; j++) { + if (strcmp(tempo->r1.rname, res[j].rname) == 0) { + n = tempo->r1.mod_res_no; + while (tempo->r1.mod_res_no == n) { + if (strcmp(tempo->r1.aname, " OXT") == 0 || + strcmp(tempo->r1.aname, " OT ") == 0 || + strcmp(tempo->r1.aname, " OT1") == 0 || + strcmp(tempo->r1.aname, " OT2") == 0) { + tempo->r1.DAH_type = 'E'; + oxtflag = n; #ifdef DEBUG - cout << "found OXT? ?" << oxtflag << endl; + cout << "found OXT? ?" << oxtflag << endl; #endif - } - tempo=tempo->next; - } - tempo=tempo->prior; - while(strcmp(tempo->r1.aname," O ")!=0) tempo=tempo->prior; - if( oxtflag == 0 ) { - if( usage == 0 ) { - cout << endl << "\tThe final residue, # " << tempo->r1.res_no << " of chain ID " - << tempo->r1.chain <r1.DAH_type='E'; - } - if( ans != '\n' ) - cin.ignore( 80, '\n' ); - - } - else { - tempo->r1.DAH_type='A'; - } - } - else { - if(strcmp(tempo->r1.aname," O ") == 0 ) - tempo->r1.DAH_type='E'; - } - } - } + } + tempo = tempo->next; + } + tempo = tempo->prior; + while (strcmp(tempo->r1.aname, " O ") != 0) + tempo = tempo->prior; + if (oxtflag == 0) { + if (usage == 0) { + cout << endl + << "\tThe final residue, # " << tempo->r1.res_no + << " of chain ID " << tempo->r1.chain << endl + << "\twas not identified as a terminal oxygen " + << "(OXT)." << endl + << "\t" + << "Enter (y)es if the main chain oxygen in this residue" + << endl + << "\tshould be regarded as a charged acceptor at the " + "C-terminus: " + << endl; + + ans = cin.get(); + + if (ans == 'y' || ans == 'Y') { + tempo->r1.DAH_type = 'E'; + } + if (ans != '\n') + cin.ignore(80, '\n'); + + } else { + tempo->r1.DAH_type = 'A'; + } + } else { + if (strcmp(tempo->r1.aname, " O ") == 0) + tempo->r1.DAH_type = 'E'; + } + } + } } } } flag8 = 0; tempo = start; - while( strcmp( tempo->r1.field1,"ATOM ") != 0 ) - { - if(tempo==last) - { - flag8=1; - break; - } - tempo=tempo->next; + while (strcmp(tempo->r1.field1, "ATOM ") != 0) { + if (tempo == last) { + flag8 = 1; + break; } - if(flag8!=1) - { - for(j=0;j<20;j++) - { - if(strcmp(tempo->r1.rname,res[j].rname)==0) - { - n=tempo->r1.mod_res_no; - while(tempo->r1.mod_res_no==n) - { - if(strcmp(tempo->r1.aname," OXT")==0 || - strcmp(tempo->r1.aname," OT ")==0 || - strcmp(tempo->r1.aname," OT1")==0 || - strcmp(tempo->r1.aname," OT2")==0) - { - tempo->r1.DAH_type='E'; - } - if(strcmp(tempo->r1.aname," O ")==0 ) - { - /*if(usage == 0){ - cout << endl << "\tEnter (n) if the oxygen in residue " << tempo->r1.rname - << " at the end" << endl << "\tof chain ID [" << tempo->r1.chain - << "] and residue # " << tempo->r1.res_no << " should NOT be" - << endl << "\tregarded as a charged acceptor at a C-terminus: " ; - - cin >> answer; - if( strlen(answer) == 1 ) ans = answer[0]; - else ans = 'Y'; - if( ans == 'n' ) ans = 'N'; - if(ans!='N') - tempo->r1.DAH_type='E'; - } - - else tempo->r1.DAH_type='E';*/ - tempo->r1.DAH_type='E'; - } - if(tempo==last) - { - break; - } - tempo = tempo->next; - } - break; - } - } - } - - for( i = 1; i <= no_atoms; i++ ) { - - if( p[i]->r1.aname[2] == 'H' || p[i]->r1.aname[2] == 'D' ) { - - so = p[i]->r1.ri_sr_no; - if( mult[i]==1 ) { - sf = link_noHB[so][1]; - if( p[sf]->r1.DAH_type=='B' || p[sf]->r1.DAH_type=='C' || - p[sf]->r1.DAH_type=='D' ) - { - p[so]->r1.DAH_type='V'; - h_list[h_list_count] = so; - h_list_count++; - } - else { - p[so]->r1.DAH_type='N'; - } + tempo = tempo->next; + } + if (flag8 != 1) { + for (j = 0; j < 20; j++) { + if (strcmp(tempo->r1.rname, res[j].rname) == 0) { + n = tempo->r1.mod_res_no; + while (tempo->r1.mod_res_no == n) { + if (strcmp(tempo->r1.aname, " OXT") == 0 || + strcmp(tempo->r1.aname, " OT ") == 0 || + strcmp(tempo->r1.aname, " OT1") == 0 || + strcmp(tempo->r1.aname, " OT2") == 0) { + tempo->r1.DAH_type = 'E'; + } + if (strcmp(tempo->r1.aname, " O ") == 0) { + /*if(usage == 0){ +cout << endl << "\tEnter (n) if the oxygen in residue " << tempo->r1.rname +<< " at the end" << endl << "\tof chain ID [" << tempo->r1.chain +<< "] and residue # " << tempo->r1.res_no << " should NOT be" +<< endl << "\tregarded as a charged acceptor at a C-terminus: " ; + +cin >> answer; +if( strlen(answer) == 1 ) ans = answer[0]; +else ans = 'Y'; +if( ans == 'n' ) ans = 'N'; +if(ans!='N') +tempo->r1.DAH_type='E'; + } + + else tempo->r1.DAH_type='E';*/ + tempo->r1.DAH_type = 'E'; + } + if (tempo == last) { + break; + } + tempo = tempo->next; + } + break; } - else { - p[so]->r1.DAH_type='N'; + } + } + + for (i = 1; i <= no_atoms; i++) { + + if (p[i]->r1.aname[2] == 'H' || p[i]->r1.aname[2] == 'D') { + + so = p[i]->r1.ri_sr_no; + if (mult[i] == 1) { + sf = link_noHB[so][1]; + if (p[sf]->r1.DAH_type == 'B' || p[sf]->r1.DAH_type == 'C' || + p[sf]->r1.DAH_type == 'D') { + p[so]->r1.DAH_type = 'V'; + h_list[h_list_count] = so; + h_list_count++; + } else { + p[so]->r1.DAH_type = 'N'; + } + } else { + p[so]->r1.DAH_type = 'N'; } } } - #ifdef DEBUG +#ifdef DEBUG cout << "one" << endl; - #endif -// search for hydrophobic tethers AJR 03.20.02 using new function +#endif + // search for hydrophobic tethers AJR 03.20.02 using new function no_tether = find_hydrophob(); - - #ifdef DEBUG + +#ifdef DEBUG cout << "three" << endl; - #endif -// Write all record info into _proflexdataset. +#endif + // Write all record info into _proflexdataset. make_chem_rec(); - #ifdef DEBUG +#ifdef DEBUG cout << "four" << endl; - #endif - -// Write three new pseudoatoms for each Hydrophobic Tethers +#endif + + // Write three new pseudoatoms for each Hydrophobic Tethers write_HPatom(p); #ifdef DEBUG @@ -1826,169 +1681,166 @@ printf("1. chk_bond_count =%d so %d sf %d dist %f\n",chk_bond_count,so,sf,temp); #ifdef DEBUG cout << "six" << endl; #endif -// Append CF connectivity to _proflexdataset file - - yofil.open(outputfile,ios::app); - yofil<<"REMARK:L:"<i) - { - yofil<<"REMARK:CF "< i) { + yofil << "REMARK:CF " << setw(5) << i << " " << setw(5) + << link_noHB[i][j] << endl; + } } -// write CF bonds for Hydrophobic tethers. + } + // write CF bonds for Hydrophobic tethers. write_HPCFbond(); - yofil<<"REMARK:L:"<0) - { - yofil<<"REMARK:w:check_bonding: Dist. A1# A1 Res1 Res1# C1 A2# A2 " - <<"Res2 Res2# C2"<r1.rname<<" "<r1.res_no - <r1.code[0]<<" "<r1.chain; - yofil<r1.rname<<" " - <r1.res_no<r1.code[0]<<" "<r1.chain - <0) - { - yofil<<"REMARK:w:isolated_atoms: Number of isolated atoms = "<0) - { - yofil<<"REMARK:w:isolated_water: Number of isolated water atoms = " - <0) - { - yofil<<"REMARK:w:isolated_hydrogen: Number of isolated hydrogen atoms = " - < 0) { + yofil + << "REMARK:w:check_bonding: Dist. A1# A1 Res1 Res1# C1 A2# A2 " + << "Res2 Res2# C2" << endl; + for (i = 1; i <= chk_bond_count; i++) { + if (chk_bond[i][1] != -1) { + so = chk_bond[i][1]; + sf = chk_bond[i][2]; + yofil << "REMARK:W:check_bonding:" + << setiosflags(ios::showpoint | ios::fixed) << setprecision(5) + << setw(5) << chk_bond_dist[i] << setw(5) << so << atype[so] + << " " << p[so]->r1.rname << " " << p[so]->r1.res_no + << p[so]->r1.code[0] << " " << p[so]->r1.chain; + yofil << setw(5) << sf << atype[sf] << " " << p[sf]->r1.rname << " " + << p[sf]->r1.res_no << p[sf]->r1.code[0] << " " << p[sf]->r1.chain + << endl; + } } - -//------------------------------Write number of disulfide bonds in _proflexdataset - if(ns_bond>0) - { - yofil<<"REMARK:w:disulfide_bonds: Number of disulfide bonds = "< 0) { + yofil << "REMARK:w:isolated_atoms: Number of isolated atoms = " << all_iso + << endl; + if (O_iso > 0) { + yofil << "REMARK:w:isolated_water: Number of isolated water atoms = " + << O_iso << endl; } -//--------------------------------Write SKIP_NONHYDROGEN atoms into _proflexdataset - if(skip_nhydro_count>0) - { - yofil<<"REMARK:w:skip_nonhydrogen: Atom# Atom Res Res# Chain"<r1.rname<<" "<r1.res_no<r1.code[0] - <r1.chain< 0) { + yofil + << "REMARK:w:isolated_hydrogen: Number of isolated hydrogen atoms = " + << skip_hydro_count << endl; + } + yofil << "REMARK:L:" << dash1 << dash2 << endl; + } + + //------------------------------Write number of disulfide bonds in + //_proflexdataset + if (ns_bond > 0) { + yofil << "REMARK:w:disulfide_bonds: Number of disulfide bonds = " << ns_bond + << endl; + yofil << "REMARK:L:" << dash1 << dash2 << endl; + } + //--------------------------------Write SKIP_NONHYDROGEN atoms into + //_proflexdataset + if (skip_nhydro_count > 0) { + yofil << "REMARK:w:skip_nonhydrogen: Atom# Atom Res Res# Chain" << endl; + for (i = 1; i <= skip_nhydro_count; i++) { + so = skip_nhydro[i]; + yofil << "REMARK:W:skip_nonhydrogen:" << setw(5) << so << " " << atype[so] + << " " << p[so]->r1.rname << " " << p[so]->r1.res_no + << p[so]->r1.code[0] << p[so]->r1.chain << endl; + } + yofil << "REMARK:L:" << dash1 << dash2 << endl; + } /************************************************************/ /* Writing POOR_BOND into _proflexdataset file. */ /************************************************************/ - if( poor_bond_count > 0 ) { - yofil<<"REMARK:w:poor_bond: Dist. A1# A1 Res1 Res1# C1 A2# A2 " - <<"Res2 Res2# C2"<r1.rname<<" "<r1.res_no - <r1.code[0]<<" "<r1.chain; - yofil<r1.rname<<" " - <r1.res_no<r1.code[0]<<" "<r1.chain - < 0) { + yofil << "REMARK:w:poor_bond: Dist. A1# A1 Res1 Res1# C1 A2# A2 " + << "Res2 Res2# C2" << endl; + for (i = 1; i <= poor_bond_count; i++) { + if (poor_bond[i][1] != -1) { + so = poor_bond[i][1]; + sf = poor_bond[i][2]; + yofil << "REMARK:W:poor_bond:" + << setiosflags(ios::showpoint | ios::fixed) << setprecision(5) + << setw(10) << poor_bond_dist[i] << setw(5) << so << atype[so] + << " " << p[so]->r1.rname << " " << p[so]->r1.res_no + << p[so]->r1.code[0] << " " << p[so]->r1.chain; + yofil << setw(5) << sf << atype[sf] << " " << p[sf]->r1.rname << " " + << p[sf]->r1.res_no << p[sf]->r1.code[0] << " " << p[sf]->r1.chain + << endl; } } - yofil<<"REMARK:L:"< 0 ) { - yofil<<"REMARK:w:skip_hydrogen: Atom# Atom Res Res# Chain"< 0) { + yofil << "REMARK:w:skip_hydrogen: Atom# Atom Res Res# Chain" << endl; + for (i = 1; i <= skip_hydro_count; i++) { so = skip_hydro[i]; - yofil<<"REMARK:W:skip_hydrogen:"<r1.rname<<" "<r1.res_no<r1.code[0] - <r1.chain<r1.rname << " " << p[so]->r1.res_no + << p[so]->r1.code[0] << p[so]->r1.chain << endl; } - yofil<<"REMARK:L:"< 0 ) { - yofil<<"REMARK:w:missing_atoms: Atom Res Res# Chain"< 0) { + yofil << "REMARK:w:missing_atoms: Atom Res Res# Chain" << endl; + for (i = 1; i <= ma_count; i++) { so = missing[i]; - yofil<<"REMARK:W:missing_atoms:"<<" "<r1.rname<<" "<r1.res_no<r1.code<<" " - <r1.chain<r1.rname << " " + << p[so]->r1.res_no << p[so]->r1.code << " " << p[so]->r1.chain + << endl; } - yofil<<"REMARK:L:"< 0 ) { - cout< 0) { + cout << endl << dash1 << dash3 << endl; + cout << "The following chains were relabelled:" << endl; + yofil << "REMARK:w:chain_id: Old Cid New Cid" << endl; + cout << "chain_id: Old Cid New Cid" << endl; + for (i = 1; i <= chain_change_count; i++) { + yofil << "REMARK:W:chain_id: " << chain_change[i][0] << " " + << chain_change[i][1] << endl; + cout << " " << chain_change[i][0] << " " + << chain_change[i][1] << endl; } - yofil<<"REMARK:L:"<0) { - if(conf_option==1) { - yofil<<"REMARK:w:conformation_auto: Residue Residue no. Chain " - <<"Conformation"<r1.rname - <<" "<r1.res_no<r1.code[0] - <<" "<r1.chain<<" "< 0) { + if (conf_option == 1) { + yofil << "REMARK:w:conformation_auto: Residue Residue no. Chain " + << "Conformation" << endl; + for (i = 0; i < altloccount; i++) { + yofil << "REMARK:W:conformation_auto:" + << " " << altlocptr[i]->r1.rname << " " + << altlocptr[i]->r1.res_no << altlocptr[i]->r1.code[0] + << " " << altlocptr[i]->r1.chain << " " + << conf_chosen[i] << endl; } - } - else { - yofil<<"REMARK:w:conformation_user: Residue Residue no. Chain " - <<"Conformation"<r1.rname - <<" "<r1.res_no<r1.code[0] - <<" "<r1.chain<<" "<r1.rname << " " + << altlocptr[i]->r1.res_no << altlocptr[i]->r1.code[0] + << " " << altlocptr[i]->r1.chain << " " + << conf_chosen[i] << endl; } } - yofil<<"REMARK:L:"<> answer; - - if( strlen(answer) == 1 ) ans = answer[0]; - else ans = 'Y'; - if( ans == 'n' ) ans = 'N'; - if(ans!='N') { - return (1);//-------------make connection - } - else { - return (0);//------------don't make connection - } - } - } - else { - if(d>distance[a1][a2].d[3]) { //----------dist>d_max - if(d < maxdist) { - if(usage) {return(0);}//------------don't make connection - else{ - cout<> answer; - if( strlen(answer) == 1 ) ans = answer[0]; - else ans = 'Y'; - if( ans == 'n' ) ans = 'N'; - if(ans!='N') { - return (1);//----------make connection - } - else { - return (0);//---------don't make conection - } - } - } - else { - return (0);//------------don't make connection - } + cout << endl + << "Caution: The distance of [d =" + << setiosflags(ios::showpoint | ios::fixed) << setprecision(2) + << setw(5) << d << " Ang.] seems low!" << endl; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, so, sf, atom1, rname1, res_no1, code1, chain1, atom2, + rname2, res_no2, code2, chain2); + cout << "Type n NOT to connect: "; + cin >> answer; + + if (strlen(answer) == 1) + ans = answer[0]; + else + ans = 'Y'; + if (ans == 'n') + ans = 'N'; + if (ans != 'N') { + return (1); //-------------make connection + } else { + return (0); //------------don't make connection + } } - else { - return (1); + } else { + if (d > distance[a1][a2].d[3]) { //----------dist>d_max + if (d < maxdist) { + if (usage) { + return (0); + } //------------don't make connection + else { + cout << endl + << "Caution: The distance of [d =" + << setiosflags(ios::showpoint | ios::fixed) << setprecision(3) + << setw(5) << d << " Ang.] seems high!" << endl; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, so, sf, atom1, rname1, res_no1, code1, chain1, + atom2, rname2, res_no2, code2, chain2); + cout << "Type n NOT to connect: "; + cin >> answer; + if (strlen(answer) == 1) + ans = answer[0]; + else + ans = 'Y'; + if (ans == 'n') + ans = 'N'; + if (ans != 'N') { + return (1); //----------make connection + } else { + return (0); //---------don't make conection + } + } + } else { + return (0); //------------don't make connection + } + } else { + return (1); } } - } - else if( type == 2 ) { - if(ddistance[a1][a2].d[3]) {//------(dist < d_min) or (dist > d_max) - return (0); //--------------don't make connection - } - else { - return (1); //--------------make connection - } - } - else if( type == 3 ) { - if(ddistance[a1][a2].d[3]) { //------(dist < d_min) or (dist > d_max) - return (0); //--------------don't make connection + } else if (type == 2) { + if (d < distance[a1][a2].d[0] || + d > distance[a1][a2].d[3]) { //------(dist < d_min) or (dist > d_max) + return (0); //--------------don't make connection + } else { + return (1); //--------------make connection } - else { - cout< distance[a1][a2].d[3]) { //------(dist < d_min) or (dist > d_max) + return (0); //--------------don't make connection + } else { + cout << endl << "Atoms belong to different chains!" << endl; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, so, sf, atom1, rname1, res_no1, code1, chain1, atom2, + rname2, res_no2, code2, chain2); + cout << "Type n NOT to connect: "; cin >> answer; - if( strlen(answer) == 1 ) ans = answer[0]; - else ans = 'Y'; - if(ans!='N' && ans!='n') { - return (1);//----------make connection - } - else { - return (0);//---------don't make conection + if (strlen(answer) == 1) + ans = answer[0]; + else + ans = 'Y'; + if (ans != 'N' && ans != 'n') { + return (1); //----------make connection + } else { + return (0); //---------don't make conection } - } - } - else { - if(ddistance[a1][a2].d[3]) {//------(dist < d_min) or (dist > d_max) - return (0); //--------------don't make connection } - else { - if(ddistance[a1][a2].d[2]) { //----------d_big < dist < d_max - cout< distance[a1][a2].d[3]) { //------(dist < d_min) or (dist > d_max) + return (0); //--------------don't make connection + } else { + if (d < distance[a1][a2].d[1]) { //------d_min < dist < d_low + cout << endl + << "Caution: The distance of [d =" + << setiosflags(ios::showpoint | ios::fixed) << setprecision(2) + << setw(5) << d << " Ang.] seems low!" << endl; + /*cout<<"\t"< distance[a1][a2].d[2]) { //----------d_big < dist < d_max + cout << endl + << "Caution: The distance of [d =" + << setiosflags(ios::showpoint | ios::fixed) << setprecision(2) + << setw(5) << d << " Ang.] seems high!" << endl; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, so, sf, atom1, rname1, res_no1, code1, chain1, atom2, + rname2, res_no2, code2, chain2); + return (1); //----make connection + } else { + return (1); //----------make connection + } } } } } -/**********************************************************************/ - +/**********************************************************************/ /**********************************************************************/ /* This function had the first variable renamed to my_mult since it is */ @@ -2280,15 +2158,17 @@ int list::check_dist(int so,int sf,float d, char *atom1, char *atom2, /* way the function treated mult in the past since it shadowed the class */ /* variable with the same name -- vanvoor4 April 13, 2010 */ void list::make_connection(int *my_mult, int **temp_link, int so, int sf) { - if( my_mult[so] >= maxr -1 ) { + if (my_mult[so] >= maxr - 1) { // 2007:03 SN --- "Multiplicity" is a misnomer. Change it to "Valency" - cout << "Valency of atom # " << so << " is (" << my_mult[so] << ") greater than "; - cout << maxr-1 << "; therefore EXIT!" << endl; + cout << "Valency of atom # " << so << " is (" << my_mult[so] + << ") greater than "; + cout << maxr - 1 << "; therefore EXIT!" << endl; exit(20); } - if( my_mult[sf] >= maxr -1 ) { - cout << "Valency of atom # " << sf << " is (" << my_mult[sf] << ")greater than "; - cout << maxr-1 << "; therefore EXIT!" << endl; + if (my_mult[sf] >= maxr - 1) { + cout << "Valency of atom # " << sf << " is (" << my_mult[sf] + << ")greater than "; + cout << maxr - 1 << "; therefore EXIT!" << endl; exit(20); } my_mult[so]++; @@ -2302,24 +2182,26 @@ void list::make_connection(int *my_mult, int **temp_link, int so, int sf) { /* Subroutine to format output to stdout. Based on commonly outputting*/ /* these variables at various points during FIRST. */ /**********************************************************************/ -void list::write_output(int type, int so, int sf, char *atom1, char *rname1, - char *res_no1,char *code1, char *cid1, char *atom2, - char *rname2, char *res_no2,char *code2,char *cid2) { - - if( type == 1 ) { //---------write to screen(one below the other) - cout<<"\t"< this no longer is the rate limiting */ -/* subroutine. */ -/* 03.20.02 AJR based upon makeHP.c of Brandon M. Hespenheide */ +/* 05.09.02 AJR modified and improved the search methods in not_2nd_neighb, */ +/* not_3rd_neighb, and find_hydrophob --> this no longer is the rate limiting */ +/* subroutine. */ +/* 03.20.02 AJR based upon makeHP.c of Brandon M. Hespenheide */ /* */ -/* 11.15.00 BMH */ +/* 11.15.00 BMH */ /* */ -/* 09.06.01 AJR Modified code to not assign an Hphob contact to metal CA atoms */ -/* Also introduced a check for chain_ids to print or not print them as */ -/* dictated by the input datasetfile. */ +/* 09.06.01 AJR Modified code to not assign an Hphob contact to metal CA atoms + */ +/* Also introduced a check for chain_ids to print or not print them as + */ +/* dictated by the input datasetfile. */ /* */ -/* 02.14.03 BMH Finished cleaning up code (easier to read, less logic taking */ -/* up cycles, ...). Also added some new routines for testing */ -/* alternative definitions of a hydrophobic interaction. */ +/* 02.14.03 BMH Finished cleaning up code (easier to read, less logic taking */ +/* up cycles, ...). Also added some new routines for testing */ +/* alternative definitions of a hydrophobic interaction. */ /* */ -/* vdwaals_4HP_1HB.c Written in C++ */ +/* vdwaals_4HP_1HB.c Written in C++ */ /* */ -/* This program modifies a *_proflexdataset file. Hydrophobic contacts */ -/* are identified using variable distance criteria. These HP-contacts are */ -/* represented as hydrogen bonds, with 4 "psuedo-atoms"between the donor and */ -/* the bonding hydrogen, resulting in 1 constraint for the bond. */ +/* This program modifies a *_proflexdataset file. Hydrophobic contacts */ +/* are identified using variable distance criteria. These HP-contacts are */ +/* represented as hydrogen bonds, with 4 "psuedo-atoms"between the donor and */ +/* the bonding hydrogen, resulting in 1 constraint for the bond. */ /* */ -/* Hydrogen bonds are identifies using the REMARK:HB lines in the input *_FIRST */ -/* dataset file. These bonds are modifed to have a single psuedo atom, adding */ -/* a degree of freedom back to the system. */ +/* Hydrogen bonds are identifies using the REMARK:HB lines in the input *_FIRST + */ +/* dataset file. These bonds are modifed to have a single psuedo atom, adding */ +/* a degree of freedom back to the system. */ /********************************************************************************/ -/* Program modified by AJR 09.06.01 to not assign an Hphob contact to metal CA */ -/* atoms. Also introduced a check for chain_ids to print or not print them as */ -/* dictated by the input datasetfile. */ +/* Program modified by AJR 09.06.01 to not assign an Hphob contact to metal CA + */ +/* atoms. Also introduced a check for chain_ids to print or not print them as + */ +/* dictated by the input datasetfile. */ /********************************************************************************/ /**********************************************************************/ @@ -59,62 +63,58 @@ /* given cutoff, accept the interaction as a hydrophobic tether. */ /**********************************************************************/ #include -int list::determine_vdWaals_contact( node *cp, node *tp) { - - float - atom_atom_dis = 0.0, - vdr1=0.0, - vdr2=0.0, - aad2, - sum_of_vdWaals = 0.0; - - int - j,so, - is_contact = 1; - - char atom1[6],atom2[6]; - - strcpy(atom1,cp->r1.aname); - strcpy(atom2,tp->r1.aname); +int list::determine_vdWaals_contact(node *cp, node *tp) { + + float atom_atom_dis = 0.0, vdr1 = 0.0, vdr2 = 0.0, aad2, sum_of_vdWaals = 0.0; + + int j, so, is_contact = 1; + + char atom1[6], atom2[6]; + + strcpy(atom1, cp->r1.aname); + strcpy(atom2, tp->r1.aname); so = cp->r1.ri_sr_no; - - if(atom1[2]== 'S') {vdr1 = 1.80;} - else if(atom1[2]=='C') { + + if (atom1[2] == 'S') { + vdr1 = 1.80; + } else if (atom1[2] == 'C') { vdr1 = 1.70; - if(strcmp(atom1," CA ")) { - if(!strcmp(cp->r1.field1,"HETATM") ) { - if( !strcmp(cp->r1.rname," CA") || !strcmp(cp->r1.rname,"CA ") ){vdr1 = 0.0;} - } + if (strcmp(atom1, " CA ")) { + if (!strcmp(cp->r1.field1, "HETATM")) { + if (!strcmp(cp->r1.rname, " CA") || !strcmp(cp->r1.rname, "CA ")) { + vdr1 = 0.0; + } + } } } - if(atom2[2]== 'S') {vdr2 = 1.80;} - else if(atom2[2]=='C') { + if (atom2[2] == 'S') { + vdr2 = 1.80; + } else if (atom2[2] == 'C') { vdr2 = 1.70; - if(strcmp(atom2," CA ")) { - if(!strcmp(tp->r1.field1,"HETATM") ) { - if( !strcmp(tp->r1.rname," CA") || !strcmp(tp->r1.rname,"CA ") ){vdr2 = 0.0;} - } + if (strcmp(atom2, " CA ")) { + if (!strcmp(tp->r1.field1, "HETATM")) { + if (!strcmp(tp->r1.rname, " CA") || !strcmp(tp->r1.rname, "CA ")) { + vdr2 = 0.0; + } + } } } - sum_of_vdWaals = vdr1+vdr2; - aad2=0; - for(j=1;j<=3;j++) - { - aad2+=pow((cp->r1.coord[j]-tp->r1.coord[j]),2); - } - atom_atom_dis=sqrt(aad2); + sum_of_vdWaals = vdr1 + vdr2; + aad2 = 0; + for (j = 1; j <= 3; j++) { + aad2 += pow((cp->r1.coord[j] - tp->r1.coord[j]), 2); + } + atom_atom_dis = sqrt(aad2); /**************************************************/ /* the value 2.2 Angstrom was selected to exclude */ - /* covalently bonded atom pairs. */ + /* covalently bonded atom pairs. */ /**************************************************/ - if( (atom_atom_dis < 2.20 ) || - (atom_atom_dis > ((sum_of_vdWaals) + R_factor)) ) + if ((atom_atom_dis < 2.20) || (atom_atom_dis > ((sum_of_vdWaals) + R_factor))) is_contact = 0; - + return (is_contact); - } /**********************************************************************/ @@ -127,13 +127,12 @@ int list::test_for_covalent(int so, int sf, int mso) { int i = 0; - for( i = 1; i <= mso; i++) { - if( link_noHB[so][i] == sf ) - return( sf ); + for (i = 1; i <= mso; i++) { + if (link_noHB[so][i] == sf) + return (sf); } - return( 0 ); - + return (0); } /**********************************************************************/ @@ -145,19 +144,17 @@ int list::test_for_covalent(int so, int sf, int mso) { /**********************************************************************/ int list::not_2nd_neighb(int s1, int s2) { - int - sa = 0, - m = 0; - - for( m = 1; m <= mult[s1]; m++){ - sa = link_noHB[s1][m]; - if( p[sa]->r1.aname[2] != 'H' && p[sa]->r1.aname[2] != 'D' ){ - if( test_for_covalent(s2, sa, mult[s2]) ) - return(0); - } + int sa = 0, m = 0; + + for (m = 1; m <= mult[s1]; m++) { + sa = link_noHB[s1][m]; + if (p[sa]->r1.aname[2] != 'H' && p[sa]->r1.aname[2] != 'D') { + if (test_for_covalent(s2, sa, mult[s2])) + return (0); } - - return(1); + } + + return (1); } /**********************************************************************/ @@ -168,20 +165,18 @@ int list::not_2nd_neighb(int s1, int s2) { /**********************************************************************/ int list::not_3rd_neighb(int so, int sf) { - int - i = 0, - sa = 0; + int i = 0, sa = 0; - for( i = 1; i <= mult[so]; i++) { + for (i = 1; i <= mult[so]; i++) { sa = link_noHB[so][i]; // exclude hydrogens, they're monovalent - if( p[sa]->r1.aname[2] != 'H' && p[sa]->r1.aname[2] != 'D' ){ - if( !not_2nd_neighb(sa,sf) ) - return( 0 ); + if (p[sa]->r1.aname[2] != 'H' && p[sa]->r1.aname[2] != 'D') { + if (!not_2nd_neighb(sa, sf)) + return (0); } } - - return(1); + + return (1); } /**********************************************************************/ @@ -190,32 +185,33 @@ int list::not_3rd_neighb(int so, int sf) { /* both hydrophobic atoms are bonded to only other carbon or sulfur */ /* atoms. */ /**********************************************************************/ -int list::only_bonded_to_Hphobes(int so, int sf){ +int list::only_bonded_to_Hphobes(int so, int sf) { - int - a = 0; + int a = 0; - for( a = 1; a <= mult[so]; a++ ) { - if( p[ link_noHB[so][a] ]->r1.aname[2] != 'C' && - p[ link_noHB[so][a] ]->r1.aname[2] != 'S' && + for (a = 1; a <= mult[so]; a++) { + if (p[link_noHB[so][a]]->r1.aname[2] != 'C' && + p[link_noHB[so][a]]->r1.aname[2] != 'S' && - // AJR 06.24.03 added a line to omit hydrogen atoms as counting against - Sameer - p[ link_noHB[so][a] ]->r1.aname[2] != 'H' ) + // AJR 06.24.03 added a line to omit hydrogen atoms as counting against + // - Sameer + p[link_noHB[so][a]]->r1.aname[2] != 'H') - return(0); + return (0); } - for( a = 1; a <= mult[sf]; a++ ) { - if( p[ link_noHB[sf][a] ]->r1.aname[2] != 'C' && - p[ link_noHB[sf][a] ]->r1.aname[2] != 'S' && + for (a = 1; a <= mult[sf]; a++) { + if (p[link_noHB[sf][a]]->r1.aname[2] != 'C' && + p[link_noHB[sf][a]]->r1.aname[2] != 'S' && - // AJR 06.24.03 added a line to omit hydrogen atoms as counting against - Sameer - p[ link_noHB[sf][a] ]->r1.aname[2] != 'H' ) + // AJR 06.24.03 added a line to omit hydrogen atoms as counting against + // - Sameer + p[link_noHB[sf][a]]->r1.aname[2] != 'H') - return(0); + return (0); } - - return(1); + + return (1); } /**********************************************************************/ @@ -224,7 +220,7 @@ int list::only_bonded_to_Hphobes(int so, int sf){ /* between atoms that have a specific atomic density of Hphobic atoms */ /* within a given sphere radius. */ /**********************************************************************/ -int list::Hphobe_atomic_density( int so, int sf ){ +int list::Hphobe_atomic_density(int so, int sf) { std::cerr << "Unimplemented function in hydrophobic.cpp!!!" << std::endl; return 0; } @@ -235,38 +231,39 @@ int list::Hphobe_atomic_density( int so, int sf ){ /**********************************************************************/ int list::find_hydrophob(void) { - int i,so,sf, **temp_hpteth; - int iix,iiy,iiz,jx,jy,jz,kx,ky,kz,nval; + int i, so, sf, **temp_hpteth; + int iix, iiy, iiz, jx, jy, jz, kx, ky, kz, nval; char atype1[6], atype2[6]; ofstream xofil; nval = no_atoms; - //if(no_atoms >= 20000) { nval = (int)(no_atoms/2); } - temp_hpteth = (int **)new int *[nval+1]; - for(i=0; i<=nval;i++){ + // if(no_atoms >= 20000) { nval = (int)(no_atoms/2); } + temp_hpteth = (int **)new int *[nval + 1]; + for (i = 0; i <= nval; i++) { // temp_hpteth = (int **)new int *[no_atoms+1]; - //for(i=0; i<=no_atoms;i++){ - *(temp_hpteth+i) = (int *) new int[2]; + // for(i=0; i<=no_atoms;i++){ + *(temp_hpteth + i) = (int *)new int[2]; } - int hpcount=0; + int hpcount = 0; - /* ################################################################AJR 03.21.02 - Identify the Hydrophobic contacts and place them into the array hp_tether[hpcount][i] + /* ################################################################AJR + 03.21.02 Identify the Hydrophobic contacts and place them into the array + hp_tether[hpcount][i] ######################################################################################*/ /* Cleaned up a bit. BMH 9.25.02 */ /************************************************************/ /* Hphob contact found by using "Hash code data structure */ /************************************************************/ - for( i = 1; i <= no_atoms; i++ ){ + for (i = 1; i <= no_atoms; i++) { so = p[i]->r1.ri_sr_no; - strcpy(atype1,p[i]->r1.aname); - if( atype1[2]== 'C' || atype1[2]=='S'){ - - iix=(int)((p[i]->r1.coord[1]-xmin)/grdlen); - iiy=(int)((p[i]->r1.coord[2]-ymin)/grdlen); - iiz=(int)((p[i]->r1.coord[3]-zmin)/grdlen); - + strcpy(atype1, p[i]->r1.aname); + if (atype1[2] == 'C' || atype1[2] == 'S') { + + iix = (int)((p[i]->r1.coord[1] - xmin) / grdlen); + iiy = (int)((p[i]->r1.coord[2] - ymin) / grdlen); + iiz = (int)((p[i]->r1.coord[3] - zmin) / grdlen); + /**********************************************************************/ /* The following code uses the "hash" routine employed in various */ /* spots in FIRST. The method relies on placing a 3D grid on the prot.*/ @@ -282,161 +279,155 @@ int list::find_hydrophob(void) { /* The for loop searches over all 27 grid cubes adjacent to cube in */ /* which point "so" resides. */ /**********************************************************************/ - for(jx = -1; jx <= 1; jx++) { - for( jy =- 1; jy <= 1; jy++) { - for( jz =- 1; jz <= 1; jz++) { - - kx = (iix+jx)%32; - ky = (iiy+jy)%32; - kz = (iiz+jz)%32; - - sf = grid[kx][ky][kz]; - - while( sf != 0 ) { - - if(sf > so) { // prevents double counting of tethers. - strcpy(atype2,p[sf]->r1.aname); - - if( (atype2[2]== 'C' || atype2[2]=='S') && - determine_vdWaals_contact( p[i], p[sf]) && - not_2nd_neighb(so,sf) && - not_3rd_neighb(so,sf) && - only_bonded_to_Hphobes(so,sf) ) { - hpcount++; - temp_hpteth[hpcount][0] = so; - temp_hpteth[hpcount][1] = sf; + for (jx = -1; jx <= 1; jx++) { + for (jy = -1; jy <= 1; jy++) { + for (jz = -1; jz <= 1; jz++) { + + kx = (iix + jx) % 32; + ky = (iiy + jy) % 32; + kz = (iiz + jz) % 32; + + sf = grid[kx][ky][kz]; + + while (sf != 0) { + + if (sf > so) { // prevents double counting of tethers. + strcpy(atype2, p[sf]->r1.aname); + + if ((atype2[2] == 'C' || atype2[2] == 'S') && + determine_vdWaals_contact(p[i], p[sf]) && + not_2nd_neighb(so, sf) && not_3rd_neighb(so, sf) && + only_bonded_to_Hphobes(so, sf)) { + hpcount++; + temp_hpteth[hpcount][0] = so; + temp_hpteth[hpcount][1] = sf; #ifdef DEBUG_HPHOB - cout << so << " " << sf << endl; + cout << so << " " << sf << endl; #endif - } - } - sf = chain[sf]; - } - } - } + } + } + sf = chain[sf]; + } + } + } } } } - #ifdef DEBUG_HPHOB cout << "R_factor " << R_factor << " hphobes " << hpcount << endl; #endif - //exit(0); + // exit(0); /************************************************************/ /* copy the temp_hpteth table to new memory optimized array */ /************************************************************/ - hp_tether =(int**) new int *[hpcount+1]; - - for( i = 0; i <= hpcount; i++ ){ - *(hp_tether+i) = (int*) new int[2]; + hp_tether = (int **)new int *[hpcount + 1]; + + for (i = 0; i <= hpcount; i++) { + *(hp_tether + i) = (int *)new int[2]; } - - for( i = 1; i <= hpcount; i++) { - hp_tether[i][0]=temp_hpteth[i][0]; - hp_tether[i][1]=temp_hpteth[i][1]; + + for (i = 1; i <= hpcount; i++) { + hp_tether[i][0] = temp_hpteth[i][0]; + hp_tether[i][1] = temp_hpteth[i][1]; } - - for( i = 0; i <= nval; i++){ - delete [] *(temp_hpteth+i); + + for (i = 0; i <= nval; i++) { + delete[] * (temp_hpteth + i); } - - return(hpcount); + + return (hpcount); } /**********************************************************************/ /**********************************************************************/ void list::HPaugment(node **node_p) { /* AJR 03.22.02 this routine not yet implemented */ - int a,i,numatoms,nHPat,*tempbond,**templink,so,sf; + int a, i, numatoms, nHPat, *tempbond, **templink, so, sf; - float - unit_vector[3], - vector_one[3], - vector_two[3], - vector_three[3]; + float unit_vector[3], vector_one[3], vector_two[3], vector_three[3]; - node *fresh,*endpt; + node *fresh, *endpt; - nHPat = no_tether*3; - numatoms = no_atoms+no_tether*3; + nHPat = no_tether * 3; + numatoms = no_atoms + no_tether * 3; - tempbond = new int[numatoms+1]; - templink = (int **) new int *[numatoms+1]; - for(i=0;i<=numatoms;i++){ - if(i<=no_atoms){ + tempbond = new int[numatoms + 1]; + templink = (int **)new int *[numatoms + 1]; + for (i = 0; i <= numatoms; i++) { + if (i <= no_atoms) { tempbond[i] = mult[i]; } - *(templink+i) = (int*) new int[maxr]; + *(templink + i) = (int *)new int[maxr]; } endpt = start; - int nps=no_atoms, rescount=1; + int nps = no_atoms, rescount = 1; fresh = NULL; - for(i=1; i<=no_tether;i++){ + for (i = 1; i <= no_tether; i++) { so = hp_tether[i][0]; sf = hp_tether[i][1]; /**********************************/ - for( a = 1; a < 4; a++ ){ - unit_vector[a] = node_p[so]->r1.coord[a] - node_p[sf]->r1.coord[a]; - vector_one[a] = node_p[sf]->r1.coord[a] + (0.25*unit_vector[a]); - vector_two[a] = node_p[sf]->r1.coord[a] + (0.5*unit_vector[a]); - vector_three[a] = node_p[sf]->r1.coord[a] + (0.75*unit_vector[a]); - + for (a = 1; a < 4; a++) { + unit_vector[a] = node_p[so]->r1.coord[a] - node_p[sf]->r1.coord[a]; + vector_one[a] = node_p[sf]->r1.coord[a] + (0.25 * unit_vector[a]); + vector_two[a] = node_p[sf]->r1.coord[a] + (0.5 * unit_vector[a]); + vector_three[a] = node_p[sf]->r1.coord[a] + (0.75 * unit_vector[a]); fresh = new node; - strcpy(fresh->r1.field1,"HETATM"); // PDB field identifier (ie. ATOM, HETATM, REMARK) - // strcpy(fresh->r1.sr_no,line+6,5); // Atom number - strcpy(fresh->r1.aname," X "); // Atom name - strcpy(fresh->r1.altloc," "); // - strcpy(fresh->r1.rname,"XXX"); // Amino-acid name - strcpy(fresh->r1.chain," T"); // Chain ID - //strcpy(string, line+66, 5 ); // some kind of internal FIRST identifier. - fresh->r1.mod_res_no = rescount; // - fresh->r1.DAH_type = 'N'; - fresh->r1.coord[1] = vector_one[a]; - fresh->r1.coord[2] = vector_two[a]; - fresh->r1.coord[3] = vector_three[a]; - strcpy(fresh->r1.occupancy," 0.00");// Temperature factor (B_value) - strcpy(fresh->r1.temp_string," 0.00"); // - fresh->r1.occ = 0.00; - fresh->r1.temperature = 0.00; - fresh->r1.ri_sr_no = nps++; - - // AJR 03.21.02 temporary fix: - strcpy(fresh->r1.res_no," 100"); // Residue number - strcpy(fresh->r1.sr_no," 1252"); // Atom number - strcpy(fresh->r1.code," "); - strcpy(fresh->r1.strx," 51.000"); // X-coordinate - strcpy(fresh->r1.stry," 11.000"); // Y-coordinate - strcpy(fresh->r1.strz," -1.000"); // Z-coordinate - // strcpy(fresh->r1.strx,line+30,8); // X-coordinate - //strcpy(fresh->r1.stry,line+38,8); // Y-coordinate - //strcpy(fresh->r1.strz,line+46,8); // Z-coordinate - //cout << fresh->r1.field1 <<" "<next = fresh->prior = NULL; + strcpy(fresh->r1.field1, + "HETATM"); // PDB field identifier (ie. ATOM, HETATM, REMARK) + // strcpy(fresh->r1.sr_no,line+6,5); // Atom number + strcpy(fresh->r1.aname, " X "); // Atom name + strcpy(fresh->r1.altloc, " "); // + strcpy(fresh->r1.rname, "XXX"); // Amino-acid name + strcpy(fresh->r1.chain, " T"); // Chain ID + // strcpy(string, line+66, 5 ); // some kind of internal FIRST + // identifier. + fresh->r1.mod_res_no = rescount; // + fresh->r1.DAH_type = 'N'; + fresh->r1.coord[1] = vector_one[a]; + fresh->r1.coord[2] = vector_two[a]; + fresh->r1.coord[3] = vector_three[a]; + strcpy(fresh->r1.occupancy, " 0.00"); // Temperature factor (B_value) + strcpy(fresh->r1.temp_string, " 0.00"); // + fresh->r1.occ = 0.00; + fresh->r1.temperature = 0.00; + fresh->r1.ri_sr_no = nps++; + + // AJR 03.21.02 temporary fix: + strcpy(fresh->r1.res_no, " 100"); // Residue number + strcpy(fresh->r1.sr_no, " 1252"); // Atom number + strcpy(fresh->r1.code, " "); + strcpy(fresh->r1.strx, " 51.000"); // X-coordinate + strcpy(fresh->r1.stry, " 11.000"); // Y-coordinate + strcpy(fresh->r1.strz, " -1.000"); // Z-coordinate + // strcpy(fresh->r1.strx,line+30,8); // X-coordinate + // strcpy(fresh->r1.stry,line+38,8); // Y-coordinate + // strcpy(fresh->r1.strz,line+46,8); // Z-coordinate + // cout << fresh->r1.field1 <<" "<next = fresh->prior = NULL; } - + i = no_tether; rescount++; - // npseudo+=3; + // npseudo+=3; } - //cout<next = fresh->prior=NULL;*/ // int chainflg = 0; // float vector_four[3]; - - int - last_resno, - a = 0; - - float - unit_vector[3], - vector_one[3], - vector_two[3], - vector_three[3]; + + int last_resno, a = 0; + + float unit_vector[3], vector_one[3], vector_two[3], vector_three[3]; char str_resno[5]; node *tempo; // cout << lastno <<"\t"<r1.res_no); + strcpy(str_resno, tempo->r1.res_no); last_resno = atoi(str_resno); - //cout << last_resno <r1.coord[1] - unit_vector[a] = temp1->r1.coord[a] - temp2->r1.coord[a]; - vector_one[a] = temp2->r1.coord[a] + (0.25*unit_vector[a]); - vector_two[a] = temp2->r1.coord[a] + (0.5*unit_vector[a]); - vector_three[a] = temp2->r1.coord[a] + (0.75*unit_vector[a]); + unit_vector[a] = temp1->r1.coord[a] - temp2->r1.coord[a]; + vector_one[a] = temp2->r1.coord[a] + (0.25 * unit_vector[a]); + vector_two[a] = temp2->r1.coord[a] + (0.5 * unit_vector[a]); + vector_three[a] = temp2->r1.coord[a] + (0.75 * unit_vector[a]); // vector_four[a] = temp2->r1.coord[a] + (0.8*unit_vector[a]); - //hp_points[*hp_point_counter][a] = current_atom.coords[a] + (0.5*unit_vector[a]); -// unit_vector[a] = test_point.coords[a] - current_atom.coords[a]; -// vector_one[a] = current_atom.coords[a] + (0.2*unit_vector[a]); -// vector_two[a] = current_atom.coords[a] + (0.4*unit_vector[a]); -// vector_three[a] = current_atom.coords[a] + (0.6*unit_vector[a]); -// vector_four[a] = current_atom.coords[a] + (0.8*unit_vector[a]); -// hp_points[*hp_point_counter][a] = current_atom.coords[a] + (0.5*unit_vector[a]); + // hp_points[*hp_point_counter][a] = current_atom.coords[a] + + // (0.5*unit_vector[a]); + // unit_vector[a] = test_point.coords[a] - current_atom.coords[a]; + // vector_one[a] = current_atom.coords[a] + (0.2*unit_vector[a]); + // vector_two[a] = current_atom.coords[a] + (0.4*unit_vector[a]); + // vector_three[a] = current_atom.coords[a] + (0.6*unit_vector[a]); + // vector_four[a] = current_atom.coords[a] + (0.8*unit_vector[a]); + // hp_points[*hp_point_counter][a] = current_atom.coords[a] + + // (0.5*unit_vector[a]); } // (*hp_point_counter)++; /* - fprintf( output_file, "HETATM%5d X XXX %c%4d %7.3f %7.3f %7.3f 1.00 1.00 N\n", - *next_atom_num, cid, *residue_number, vector_one[0], vector_one[1], vector_one[2] ); - fprintf( output_file, "HETATM%5d X XXX %c%4d %7.3f %7.3f %7.3f 1.00 1.00 N\n", - *next_atom_num+1, cid, *residue_number, vector_two[0], vector_two[1], vector_two[2] + fprintf( output_file, "HETATM%5d X XXX %c%4d %7.3f %7.3f +%7.3f 1.00 1.00 N\n", *next_atom_num, cid, *residue_number, +vector_one[0], vector_one[1], vector_one[2] ); fprintf( output_file, "HETATM%5d +X XXX %c%4d %7.3f %7.3f %7.3f 1.00 1.00 N\n", *next_atom_num+1, +cid, *residue_number, vector_two[0], vector_two[1], vector_two[2] ); - fprintf( output_file, "HETATM%5d X XXX %c%4d %7.3f %7.3f %7.3f 1.00 1.00 N\n", - *next_atom_num+2, cid, *residue_number, vector_three[0], vector_three[1],vector_three[2] ); + fprintf( output_file, "HETATM%5d X XXX %c%4d %7.3f %7.3f +%7.3f 1.00 1.00 N\n", *next_atom_num+2, cid, *residue_number, +vector_three[0], vector_three[1],vector_three[2] ); (*residue_number)++; */ } @@ -527,22 +517,23 @@ void list::create_newPSEUDO(node *temp1, node *temp2) { /**************************************************/ void list::write_HPCFbond(void) { - int i,so,latom = no_atoms; + int i, so, latom = no_atoms; ofstream xofil; - xofil.open(outputfile,ios::app); + xofil.open(outputfile, ios::app); - if( xofil == NULL ) { - cout<<"Error in opening outputfile"<r1.coord[1] - unit_vector[a] = node_p[so]->r1.coord[a+1] - node_p[sf]->r1.coord[a+1]; - vector_one[a] = node_p[sf]->r1.coord[a+1] + (0.75*unit_vector[a]); - vector_two[a] = node_p[sf]->r1.coord[a+1] + (0.5*unit_vector[a]); - vector_three[a] = node_p[sf]->r1.coord[a+1] + (0.25*unit_vector[a]); + + for (a = 0; a < 3; a++) { + // node_p[so]->r1.coord[1] + unit_vector[a] = + node_p[so]->r1.coord[a + 1] - node_p[sf]->r1.coord[a + 1]; + vector_one[a] = node_p[sf]->r1.coord[a + 1] + (0.75 * unit_vector[a]); + vector_two[a] = node_p[sf]->r1.coord[a + 1] + (0.5 * unit_vector[a]); + vector_three[a] = node_p[sf]->r1.coord[a + 1] + (0.25 * unit_vector[a]); } jt++; - xofil<<"HETATM"< -#include #include +#include +#include -#include"../../include/class.h" // Contains the class descriptions and headers -#include"makechem.cpp" // Make the proflexdataset file given a protein +#include "../../include/class.h" // Contains the class descriptions and headers +#include "makechem.cpp" // Make the proflexdataset file given a protein // structure in pdb format -#include"fixbabel.cpp" // Creates the linked list describing the +#include "fixbabel.cpp" // Creates the linked list describing the // connectivity of the protein atoms -#include"find_hbonds.cpp" // Given the explicit hydrogen atoms, identify +#include "find_hbonds.cpp" // Given the explicit hydrogen atoms, identify // all potential hydrogen bonds -#include"transitions.cpp" // Read in the data from a proflexdataset file -#include"pick_hbonds.cpp" // Selection of desired H-bonds -#include"hydrophobic.cpp" // Finds and adds Hydrophobic tethers - - - +#include "hydrophobic.cpp" // Finds and adds Hydrophobic tethers +#include "pick_hbonds.cpp" // Selection of desired H-bonds +#include "transitions.cpp" // Read in the data from a proflexdataset file /* ------- Usage Msg Function -----------------------------------------*/ -void display_usage(char * program_name){ - //system( "clear" ); - cout<<"\n Usage : "<< program_name<<" [-r] [-e] [-nonh|nonf] <-h|{-p|-pw}> "< Expected to have a .pdb or .PDB file extension."< Hydrogen atoms that are currently listed are IGNORED, unless"< the -h option is also used. (see -h option)"< When used with the -ah option, the listed hydrogen atoms are"< preserved with their coordinates unchanged in the optimization."< " << endl; + // Adding hydrogens through FIRST is not yet supported - Sameer Arora Jan 7 + // '04 + // cout<<"\n Usage is: first [-ah][-h][-p][-pw][-res][filename]"< Expected to have a .pdb or .PDB file extension." + << endl; + cout << "\t With the -p or -pw option the extension may be " + "_proflexdataset." + << endl; + cout << endl; + cout << "\n\t\aOption definitions:" << endl; + cout << "\n\t-nonh Use for non-interactive hydrogen bond dilution." << endl; + cout << "\n\t-nonf Use for non-interactive flexibility analysis." << endl; + cout << "\n\t **NOTE: Any filtering using stereochemical, energy,"; + cout << "\n\t hydrophobic, side chain, and water criteria from the"; + cout << "\n\t previous ProFlex run generating the proflex_dataset " + "file"; + cout << "\n\t are not applied in -non mode. Only the default " + "stereochemical"; + cout << "\n\t criteria are applied. Be sure to only include buried"; + cout << "\n\t water molecules in the input PDB file.**" << endl; + // cout<<"\n\t-ah Use to Add Hydrogen atoms explicitly to the PDB formated + // file."< Hydrogen atoms that are currently listed are IGNORED, + // unless"< the -h option is also used. (see -h + // option)"< When used with the -ah option, the listed hydrogen atoms + // are"< preserved with their coordinates unchanged in + // the optimization."< 3 ) { + + if (length > 3) { j = length - 4; - if( !strncmp(argv[i]+j, ".pdb", 4) || \ - !strncmp(argv[i]+j,".PDB",4)){ - - for( j = 0; j <= length; j++) - inputfile[j] = *(argv[i]+j); - - /* - * If the input to proflex is in a different directory then - * the input argument has to be stripped of any path information - */ -/* - for( j = length-5; j >= 0; j-- ) - if( *(argv[i]+j) == '/' ) - break; - - if(j == -1) - for(j=0 ; j <= length; j++ ) - inputfile[j] = *(argv[i]+j); - else - for( k=j+1; k <= length; k++ ) - inputfile[k-(j+1)] = *(argv[i]+k); -*/ - - - command_option[11] += 1; - correct_args_flag = 1; - continue; + if (!strncmp(argv[i] + j, ".pdb", 4) || + !strncmp(argv[i] + j, ".PDB", 4)) { + + for (j = 0; j <= length; j++) + inputfile[j] = *(argv[i] + j); + + /* + * If the input to proflex is in a different directory then + * the input argument has to be stripped of any path information + */ + /* + for( j = length-5; j >= 0; j-- ) + if( *(argv[i]+j) == '/' ) + break; + + if(j == -1) + for(j=0 ; j <= length; j++ ) + inputfile[j] = *(argv[i]+j); + else + for( k=j+1; k <= length; k++ ) + inputfile[k-(j+1)] = *(argv[i]+k); + */ + + command_option[11] += 1; + correct_args_flag = 1; + continue; } } - - /* + + /* * 2006:02:28 SN - Change the length to 15 = length(_proflexdataset) - */ - if( length > 15) { + */ + if (length > 15) { j = length - 15; - if( !strncmp(argv[i]+j, "_proflexdataset", 15) ) { + if (!strncmp(argv[i] + j, "_proflexdataset", 15)) { - for( j = 0; j <= length; j++) - inputfile[j] = *(argv[i]+j); + for (j = 0; j <= length; j++) + inputfile[j] = *(argv[i] + j); - command_option[12] += 1; - correct_args_flag = 1; - continue; + command_option[12] += 1; + correct_args_flag = 1; + continue; } } - if( correct_args_flag == 0 ) { - /* looks like incorrect args - Sameer, 13 Feb 2004*/ - display_usage(argv[0]); - /* SN 2008:04 - change the Warning message to indicate what is a correct input! */ - printf("ERROR: Invalid arguments! Please see above for a description of valid input"); - exit(-1); + if (correct_args_flag == 0) { + /* looks like incorrect args - Sameer, 13 Feb 2004*/ + display_usage(argv[0]); + /* SN 2008:04 + change the Warning message to indicate what is a correct input! */ + printf("ERROR: Invalid arguments! Please see above for a description of " + "valid input"); + exit(-1); } } - + // check expected input file name opt_sum = command_option[11] + command_option[12]; - - // if the used the -p flag, but supplied no file name. - if(opt_sum == 0) { - if( command_option[2] == 1 ) { - cout<<"\n\tNOTE: Use extension .pdb instead of _proflexdataset" << endl; - cout<<"\t even if the original .pdb file is not present."; + + // if the used the -p flag, but supplied no file name. + if (opt_sum == 0) { + if (command_option[2] == 1) { + cout << "\n\tNOTE: Use extension .pdb instead of _proflexdataset" << endl; + cout << "\t even if the original .pdb file is not present."; } - cout<<"\n\n\aPlease enter filename (with extension .pdb): "; + cout << "\n\n\aPlease enter filename (with extension .pdb): "; cin >> inputfile; l = strlen(inputfile); - if( strncmp( inputfile+(l-4), ".pdb", 4) ) { - cout << "\n\n\aExpected file name must have a .pdb extension.\n\n" << endl; + if (strncmp(inputfile + (l - 4), ".pdb", 4)) { + cout << "\n\n\aExpected file name must have a .pdb extension.\n\n" + << endl; exit(2); } command_option[11] = 1; } - - else if(opt_sum > 1) { - if( command_option[2] == 1 ) { - cout<<"\n\tNOTE: Use extension .pdb instead of _proflexdataset" << endl; - cout<<"\t even if the original .pdb file is not present."; + + else if (opt_sum > 1) { + if (command_option[2] == 1) { + cout << "\n\tNOTE: Use extension .pdb instead of _proflexdataset" << endl; + cout << "\t even if the original .pdb file is not present."; } - cout<<"\n\n\aPlease enter ONLY ONE filename (with extension .pdb): "; + cout << "\n\n\aPlease enter ONLY ONE filename (with extension .pdb): "; cin >> inputfile; l = strlen(inputfile); - if( strncmp( inputfile+(l-4), ".pdb", 4) ) { - cout<<"\n\n\aExpected file name must have a .pdb extension.\n\n"<= 0; j-- ) - if( inputfile[j] == '/' ) // Strip of path info. + /* + * If the input PDB file is in a different directory then + * the input argument has to be stripped of any path information. + * Although, with '-p' option the proflexdataset has to be in + * current working directory! + */ + length = strlen(inputfile); + for (j = length - 1; j >= 0; j--) + if (inputfile[j] == '/') // Strip of path info. { - strcpy(outputfile,(inputfile+j+1)); - break; + strcpy(outputfile, (inputfile + j + 1)); + break; } - if(j == -1) - strcpy(outputfile,inputfile); + if (j == -1) + strcpy(outputfile, inputfile); - if( command_option[12] != 1 || command_option[2] != 1 ) { + if (command_option[12] != 1 || command_option[2] != 1) { l = strlen(outputfile); - outputfile[l-4]='\0'; - strcat(outputfile,"_proflexdataset"); + outputfile[l - 4] = '\0'; + strcat(outputfile, "_proflexdataset"); } - - //----------------------------------------------------------------------------- - //----------------------------------------------------------------------------- + + //----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- // display the introduction screen, FIRST - //system( "clear" ); + // system( "clear" ); cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; - //system( "clear" ); + // system( "clear" ); cout << "\n" - << "\t # # #### # #\n" - << "\t ## ## # # #\n" - << "\t # ## # #### # #\n" - << "\t # # # # #\n" - << "\t # # # # # #\n" - << "\t # # #### ####\n" - << "\n" - << "\t ###### #######\n" - << "\t # # ##### #### # # ###### # #\n" - << "\t # # # # # # # # # # #\n" - << "\t ###### # # # # ##### # ##### ##\n" - << "\t # ##### # # # # # ##\n" - << "\t # # # # # # # # # #\n" - << "\t # # # #### # ###### ###### # #\n" - << "\t----------------------------------------------------------\n" - << "\t Software for Protein Flexibility Prediction and Analysis\n" - << "\t version 5.0\n" - << "\t Copyright (C) 1997 - 2008, Michigan State University\n" - << "\t (formerly called FIRST)\n" - << "\t Protein Structural Analysis and Design Laboratory\n" - << "\t Michigan State University\n" - << "\t East Lansing MI, USA\n" << endl; - + << "\t # # #### # #\n" + << "\t ## ## # # #\n" + << "\t # ## # #### # #\n" + << "\t # # # # #\n" + << "\t # # # # # #\n" + << "\t # # #### ####\n" + << "\n" + << "\t ###### #######\n" + << "\t # # ##### #### # # ###### # #\n" + << "\t # # # # # # # # # # #\n" + << "\t ###### # # # # ##### # ##### ##\n" + << "\t # ##### # # # # # ##\n" + << "\t # # # # # # # # # #\n" + << "\t # # # #### # ###### ###### # #\n" + << "\t----------------------------------------------------------\n" + << "\t Software for Protein Flexibility Prediction and Analysis\n" + << "\t version 5.0\n" + << "\t Copyright (C) 1997 - 2008, Michigan State University\n" + << "\t (formerly called FIRST)\n" + << "\t Protein Structural Analysis and Design Laboratory\n" + << "\t Michigan State University\n" + << "\t East Lansing MI, USA\n" + << endl; + + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- - //----------------------------------------------------------------------------- - - + // The -p option. Work with the previous proflexdataset - if( command_option[2] == 1 ) { - ifil.open( outputfile, ios::in ); - if( ifil == NULL ) { - cout<< "\n\n\aPrevious data set ["< 25; j--) { + if (strncmp(line + j, "=", 1) == 0) { + i = j + 1; + break; + } + } + j = atoi(line + i); + cout << "\t Number of isolated atoms found = " << j << "." << endl; } - */ - if(strncmp(line+6,":w:check_bonding",16)==0) { - cout << "\t Some covalent bonds were identified by distance" << endl - << "\t criteria: See check_bonding in *proflexdataset* for details."<< endl; - } - if(strncmp(line+6,":w:isolated_atoms",17)==0) { - l = strlen(line); - for( j=l; j>25 ; j-- ) { - if( strncmp(line+j,"=",1) == 0 ) { - i = j+1; - break; - } - } - j = atoi(line+i); - cout << "\t Number of isolated atoms found = " - << j << "." << endl; - } - if(strncmp(line+6,":w:isolated_water",17)==0) { - l = strlen(line); - for( j=l; j>25 ; j-- ) { - if( strncmp(line+j,"=",1) == 0 ) { - i = j+1; - break; - } - } - j = atoi(line+i); - cout << "\t Number of isolated oxygen atoms found in water = " - << j << "." <25 ; j-- ) { - if( strncmp(line+j,"=",1) == 0 ) { - i = j+1; - break; - } - } - j = atoi(line+i); - cout << "\t Number of isolated hydrogen atoms found = " - << j << "." << endl; - } - if(strncmp(line+6,":w:disulfide_bond",17)==0) { - l = strlen(line); - for( j=l; j>25 ; j-- ) { - if( strncmp(line+j,"=",1) == 0 ) { - i = j+1; - break; - } - } - j = atoi(line+i); - cout << "\t Number of disulfide bonds found = " - << j << "." << endl; - } - if(strncmp(line+6,":w:skip_nonhydrog",17)==0) { - cout << "\t Some heavy atoms were not connected to anything:" << endl; - cout << "\t See skip_nonhydrogen in *proflexdataset* for details." - << endl; - } - if(strncmp(line+6,":w:poor_bond",12)==0) { - cout << "\t Some [Expected] covalent bonds were too poor" << endl; - cout << "\t to connect: See poor_bond in *proflexdataset* for details." - << endl; - } - if(strncmp(line+6,":w:skip_hydrogen",16)==0) { - cout << "\t Some hydrogen atoms were not connected to anything:" << endl; - cout << "\t See skip_hydrogen in *proflexdataset* for details." - << endl; - } - if(strncmp(line+6,":w:missing_atoms",16)==0) { - cout << "\t Some [Expected] heavy atoms were missing from" << endl; - cout << "\t known groups: See missing_atoms in *proflexdataset* for details." - << endl; - } - if(strncmp(line+6,":w:chain_id",11)==0) { - cout << "\t Some chain IDs in the original PDB file were" << endl; - cout << "\t re-labeled: See chain_id in *proflexdataset* for details" << endl; - } - if(strncmp(line+6,":w:conformation_auto",20)==0) { - cout << "\t Multiple conformations were present in the original" << endl; - cout << "\t PDB file: Default option selected conformations" << endl; - cout << "\t with maximum occupancy or minimum mobility." << endl; - } - if(strncmp(line+6,":w:conformation_user",20)==0) { - cout << "\t Multiple conformations were present in the original" << endl; - cout << "\t PDB file: Each conformation was selected by user" << endl; - cout << "\t See conformation_user in *proflexdataset* for details." << endl; - } - ifil.getline(line,90); - } + if (strncmp(line + 6, ":w:isolated_water", 17) == 0) { + l = strlen(line); + for (j = l; j > 25; j--) { + if (strncmp(line + j, "=", 1) == 0) { + i = j + 1; + break; + } + } + j = atoi(line + i); + cout << "\t Number of isolated oxygen atoms found in water = " << j + << "." << endl; + } + if (strncmp(line + 6, ":w:isolated_hydro", 17) == 0) { + l = strlen(line); + for (j = l; j > 25; j--) { + if (strncmp(line + j, "=", 1) == 0) { + i = j + 1; + break; + } + } + j = atoi(line + i); + cout << "\t Number of isolated hydrogen atoms found = " << j << "." + << endl; + } + if (strncmp(line + 6, ":w:disulfide_bond", 17) == 0) { + l = strlen(line); + for (j = l; j > 25; j--) { + if (strncmp(line + j, "=", 1) == 0) { + i = j + 1; + break; + } + } + j = atoi(line + i); + cout << "\t Number of disulfide bonds found = " << j << "." << endl; + } + if (strncmp(line + 6, ":w:skip_nonhydrog", 17) == 0) { + cout << "\t Some heavy atoms were not connected to anything:" + << endl; + cout + << "\t See skip_nonhydrogen in *proflexdataset* for details." + << endl; + } + if (strncmp(line + 6, ":w:poor_bond", 12) == 0) { + cout << "\t Some [Expected] covalent bonds were too poor" << endl; + cout << "\t to connect: See poor_bond in *proflexdataset* for " + "details." + << endl; + } + if (strncmp(line + 6, ":w:skip_hydrogen", 16) == 0) { + cout << "\t Some hydrogen atoms were not connected to anything:" + << endl; + cout << "\t See skip_hydrogen in *proflexdataset* for details." + << endl; + } + if (strncmp(line + 6, ":w:missing_atoms", 16) == 0) { + cout << "\t Some [Expected] heavy atoms were missing from" << endl; + cout << "\t known groups: See missing_atoms in *proflexdataset* " + "for details." + << endl; + } + if (strncmp(line + 6, ":w:chain_id", 11) == 0) { + cout << "\t Some chain IDs in the original PDB file were" << endl; + cout << "\t re-labeled: See chain_id in *proflexdataset* for " + "details" + << endl; + } + if (strncmp(line + 6, ":w:conformation_auto", 20) == 0) { + cout << "\t Multiple conformations were present in the original" + << endl; + cout << "\t PDB file: Default option selected conformations" + << endl; + cout << "\t with maximum occupancy or minimum mobility." << endl; + } + if (strncmp(line + 6, ":w:conformation_user", 20) == 0) { + cout << "\t Multiple conformations were present in the original" + << endl; + cout << "\t PDB file: Each conformation was selected by user" + << endl; + cout << "\t See conformation_user in *proflexdataset* for " + "details." + << endl; + } + ifil.getline(line, 90); + } } - } - else { + } else { cout << "\n\tWARNING MESSAGES SUPPRESSED with -p option.\n" << endl; } ifil.close(); - + l1.read_proflexdataset(); - - l1.check(); - + + l1.check(); + getfiles(); - + } // end of the code for the -p option - - // The -h option. Work with the pdb file in the absence of a _proflexdataset file + // The -h option. Work with the pdb file in the absence of a _proflexdataset + // file else { // check to see if a _proflexdataset file exists - ifil.open( outputfile, ios::in ); - if( !ifil ) { - cout<< "\n\nProcessing the new data set ["< [" - << outputfile<<"]\n\n"; - } - else { // if a *_proflexdataset file exists in this directory - cout<<"\n\n\aCAUTION: Previous file [" << outputfile - <<"] already exists!\n" << endl; - cout<<" This file will be over-written, but not its" << endl; - cout<<" associated FIRST analysis output files. It is" << endl; - cout<<" recommended to either rename " << inputfile << endl; - cout<<" or remove the existing data files, or rename the " << endl; - cout<<" existing data files. This is because the file with" << endl; - cout<<" an extension _proflexdataset serves as a record." << endl; - //cout<<"\n\a ** The .ijkl files will be incremented while the" << endl; - //cout<<" original input file will be over-written!\n" << endl; - cout<<"\n\a Use [-p] to keep intact: [" << outputfile << "]" << endl << endl; - - if( command_option[0] == 0 ) { - cout <<" Type I (default --> stop) to IGNORE this WARNING: "; - ans = cin.get(); - if( ans == '\n' ){ - cout << endl; - ifil.close(); - exit(5); - } - else - cin.ignore(80, '\n'); - } - + ifil.open(outputfile, ios::in); + if (!ifil) { + cout << "\n\nProcessing the new data set [" << inputfile << "] --> [" + << outputfile << "]\n\n"; + } else { // if a *_proflexdataset file exists in this directory + cout << "\n\n\aCAUTION: Previous file [" << outputfile + << "] already exists!\n" + << endl; + cout << " This file will be over-written, but not its" << endl; + cout << " associated FIRST analysis output files. It is" << endl; + cout << " recommended to either rename " << inputfile << endl; + cout << " or remove the existing data files, or rename the " + << endl; + cout << " existing data files. This is because the file with" + << endl; + cout << " an extension _proflexdataset serves as a record." + << endl; + // cout<<"\n\a ** The .ijkl files will be incremented while the" << + // endl; cout<<" original input file will be over-written!\n" << + // endl; + cout << "\n\a Use [-p] to keep intact: [" << outputfile << "]" + << endl + << endl; + + if (command_option[0] == 0) { + cout << " Type I (default --> stop) to IGNORE this WARNING: "; + ans = cin.get(); + if (ans == '\n') { + cout << endl; + ifil.close(); + exit(5); + } else + cin.ignore(80, '\n'); + } } - + ifil.close(); ifil.clear(); - + l1.add_record(usage); - + l1.cal_maxmin(); ifil.close(); ifil.clear(); - //------------------------------------------Read in the standard residue library + //------------------------------------------Read in the standard residue + // library residue_lib[0] = '\0'; - strcat( residue_lib,path ); - strcat( residue_lib, "/first/lib/residue.lib" ); - ifil.open( residue_lib, ios::in ); - - if( ifil.fail() ) { - cout<> temp_res; - while( strcmp(temp_res,"end") != 0 ) { + while (strcmp(temp_res, "end") != 0) { res[res_count].get_residue(temp_res); res_count++; ifil >> temp_res; @@ -622,7 +658,7 @@ int main(int argc, char *argv[]) { ifil.clear(); res_count++; - // The following 50 or so lines replace the old code that tried to + // The following 50 or so lines replace the old code that tried to // swap even if the locations were the same. One issue that may have // caused problems is the classes do not have copy constructor or assignment // operators defined and copying an object to itself could be undefined. @@ -648,31 +684,34 @@ int main(int argc, char *argv[]) { residue_order.push_back("TYR"); residue_order.push_back("TRP"); - k=0; - for(size_t III = 0; III < residue_order.size(); ++III){ - for(size_t JJJ = III; JJJ < res_count; ++JJJ){ + k = 0; + for (size_t III = 0; III < residue_order.size(); ++III) { + for (size_t JJJ = III; JJJ < res_count; ++JJJ) { // The jth residue in the res array does not have the same name as // the ith (current) residue in our prescribed order - if(std::string(res[JJJ].rname) != residue_order[III]) continue; - + if (std::string(res[JJJ].rname) != residue_order[III]) + continue; + // The current residue (jth residue) is not in the correct slot in the // res array - if(JJJ != III){ - res[res_count] = res[III]; - res[III] = res[JJJ]; - res[JJJ] = res[res_count]; + if (JJJ != III) { + res[res_count] = res[III]; + res[III] = res[JJJ]; + res[JJJ] = res[res_count]; } - // If the current residue (jth residue) is in the correct slot in + // If the current residue (jth residue) is in the correct slot in // the res array, there is no need to move/copy anything ++k; break; } } - if( k != 20 ) { - cout << endl <> temp_res; - while( strcmp(temp_res,"end") != 0 ) { + while (strcmp(temp_res, "end") != 0) { polar[polar_count].get_polar_record(temp_res); polar_count++; ifil >> temp_res; @@ -722,175 +762,185 @@ int main(int argc, char *argv[]) { ifil.close(); ifil.clear(); /************************************************************/ - - l1.make_connectivity(usage); //--- SN 2006:03 --- This also finds - // and processes tethers -//cout<<"\nTEST1:"<25 ; j-- ) { - if( strncmp(line+j,"=",1) == 0 ) { - i = j+1; - break; - } - } - j = atoi(line+i); - cout << "\t Number of isolated atoms found = " - << j << "." << endl; - } - if(strncmp(line+6,":w:isolated_water",17)==0) { - l = strlen(line); - for( j=l; j>25 ; j-- ) { - if( strncmp(line+j,"=",1) == 0 ) { - i = j+1; - break; - } - } - j = atoi(line+i); - cout << "\t Number of isolated oxygen atoms found in water = " - << j << "." <25 ; j-- ) { - if( strncmp(line+j,"=",1) == 0 ) { - i = j+1; - break; - } - } - j = atoi(line+i); - cout << "\t Number of isolated hydrogen atoms found = " - << j << "." << endl; - } - if(strncmp(line+6,":w:disulfide_bond",17)==0) { - l = strlen(line); - for( j=l; j>25 ; j-- ) { - if( strncmp(line+j,"=",1) == 0 ) { - i = j+1; - break; - } - } - j = atoi(line+i); - cout << "\t Number of disulfide bonds found = " - << j << "." << endl; - } - if(strncmp(line+6,":w:skip_nonhydrog",17)==0) { - cout << "\t Some heavy atoms were not connected to anything:" << endl; - cout << "\t See skip_nonhydrogen in *proflexdataset* for details." - << endl; - } - if(strncmp(line+6,":w:poor_bond",12)==0) { - cout << "\t Some [Expected] covalent bonds were too poor" << endl; - cout << "\t to connect: See poor_bond in *proflexdataset* for details." - << endl; - } - if(strncmp(line+6,":w:skip_hydrogen",16)==0) { - cout << "\t Some hydrogen atoms were not connected to anything:" << endl; - cout << "\t See skip_hydrogen in *proflexdataset* for details." - << endl; - } - if(strncmp(line+6,":w:missing_atoms",16)==0) { - cout << "\t Some [Expected] heavy atoms were missing from" << endl; - cout << "\t known groups: See missing_atoms in *proflexdataset* for details." - << endl; - } - if(strncmp(line+6,":w:chain_id",11)==0) { - cout << "\t Some chain IDs in the original PDB file were" << endl; - cout << "\t re-labeled: See chain_id in *proflexdataset* for details" << endl; - } - if(strncmp(line+6,":w:conformation_auto",20)==0) { - cout << "\t Multiple conformations were present in the original" << endl; - cout << "\t PDB file: Default option selected conformations" << endl; - cout << "\t with maximum occupancy or minimum mobility." << endl; - } - if(strncmp(line+6,":w:conformation_user",20)==0) { - cout << "\t Multiple conformations were present in the original" << endl; - cout << "\t PDB file: Each conformation was selected by user" << endl; - cout << "\t See conformation_user in *proflexdataset* for details." << endl; - } - ifil.getline(line,90); + } else { + while (strncmp(line, "END", 3) != 0) { + if (strncmp(line + 6, ":w:check_bonding", 16) == 0) { + cout << "\t Some covalent bonds were identified by distance" << endl + << "\t criteria: See check_bonding in *proflexdataset* for " + "details." + << endl; + } + if (strncmp(line + 6, ":w:isolated_atoms", 17) == 0) { + l = strlen(line); + for (j = l; j > 25; j--) { + if (strncmp(line + j, "=", 1) == 0) { + i = j + 1; + break; + } + } + j = atoi(line + i); + cout << "\t Number of isolated atoms found = " << j << "." << endl; + } + if (strncmp(line + 6, ":w:isolated_water", 17) == 0) { + l = strlen(line); + for (j = l; j > 25; j--) { + if (strncmp(line + j, "=", 1) == 0) { + i = j + 1; + break; + } + } + j = atoi(line + i); + cout << "\t Number of isolated oxygen atoms found in water = " << j + << "." << endl; + } + if (strncmp(line + 6, ":w:isolated_hydro", 17) == 0) { + l = strlen(line); + for (j = l; j > 25; j--) { + if (strncmp(line + j, "=", 1) == 0) { + i = j + 1; + break; + } + } + j = atoi(line + i); + cout << "\t Number of isolated hydrogen atoms found = " << j << "." + << endl; + } + if (strncmp(line + 6, ":w:disulfide_bond", 17) == 0) { + l = strlen(line); + for (j = l; j > 25; j--) { + if (strncmp(line + j, "=", 1) == 0) { + i = j + 1; + break; + } + } + j = atoi(line + i); + cout << "\t Number of disulfide bonds found = " << j << "." << endl; + } + if (strncmp(line + 6, ":w:skip_nonhydrog", 17) == 0) { + cout << "\t Some heavy atoms were not connected to anything:" << endl; + cout << "\t See skip_nonhydrogen in *proflexdataset* for details." + << endl; + } + if (strncmp(line + 6, ":w:poor_bond", 12) == 0) { + cout << "\t Some [Expected] covalent bonds were too poor" << endl; + cout << "\t to connect: See poor_bond in *proflexdataset* for " + "details." + << endl; + } + if (strncmp(line + 6, ":w:skip_hydrogen", 16) == 0) { + cout << "\t Some hydrogen atoms were not connected to anything:" + << endl; + cout << "\t See skip_hydrogen in *proflexdataset* for details." + << endl; + } + if (strncmp(line + 6, ":w:missing_atoms", 16) == 0) { + cout << "\t Some [Expected] heavy atoms were missing from" << endl; + cout << "\t known groups: See missing_atoms in *proflexdataset* " + "for details." + << endl; + } + if (strncmp(line + 6, ":w:chain_id", 11) == 0) { + cout << "\t Some chain IDs in the original PDB file were" << endl; + cout << "\t re-labeled: See chain_id in *proflexdataset* for " + "details" + << endl; + } + if (strncmp(line + 6, ":w:conformation_auto", 20) == 0) { + cout << "\t Multiple conformations were present in the original" + << endl; + cout << "\t PDB file: Default option selected conformations" + << endl; + cout << "\t with maximum occupancy or minimum mobility." << endl; + } + if (strncmp(line + 6, ":w:conformation_user", 20) == 0) { + cout << "\t Multiple conformations were present in the original" + << endl; + cout << "\t PDB file: Each conformation was selected by user" + << endl; + cout << "\t See conformation_user in *proflexdataset* for details." + << endl; + } + ifil.getline(line, 90); } } getfiles(); } - if( !usage ){ + if (!usage) { // Mandatory pause cout << endl << "Type \"s\" to stop or any other key to continue: "; ans = cin.get(); - if( ans == 's' || ans == 'S') { + if (ans == 's' || ans == 'S') { cout << endl << endl; exit(5); } - if( ans != '\n' ) - cin.ignore(80,'\n'); + if (ans != '\n') + cin.ignore(80, '\n'); } - + summon_fortran[0] = '\0'; - strcat( summon_fortran, path); - strcat( summon_fortran, "/first/bin/first" ); + strcat(summon_fortran, path); + strcat(summon_fortran, "/first/bin/first"); // 03.22.02 AJR allows correct hbond list output for -p or -h with -non option - if( usage ) + if (usage) modusage = usage + command_option[2]; - l1.pick_hbonds(modusage,command_option[2]); //--- 2006:03:15 SN - // preacptr_info will be read only is - // '-p' is selected and user wants to do - // stringent stereochemical filtering + l1.pick_hbonds(modusage, + command_option[2]); //--- 2006:03:15 SN + // preacptr_info will be read only is + // '-p' is selected and user wants to do + // stringent stereochemical filtering - //------------------------------------------------------ summon the FORTRAN code - ofil.open( "qXyZaB.proflexdataset", ios::out ); + //------------------------------------------------------ summon the FORTRAN + // code + ofil.open("qXyZaB.proflexdataset", ios::out); ofil << outputfile << endl; ofil << nfile << endl; - ofil << usage <> answer; - - if( strcmp(answer, "qXyZaB.proflexdataset") ) { - strcpy( outfile[0], answer ); - for( i = 1; i < 7; i++ ) + + if (strcmp(answer, "qXyZaB.proflexdataset")) { + strcpy(outfile[0], answer); + for (i = 1; i < 7; i++) qfil >> outfile[i]; - + qfil >> nfile; - } - else { + } else { answer[0] = '\0'; - strcat(answer,"rm "); - strcat(answer,outfile[0]); - system( answer ); + strcat(answer, "rm "); + strcat(answer, outfile[0]); + system(answer); } qfil.close(); } diff --git a/proflex/prog/first/src/c++/makechem.cpp b/proflex/prog/first/src/c++/makechem.cpp index daed998..cddef11 100755 --- a/proflex/prog/first/src/c++/makechem.cpp +++ b/proflex/prog/first/src/c++/makechem.cpp @@ -1,24 +1,23 @@ /******************************************************************************* -* MSU ProFlex, formerly called FIRST, is a software developed to predict and * -* analyze protein flexibility. * -* This source file is a part of MSU ProFlex. * -* * -* Copyright (C) 1997 - 2008, Michigan State University. * -* * -* This program is free software; you can redistribute to academic users only, * -* it and/or modify it under the terms of the GNU General Public License, * -* version 2, as published by the Free Software Foundation. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, * -* or see http://www.gnu.org/licenses/gpl.txt * -*******************************************************************************/ + * MSU ProFlex, formerly called FIRST, is a software developed to predict and * + * analyze protein flexibility. * This source file is a part of MSU ProFlex. * + * * + * Copyright (C) 1997 - 2008, Michigan State University. * + * * + * This program is free software; you can redistribute to academic users only, + ** it and/or modify it under the terms of the GNU General Public License, * + * version 2, as published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * but + *WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General + *Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * along + *with this program; if not, write to the Free Software * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, * + * or see http://www.gnu.org/licenses/gpl.txt * + *******************************************************************************/ /**********************************************************************/ /* makechem.cpp */ @@ -39,131 +38,123 @@ #include void record::getrecord(void) { - int - i, l, - is_atom = 0, is_hetatm = 0, is_ter = 0; - + int i, l, is_atom = 0, is_hetatm = 0, is_ter = 0; + char line[90]; char sr_mod_num[6]; - int modelno,linelengthflag=0,shortlineflag=0; + int modelno, linelengthflag = 0, shortlineflag = 0; + // if( !ifil.getline(line, 90) ) // if the next line is the EOF, return + // return; - //if( !ifil.getline(line, 90) ) // if the next line is the EOF, return - // return; - - ifil.getline( line, 90 ); + ifil.getline(line, 90); line[89] = '\0'; - - is_atom = !strncmp( line, "ATOM", 4 ); - is_hetatm = !strncmp( line, "HETATM", 6 ); - is_ter = !strncmp( line, "TER", 3 ); + is_atom = !strncmp(line, "ATOM", 4); + is_hetatm = !strncmp(line, "HETATM", 6); + is_ter = !strncmp(line, "TER", 3); /* This code seems to keep reading the lines and skip CONECT/MASTER/END - * records until either a ATOM/HETATM/TER record appears. Meanwhile if it - * gets the model number, it sets the model no and returns - Sameer Mar 4 2004 + * records until either a ATOM/HETATM/TER record appears. Meanwhile if it + * gets the model number, it sets the model no and returns - Sameer Mar 4 + * 2004 */ - while( !is_atom && !is_hetatm && !is_ter && !ifil.eof() ){ - // print to file all lines that aren't CONECT, MASTER, and END. + while (!is_atom && !is_hetatm && !is_ter && !ifil.eof()) { + // print to file all lines that aren't CONECT, MASTER, and END. // _______ SN 2007:01:30 --- Also skip ANISOU records ______ - if( strncmp(line, "CONECT", 6) && - strncmp(line, "ANISOU", 6) && - strncmp(line, "MASTER", 6) && - strncmp(line, "END", 3)){ -// __trying to cope with MODEL & LINK input lines_________AJR 05.08.02 - if( !strncmp(line, "MODEL",5)) { - strncpy( sr_mod_num, line+11, 5 ); - modelno = atoi(sr_mod_num); - modelflag=modelno; - if(modelflag >1) return; + if (strncmp(line, "CONECT", 6) && strncmp(line, "ANISOU", 6) && + strncmp(line, "MASTER", 6) && strncmp(line, "END", 3)) { + // __trying to cope with MODEL & LINK input lines_________AJR 05.08.02 + if (!strncmp(line, "MODEL", 5)) { + strncpy(sr_mod_num, line + 11, 5); + modelno = atoi(sr_mod_num); + modelflag = modelno; + if (modelflag > 1) + return; } ofil << line << "\n"; - } - + } + // The following code checks to see if the getline operation on ifil failed. - // This will occur if the input buffer exceeds the buffer size of the variable - // line. BMH 5.24.02. - if( ifil.fail() ){ + // This will occur if the input buffer exceeds the buffer size of the + // variable line. BMH 5.24.02. + if (ifil.fail()) { cout << "Error reading from input file in record::getrecord.\n" << endl; exit(14); } - - if( ifil.getline( line, 90 ) ) { - is_atom = !strncmp( line, "ATOM", 4 ); - is_hetatm = !strncmp( line, "HETATM", 6 ); - is_ter = !strncmp( line, "TER", 3 ); + if (ifil.getline(line, 90)) { + is_atom = !strncmp(line, "ATOM", 4); + is_hetatm = !strncmp(line, "HETATM", 6); + is_ter = !strncmp(line, "TER", 3); } } - - - if( is_atom || is_hetatm || is_ter ){ -// AJR 07.31.02 these lines and below deals with case when input line lacks -// the occupancy and temperature data, i.e. line is too short. - if( !linelengthflag) { - if(strlen(line)<66) shortlineflag = 1; + + if (is_atom || is_hetatm || is_ter) { + // AJR 07.31.02 these lines and below deals with case when input line lacks + // the occupancy and temperature data, i.e. line is too short. + if (!linelengthflag) { + if (strlen(line) < 66) + shortlineflag = 1; } - - // re-initialze the buffer on finding the TER record - if( !strncmp(line, "TER", 3) ) { + + // re-initialze the buffer on finding the TER record + if (!strncmp(line, "TER", 3)) { l = strlen(line); - for( i = 0; i < (85-l); i++ ) { - line[l+i]=' '; + for (i = 0; i < (85 - l); i++) { + line[l + i] = ' '; } - line[84]='\0'; + line[84] = '\0'; } - - strncpy( field1, line, 6 ); - strncpy( sr_no, line+6, 5 ); - strncpy( aname, line+11, 5 ); - strncpy( altloc, line+16, 1 ); - strncpy( rname, line+17, 3 ); - strncpy( chain, line+20, 2 ); - strncpy( res_no, line+22, 4 ); - strncpy( code, line+26, 4 ); - strncpy( strx, line+30, 8 ); - strncpy( stry, line+38, 8 ); - strncpy( strz, line+46, 8 ); -// AJR 07.31.02 fix the case when occupancy and temp aren't provided. - if(shortlineflag) { - strcpy( occupancy, " 0.00"); - strcpy( temp_string, " 0.00"); + + strncpy(field1, line, 6); + strncpy(sr_no, line + 6, 5); + strncpy(aname, line + 11, 5); + strncpy(altloc, line + 16, 1); + strncpy(rname, line + 17, 3); + strncpy(chain, line + 20, 2); + strncpy(res_no, line + 22, 4); + strncpy(code, line + 26, 4); + strncpy(strx, line + 30, 8); + strncpy(stry, line + 38, 8); + strncpy(strz, line + 46, 8); + // AJR 07.31.02 fix the case when occupancy and temp aren't provided. + if (shortlineflag) { + strcpy(occupancy, " 0.00"); + strcpy(temp_string, " 0.00"); + } else { + strncpy(occupancy, line + 54, 6); + strncpy(temp_string, line + 60, 6); } - else { - strncpy( occupancy, line+54, 6 ); - strncpy( temp_string, line+60, 6 ); - } - - coord[1] = atof(strx); - coord[2] = atof(stry); - coord[3] = atof(strz); - occ = atof(occupancy); + + coord[1] = atof(strx); + coord[2] = atof(stry); + coord[3] = atof(strz); + occ = atof(occupancy); temperature = atof(temp_string); - ri_sr_no = atoi(sr_no); + ri_sr_no = atoi(sr_no); -// AJR 07.31.02 temporary fix of nonstandard hydrogen names - if( !strncmp(aname," H",2) && !strcmp(field1,"ATOM ")) { + // AJR 07.31.02 temporary fix of nonstandard hydrogen names + if (!strncmp(aname, " H", 2) && !strcmp(field1, "ATOM ")) { strcpy(aname, " H "); } -// AJR 07.31.02 end temporary fix of nonstandard hydrogen names + // AJR 07.31.02 end temporary fix of nonstandard hydrogen names -// _____ SN 2007:02:08 --- Change 'D'uetirium atoms to 'H' -// _____ SN 2007:02:20 --- EXIT and output error to user asking to -// replace all 'D'uetirium atoms to 'H' - if( !strncmp(&aname[2],"D",1)) { - strncpy(&aname[2],"H",1); + // _____ SN 2007:02:08 --- Change 'D'uetirium atoms to 'H' + // _____ SN 2007:02:20 --- EXIT and output error to user asking to + // replace all 'D'uetirium atoms to 'H' + if (!strncmp(&aname[2], "D", 1)) { + strncpy(&aname[2], "H", 1); + } + if (!strcmp(rname, "DOD")) { + strcpy(rname, "HOH"); } - if( !strcmp(rname,"DOD")) { - strcpy(rname,"HOH"); - } -// ______________ End of fix ______________ + // ______________ End of fix ______________ - if( !strncmp(line,"ATOM", 4) || - !strncmp(line,"HETATM",6) ) { + if (!strncmp(line, "ATOM", 4) || !strncmp(line, "HETATM", 6)) { no_atoms += 1; - } - else { + } else { ri_sr_no = 0; } } @@ -180,104 +171,97 @@ void record::getrecord(void) { /**********************************************************************/ void conect::getconect(void) { - char sr_no[6],conect1_sr_no[6],conect2_sr_no[6]; - char conect3_sr_no[6],conect4_sr_no[6]; + char sr_no[6], conect1_sr_no[6], conect2_sr_no[6]; + char conect3_sr_no[6], conect4_sr_no[6]; char line[90]; - int i,num[4], flag=0; - - ifil.getline(line,90); - - while( flag == 0 ) { - - if(strncmp(line,"CONECT",6)==0) { - strncpy(sr_no,line+6,5); - sr_no[5]='\0'; - strncpy(conect1_sr_no,line+11,5); - conect1_sr_no[5]='\0'; - strncpy(conect2_sr_no,line+16,5); - conect2_sr_no[5]='\0'; - strncpy(conect3_sr_no,line+21,5); - conect3_sr_no[5]='\0'; - strncpy(conect4_sr_no,line+26,5); - conect4_sr_no[5]='\0'; - - ci_sr_no=atoi(sr_no); - num[0]=atoi(conect1_sr_no); - num[1]=atoi(conect2_sr_no); - num[2]=atoi(conect3_sr_no); - num[3]=atoi(conect4_sr_no); - - ci_sr_no=map_array[ci_sr_no]; - for(i=0;i<4;i++) { - i_conect_sr_no[i]=map_array[num[i]]; + int i, num[4], flag = 0; + + ifil.getline(line, 90); + + while (flag == 0) { + + if (strncmp(line, "CONECT", 6) == 0) { + strncpy(sr_no, line + 6, 5); + sr_no[5] = '\0'; + strncpy(conect1_sr_no, line + 11, 5); + conect1_sr_no[5] = '\0'; + strncpy(conect2_sr_no, line + 16, 5); + conect2_sr_no[5] = '\0'; + strncpy(conect3_sr_no, line + 21, 5); + conect3_sr_no[5] = '\0'; + strncpy(conect4_sr_no, line + 26, 5); + conect4_sr_no[5] = '\0'; + + ci_sr_no = atoi(sr_no); + num[0] = atoi(conect1_sr_no); + num[1] = atoi(conect2_sr_no); + num[2] = atoi(conect3_sr_no); + num[3] = atoi(conect4_sr_no); + + ci_sr_no = map_array[ci_sr_no]; + for (i = 0; i < 4; i++) { + i_conect_sr_no[i] = map_array[num[i]]; } - + /*i_conect1_sr_no=map_array[i_conect1_sr_no]; - i_conect2_sr_no=map_array[i_conect2_sr_no]; - i_conect3_sr_no=map_array[i_conect3_sr_no]; - i_conect4_sr_no=map_array[i_conect4_sr_no];*/ - - if(ci_sr_no!=0) { - ofil<<"CONECT"<add_rec_node(); // read a line from the pdb file - if( fresh->r1.modelflag >= 2){ + fresh->add_rec_node(); // read a line from the pdb file + if (fresh->r1.modelflag >= 2) { model_flag = fresh->r1.modelflag; break; } fresh->next = fresh->prior = NULL; - if( ifil.eof() ) // This line is necessary, as a new node is allocated before - break; // it is known whether the end-of-file has been reached. + if (ifil.eof()) // This line is necessary, as a new node is allocated before + break; // it is known whether the end-of-file has been reached. + + /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AJR 05.07.02 testing enum idea %%% */ + // cout<< fresh->r1.aname <<"\t"<r1.aname <<"\t"<r1.chain, " ")) + strcpy(fresh->r1.chain, "~~"); - if( !strcmp(fresh->r1.chain," ") ) - strcpy(fresh->r1.chain,"~~"); - /* Initialize the linked list */ - if( start == NULL ) { + if (!start) { start = fresh; - last = fresh; + last = fresh; } else { temp = start; - while( flag2 != 0 ) { + while (flag2 != 0) { - // DEBUG -ve residue indices - //if( strncmp( temp->r1.res_no, " -", 3 ) == 0 ) + // DEBUG -ve residue indices + // if( strncmp( temp->r1.res_no, " -", 3 ) == 0 ) //{ // printf("\n fresh: %s temp: %s strcmp: %d",fresh->r1.res_no, - // temp->r1.res_no, - // strcmp(fresh->r1.res_no,temp->r1.res_no)); + // temp->r1.res_no, + // strcmp(fresh->r1.res_no,temp->r1.res_no)); //} - /************************************************************/ - /* If the last record and this record have different chain */ - /* IDs. */ - /************************************************************/ - if( strcmp(fresh->r1.chain,temp->r1.chain) > 0 ) { - if( temp == start ) { - fresh->next=start; - start->prior=fresh; - start=fresh; - flag2=0; - } - else { - fresh->next=temp; - fresh->prior=temp->prior; - prev=temp->prior; - prev->next=fresh; - temp->prior=fresh; - flag2=0; - } - } - - /************************************************************/ - /* If the last record and this record have THE SAME chain */ - /* IDs. */ - /************************************************************/ - else { - if( strcmp(fresh->r1.chain,temp->r1.chain) == 0 ) { - - /* SN 2008:07 bugfix to handle negative rsd indices: - Change '>' to '!=' as: " 1" > "-1" is FALSE */ - if( strcmp(fresh->r1.res_no,temp->r1.res_no) != 0){ - if( temp == start ) { - fresh->next=start; - start->prior=fresh; - start=fresh; - flag2=0; - } - else { - fresh->next=temp; - fresh->prior=temp->prior; - prev=temp->prior; - prev->next=fresh; - temp->prior=fresh; - flag2=0; - } - } - else { - if( strcmp(fresh->r1.res_no,temp->r1.res_no) == 0 ) { - - if( strcmp( fresh->r1.sr_no,temp->r1.sr_no) != 0 ) { - if( temp == start ) { - fresh->next=start; - start->prior=fresh; - start=fresh; - flag2=0; - } - else { - fresh->next=temp; - fresh->prior=temp->prior; - prev=temp->prior; - prev->next=fresh; - temp->prior=fresh; - flag2=0; - } - } - else { - if( temp == last ) { - last->next = fresh; - fresh->prior = last; - last = fresh; - flag2 = 0; - } - else { - temp = temp->next; - } - } - } - else { - if( temp == last ) { - last->next=fresh; - fresh->prior=last; - last=fresh; - flag2=0; - } - else { - temp = temp->next; - } - } - } - } - else { - if( temp == last ) { - last->next = fresh; - fresh->prior = last; - last = fresh; - flag2 = 0; - } - else { - temp = temp->next; - } - } - } + /************************************************************/ + /* If the last record and this record have different chain */ + /* IDs. */ + /************************************************************/ + if (strcmp(fresh->r1.chain, temp->r1.chain) > 0) { + if (temp == start) { + fresh->next = start; + start->prior = fresh; + start = fresh; + flag2 = 0; + } else { + fresh->next = temp; + fresh->prior = temp->prior; + prev = temp->prior; + prev->next = fresh; + temp->prior = fresh; + flag2 = 0; + } + } + + /************************************************************/ + /* If the last record and this record have THE SAME chain */ + /* IDs. */ + /************************************************************/ + else { + if (strcmp(fresh->r1.chain, temp->r1.chain) == 0) { + + /* SN 2008:07 bugfix to handle negative rsd indices: + Change '>' to '!=' as: " 1" > "-1" is FALSE */ + if (strcmp(fresh->r1.res_no, temp->r1.res_no) != 0) { + if (temp == start) { + fresh->next = start; + start->prior = fresh; + start = fresh; + flag2 = 0; + } else { + fresh->next = temp; + fresh->prior = temp->prior; + prev = temp->prior; + prev->next = fresh; + temp->prior = fresh; + flag2 = 0; + } + } else { + if (strcmp(fresh->r1.res_no, temp->r1.res_no) == 0) { + + if (strcmp(fresh->r1.sr_no, temp->r1.sr_no) != 0) { + if (temp == start) { + fresh->next = start; + start->prior = fresh; + start = fresh; + flag2 = 0; + } else { + fresh->next = temp; + fresh->prior = temp->prior; + prev = temp->prior; + prev->next = fresh; + temp->prior = fresh; + flag2 = 0; + } + } else { + if (temp == last) { + last->next = fresh; + fresh->prior = last; + last = fresh; + flag2 = 0; + } else { + temp = temp->next; + } + } + } else { + if (temp == last) { + last->next = fresh; + fresh->prior = last; + last = fresh; + flag2 = 0; + } else { + temp = temp->next; + } + } + } + } else { + if (temp == last) { + last->next = fresh; + fresh->prior = last; + last = fresh; + flag2 = 0; + } else { + temp = temp->next; + } + } + } } flag2 = 1; } @@ -499,261 +473,260 @@ void list::add_record(int usage) { /************************************************************ the error produced by the SUN compiler (CC) orrur somewhere - before the following error check. Seems to be including a - ghost line with all fields empty except ri_sr_no = 0. BMH + before the following error check. Seems to be including a + ghost line with all fields empty except ri_sr_no = 0. BMH test_chem.open("test_chem", ios::out); -// A possible reason for the error is the class used to have a class variable -// with the name temp and we have a local variable in this function with the -// name temp. Compiler warnings about shadowing the "temp" class variable +// A possible reason for the error is the class used to have a class variable +// with the name temp and we have a local variable in this function with the +// name temp. Compiler warnings about shadowing the "temp" class variable // lend support to this hypothesis. temp = last; while( temp ) { test_chem << "check" << temp->r1.field1<r1.ri_sr_no - << temp->r1.aname<r1.altloc - << temp->r1.rname<r1.chain - << temp->r1.res_no<r1.code - << temp->r1.strx<r1.stry - << temp->r1.strz<r1.occupancy - << temp->r1.temp_string<r1.mod_res_no - << " "<r1.DAH_type - << endl; + << temp->r1.aname<r1.altloc + << temp->r1.rname<r1.chain + << temp->r1.res_no<r1.code + << temp->r1.strx<r1.stry + << temp->r1.strz<r1.occupancy + << temp->r1.temp_string<r1.mod_res_no + << " "<r1.DAH_type + << endl; temp = temp->prior; - } + } test_chem.close(); ************************************************************/ //--------------------------Check if any records are present - if( !start && !last) { - cout<< endl << "\a\tThere were no atom records in the PDB file!" - << endl << endl; + if (!start && !last) { + cout << endl + << "\a\tThere were no atom records in the PDB file!" << endl + << endl; answer[0] = 'r'; answer[1] = 'm'; answer[2] = ' '; answer[3] = '\0'; - strcat(answer,outputfile); - system( answer ); + strcat(answer, outputfile); + system(answer); exit(11); - } - + } + //--------------Marking the start of a new chain temp = last; chainptr[0] = temp; chainletter[0] = chainptr[0]->r1.chain[1]; - while( temp != start ) { - temp=temp->prior; - if(strcmp(temp->r1.chain,chainptr[chaincount]->r1.chain)!=0) { - chainptr[chaincount+1]=temp; + while (temp != start) { + temp = temp->prior; + if (strcmp(temp->r1.chain, chainptr[chaincount]->r1.chain) != 0) { + chainptr[chaincount + 1] = temp; ++chaincount; - chainletter[chaincount]=chainptr[chaincount]->r1.chain[1]; - + chainletter[chaincount] = chainptr[chaincount]->r1.chain[1]; } } - //--------------------------------------------check for chain IDs that are U,V,..etc + //--------------------------------------------check for chain IDs that are + // U,V,..etc chain_change_count = 0; ++chaincount; m = 0; - for( i = 0; i < chaincount; i++ ) { - //cout<r1.chain[1]; - chain_change[chain_change_count][1]=('A'+m); - - temp = chainptr[i]; - strcpy( buffer, temp->r1.chain ); - temp->r1.chain[1]=('A'+m); - - /* rewrote, see below. BMH 3.16.00 - while(1) { - temp = temp->prior; - if( !strcmp( temp->r1.chain, buffer ) ) { - temp->r1.chain[1]=('A'+m); - if( temp == start ) { - break; - } - } - else { - break; - } - } - */ - - temp = temp->prior; - while( (temp != NULL) && !strcmp( temp->r1.chain, buffer ) ) { - temp->r1.chain[1]=('A'+m); - temp = temp->prior; - } - - m++; - break; - } - else { - m++; - } + for (i = 0; i < chaincount; i++) { + // cout<r1.chain[1]; + chain_change[chain_change_count][1] = ('A' + m); + + temp = chainptr[i]; + strcpy(buffer, temp->r1.chain); + temp->r1.chain[1] = ('A' + m); + + /* rewrote, see below. BMH 3.16.00 + while(1) { + temp = temp->prior; + if( !strcmp( temp->r1.chain, buffer ) ) { + temp->r1.chain[1]=('A'+m); + if( temp == start ) { + break; + } + } + else { + break; + } + } + */ + + temp = temp->prior; + while ((temp != NULL) && !strcmp(temp->r1.chain, buffer)) { + temp->r1.chain[1] = ('A' + m); + temp = temp->prior; + } + + m++; + break; + } else { + m++; + } } } } - + i = 0; temp = chainptr[i]; temp->r1.mod_res_no = 1; prev = temp; temp = temp->prior; - // Modify the residue numbers - while( i < chaincount ) { - - if( !strcmp(temp->r1.chain,chainptr[i]->r1.chain) ) { - if( !strcmp(temp->r1.res_no,prev->r1.res_no) ) { - if( !strcmp(temp->r1.code,prev->r1.code) ) { - temp->r1.mod_res_no=prev->r1.mod_res_no; - if( temp == start ) { - break; - } - prev = temp; - temp = temp->prior; - } - else { - temp->r1.mod_res_no = prev->r1.mod_res_no+1; - if( temp == start ) { - break; - } - prev = temp; - temp=temp->prior; - } - } - else { - temp->r1.mod_res_no=prev->r1.mod_res_no+1; - if( temp == start ) { - break; - } - prev = temp; - temp = temp->prior; + // Modify the residue numbers + while (i < chaincount) { + + if (!strcmp(temp->r1.chain, chainptr[i]->r1.chain)) { + if (!strcmp(temp->r1.res_no, prev->r1.res_no)) { + if (!strcmp(temp->r1.code, prev->r1.code)) { + temp->r1.mod_res_no = prev->r1.mod_res_no; + if (temp == start) { + break; + } + prev = temp; + temp = temp->prior; + } else { + temp->r1.mod_res_no = prev->r1.mod_res_no + 1; + if (temp == start) { + break; + } + prev = temp; + temp = temp->prior; + } + } else { + temp->r1.mod_res_no = prev->r1.mod_res_no + 1; + if (temp == start) { + break; + } + prev = temp; + temp = temp->prior; } - } - else { - if( temp == start ) { - break; + } else { + if (temp == start) { + break; } i++; - temp=chainptr[i]; - temp->r1.mod_res_no=1; - prev=temp; - temp=temp->prior; + temp = chainptr[i]; + temp->r1.mod_res_no = 1; + prev = temp; + temp = temp->prior; } } temp = last; - if( !strncmp(temp->r1.field1,"TER",3) ) { + if (!strncmp(temp->r1.field1, "TER", 3)) { temp = temp->prior; } - if( strcmp(temp->r1.altloc," ") ) { - altlocptr[0]=temp; + if (strcmp(temp->r1.altloc, " ")) { + altlocptr[0] = temp; no_conf[altloccount]++; altloccount++; flag1 = 1; - } - while( temp != start ) { + } + while (temp != start) { prev = temp; temp = temp->prior; - if( !strcmp(temp->r1.field1,"TER ") ) { - if( temp == start ) { - break; + if (!strcmp(temp->r1.field1, "TER ")) { + if (temp == start) { + break; } temp = temp->prior; } - if( strcmp(temp->r1.altloc," ") ) { - if( !flag1 ) { - if( !strcmp(temp->prior->r1.aname,temp->r1.aname) ) { - altlocptr[0]=temp; - no_conf[altloccount]++; - altloccount++; - flag1=1; - } - } - else { - if( temp->r1.mod_res_no != altlocptr[altloccount-1]->r1.mod_res_no ) { - if( !strcmp(temp->prior->r1.aname,temp->r1.aname) ) { - altlocptr[altloccount]=temp; - no_conf[altloccount]++; - altloccount++; - } - } - else { - if( !strcmp(altlocptr[altloccount-1]->r1.aname,temp->r1.aname) ) { - no_conf[altloccount-1]++; - } - } + if (strcmp(temp->r1.altloc, " ")) { + if (!flag1) { + if (!strcmp(temp->prior->r1.aname, temp->r1.aname)) { + altlocptr[0] = temp; + no_conf[altloccount]++; + altloccount++; + flag1 = 1; + } + } else { + if (temp->r1.mod_res_no != altlocptr[altloccount - 1]->r1.mod_res_no) { + if (!strcmp(temp->prior->r1.aname, temp->r1.aname)) { + altlocptr[altloccount] = temp; + no_conf[altloccount]++; + altloccount++; + } + } else { + if (!strcmp(altlocptr[altloccount - 1]->r1.aname, temp->r1.aname)) { + no_conf[altloccount - 1]++; + } + } } } } - - if(altloccount != 0){ - -//---------------------------- AJR 04.29.02 adding default, "-non", option <-> usage = 1. - cout<> my_choice; + + if (altloccount != 0) { + + //---------------------------- AJR 04.29.02 adding default, "-non", option + //<-> usage = 1. + cout << endl + << "Multiple conformations were found for certain residues." << endl; + cout << endl << "Choose one of the following: " << endl << endl; + cout << " 1. Default (selects lowest mobility)" << endl; + cout << " 2. New selection" << endl; + if (prev_sel_flag != 0) { + cout << " 3. Previous selection" << endl; } - else if(usage) { - if( prev_sel_flag == 1) my_choice = "3"; - if( prev_sel_flag == 0) my_choice = "1"; + if (usage == 0) { + cout << endl << "Enter Choice: "; + cin >> my_choice; + } else if (usage) { + if (prev_sel_flag == 1) + my_choice = "3"; + if (prev_sel_flag == 0) + my_choice = "1"; } - if( prev_sel_flag == 0 ) { - while(my_choice != "1" && my_choice != "2"){ - // fflush(cin); - // cout<> my_choice; + if (prev_sel_flag == 0) { + while (my_choice != "1" && my_choice != "2") { + // fflush(cin); + // cout<> my_choice; } - conf_chosen = new char[altloccount+1]; - del_conf(my_choice,usage); - } - else { - while(my_choice != "1" && my_choice != "2" && my_choice != "3"){ - // fflush(cin); - // cout<> my_choice; - //ccccccccccccccccccccccccccccccccccc - } - conf_chosen = new char[altloccount+1]; - del_conf(my_choice,usage); + conf_chosen = new char[altloccount + 1]; + del_conf(my_choice, usage); + } else { + while (my_choice != "1" && my_choice != "2" && my_choice != "3") { + // fflush(cin); + // cout<> my_choice; + // ccccccccccccccccccccccccccccccccccc + } + conf_chosen = new char[altloccount + 1]; + del_conf(my_choice, usage); } } -/* _____ SN 2007:02 --- Check if the input file is missing even polar 'H' atoms - Note that all ATOM recs are stored in chainptr[0] with - consecutive records linked by "prior" pointer and not - "next"! - --- It is sufficient to check just the first residue's amide nitrogen */ -/* _____ SN 2008:02 --- Check all the chains! - Also, make sure that only standard residue types are - tested for hydrogens as ligand atoms form a different - chain and usually are assigned non-standard rsd names!*/ + /* _____ SN 2007:02 --- Check if the input file is missing even polar 'H' + atoms Note that all ATOM recs are stored in chainptr[0] with consecutive + records linked by "prior" pointer and not "next"! + --- It is sufficient to check just the first residue's amide nitrogen + */ + /* _____ SN 2008:02 --- Check all the chains! + Also, make sure that only standard residue types are + tested for hydrogens as ligand atoms form a different + chain and usually are assigned non-standard rsd + names!*/ // The variable that used to be used here shadows the global variable // "residue *res" in ../../include/class.h @@ -781,513 +754,499 @@ void list::add_record(int usage) { std_res_names["TYR"] = true; std_res_names["TRP"] = true; - flag1 = 0; // Count all chains that have polar Hs on their atoms - while(flag1 < chaincount) - { - temp = chainptr[flag1]; + flag1 = 0; // Count all chains that have polar Hs on their atoms + while (flag1 < chaincount) { + temp = chainptr[flag1]; std::string curr_resName = temp->r1.rname; // Check if the residue name is a standard one - if(std_res_names.find(curr_resName) != std_res_names.end()){ - while(temp != NULL && curr_resName == temp->r1.rname) { - if(temp->r1.aname[2] == 'H') { - flag1++; - break; /* Break at the first occurrence of an 'H' */ + if (std_res_names.find(curr_resName) != std_res_names.end()) { + while (temp != NULL && curr_resName == temp->r1.rname) { + if (temp->r1.aname[2] == 'H') { + flag1++; + break; /* Break at the first occurrence of an 'H' */ } temp = temp->prior; } } - //Non-standard residue; goto next chain - else flag1++; + // Non-standard residue; goto next chain + else + flag1++; } - if(flag1 != chaincount) { - cout<<"\n################################################################"; - cout<<"\n# #"; - cout<<"\n# WARNING: Input file is missing hydrogens on residues. #"; - cout<<"\n# Please add and equilibrate hydrogens using software #"; - cout<<"\n# such as AMBER, CHARMM, Reduce or WhatIf, #"; - cout<<"\n# delete the proflexdataset file, and re-run ProFlex. #"; - cout<<"\n# #"; - cout<<"\n# Make sure the ligand and other co-factor atoms are #"; - cout<<"\n# appropriately protonated. #"; - cout<<"\n# #"; - cout<<"\n################################################################\n"; - //cout<<"\n\natom #: "<r1.ri_sr_no; - exit(1); - } - -// _____ End of fix _____ - + if (flag1 != chaincount) { + cout + << "\n################################################################"; + cout + << "\n# #"; + cout + << "\n# WARNING: Input file is missing hydrogens on residues. #"; + cout + << "\n# Please add and equilibrate hydrogens using software #"; + cout + << "\n# such as AMBER, CHARMM, Reduce or WhatIf, #"; + cout + << "\n# delete the proflexdataset file, and re-run ProFlex. #"; + cout + << "\n# #"; + cout + << "\n# Make sure the ligand and other co-factor atoms are #"; + cout + << "\n# appropriately protonated. #"; + cout + << "\n# #"; + cout << "\n################################################################" + "\n"; + // cout<<"\n\natom #: "<r1.ri_sr_no; + exit(1); + } + // _____ End of fix _____ temp = last; flag1 = 0; - while( temp != NULL ) { - -// _____ SN 2007:02 --- fix to catch water molecules with no 'H's in input PDB file - - if(!strcmp(temp->r1.rname,"HOH") && temp->r1.aname[2] == 'O') { - flag1++; - if((temp->prior)->r1.aname[2] != 'H') { - cout<<"\n################################################################"; - cout<<"\n# #"; - cout<<"\n# WARNING: Input file is missing hydrogens on water molecules #"; - cout<<"\n# Please add and equilibrate hydrogens using software #"; - cout<<"\n# such as AMBER, CHARMM, Reduce or WhatIf, #"; - cout<<"\n# delete the proflexdataset file, and re-run ProFlex #"; - cout<<"\n# #"; - cout<<"\n# Make sure the ligand and other co-factor atoms are #"; - cout<<"\n# appropriately protonated. #"; - cout<<"\n# #"; - cout<<"\n################################################################\n"; - exit(1); - } - } - else if(flag1 > 1) // Two water molecules checked and found 'H' atoms - // Assuming the rest of the waters have 'H's we break out of check - break; + while (temp != NULL) { + + // _____ SN 2007:02 --- fix to catch water molecules with no 'H's in input + // PDB file + + if (!strcmp(temp->r1.rname, "HOH") && temp->r1.aname[2] == 'O') { + flag1++; + if ((temp->prior)->r1.aname[2] != 'H') { + cout << "\n############################################################" + "####"; + cout << "\n# " + " #"; + cout << "\n# WARNING: Input file is missing hydrogens on water " + "molecules #"; + cout << "\n# Please add and equilibrate hydrogens using " + "software #"; + cout << "\n# such as AMBER, CHARMM, Reduce or WhatIf, " + " #"; + cout << "\n# delete the proflexdataset file, and re-run " + "ProFlex #"; + cout << "\n# " + " #"; + cout << "\n# Make sure the ligand and other co-factor atoms " + "are #"; + cout << "\n# appropriately protonated. " + " #"; + cout << "\n# " + " #"; + cout << "\n############################################################" + "####\n"; + exit(1); + } + } else if (flag1 > 1) // Two water molecules checked and found 'H' atoms + // Assuming the rest of the waters have 'H's we break + // out of check + break; temp = temp->prior; } -// _____ End of fix _______ - + // _____ End of fix _______ int count = 1; temp = last; nh = 0; - while( temp != NULL ) { + while (temp != NULL) { - if(temp->r1.aname[2]=='H') { + if (temp->r1.aname[2] == 'H') { nh++; } - if(temp->r1.aname[2]=='S') { + if (temp->r1.aname[2] == 'S') { ns++; } - - if( strncmp( temp->r1.field1,"TER",3 ) ) { + + if (strncmp(temp->r1.field1, "TER", 3)) { map_array[temp->r1.ri_sr_no] = count; temp->r1.ri_sr_no = count; - if( temp != start ) - count++; + if (temp != start) + count++; } temp = temp->prior; } - ofil.close(); + ofil.close(); ofil.clear(); } /**********************************************************************/ /* End of void list::add_record(int ) */ /**********************************************************************/ - /**********************************************************************/ void list::del_conf(std::string choice_in, int usage) { int i, j, k, f = 0, occ_flag, ich; -// int i, j, k, f = 0, flag = 0, occ_flag, temp_flag=0, ich; - + // int i, j, k, f = 0, flag = 0, occ_flag, temp_flag=0, ich; + float temp_sum[20], max_occ, low_temp; char ans; std::string my_choice; - + node *temp, *prev, *t; - + ich = atoi(choice_in.c_str()); - switch(ich) { - case 1: //---------------------------------Default - { - // TESTING cout << "altloccount = " << altloccount << endl; - for(i=0;ir1.occ; - t=temp; - //occu[0]=max_occ; - for(j=1;jprior; - /* TESTING - cout << "altloc = " << i << " conf. = " - << j << " --> " << temp->r1.altloc << " on Res: " - << temp->r1.rname << " Res. # = " << temp->r1.res_no - << " atom # = " << temp->r1.sr_no - << " occ = " << temp->r1.occ << " max = " - << max_occ << endl; - END OF TESTING */ - //occu[i]=temp->r1.occ; - if(max_occ < temp->r1.occ) - { - max_occ=temp->r1.occ; - t=temp; - temp=temp->prior; - // TESTING cout << "temp pointer changed!!" << endl; - occ_flag=1; //asymmetry - } - else - { - // TESTING cout << "CONSTANT pointer." << endl; - if(max_occ!=temp->r1.occ) - { - // TESTING cout << "asymmetry." << endl; - occ_flag=1; //asymmetry - } - } - } - for(j=0;j<20;j++) - { - temp_sum[j]=0; - } - if(occ_flag==0) // Determine the conformation that has highest mobility - { - temp=altlocptr[i]; //extra line - for(j=0;jr1.mod_res_no == altlocptr[i]->r1.mod_res_no) - { - if(strcmp(temp->r1.altloc,t->r1.altloc)==0) - { - temp_sum[j]+=temp->r1.temperature; - /* TESTING - cout << "conf. = " << j << " --> " - << temp->r1.altloc << " on Res: " - << temp->r1.rname << " Res # = " - << temp->r1.res_no << " atom # = " - << temp->r1.sr_no << endl; - END OF TESTING */ - } - temp=temp->prior; - } - t=t->prior; - temp=t; - } - //aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - /* TESTING - for(j=0;jnext=temp->next; - temp->next->prior=prev; - delete temp; - } - temp=prev; - prev=temp->prior; - } - } - else - { - temp=altlocptr[i]; - prev=temp->prior; - while(temp->r1.mod_res_no == altlocptr[i]->r1.mod_res_no) - { - if(strcmp(temp->r1.altloc,t->r1.altloc)!=0 && strcmp(temp->r1.altloc," ")!=0) - { - if(temp==altlocptr[i]) - { - altlocptr[i]=t; - } - for(j=0;jnext=temp->next; - temp->next->prior=prev; - delete temp; - } - temp=prev; - prev=temp->prior; - } - } - conf_chosen[i]=t->r1.altloc[0]; - conf_option=1; - } - break; + switch (ich) { + case 1: //---------------------------------Default + { + // TESTING cout << "altloccount = " << altloccount << endl; + for (i = 0; i < altloccount; i++) { + occ_flag = 0; // symmetry + temp = altlocptr[i]; + + max_occ = temp->r1.occ; + t = temp; + // occu[0]=max_occ; + for (j = 1; j < no_conf[i]; + j++) // Determine the conformation that has max. occupancy + { + temp = temp->prior; + /* TESTING + cout << "altloc = " << i << " conf. = " + << j << " --> " << temp->r1.altloc << " on Res: " + << temp->r1.rname << " Res. # = " << temp->r1.res_no + << " atom # = " << temp->r1.sr_no + << " occ = " << temp->r1.occ << " max = " + << max_occ << endl; + END OF TESTING */ + // occu[i]=temp->r1.occ; + if (max_occ < temp->r1.occ) { + max_occ = temp->r1.occ; + t = temp; + temp = temp->prior; + // TESTING cout << "temp pointer changed!!" << + // endl; + occ_flag = 1; // asymmetry + } else { + // TESTING cout << "CONSTANT pointer." << endl; + if (max_occ != temp->r1.occ) { + // TESTING cout << "asymmetry." << endl; + occ_flag = 1; // asymmetry + } + } + } + for (j = 0; j < 20; j++) { + temp_sum[j] = 0; + } + if (occ_flag == 0) // Determine the conformation that has highest mobility + { + temp = altlocptr[i]; // extra line + for (j = 0; j < no_conf[i]; j++) { + while (temp->r1.mod_res_no == altlocptr[i]->r1.mod_res_no) { + if (strcmp(temp->r1.altloc, t->r1.altloc) == 0) { + temp_sum[j] += temp->r1.temperature; + /* TESTING + cout << "conf. = " << j << " --> " + << temp->r1.altloc << " on Res: " + << temp->r1.rname << " Res # = " + << temp->r1.res_no << " atom # = " + << temp->r1.sr_no << endl; + END OF TESTING */ + } + temp = temp->prior; + } + t = t->prior; + temp = t; + } + // aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + /* TESTING + for(j=0;j temp_sum[j]) { + low_temp = temp_sum[j]; + k = j; + // temp_flag=1; + } + } + t = altlocptr[i]; + for (j = 0; j < k; j++) { + t = t->prior; + } + temp = altlocptr[i]; + prev = temp->prior; + while (temp->r1.mod_res_no == altlocptr[i]->r1.mod_res_no) { + if (strcmp(temp->r1.altloc, t->r1.altloc) != 0 && + strcmp(temp->r1.altloc, " ") != 0) { + if (temp == altlocptr[i]) { + altlocptr[i] = t; + } + for (j = 0; j < chaincount; j++) { + if (chainptr[j] == temp) { + chainptr[j] = prev; + break; + } + } + prev->next = temp->next; + temp->next->prior = prev; + delete temp; + } + temp = prev; + prev = temp->prior; + } + } else { + temp = altlocptr[i]; + prev = temp->prior; + while (temp->r1.mod_res_no == altlocptr[i]->r1.mod_res_no) { + if (strcmp(temp->r1.altloc, t->r1.altloc) != 0 && + strcmp(temp->r1.altloc, " ") != 0) { + if (temp == altlocptr[i]) { + altlocptr[i] = t; + } + for (j = 0; j < chaincount; j++) { + if (chainptr[j] == temp) { + chainptr[j] = prev; + break; + } + } + prev->next = temp->next; + temp->next->prior = prev; + delete temp; + } + temp = prev; + prev = temp->prior; + } + } + conf_chosen[i] = t->r1.altloc[0]; + conf_option = 1; } - - case 3: //-----------------------------------------------Previous selection - { - - if(prev_sel_flag==0) - { - //system("clear"); - cout<>my_choice; - if(usage) my_choice = "1"; - while(my_choice != "1" && my_choice != "2") - { - // cout<>my_choice; - } - if(my_choice == "1" || my_choice == "2") - { - del_conf(my_choice,usage); - //flag = 1; - break; - } - } + break; + } + + case 3: //-----------------------------------------------Previous selection + { + + if (prev_sel_flag == 0) { + // system("clear"); + cout << endl << "No previous selections were made !!" << endl; + cout << endl << "Choose one of the following: " << endl; + cout << endl << " 1. Default (selects lowest mobility)" << endl; + cout << " 2. New Selection" << endl; + cout << endl << "Enter Choice: "; + cin >> my_choice; + if (usage) + my_choice = "1"; + while (my_choice != "1" && my_choice != "2") { + // cout<> my_choice; + } + if (my_choice == "1" || my_choice == "2") { + del_conf(my_choice, usage); + // flag = 1; + break; + } + } else { + // system("clear"); + cout << endl << endl << "Your previous selections were: " << endl; + cout << endl + << "RESIDUE " + << "RESIDUE NO. " + << "CHAIN " + << "CONFORMATIONS" + << " SELECTION" << endl + << endl; + for (i = 0; i < altloccount; i++) { + // pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp + /* + cout<<" "<r1.rname<r1.res_no<r1.code<<" " + <r1.chain<<" "; + */ + + if (strcmp(altlocptr[i]->r1.chain, "~~") != 0) { + cout << " " << altlocptr[i]->r1.rname << setw(10) + << altlocptr[i]->r1.res_no << altlocptr[i]->r1.code << " " + << altlocptr[i]->r1.chain << " "; + } else { + cout << " " << altlocptr[i]->r1.rname << setw(10) + << altlocptr[i]->r1.res_no << altlocptr[i]->r1.code << " " + << " " + << " "; + } + + temp = altlocptr[i]; + for (j = 0; j < no_conf[i]; j++) { + cout << " " << temp->r1.altloc; + // <<" " + // <prior; + } + cout << " " << prev_sel[i] << endl; + } + cout << endl << endl << "Type n for new selection: "; + cin >> answer; + if (strlen(answer) == 1) + ans = answer[0]; else - { - //system("clear"); - cout<r1.rname<r1.res_no<r1.code<<" " - <r1.chain<<" "; - */ - - if(strcmp(altlocptr[i]->r1.chain,"~~")!=0) - { - cout<<" "<r1.rname<r1.res_no<r1.code<<" " - <r1.chain<<" "; - } - else - { - cout<<" "<r1.rname<r1.res_no<r1.code<<" " - <<" "<<" "; - } - - temp=altlocptr[i]; - for(j=0;jr1.altloc; - // <<" " - // <prior; - } - cout<<" "<> answer; - if( strlen(answer) == 1 ) ans = answer[0]; - else ans = 'Y'; - if(ans!='n' && ans!='N') - { - for(i=0;iprior; - while(temp->r1.mod_res_no == altlocptr[i]->r1.mod_res_no) - { - if(temp->r1.altloc[0]!=prev_sel[i] && strcmp(temp->r1.altloc," ")!=0) - { - if(temp==altlocptr[i]) - { - altlocptr[i]=temp->prior; - } - for(j=0;jnext=temp->next; - temp->next->prior=prev; - delete temp; - } - temp=prev; - prev=temp->prior; - } - conf_chosen[i]=prev_sel[i]; - } - - } - else - { - //system("clear"); - cout<>my_choice; - if(usage) my_choice = "1"; - while(my_choice != "1" && my_choice != "2") - { - // cout<>my_choice; - } - // if(my_choice==1 || my_choice==2) - // { - del_conf(my_choice,usage); - //flag=1; - break; - // } - } - } - break; + ans = 'Y'; + if (ans != 'n' && ans != 'N') { + for (i = 0; i < altloccount; i++) { + temp = altlocptr[i]; + prev = temp->prior; + while (temp->r1.mod_res_no == altlocptr[i]->r1.mod_res_no) { + if (temp->r1.altloc[0] != prev_sel[i] && + strcmp(temp->r1.altloc, " ") != 0) { + if (temp == altlocptr[i]) { + altlocptr[i] = temp->prior; + } + for (j = 0; j < chaincount; j++) { + if (chainptr[j] == temp) { + chainptr[j] = prev; + break; + } + } + prev->next = temp->next; + temp->next->prior = prev; + delete temp; + } + temp = prev; + prev = temp->prior; + } + conf_chosen[i] = prev_sel[i]; + } + + } else { + // system("clear"); + cout << endl << "Choose one of the following: " << endl; + cout << endl << " 1. Default (selects lowest mobility)" << endl; + cout << " 2. New Selection" << endl; + cout << endl << "Enter Choice: "; + cin >> my_choice; + if (usage) + my_choice = "1"; + while (my_choice != "1" && my_choice != "2") { + // cout<> my_choice; + } + // if(my_choice==1 || my_choice==2) + // { + del_conf(my_choice, usage); + // flag=1; + break; + // } + } } - - case 2: //----------------------------------------------New selection - { - //system("clear"); - - cout<r1.rname<r1.res_no<r1.code<<" " - <r1.chain<<" "; - */ - - if(strcmp(altlocptr[i]->r1.chain,"~~")==0) - { - cout<<" "<r1.rname<r1.res_no<r1.code<<" " - <<" "<<" "; - } - else - { - cout<<" "<r1.rname<r1.res_no<r1.code<<" " - <r1.chain<<" "; - } - - temp=altlocptr[i]; - for(j=0;jr1.altloc; - // strcpy(string[i],temp->r1.altloc); - temp=temp->prior; - } - cout<r1.res_no<r1.code<<" (" - <r1.rname<<"): "; - cin>>conf_chosen[i]; - for(j=0;jr1.altloc[0]==conf_chosen[i]) - { - f=1; - break; - } - temp=temp->prior; - } - if(f==0) - { - cout<prior; - while(temp->r1.mod_res_no == altlocptr[i]->r1.mod_res_no) - { - cout << endl << "temp = " << temp << " prior = " << temp->prior << " next = " << temp->next << endl; - cout << "temp: " << "Res = " << temp->r1.rname << " Res # = " << temp->r1.res_no << " conf = " << temp->r1.altloc << " Atom = " << temp->r1.aname << " Atom # = " << temp->r1.sr_no << endl; - prev = temp->prior; - cout << "prior: " << "Res = " << prev->r1.rname << " Res # = " << prev->r1.res_no << " conf = " << prev->r1.altloc << " Atom = " << prev->r1.aname << " Atom # = " << prev->r1.sr_no << endl; - prev = temp->next; - cout << "next: " << "Res = " << prev->r1.rname << " Res # = " << prev->r1.res_no << " conf = " << prev->r1.altloc << " Atom = " << prev->r1.aname << " Atom # = " << prev->r1.sr_no << endl; - prev=temp->prior; - temp=prev; - } - cout << endl << endl; - cin >> k; - */ - temp=altlocptr[i]; - prev=temp->prior; - while(temp->r1.mod_res_no == altlocptr[i]->r1.mod_res_no) - { - if(temp->r1.altloc[0]!=conf_chosen[i] && strcmp(temp->r1.altloc," ")!=0) - { - if(temp==altlocptr[i]) - { - altlocptr[i]=temp->prior; - } - for(j=0;jnext=temp->next; - temp->next->prior=prev; - delete temp; - } - temp=prev; - prev=temp->prior; - } - } - break; + break; + } + + case 2: //----------------------------------------------New selection + { + // system("clear"); + + cout << endl + << "RESIDUE " + << "RESIDUE NO. " + << "CHAIN " + << "CONFORMATIONS" << endl + << endl; + for (i = 0; i < altloccount; i++) { + /* + cout<<" "<r1.rname<r1.res_no<r1.code<<" " + <r1.chain<<" "; + */ + + if (strcmp(altlocptr[i]->r1.chain, "~~") == 0) { + cout << " " << altlocptr[i]->r1.rname << setw(10) + << altlocptr[i]->r1.res_no << altlocptr[i]->r1.code << " " + << " " + << " "; + } else { + cout << " " << altlocptr[i]->r1.rname << setw(10) + << altlocptr[i]->r1.res_no << altlocptr[i]->r1.code << " " + << altlocptr[i]->r1.chain << " "; + } + + temp = altlocptr[i]; + for (j = 0; j < no_conf[i]; j++) { + cout << " " << temp->r1.altloc; + // strcpy(string[i],temp->r1.altloc); + temp = temp->prior; + } + cout << endl; } + + for (i = 0; i < altloccount; i++) { + temp = altlocptr[i]; + f = 0; + while (f == 0) { + cout << endl + << "Choose the conformation for residue " + << altlocptr[i]->r1.res_no << altlocptr[i]->r1.code << " (" + << altlocptr[i]->r1.rname << "): "; + cin >> conf_chosen[i]; + for (j = 0; j < no_conf[i]; j++) { + if (temp->r1.altloc[0] == conf_chosen[i]) { + f = 1; + break; + } + temp = temp->prior; + } + if (f == 0) { + cout << endl << "\t Invalid selection!!" << endl; + } + } + conf_option = 2; + f = 0; + } + for (i = 0; i < altloccount; i++) { + /* + temp=altlocptr[i]; + prev=temp->prior; + while(temp->r1.mod_res_no == altlocptr[i]->r1.mod_res_no) + { + cout << endl << "temp = " << temp << " prior = " << temp->prior << " + next = " << temp->next << endl; cout << "temp: " << "Res = " << + temp->r1.rname << " Res # = " << temp->r1.res_no << " conf = " << + temp->r1.altloc << " Atom = " << temp->r1.aname << " Atom # = " << + temp->r1.sr_no << endl; prev = temp->prior; cout << "prior: " << "Res = + " << prev->r1.rname << " Res # = " << prev->r1.res_no << " conf = " << + prev->r1.altloc << " Atom = " << prev->r1.aname << " Atom # = " << + prev->r1.sr_no << endl; prev = temp->next; cout << "next: " << "Res = " + << prev->r1.rname << " Res # = " << prev->r1.res_no << " conf = " << + prev->r1.altloc << " Atom = " << prev->r1.aname << " Atom # = " << + prev->r1.sr_no << endl; prev=temp->prior; temp=prev; + } + cout << endl << endl; + cin >> k; + */ + temp = altlocptr[i]; + prev = temp->prior; + while (temp->r1.mod_res_no == altlocptr[i]->r1.mod_res_no) { + if (temp->r1.altloc[0] != conf_chosen[i] && + strcmp(temp->r1.altloc, " ") != 0) { + if (temp == altlocptr[i]) { + altlocptr[i] = temp->prior; + } + for (j = 0; j < chaincount; j++) { + if (chainptr[j] == temp) { + chainptr[j] = prev; + break; + } + } + prev->next = temp->next; + temp->next->prior = prev; + delete temp; + } + temp = prev; + prev = temp->prior; + } + } + break; + } } /* cout << endl << endl; @@ -1298,20 +1257,18 @@ void list::del_conf(std::string choice_in, int usage) { cin >> i; */ return; - } /**********************************************************************/ /* End of void list::del_conf( char ch[] int usage) */ /**********************************************************************/ - /**********************************************************************/ /* Add a CONECT record in the link list l2 */ /**********************************************************************/ void conect_list::add_conect(void) { conect_node *fresh; - + /* BMH the code below is pointless. what the hell? if( file_open_flag == 0 ) { ifil.open(inputfile,ios::in); @@ -1319,35 +1276,34 @@ void conect_list::add_conect(void) { file_open_flag=1; } */ - - ifil.open(inputfile,ios::in); - ofil.open(outputfile,ios::app); - while( ifil != NULL ) { - + ifil.open(inputfile, ios::in); + ofil.open(outputfile, ios::app); + + while (ifil) { + fresh = new conect_node; - + fresh->add_conect_node(); - - if( ifil == NULL ) + + if (!ifil) break; - - if( start == NULL ) { + + if (!start) { start = fresh; - last = fresh; + last = fresh; } - + else { - fresh->next=start; - start->prior=fresh; - start=fresh; + fresh->next = start; + start->prior = fresh; + start = fresh; } - } ifil.close(); ifil.clear(); - ofil.close(); + ofil.close(); ofil.clear(); return; } @@ -1355,50 +1311,41 @@ void conect_list::add_conect(void) { /* End of void connect_list::add_connect(void) */ /**********************************************************************/ - /**********************************************************************/ void list::make_chem_rec(void) { int flag3 = 0; - + node *tem; - + tem = last; ofstream xofil; - - xofil.open(outputfile,ios::app); - if( xofil == NULL ) { - cout<<"Error in opening outputfile"<r1.field1 << setw(5) << tem->r1.ri_sr_no - << tem->r1.aname << tem->r1.altloc - << tem->r1.rname << tem->r1.chain - << tem->r1.res_no << tem->r1.code - << tem->r1.strx << tem->r1.stry - << tem->r1.strz << tem->r1.occupancy - << tem->r1.temp_string << setw(5) << tem->r1.mod_res_no - << " " << tem->r1.DAH_type - << endl; - + while (flag3 != 1) { + if (tem == start) { + + xofil << tem->r1.field1 << setw(5) << tem->r1.ri_sr_no << tem->r1.aname + << tem->r1.altloc << tem->r1.rname << tem->r1.chain + << tem->r1.res_no << tem->r1.code << tem->r1.strx << tem->r1.stry + << tem->r1.strz << tem->r1.occupancy << tem->r1.temp_string + << setw(5) << tem->r1.mod_res_no << " " << tem->r1.DAH_type << endl; + xofil.close(); - flag3 = 1; - } - else { - if(strncmp(tem->r1.field1,"TER",3) ){ // AJR 05.13.02 omit TER lines - xofil << tem->r1.field1 << setw(5) << tem->r1.ri_sr_no - << tem->r1.aname << tem->r1.altloc - << tem->r1.rname << tem->r1.chain - << tem->r1.res_no << tem->r1.code - << tem->r1.strx << tem->r1.stry - << tem->r1.strz << tem->r1.occupancy - << tem->r1.temp_string << setw(5) << tem->r1.mod_res_no - << " " << tem->r1.DAH_type - << endl; + flag3 = 1; + } else { + if (strncmp(tem->r1.field1, "TER", 3)) { // AJR 05.13.02 omit TER lines + xofil << tem->r1.field1 << setw(5) << tem->r1.ri_sr_no << tem->r1.aname + << tem->r1.altloc << tem->r1.rname << tem->r1.chain + << tem->r1.res_no << tem->r1.code << tem->r1.strx << tem->r1.stry + << tem->r1.strz << tem->r1.occupancy << tem->r1.temp_string + << setw(5) << tem->r1.mod_res_no << " " << tem->r1.DAH_type + << endl; } tem = tem->prior; } @@ -1408,72 +1355,68 @@ void list::make_chem_rec(void) { /* End of void list::make_chem_rec(void) */ /**********************************************************************/ - /**********************************************************************/ /* Determine the largest and smallest residue number, and x, y, and z */ /* coordinate value. */ /**********************************************************************/ void list::cal_maxmin(void) { - int flag3 = 0, max_res_count=1; + int flag3 = 0, max_res_count = 1; node *tem; - + tem = last; // last is the first ATOM in the protein no_atoms = 0; - while( flag3 != 1 ) { - if( !strcmp(tem->r1.chain,"~~") ) { - strcpy(tem->r1.chain," "); + while (flag3 != 1) { + if (!strcmp(tem->r1.chain, "~~")) { + strcpy(tem->r1.chain, " "); } - if( tem == start ) { - if(tem->r1.field1[0]!='T'){ - no_atoms++; - //cout << tem->r1.sr_no << endl; + if (tem == start) { + if (tem->r1.field1[0] != 'T') { + no_atoms++; + // cout << tem->r1.sr_no << endl; } - if(tem->r1.coord[1]r1.coord[1]; - if(tem->r1.coord[2]r1.coord[2]; - if(tem->r1.coord[3]r1.coord[3]; - - if( largest_res < max_res_count ) { - largest_res = max_res_count; + if (tem->r1.coord[1] < xmin) + xmin = tem->r1.coord[1]; + if (tem->r1.coord[2] < ymin) + ymin = tem->r1.coord[2]; + if (tem->r1.coord[3] < zmin) + zmin = tem->r1.coord[3]; + + if (largest_res < max_res_count) { + largest_res = max_res_count; } - flag3 = 1; + flag3 = 1; } - + else { - if( tem->r1.field1[0] != 'T' ){ // if the current list node is not a TER record in the pdb file - no_atoms++; - //cout << tem->r1.sr_no << endl; + if (tem->r1.field1[0] != + 'T') { // if the current list node is not a TER record in the pdb file + no_atoms++; + // cout << tem->r1.sr_no << endl; } - if( tem->r1.coord[1] < xmin ) - xmin = tem->r1.coord[1]; - if( tem->r1.coord[2] < ymin ) - ymin = tem->r1.coord[2]; - if( tem->r1.coord[3] < zmin ) - zmin = tem->r1.coord[3]; - - if( tem->r1.mod_res_no == tem->prior->r1.mod_res_no ) { - max_res_count++; - } - else { - if( largest_res < max_res_count ) { - largest_res = max_res_count; - } - max_res_count = 1; + if (tem->r1.coord[1] < xmin) + xmin = tem->r1.coord[1]; + if (tem->r1.coord[2] < ymin) + ymin = tem->r1.coord[2]; + if (tem->r1.coord[3] < zmin) + zmin = tem->r1.coord[3]; + + if (tem->r1.mod_res_no == tem->prior->r1.mod_res_no) { + max_res_count++; + } else { + if (largest_res < max_res_count) { + largest_res = max_res_count; + } + max_res_count = 1; } - + tem = tem->prior; } } - //cout << "number of atoms" << no_atoms << endl; + // cout << "number of atoms" << no_atoms << endl; } /**********************************************************************/ /* End of void list::cal_maxmin(void) */ /**********************************************************************/ - - - diff --git a/proflex/prog/first/src/c++/pick_hbonds.cpp b/proflex/prog/first/src/c++/pick_hbonds.cpp index 673a16e..38bde7c 100755 --- a/proflex/prog/first/src/c++/pick_hbonds.cpp +++ b/proflex/prog/first/src/c++/pick_hbonds.cpp @@ -1,94 +1,96 @@ /******************************************************************************* -* MSU ProFlex, formerly called FIRST, is a software developed to predict and * -* analyze protein flexibility. * -* This source file is a part of MSU ProFlex. * -* * -* Copyright (C) 1997 - 2008, Michigan State University. * -* * -* This program is free software; you can redistribute to academic users only, * -* it and/or modify it under the terms of the GNU General Public License, * -* version 2, as published by the Free Software Foundation. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, * -* or see http://www.gnu.org/licenses/gpl.txt * -*******************************************************************************/ + * MSU ProFlex, formerly called FIRST, is a software developed to predict and * + * analyze protein flexibility. * This source file is a part of MSU ProFlex. * + * * + * Copyright (C) 1997 - 2008, Michigan State University. * + * * + * This program is free software; you can redistribute to academic users only, + ** it and/or modify it under the terms of the GNU General Public License, * + * version 2, as published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * but + *WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General + *Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * along + *with this program; if not, write to the Free Software * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, * + * or see http://www.gnu.org/licenses/gpl.txt * + *******************************************************************************/ /* THIS IS THE C++ CODE FOR pick_Hbonds() subroutine */ -/* 2006:01:26 --- Sandeep (SN) (WRITTEN AFRESH RETAINING RELEVANT PREVIOUS CODE) +/* 2006:01:26 --- Sandeep (SN) (WRITTEN AFRESH RETAINING RELEVANT PREVIOUS + CODE) usage >= 1 --> Keep all H-bonds and filter by H-bond cutoff energy Changes to be implemented: -------------------------- - - First, filter the H-bond list through tight geometric rules for - H-A, D-A distances, D-H-A and H-A-P angles. Further, user can - specify more stringent ruleset. + - First, filter the H-bond list through tight geometric rules for + H-A, D-A distances, D-H-A and H-A-P angles. Further, user can + specify more stringent ruleset. - Filtering options are made more hierarchical i.e., first start with all H-bonds, ask the user if Water molecules have to removed, then the side chain H-bonds, and finally, HETATM H-bonds (aside from water) - - Next, using the filtered H-bonds list, ask the user for an energy cutoff, - which is then used as an additional energy-based filter - STEPS: + - Next, using the filtered H-bonds list, ask the user for an energy + cutoff, which is then used as an additional energy-based filter STEPS: ------ 1) Disable all unused options by removing the correponding code 2) Make changes to some global variables decalred in "class.h" 3) Change the initial screening options - 4) Impose stronger stereochemical selection criteria to select - the initial "DEFAULT" list of H-bonds - 5) Provide options for further stronger geometric filter - 6) Provide filters based on the type of bond (HET, tether, etc.) - 7) Output proflexdataset - 8) Energy-based filtering with the user-input or default cutoff - 9) Output allbonds_SEfilt - 10) Output summary file that documents all the above changes incorporated - - 2006:03:15 --- added extra p_flag to facilitate stringent stereo - chemical filtering by user when '-p' flag is selected - - 2006:04:10 --- Changes to non-H2O HETatm filter - --- sidechain-non-water HETATM filter added - This matters when the user only selects to remove - nonwater-HETATM H-bonds as this set of bonds were - being left out unscreened. - Further, - : the atom name field format is as follows: - '[][][atom-tye][position][label]' ex: ' NH1',' CD ' - --- So, the filter should just check for the atom-type and not - the whole atom name - + 4) Impose stronger stereochemical selection criteria to select + the initial "DEFAULT" list of H-bonds + 5) Provide options for further stronger geometric filter + 6) Provide filters based on the type of bond (HET, tether, etc.) + 7) Output proflexdataset + 8) Energy-based filtering with the user-input or default cutoff + 9) Output allbonds_SEfilt + 10) Output summary file that documents all the above changes + incorporated + + 2006:03:15 --- added extra p_flag to facilitate stringent stereo + chemical filtering by user when '-p' flag is + selected + + 2006:04:10 --- Changes to non-H2O HETatm filter + --- sidechain-non-water HETATM filter added + This matters when the user only selects to remove + nonwater-HETATM H-bonds as this set of bonds were + being left out unscreened. + Further, + : the atom name field format is as follows: + '[][][atom-tye][position][label]' ex: ' NH1',' + CD ' + --- So, the filter should just check for the atom-type + and not the whole atom name + */ /* --- modifications on 04.17.01 by AJR --- I remedied the usagse of screening options 11,16,and 17. Also attempting to add an option: input file with desired h-bond list. AJR 03.25.02 - usage == 1 --> -non -h runoptions + usage == 1 --> -non -h runoptions usage == 2 --> -non -p runoptions usage == 0 --> otherwise - -non => non-interactive H-bond dilution => default energy filter + -non => non-interactive H-bond dilution => default energy filter */ - /**********************************************************************/ #include -void list::pick_hbonds(int usage, int p_flag ) { -//---------------------------------------------------------Declare variables - float xda,xha,adha,ahap; //DONOR-H-ACPTR-PREAC distance and angles - float s_xda,sb_xda,s_xha,sb_xha; - float min_theta,hb_ecut,energy_max,hd2,ha2,ad2,costheta,ha2max,ad2max; - float hp2,ap2,cosdelta,min_delta,min_cosdelta,min_costheta; // pre-acptr related - int i,j,khb,khb_min,khb_max,khb2; - int flag=0; - int so,s,sf,nsc,sp; // sp -- preacptr - char my_answer,ans; +void list::pick_hbonds(int usage, int p_flag) { + //---------------------------------------------------------Declare variables + float xda, xha, adha, ahap; // DONOR-H-ACPTR-PREAC distance and angles + float s_xda, sb_xda, s_xha, sb_xha; + float min_theta, hb_ecut, energy_max, hd2, ha2, ad2, costheta, ha2max, ad2max; + float hp2, ap2, cosdelta, min_delta, min_cosdelta, + min_costheta; // pre-acptr related + int i, j, khb, khb_min, khb_max, khb2; + int flag = 0; + int so, s, sf, nsc, sp; // sp -- preacptr + char my_answer, ans; float energy_input; ofstream fptr; ifstream pacc_ifil; //--- 2006:03 SN @@ -96,371 +98,357 @@ void list::pick_hbonds(int usage, int p_flag ) { /************************************************************/ /* Allocate memory for hb_pick[] */ /************************************************************/ - if(p_flag == 1) //--- 2006:03 SN --- *COMPLICATION* When '-p' option is - // chosen, real_hb_no gives the actual HB+SB count and - // nhb is the cumulative of tether and real_hb_no - { - khb = real_hb_no; - no_tether = nhb - khb; - nhb = khb; - } - else //--- 2006:03 SN --- '-h' or options other than '-p' - khb = nhb; - - hb_pick = new int[nhb+1]; - -// --- SN 2006:02 --- Initialize hb_pick[] - for(i=0;i<=nhb;i++) - hb_pick[i]=1; - - //------------- DEFAULT OPTION:-Keep all hydrogen bonds => khb = nhb - // This variable is now decremented once per bond whose hb_pick[] is made 0 - // ------- SN 2006:03:01 - - -//-----------------------------------------Initialize assumed geometric criteria -//----------------------------------------- read from the ../../include/class.h - xda=admaxd; - xha=hamaxd; - adha=dha_ang; - //2006:01 --- added by SN - ahap=hap_ang; - - //Delta and Theta anglular constraints are assumed to be the same for SB and - //Sulfur-based H-bonds. So, I only implement the distance-based constraints - s_xda=s_admaxd; - sb_xda=sb_admaxd; - s_xha=s_hamaxd; - sb_xha=sb_hamaxd; + if (p_flag == 1) //--- 2006:03 SN --- *COMPLICATION* When '-p' option is + // chosen, real_hb_no gives the actual HB+SB count and + // nhb is the cumulative of tether and real_hb_no + { + khb = real_hb_no; + no_tether = nhb - khb; + nhb = khb; + } else //--- 2006:03 SN --- '-h' or options other than '-p' + khb = nhb; + + hb_pick = new int[nhb + 1]; + + // --- SN 2006:02 --- Initialize hb_pick[] + for (i = 0; i <= nhb; i++) + hb_pick[i] = 1; + + //------------- DEFAULT OPTION:-Keep all hydrogen bonds => khb = nhb + // This variable is now decremented once per bond whose hb_pick[] is made 0 + // ------- SN 2006:03:01 + + //-----------------------------------------Initialize assumed geometric + //criteria + //----------------------------------------- read from the + //../../include/class.h + xda = admaxd; + xha = hamaxd; + adha = dha_ang; + // 2006:01 --- added by SN + ahap = hap_ang; + + // Delta and Theta anglular constraints are assumed to be the same for SB and + // Sulfur-based H-bonds. So, I only implement the distance-based constraints + s_xda = s_admaxd; + sb_xda = sb_admaxd; + s_xha = s_hamaxd; + sb_xha = sb_hamaxd; // If user chooses interactive filtering then - if(usage == 0) - { + if (usage == 0) { //---------------------------------------------------------- //--- Ask user if stronger geometric constraints are to be imposed //--- If so, read the constraints and impose the constraints - do{ - system("clear"); - cout<<"\t\tH-BOND/SALT BRIDGE BOND LENGTH & ANGLE CRITERIA"<= 110 Degrees"; - cout<<"\n\tDelta (H-A-Pre-acceptor angle) >= 90 Degrees"; - cout<<"\n\nIndices of H-bonds filtered more stringently (see below) are written to"; - cout<<"\n'_h-bonds_SEfilt' file."; - cout<<"\n\nDo you wish to impose more stringent rules? (y/n): "; - cin>>my_answer; - - }while(my_answer != 'n' && my_answer != 'N' && my_answer != 'y' && - my_answer != 'Y'); + do { + system("clear"); + cout << "\t\tH-BOND/SALT BRIDGE BOND LENGTH & ANGLE CRITERIA" << endl + << endl; + cout << "Default H-bond & salt bridge list has been compiled and written " + "to" + << endl; + cout << "'_proflexdataset' file. It includes intra- and inter-molecular" + << endl; + cout << "H-bonds meeting the following default stereochemical criteria:" + << endl; + cout << "\n\n\tHydrogen-Acceptor (H-A) distance <= 2.5 Angstroms"; + cout << "\n\t with Sulfur atom <= 3.0 Angstroms"; + cout << "\n\t for Salt bridge <= 3.5 Angstroms" << endl; + cout << "\n\tDonor-Acceptor (D-A) distance <= 3.5 Angstroms"; + cout << "\n\t with Sulfur atom <= 4.0 Angstroms"; + cout << "\n\t for Salt bridge <= 4.5 Angstroms" << endl; + cout << "\n\tTheta (D-H-A angle) >= 110 Degrees"; + cout << "\n\tDelta (H-A-Pre-acceptor angle) >= 90 Degrees"; + cout << "\n\nIndices of H-bonds filtered more stringently (see below) " + "are written to"; + cout << "\n'_h-bonds_SEfilt' file."; + cout << "\n\nDo you wish to impose more stringent rules? (y/n): "; + cin >> my_answer; + + } while (my_answer != 'n' && my_answer != 'N' && my_answer != 'y' && + my_answer != 'Y'); } // End interactive mode - else - { + else { my_answer = 'n'; } - - if(my_answer == 'y' || my_answer == 'Y') - { - system("clear"); - - //------------------------------------------------------------Read xha - cout<<"\n\tEnter H-A Distance (<= 2.5 A): "; - cin>>xha; - - while(xha > hamaxd || xha < 0) - { - cout<>xha; - } - - //------------------------------------------------------------Read s_xha - cout<<"\n\tEnter H-A Distance for H-bonds with Sulfur (<= 3.0 A): "; - cin>>s_xha; - - while(s_xha > s_hamaxd || s_xha < 0) - { - cout<>s_xha; - } - //------------------------------------------------------------Read sb_xha - cout<<"\n\tEnter H-A Distance for salt bridges (<= 3.5 A): "; - cin>>sb_xha; + if (my_answer == 'y' || my_answer == 'Y') { + system("clear"); - while(sb_xha > sb_hamaxd || sb_xha < 0) - { - cout<>sb_xha; - } + //------------------------------------------------------------Read xha + cout << "\n\tEnter H-A Distance (<= 2.5 A): "; + cin >> xha; - //------------------------------------------------------------Read xda - cout<<"\n\tEnter D-A Distance (<= 3.5): "; - cin>>xda; - - while(xda > admaxd || xda < 0) - { - cout<>xda; - } - - //------------------------------------------------------------Read s_xda - cout<<"\n\tEnter D-A Distance for H-bonds with Sulfur (<= 4.0): "; - cin>>s_xda; - - while(s_xda > s_admaxd || s_xda < 0) - { - cout<>s_xda; - } + while (xha > hamaxd || xha < 0) { + cout << endl << "\t\tInvalid value; must be <= 2.5 A"; + cout << endl << "\t\tPlease enter another value: "; + cin >> xha; + } - //------------------------------------------------------------Read sb_xda - cout<<"\n\tEnter D-A Distance for salt bridges (<= 4.5): "; - cin>>sb_xda; + //------------------------------------------------------------Read s_xha + cout << "\n\tEnter H-A Distance for H-bonds with Sulfur (<= 3.0 A): "; + cin >> s_xha; - while(sb_xda > sb_admaxd || sb_xda < 0) - { - cout<>sb_xda; - } + while (s_xha > s_hamaxd || s_xha < 0) { + cout << endl << "\t\tInvalid value; must be <= 3.0 A"; + cout << endl << "\t\tPlease enter another value: "; + cin >> s_xha; + } + //------------------------------------------------------------Read sb_xha + cout << "\n\tEnter H-A Distance for salt bridges (<= 3.5 A): "; + cin >> sb_xha; - //------------------------------------------------------------Read theta - cout<<"\n\tEnter Theta Angle (>= 110): "; - cin>>adha; - adha = adha*raddeg; - /* - * 2006:01 -- Sandeep - * Ensure that input angle < 180 and > THETA_limit and theta input by user - */ - while( (adha > 3.14159) || (adha < dha_ang) ) - { - cout<= 110 "<>adha; - adha=adha*raddeg; - } - //------------------------------------------------------------Read delta - cout<<"\n\tEnter Delta Angle (>= 90): "; - cin>>ahap; - ahap = ahap*raddeg; - - while( (ahap > 3.14159) || (ahap < hap_ang) ) - { - cout<= 90"<>ahap; - ahap=ahap*raddeg; - } - - //------------------------------------------------------------Impose new filters - - // --- SN 2006:02 --- Initial Geometric filtering is performed in - // find_hbonds.cpp - // --- Perform new filtering only if more stringent - // --- geometric constraints have been set - - // --- SN 2006:03 --- IF p_flag is set THEN - // READ preacptr info from "preacptr_info" file - - if(p_flag == 1) - pacc_ifil.open("preacptr_info",ios::in); - - for(i=1;i<=nhb;i++) - { - if(hb_pick[i] == 1) - { - /* --- SN 2007:02 --- hbond[i][0] is loaded in - find_hbonds.cpp. So, we need not - read the preacptr_info file - - // --- SN 2006:03 --- IF p_flag is set THEN - // READ preacptr info from "preacptr_info" file - if(p_flag == 1 && !pacc_ifil.eof()) - { - pacc_ifil.getline(line,10); - strncpy(pacc_val,line,5); - hbond[i][0]=atoi(pacc_val); - } - */ - - /************************************************************/ - /* Perform stereochemical filtering to obtain the initial */ - /* list of H-bonds */ - /************************************************************/ - sp=hbond[i][0]; - so=hbond[i][1]; - s=hbond[i][2]; - sf=hbond[i][3]; + while (sb_xha > sb_hamaxd || sb_xha < 0) { + cout << endl << "\t\tInvalid value; Must be <= 3.5 A"; + cout << endl << "\t\tPlease enter another value: "; + cin >> sb_xha; + } + + //------------------------------------------------------------Read xda + cout << "\n\tEnter D-A Distance (<= 3.5): "; + cin >> xda; + + while (xda > admaxd || xda < 0) { + cout << endl << "\t\tInvalid value; <= 3.5 A"; + cout << endl << "\t\tPlease enter another value: "; + cin >> xda; + } + + //------------------------------------------------------------Read s_xda + cout << "\n\tEnter D-A Distance for H-bonds with Sulfur (<= 4.0): "; + cin >> s_xda; + + while (s_xda > s_admaxd || s_xda < 0) { + cout << endl << "\t\tInvalid value; must be <= 4.0 A"; + cout << endl << "\t\tPlease enter another value: "; + cin >> s_xda; + } + + //------------------------------------------------------------Read sb_xda + cout << "\n\tEnter D-A Distance for salt bridges (<= 4.5): "; + cin >> sb_xda; + + while (sb_xda > sb_admaxd || sb_xda < 0) { + cout << endl << "\t\tInvalid value; must be <= 4.5 A"; + cout << endl << "\t\tPlease enter another value: "; + cin >> sb_xda; + } + + //------------------------------------------------------------Read theta + cout << "\n\tEnter Theta Angle (>= 110): "; + cin >> adha; + adha = adha * raddeg; + /* + * 2006:01 -- Sandeep + * Ensure that input angle < 180 and > THETA_limit and theta input by user + */ + while ((adha > 3.14159) || (adha < dha_ang)) { + cout << endl << "\tInvalid value; must be >= 110 " << endl; + cout << endl << "\t\tPlease enter another value: "; + cin >> adha; + adha = adha * raddeg; + } + //------------------------------------------------------------Read delta + cout << "\n\tEnter Delta Angle (>= 90): "; + cin >> ahap; + ahap = ahap * raddeg; + + while ((ahap > 3.14159) || (ahap < hap_ang)) { + cout << endl << "\tInvalid value; must be >= 90" << endl; + cout << endl << "\t\tPlease enter another value: "; + cin >> ahap; + ahap = ahap * raddeg; + } + + //------------------------------------------------------------Impose new + //filters + + // --- SN 2006:02 --- Initial Geometric filtering is performed in + // find_hbonds.cpp + // --- Perform new filtering only if more stringent + // --- geometric constraints have been set + + // --- SN 2006:03 --- IF p_flag is set THEN + // READ preacptr info from "preacptr_info" file + + if (p_flag == 1) + pacc_ifil.open("preacptr_info", ios::in); + + for (i = 1; i <= nhb; i++) { + if (hb_pick[i] == 1) { + /* --- SN 2007:02 --- hbond[i][0] is loaded in + find_hbonds.cpp. So, we need not + read the preacptr_info file + + // --- SN 2006:03 --- IF p_flag is set THEN + // READ preacptr info from "preacptr_info" file + if(p_flag == 1 && !pacc_ifil.eof()) + { + pacc_ifil.getline(line,10); + strncpy(pacc_val,line,5); + hbond[i][0]=atoi(pacc_val); + } + */ + + /************************************************************/ + /* Perform stereochemical filtering to obtain the initial */ + /* list of H-bonds */ + /************************************************************/ + sp = hbond[i][0]; + so = hbond[i][1]; + s = hbond[i][2]; + sf = hbond[i][3]; #ifdef CHKPT - cout<<"\n"<>my_answer; - } - + if (usage == 0) // interactive mode + { + cout << "\n\tNumber of H-bonds remaining: " << khb; + cout << "\n\tNumber of hydrophobic tethers remaining: " << no_tether + << endl; + cout << "\n\n\nPlease enter 'c' and press enter to continue:"; + cin >> my_answer; + } /************************************************************/ /* Define and accept screen options for identifying Hbonds */ /************************************************************/ - while( flag == 0 ) { - if(usage == 0) { + while (flag == 0) { + if (usage == 0) { pick_hbonds_options(); - - cout << endl << endl << endl << "\t\tSELECTED SCREENING OPTIONS" << endl << endl; - - //--- 2006:03 SN - If default (option '5' or choice[1]) is selected then make - //--- other choices zero and proceed as if 'f' were selected - if(choice[1] == 1) - { - cout<<"\t"<= 1) { - for( i = 2; i <= maxnopt; i++ ) { - choice[i]=0; + } else if (usage >= 1) { + for (i = 2; i <= maxnopt; i++) { + choice[i] = 0; } choice[1] = 1; - flag =1; + flag = 1; } } - - for(i = 1; i <= nhb; i++) - { - if(hb_pick[i] == 1) - { + for (i = 1; i <= nhb; i++) { + if (hb_pick[i] == 1) { so = hbond[i][1]; sf = hbond[i][3]; @@ -469,283 +457,250 @@ void list::pick_hbonds(int usage, int p_flag ) { /************************************************************/ /* -------- SN 2006:03 ------------ - Removing *ALL* water-bound H-bonds is default. So, the below filter - has to be implemented unless the user chooses not to by selecting choice[2] + Removing *ALL* water-bound H-bonds is default. So, the below filter + has to be implemented unless the user chooses not to by selecting + choice[2] */ - if(choice[2] == 0) - //----------------------------------------- Remove *ALL* H-bonds involving Water - //----------------------------------------- Old choices: 5,8, and 10 - { - //--------------------------------------- 5) mainchain-WATERatom H-bonds - //--------------------------------------- 8) sidechain-WATERatom H-bonds - //--------------------------------------- 10) WATERatom-WATERatom H-bonds - - if(( p[so]->r1.field1[0]!='H' && strcmp(p[sf]->r1.rname,"HOH")==0 && - (strcmp(p[so]->r1.aname," N ")==0 - || strcmp(p[so]->r1.aname," O ")==0) - ) - ||(p[sf]->r1.field1[0]!='H' && strcmp(p[so]->r1.rname,"HOH")==0 && - (strcmp(p[sf]->r1.aname," N ")==0 - || strcmp(p[sf]->r1.aname," O ")==0) - ) - ) - { - khb--; - hb_pick[i] = 0; - } - else - if(((strcmp(p[sf]->r1.rname,"HOH")==0 && p[so]->r1.field1[0]!='H') && - (strcmp(p[so]->r1.aname," N ")!=0 && strcmp(p[so]->r1.aname," O ")!=0)) - ||((strcmp(p[so]->r1.rname,"HOH")==0 && p[sf]->r1.field1[0]!='H')&& - (strcmp(p[sf]->r1.aname," N ")!=0 && strcmp(p[sf]->r1.aname," O ")!=0)) - ) - { - khb--; - hb_pick[i]=0; - } - else - if(strcmp(p[sf]->r1.rname,"HOH")==0 && strcmp(p[so]->r1.rname,"HOH")==0) - { - hb_pick[i]=0; - khb--; - } - } - + if (choice[2] == 0) + //----------------------------------------- Remove *ALL* H-bonds involving + //Water + //----------------------------------------- Old choices: 5,8, and 10 + { + //--------------------------------------- 5) mainchain-WATERatom + //H-bonds + //--------------------------------------- 8) sidechain-WATERatom + //H-bonds + //--------------------------------------- 10) WATERatom-WATERatom + //H-bonds + + if ((p[so]->r1.field1[0] != 'H' && + strcmp(p[sf]->r1.rname, "HOH") == 0 && + (strcmp(p[so]->r1.aname, " N ") == 0 || + strcmp(p[so]->r1.aname, " O ") == 0)) || + (p[sf]->r1.field1[0] != 'H' && + strcmp(p[so]->r1.rname, "HOH") == 0 && + (strcmp(p[sf]->r1.aname, " N ") == 0 || + strcmp(p[sf]->r1.aname, " O ") == 0))) { + khb--; + hb_pick[i] = 0; + } else if (((strcmp(p[sf]->r1.rname, "HOH") == 0 && + p[so]->r1.field1[0] != 'H') && + (strcmp(p[so]->r1.aname, " N ") != 0 && + strcmp(p[so]->r1.aname, " O ") != 0)) || + ((strcmp(p[so]->r1.rname, "HOH") == 0 && + p[sf]->r1.field1[0] != 'H') && + (strcmp(p[sf]->r1.aname, " N ") != 0 && + strcmp(p[sf]->r1.aname, " O ") != 0))) { + khb--; + hb_pick[i] = 0; + } else if (strcmp(p[sf]->r1.rname, "HOH") == 0 && + strcmp(p[so]->r1.rname, "HOH") == 0) { + hb_pick[i] = 0; + khb--; + } + } + //------------ Remove *ALL* H-bonds involving side-chains //------------ Old choices: 3,6, and 7 - if(choice[3] == 1) - { - //------------------------------------ 3) mainchain-sidechain H-bonds - //------------------------------------ 6) sidechain-sidechain H-bonds - //------------------------------------ 7) sidechain-HET_NWatoms H-bonds - - if((p[so]->r1.field1[0]!='H' && p[sf]->r1.field1[0]!='H') - && (((strcmp(p[so]->r1.aname," N ") == 0 - || strcmp(p[so]->r1.aname," O ")==0) - && (strcmp(p[sf]->r1.aname," N ") !=0 - && strcmp(p[sf]->r1.aname," O ")!=0) - ) - || ((strcmp(p[sf]->r1.aname," N ")==0 - || strcmp(p[sf]->r1.aname," O ")==0) - && (strcmp(p[so]->r1.aname," N ")!=0 - && strcmp(p[so]->r1.aname," O ")!=0) - ) - ) - ) - { - khb--; - hb_pick[i] = 0; - } - else - if((p[so]->r1.field1[0]!='H' && p[sf]->r1.field1[0]!='H') - && ((strcmp(p[so]->r1.aname," N ")!=0 - && strcmp(p[so]->r1.aname," O ")!=0) - && (strcmp(p[sf]->r1.aname," N ")!=0 - && strcmp(p[sf]->r1.aname," O ")!=0)) - ) - { - khb--; - hb_pick[i] = 0; - } - else - if(((p[so]->r1.field1[0]!='H' && p[sf]->r1.field1[0]=='H') && - (strcmp(p[so]->r1.aname," N ")!=0 && strcmp(p[so]->r1.aname," O ")!=0)) - ||((p[sf]->r1.field1[0]!='H' && p[so]->r1.field1[0]=='H') && - (strcmp(p[sf]->r1.aname," N ")!=0 && strcmp(p[sf]->r1.aname," O ")!=0)) - ) - { - if( !(strcmp(p[sf]->r1.rname,"HOH")==0 || - strcmp(p[so]->r1.rname,"HOH")==0) ) - { - hb_pick[i]=0; - khb--; - } - } - - } // --- End choice[3] --- + if (choice[3] == 1) { + //------------------------------------ 3) mainchain-sidechain H-bonds + //------------------------------------ 6) sidechain-sidechain H-bonds + //------------------------------------ 7) sidechain-HET_NWatoms H-bonds + + if ((p[so]->r1.field1[0] != 'H' && p[sf]->r1.field1[0] != 'H') && + (((strcmp(p[so]->r1.aname, " N ") == 0 || + strcmp(p[so]->r1.aname, " O ") == 0) && + (strcmp(p[sf]->r1.aname, " N ") != 0 && + strcmp(p[sf]->r1.aname, " O ") != 0)) || + ((strcmp(p[sf]->r1.aname, " N ") == 0 || + strcmp(p[sf]->r1.aname, " O ") == 0) && + (strcmp(p[so]->r1.aname, " N ") != 0 && + strcmp(p[so]->r1.aname, " O ") != 0)))) { + khb--; + hb_pick[i] = 0; + } else if ((p[so]->r1.field1[0] != 'H' && p[sf]->r1.field1[0] != 'H') && + ((strcmp(p[so]->r1.aname, " N ") != 0 && + strcmp(p[so]->r1.aname, " O ") != 0) && + (strcmp(p[sf]->r1.aname, " N ") != 0 && + strcmp(p[sf]->r1.aname, " O ") != 0))) { + khb--; + hb_pick[i] = 0; + } else if (((p[so]->r1.field1[0] != 'H' && + p[sf]->r1.field1[0] == 'H') && + (strcmp(p[so]->r1.aname, " N ") != 0 && + strcmp(p[so]->r1.aname, " O ") != 0)) || + ((p[sf]->r1.field1[0] != 'H' && + p[so]->r1.field1[0] == 'H') && + (strcmp(p[sf]->r1.aname, " N ") != 0 && + strcmp(p[sf]->r1.aname, " O ") != 0))) { + if (!(strcmp(p[sf]->r1.rname, "HOH") == 0 || + strcmp(p[so]->r1.rname, "HOH") == 0)) { + hb_pick[i] = 0; + khb--; + } + } + + } // --- End choice[3] --- //---------------- Remove *ALL* H-bonds with non-Water HETATOMs //---------------- Old choices: 4 and 9 - if(choice[4] == 1) - { - //---------------------------------- 4) mainchain-HET_NWatom H-bonds - //---------------------------------- 10) sidechain-HET_NWatom H-bonds - //---------------------------------- 9) HET_atom-HET_NWatom H-bonds - - //--- 2006:04 Sandeep - The atom-type is what has to be compared - //--- Note that PDB file has atom-type+positional - //--- label as the atom name ex: NH1 and not just N - //--- - Hence, changed the conditions below - - if( ((p[so]->r1.field1[0]!='H' && p[sf]->r1.field1[0]=='H') && - (strcmp(p[so]->r1.aname," N ")==0||strcmp(p[so]->r1.aname," O ")==0))|| - ((p[sf]->r1.field1[0]!='H' && p[so]->r1.field1[0]=='H') && - (strcmp(p[sf]->r1.aname," N ")==0||strcmp(p[sf]->r1.aname," O ")==0)) - ) - { - if( !(strcmp(p[sf]->r1.rname,"HOH")==0 || - strcmp(p[so]->r1.rname,"HOH")==0) ) - { - hb_pick[i]=0; - khb--; - } - } - else if(choice[3] == 0){ - if(((p[so]->r1.field1[0]!='H' && p[sf]->r1.field1[0]=='H') && - (strcmp(p[so]->r1.aname," N ")!=0 && strcmp(p[so]->r1.aname," O ")!=0)) - ||((p[sf]->r1.field1[0]!='H' && p[so]->r1.field1[0]=='H') && - (strcmp(p[sf]->r1.aname," N ")!=0 && strcmp(p[sf]->r1.aname," O ")!=0)) - ) - { - if( !(strcmp(p[sf]->r1.rname,"HOH")==0 || - strcmp(p[so]->r1.rname,"HOH")==0) ) - { - hb_pick[i]=0; - khb--; - } - } - } //End of if(choice[3] == 0) - else - if(p[so]->r1.field1[0]=='H' && p[sf]->r1.field1[0]=='H') - { - if( !(strcmp(p[sf]->r1.rname,"HOH")==0 && - strcmp(p[so]->r1.rname,"HOH")==0) ) - { - hb_pick[i]=0; - khb--; - } - } - } // --- End of choice[4] - } // End of if(hb_pick[i] == 1) - } // End of for(i = ... ) - - - //----------- END OF H-BOND FILTERING ------------- - // Display the number of H-bonds remaining -// if(usage >= 1) -// cout<<"\nNumber of H-bonds remaining after removal of H-bonds with waters (Default option): "<0) - { - khb_max=i; - break; + if (choice[4] == 1) { + //---------------------------------- 4) mainchain-HET_NWatom H-bonds + //---------------------------------- 10) sidechain-HET_NWatom H-bonds + //---------------------------------- 9) HET_atom-HET_NWatom H-bonds + + //--- 2006:04 Sandeep - The atom-type is what has to be + //compared + //--- Note that PDB file has + //atom-type+positional + //--- label as the atom name ex: NH1 and not + //just N + //--- - Hence, changed the conditions below + + if (((p[so]->r1.field1[0] != 'H' && p[sf]->r1.field1[0] == 'H') && + (strcmp(p[so]->r1.aname, " N ") == 0 || + strcmp(p[so]->r1.aname, " O ") == 0)) || + ((p[sf]->r1.field1[0] != 'H' && p[so]->r1.field1[0] == 'H') && + (strcmp(p[sf]->r1.aname, " N ") == 0 || + strcmp(p[sf]->r1.aname, " O ") == 0))) { + if (!(strcmp(p[sf]->r1.rname, "HOH") == 0 || + strcmp(p[so]->r1.rname, "HOH") == 0)) { + hb_pick[i] = 0; + khb--; + } + } else if (choice[3] == 0) { + if (((p[so]->r1.field1[0] != 'H' && p[sf]->r1.field1[0] == 'H') && + (strcmp(p[so]->r1.aname, " N ") != 0 && + strcmp(p[so]->r1.aname, " O ") != 0)) || + ((p[sf]->r1.field1[0] != 'H' && p[so]->r1.field1[0] == 'H') && + (strcmp(p[sf]->r1.aname, " N ") != 0 && + strcmp(p[sf]->r1.aname, " O ") != 0))) { + if (!(strcmp(p[sf]->r1.rname, "HOH") == 0 || + strcmp(p[so]->r1.rname, "HOH") == 0)) { + hb_pick[i] = 0; + khb--; } - } - khb_min=1; - for(i=nhb;i>=1;i--) - { - if(hb_pick[i]>0) - { - khb_min=i; - break; - } - } - energy_max=hb_energy[khb_max]; - - if(usage >= 1) { - hb_ecut=100; - energy_max = max_energy; } - else{ - - system("clear"); - - // Display the number of H-bonds remaining - cout<<"\nNumber of H-bonds remaining: "<> energy_input; - energy_max = energy_input; + } // End of if(choice[3] == 0) + else if (p[so]->r1.field1[0] == 'H' && p[sf]->r1.field1[0] == 'H') { + if (!(strcmp(p[sf]->r1.rname, "HOH") == 0 && + strcmp(p[so]->r1.rname, "HOH") == 0)) { + hb_pick[i] = 0; + khb--; } + } + } // --- End of choice[4] + } // End of if(hb_pick[i] == 1) + } // End of for(i = ... ) + + //----------- END OF H-BOND FILTERING ------------- + // Display the number of H-bonds remaining + // if(usage >= 1) + // cout<<"\nNumber of H-bonds remaining after removal of H-bonds + // with waters (Default option): "< 0) { + khb_max = i; + break; + } + } + khb_min = 1; + for (i = nhb; i >= 1; i--) { + if (hb_pick[i] > 0) { + khb_min = i; + break; + } + } + energy_max = hb_energy[khb_max]; + if (usage >= 1) { + hb_ecut = 100; + energy_max = max_energy; + } else { - if(energy_max > hb_energy[khb_max]) - energy_max=hb_energy[khb_max]; - -// khb2 = int( (khb*hb_ecut)/100); -// khb=0; - - for(i=nhb;i>=1;i--) - { - if(hb_pick[i] == 1) - { - if(hb_energy[i] > energy_max) - { - hb_pick[i]=0; - khb--; - } - } - } - -// ------------------------------- END OF ENERGY-BASED FILTERING -------------------- - - if(usage >= 1) - cout<<"\nNumber of H-bonds remaining after filtering with default energy cutoff of "<> energy_input; + energy_max = energy_input; + } + if (energy_max > hb_energy[khb_max]) + energy_max = hb_energy[khb_max]; + // khb2 = int( (khb*hb_ecut)/100); + // khb=0; -//Output allbonds_SEfilt --- Generated by main.cpp -//Actually, output by FORTRAN code + for (i = nhb; i >= 1; i--) { + if (hb_pick[i] == 1) { + if (hb_energy[i] > energy_max) { + hb_pick[i] = 0; + khb--; + } + } + } + // ------------------------------- END OF ENERGY-BASED FILTERING + // -------------------- + if (usage >= 1) + cout << "\nNumber of H-bonds remaining after filtering with default energy " + "cutoff of " + << energy_max << " Kcal/Mol: " << khb << endl; + // Output allbonds_SEfilt --- Generated by main.cpp + // Actually, output by FORTRAN code -//------------------ Output "hbonds_SEfilt" file -------------------- - khb2=0; - for(i=1;i<=nhb;i++) - { - if(hb_pick[i]>0) - { - khb2++; - hb_pick[khb2]=i; - } - } - if(khb2!=khb) - { - cout<<"Error: Inconsistency in number of selected hydrogen bonds\n"; - cout<<"khb2="< 0) { + khb2++; + hb_pick[khb2] = i; + } + } + if (khb2 != khb) { + cout << "Error: Inconsistency in number of selected hydrogen bonds\n"; + cout << "khb2=" << khb2 << " khb=" << khb << endl; + exit(33); + } //********************************************************************** // The following chunk of code generates a single column list of integers @@ -760,100 +715,93 @@ void list::pick_hbonds(int usage, int p_flag ) { // usage == 0 --> otherwise //********************************************************************** - hblist.open(outfile[0],ios::out); + hblist.open(outfile[0], ios::out); - for( i = 1; i <= khb; i++){ - j = hb_pick[i]; - hblist << hb_id[j] << endl; - } + for (i = 1; i <= khb; i++) { + j = hb_pick[i]; + hblist << hb_id[j] << endl; + } - if(choice[5] != 1) //--- INCLUDE TETHERS - { - for( i = 1; i <= no_tether; i++) { - hblist << nhb+i << endl; - } - } + if (choice[5] != 1) //--- INCLUDE TETHERS + { + for (i = 1; i <= no_tether; i++) { + hblist << nhb + i << endl; + } + } hblist.close(); hblist.clear(); + //--- Output the criteria file with summary of all the options chosen --- + + // aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + // place_hbonds(khb); + //-----------------------------------------------------Record selection + //criteria + fptr.open("qXyZaB.criteria", ios::out); + nsc = 0; + setiosflags(ios::showpoint | ios::fixed); + setprecision(2); + setw(6); + // fptr<<"---------------------------------------------------------------- + //"<= " << adha / raddeg + << " Deg." << endl; + fptr << " Hydrogen-Acceptor-Preacceptor angle >= " << ahap / raddeg + << " Deg." << endl + << endl; + + fptr << " Hydrogen bond energetic selection criteria:" << endl; + fptr << " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl; + fptr << " Maximum allowed hydrogen bonding energy = " + << setprecision(4) << energy_max << " Kcal/Mol" << endl; + fptr << endl; + + fptr << " Non-covalent bond selection criteria:" << endl; + fptr << " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl; + nsc += 17; + + if (!usage) { + if (choice[2] == 0) { + fptr << " Default: Remove *ALL* H-bonds involving waters" << endl; + nsc++; + } else { + fptr << " " << screen_msgs[2] << endl; + nsc += 3; + } + for (i = 3; i <= maxnopt; i++) { + if (choice[i] == 1) { + fptr << " " << screen_msgs[i] << endl; + nsc++; + } + } + } else { + fptr << " Keep all hydrogen bonds and hydrophobic tethers except" + << endl; + fptr << " those including waters ----> Default assumption" << endl; + fptr << " Filter on Donor-Hydrogen-Acceptor angle" << endl; + nsc += 3; + } -//--- Output the criteria file with summary of all the options chosen --- - -//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -// place_hbonds(khb); -//-----------------------------------------------------Record selection criteria - fptr.open("qXyZaB.criteria",ios::out); - nsc=0; - setiosflags(ios::showpoint|ios::fixed); - setprecision(2); - setw(6); -// fptr<<"---------------------------------------------------------------- "<= "<= "< Default assumption"<> ans; - - //--- 2006:03 SN Ensure that user selects at least one option - if(choice_count == 0 && (ans == 'f' || ans == 'F')) - { - cout<<"\nPlease select at least one valid (1-5) option before finish!\n\n"; - } - else - break; - }while(1); - - //--- 2006:03 SN - If user selects '5' (defaults) prog should behave like 'f' - //--- - If other options are selected along with '5', make others + do { + cout << "\tEnter Option: "; + cin >> ans; + + //--- 2006:03 SN Ensure that user selects at least one option + if (choice_count == 0 && (ans == 'f' || ans == 'F')) { + cout << "\nPlease select at least one valid (1-5) option before " + "finish!\n\n"; + } else + break; + } while (1); + + //--- 2006:03 SN - If user selects '5' (defaults) prog should behave like + //'f' + //--- - If other options are selected along with '5', make + //others //--- zero and initiate 'f' - if(ans == '5'){ + if (ans == '5') { flag = 1; choice[1] = 1; choice_count++; - } - else if( ans == 'f' || ans == 'F'){ + } else if (ans == 'f' || ans == 'F') { flag = 1; - } - else if( ans == 's' || ans == 'S' ) { + } else if (ans == 's' || ans == 'S') { exit(-1); - } - else { + } else { ch = ans - 48; // 48 is the ASCII code for '0' /************************************************************/ /* Check for invalid options. */ /************************************************************/ - if( ch < 1 || ch > maxnopt) { - cout< maxnopt) { + cout << endl << "\tInvalid option!" << endl; + } else if (choice[ch] == 1 || + choice[ch] == -1) // OR !=0 ???? aaaaaaaaaaaaaaa + cout << endl << "\tYou already chose this option!" << endl; + else { + //------------------------------------------------Record option + choice[ch + 1] = 1; + choice_count++; } - else - if(choice[ch]==1 || choice[ch]==-1) // OR !=0 ???? aaaaaaaaaaaaaaa - cout<r1.field1,line,6); // PDB field identifier (ie. ATOM, HETATM, REMARK) - strncpy(fresh->r1.sr_no,line+6,5); // Atom number - strncpy(fresh->r1.aname,line+11,5); // Atom name - strncpy(fresh->r1.altloc,line+16,1); // - strncpy(fresh->r1.rname,line+17,3); // Amino-acid name - strncpy(fresh->r1.chain,line+20,2); // Chain ID - strncpy(fresh->r1.res_no,line+22,4); // Residue number - strncpy(fresh->r1.code,line+26,4); - strncpy(fresh->r1.strx,line+30,8); // X-coordinate - strncpy(fresh->r1.stry,line+38,8); // Y-coordinate - strncpy(fresh->r1.strz,line+46,8); // Z-coordinate - strncpy(fresh->r1.occupancy,line+54,6);// Temperature factor (B_value) - strncpy(fresh->r1.temp_string,line+60,6); // - strncpy(string, line+66, 5 ); // some kind of internal FIRST identifier. - fresh->r1.mod_res_no = atoi(string); // + strncpy(fresh->r1.field1, line, + 6); // PDB field identifier (ie. ATOM, HETATM, REMARK) + strncpy(fresh->r1.sr_no, line + 6, 5); // Atom number + strncpy(fresh->r1.aname, line + 11, 5); // Atom name + strncpy(fresh->r1.altloc, line + 16, 1); // + strncpy(fresh->r1.rname, line + 17, 3); // Amino-acid name + strncpy(fresh->r1.chain, line + 20, 2); // Chain ID + strncpy(fresh->r1.res_no, line + 22, 4); // Residue number + strncpy(fresh->r1.code, line + 26, 4); + strncpy(fresh->r1.strx, line + 30, 8); // X-coordinate + strncpy(fresh->r1.stry, line + 38, 8); // Y-coordinate + strncpy(fresh->r1.strz, line + 46, 8); // Z-coordinate + strncpy(fresh->r1.occupancy, line + 54, + 6); // Temperature factor (B_value) + strncpy(fresh->r1.temp_string, line + 60, 6); // + strncpy(string, line + 66, 5); // some kind of internal FIRST identifier. + fresh->r1.mod_res_no = atoi(string); // fresh->r1.DAH_type = line[72]; - fresh->r1.coord[1] = atof(fresh->r1.strx); - fresh->r1.coord[2] = atof(fresh->r1.stry); - fresh->r1.coord[3] = atof(fresh->r1.strz); - fresh->r1.occ = atof(fresh->r1.occupancy); + fresh->r1.coord[1] = atof(fresh->r1.strx); + fresh->r1.coord[2] = atof(fresh->r1.stry); + fresh->r1.coord[3] = atof(fresh->r1.strz); + fresh->r1.occ = atof(fresh->r1.occupancy); fresh->r1.temperature = atof(fresh->r1.temp_string); - fresh->r1.ri_sr_no = atoi(fresh->r1.sr_no); - - if( !strncmp(line,"ATOM",4) || !strncmp(line,"HETATM",6) ) { - no_atoms += 1; - p[no_atoms] = fresh; - } - else - fresh->r1.ri_sr_no = 0; - - if( start == NULL ) { - start = fresh; - last = fresh; - } - else { - fresh->next = start; - start->prior = fresh; - start = fresh; + fresh->r1.ri_sr_no = atoi(fresh->r1.sr_no); + + if (!strncmp(line, "ATOM", 4) || !strncmp(line, "HETATM", 6)) { + no_atoms += 1; + p[no_atoms] = fresh; + } else + fresh->r1.ri_sr_no = 0; + + if (!start) { + start = fresh; + last = fresh; + } else { + fresh->next = start; + start->prior = fresh; + start = fresh; } } // Read central-force bonds(CF) from proflexdataset file - else if( !strncmp(line,"REMARK:CF",9) ) { - if( flag1 == 0 ) { - - mult = new int[no_atoms+1]; - nrot_bond = (int**) new int*[no_atoms+1]; - temp_link = (int**) new int*[no_atoms+1]; - - for( i = 0; i <= no_atoms; i++ ) { - nrot_bond[i] = (int*) new int[3]; - temp_link[i] = (int*) new int[maxr]; - mult[i]=0; - } - flag1 = 1; + else if (!strncmp(line, "REMARK:CF", 9)) { + if (flag1 == 0) { + + mult = new int[no_atoms + 1]; + nrot_bond = (int **)new int *[no_atoms + 1]; + temp_link = (int **)new int *[no_atoms + 1]; + + for (i = 0; i <= no_atoms; i++) { + nrot_bond[i] = (int *)new int[3]; + temp_link[i] = (int *)new int[maxr]; + mult[i] = 0; + } + flag1 = 1; } - strncpy( string, line+10, 5 ); + strncpy(string, line + 10, 5); so = atoi(string); - strncpy(string,line+16,5); + strncpy(string, line + 16, 5); sf = atoi(string); - if( so == sf ) { - cout<r1.aname,p[sf]->r1.rname,p[sf]->r1.res_no, - p[sf]->r1.code,p[sf]->r1.chain,p[sf]->r1.aname,p[sf]->r1.aname, - p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname); - } - else { - mult[so]++; - temp_link[so][mult[so]] = sf; - mult[sf]++; - temp_link[sf][mult[sf]] = so; + if (so == sf) { + cout << endl << "\tCovalent bond self connection ignored!" << endl; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, sf, 0, p[sf]->r1.aname, p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + p[sf]->r1.aname, p[sf]->r1.aname, p[sf]->r1.aname, + p[sf]->r1.aname, p[sf]->r1.aname); + } else { + mult[so]++; + temp_link[so][mult[so]] = sf; + mult[sf]++; + temp_link[sf][mult[sf]] = so; } } // Read Torsional Force constraints (TF) from proflexdataset file - else if( !strncmp(line,"REMARK:TF",9) ) { - strncpy(string,line+10,5); + else if (!strncmp(line, "REMARK:TF", 9)) { + strncpy(string, line + 10, 5); so = atoi(string); - strncpy(string,line+16,5); + strncpy(string, line + 16, 5); sf = atoi(string); nrot_bond_count++; - nrot_bond[nrot_bond_count][1]=so; - nrot_bond[nrot_bond_count][2]=sf; + nrot_bond[nrot_bond_count][1] = so; + nrot_bond[nrot_bond_count][2] = sf; } // Read Hydrogen Bond constraints from proflexdataset file - else if( !strncmp( line, "REMARK:HB", 9 ) ) { + else if (!strncmp(line, "REMARK:HB", 9)) { nhb++; // by incrementing here, all subsequent arrays are indexed from 1 ! - /* of these HB records, count only the hydrogen bonds and salt bridges i.e. every HB record - * except the hydrophobic tethers - Sameer 12.Mar.04 + /* of these HB records, count only the hydrogen bonds and salt bridges + * i.e. every HB record except the hydrophobic tethers - Sameer 12.Mar.04 */ - if( strncmp( line+55, "PH hydr", 7 ) ) - real_hb_no++; - - - - if( flag2 == 0 ) { - temp_hb_energy = new float[no_atoms+1]; - temp_hb_type = new int[no_atoms+1]; - temp_hb_id = new int[no_atoms+1]; - temp_hbond = (int**) new int*[no_atoms+1]; - for( i = 0; i <= no_atoms; i++ ) - temp_hbond[i] = (int*) new int[4]; - - flag2 = 1; + if (strncmp(line + 55, "PH hydr", 7)) + real_hb_no++; + + if (flag2 == 0) { + temp_hb_energy = new float[no_atoms + 1]; + temp_hb_type = new int[no_atoms + 1]; + temp_hb_id = new int[no_atoms + 1]; + temp_hbond = (int **)new int *[no_atoms + 1]; + for (i = 0; i <= no_atoms; i++) + temp_hbond[i] = (int *)new int[4]; + + flag2 = 1; } // id's are listed 1 - number of H-bonds in *proflexdataset @@ -281,51 +273,52 @@ void list::read_proflexdataset(void) { // the explicit atoi's and atof's are OK for now, the dataset file // has distinct whitespace delimiters between data. BMH 3.27.00 - id_hb = atoi( line+9 ); - - temp_hb_energy[nhb] = atof( line+14 ); - - temp_hbond[nhb][1] = atoi( line+30 ); - - temp_hbond[nhb][2] = atoi( line+38 ); - - temp_hbond[nhb][3] = atoi( line+46 ); - - if( !strncmp(line+55,"HB Dsp2 Asp2",12) ) - temp_hb_type[nhb] = 0; - else if( !strncmp(line+55,"HB Dsp2 Asp3",12) ) - temp_hb_type[nhb] = 1; - else if( !strncmp(line+55,"HB Dsp3 Asp2",12) ) - temp_hb_type[nhb] = 2; - else if( !strncmp(line+55,"HB Dsp3 Asp3",12) ) - temp_hb_type[nhb] = 3; - else if( !strncmp(line+55,"SB no energy",12) ) - temp_hb_type[nhb] = 4; - else if( !strncmp(line+55,"PH hydr phob",12) ) { - temp_hb_type[nhb] = 5; - //BMH removed next line. Count tethers in pick_hbonds line 959. - // no_tether++; - } - else { - temp_hb_type[nhb] = 6; // unknown HB type! - unknown++; + id_hb = atoi(line + 9); + + temp_hb_energy[nhb] = atof(line + 14); + + temp_hbond[nhb][1] = atoi(line + 30); + + temp_hbond[nhb][2] = atoi(line + 38); + + temp_hbond[nhb][3] = atoi(line + 46); + + if (!strncmp(line + 55, "HB Dsp2 Asp2", 12)) + temp_hb_type[nhb] = 0; + else if (!strncmp(line + 55, "HB Dsp2 Asp3", 12)) + temp_hb_type[nhb] = 1; + else if (!strncmp(line + 55, "HB Dsp3 Asp2", 12)) + temp_hb_type[nhb] = 2; + else if (!strncmp(line + 55, "HB Dsp3 Asp3", 12)) + temp_hb_type[nhb] = 3; + else if (!strncmp(line + 55, "SB no energy", 12)) + temp_hb_type[nhb] = 4; + else if (!strncmp(line + 55, "PH hydr phob", 12)) { + temp_hb_type[nhb] = 5; + // BMH removed next line. Count tethers in pick_hbonds line 959. + // no_tether++; + } else { + temp_hb_type[nhb] = 6; // unknown HB type! + unknown++; } // Error checks - if( id_hb < 1 ) { - cout< 0)" - < 0)" << endl << endl; + exit(25); } - if( id_hb >= no_atoms ) { - cout<= no_atoms) { + cout << endl + << endl + << "\a\tERROR: Current hydrogen bond ID = " << id_hb << endl; + cout << "\t FIRST must terminate until ID label is changed." + << endl; + cout << "\t (Set ID < " << no_atoms << ")" << endl << endl; + exit(26); } temp_hb_id[nhb] = id_hb; } @@ -335,28 +328,30 @@ void list::read_proflexdataset(void) { fptr.close(); // Check if the file was empty - if( no_atoms == 0 ) { - cout<<"\a\tThere were no atom records in the file!"< 0 ) { + //--------------------------------------------Check if any unknown H-bonds + // detected + if (unknown > 0) { cout << endl - << "\a\tNumber of unknown hydrogen bond types detected = " - << unknown << endl; - cout << "\tGeometrical screening will proceed as if a salt bridge." - << endl; + << "\a\tNumber of unknown hydrogen bond types detected = " << unknown + << endl; + cout << "\tGeometrical screening will proceed as if a salt bridge." << endl; cout << "\tEnter c to continue: "; char ans; cin >> answer; - if( strlen(answer) == 1 ) + if (strlen(answer) == 1) ans = answer[0]; - else ans = '@'; + else + ans = '@'; - if( ans == 'c' ) + if (ans == 'c') ans = 'C'; - if( ans != 'C' ) + if (ans != 'C') exit(5); } @@ -364,461 +359,472 @@ void list::read_proflexdataset(void) { temp = last; chainptr[0] = temp; - while( temp != start ) { + while (temp != start) { temp = temp->prior; - if( strcmp(temp->r1.chain, chainptr[chaincount]->r1.chain) ) { - chainptr[chaincount+1] = temp; + if (strcmp(temp->r1.chain, chainptr[chaincount]->r1.chain)) { + chainptr[chaincount + 1] = temp; ++chaincount; } } // Allocate memory for permanent arrays - link_noHB = (int **) new int*[no_atoms+1]; + link_noHB = (int **)new int *[no_atoms + 1]; - for( i = 0; i <= no_atoms; i++ ) - link_noHB[i] = (int *) new int[mult[i]+1]; + for (i = 0; i <= no_atoms; i++) + link_noHB[i] = (int *)new int[mult[i] + 1]; - mult_net = new int[no_atoms+1]; - hb_energy = new float[nhb+1]; - hb_type = new int[nhb+1]; - hb_id = new int[nhb+1]; - hbond = (int **) new int *[nhb+1]; - for( i = 0; i <= nhb; i++ ) - hbond[i] = (int *) new int[4]; + mult_net = new int[no_atoms + 1]; + hb_energy = new float[nhb + 1]; + hb_type = new int[nhb + 1]; + hb_id = new int[nhb + 1]; + hbond = (int **)new int *[nhb + 1]; + for (i = 0; i <= nhb; i++) + hbond[i] = (int *)new int[4]; // Copy temp arrays to permanent arrays - for( i = 1; i <= no_atoms; i++ ) { - for( j = 1; j <= mult[i]; j++ ) + for (i = 1; i <= no_atoms; i++) { + for (j = 1; j <= mult[i]; j++) link_noHB[i][j] = temp_link[i][j]; } - for( i = 1; i <= no_atoms; i++ ) { + for (i = 1; i <= no_atoms; i++) { mlt = 0; - for( j = 1; j <= mult[i]; j++ ) { + for (j = 1; j <= mult[i]; j++) { // Covalent degeneracy error check iflag = -1; - for( k = j+1; k <= mult[i]; k++ ) { - if(link_noHB[i][j] == link_noHB[i][k]) - iflag = 1; - } - if( iflag < 0 ) { - mlt++; - link_noHB[i][mlt] = link_noHB[i][j]; + for (k = j + 1; k <= mult[i]; k++) { + if (link_noHB[i][j] == link_noHB[i][k]) + iflag = 1; } - else { - so = i; - sf = link_noHB[i][j]; - if( so < sf ) { - cout<r1.aname,p[so]->r1.rname,p[so]->r1.res_no, - p[so]->r1.code,p[so]->r1.chain,p[sf]->r1.aname, - p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code, - p[sf]->r1.chain); - } + if (iflag < 0) { + mlt++; + link_noHB[i][mlt] = link_noHB[i][j]; + } else { + so = i; + sf = link_noHB[i][j]; + if (so < sf) { + cout << endl + << "\tDuplicate covalent bond connection ignored!" << endl; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, so, sf, p[so]->r1.aname, p[so]->r1.rname, + p[so]->r1.res_no, p[so]->r1.code, p[so]->r1.chain, + p[sf]->r1.aname, p[sf]->r1.rname, p[sf]->r1.res_no, + p[sf]->r1.code, p[sf]->r1.chain); + } } } mult[i] = mlt; } - for( i = 1; i <= nhb; i++ ) { + for (i = 1; i <= nhb; i++) { hb_energy[i] = temp_hb_energy[i]; - hb_type[i] = temp_hb_type[i]; - hb_id[i] = temp_hb_id[i]; - hbond[i][1] = temp_hbond[i][1]; - hbond[i][2] = temp_hbond[i][2]; - hbond[i][3] = temp_hbond[i][3]; + hb_type[i] = temp_hb_type[i]; + hb_id[i] = temp_hb_id[i]; + hbond[i][1] = temp_hbond[i][1]; + hbond[i][2] = temp_hbond[i][2]; + hbond[i][3] = temp_hbond[i][3]; } // Check for HB ID degeneracy - for( i = 1; i <= no_atoms; i++ ) { + for (i = 1; i <= no_atoms; i++) { temp_hb_id[i] = 0; } // ERROR check. - for( i = 1; i <= nhb; i++ ) { - temp_hb_id[ hb_id[i] ]++; - if( temp_hb_id[ hb_id[i] ] > 1 ) { - cout << endl << endl - << "\a\tERROR: Degeneracy found in hydgrogen bond ID = " - << hb_id[i] << " " << i << " " << temp_hb_id[ hb_id[i] ] - << endl << "\t FIRST must terminate until ID labeling is corrected!" - << endl << endl; + for (i = 1; i <= nhb; i++) { + temp_hb_id[hb_id[i]]++; + if (temp_hb_id[hb_id[i]] > 1) { + cout << endl + << endl + << "\a\tERROR: Degeneracy found in hydgrogen bond ID = " << hb_id[i] + << " " << i << " " << temp_hb_id[hb_id[i]] << endl + << "\t FIRST must terminate until ID labeling is corrected!" + << endl + << endl; exit(27); } } // Expand multiplicity - for( i = 0; i <= no_atoms; i++ ) { - mult_net[i]=mult[i]; //--Copy original multiplicities into new array + for (i = 0; i <= no_atoms; i++) { + mult_net[i] = mult[i]; //--Copy original multiplicities into new array } - for( i = 1; i <= nhb; i++ ) { - s = hbond[i][2]; //--include multiplicites due to hbonds + for (i = 1; i <= nhb; i++) { + s = hbond[i][2]; //--include multiplicites due to hbonds sf = hbond[i][3]; mult_net[s]++; mult_net[sf]++; } // Allocate memory for link_net[][] - link_net =(int **) new int*[no_atoms+1]; - for( i = 0; i <= no_atoms; i++ ) - *(link_net+i)=(int *) new int[mult_net[i]+1]; + link_net = (int **)new int *[no_atoms + 1]; + for (i = 0; i <= no_atoms; i++) + *(link_net + i) = (int *)new int[mult_net[i] + 1]; // Expand connectivity table - for( i = 1; i <= no_atoms; i++ ) { - for( j = 1; j <= mult[i]; j++ ) { - link_net[i][j]=link_noHB[i][j]; + for (i = 1; i <= no_atoms; i++) { + for (j = 1; j <= mult[i]; j++) { + link_net[i][j] = link_noHB[i][j]; } mult_net[i] = mult[i]; - delete [] *(temp_link+i); + delete[] * (temp_link + i); } - for( i = 1; i <= nhb; i++ ) { - s = hbond[i][2]; //--include multiplicites due to hbonds + for (i = 1; i <= nhb; i++) { + s = hbond[i][2]; //--include multiplicites due to hbonds sf = hbond[i][3]; mult_net[s]++; mult_net[sf]++; - link_net[s][mult_net[s]] = sf; + link_net[s][mult_net[s]] = sf; link_net[sf][mult_net[sf]] = s; } - delete [] temp_link; - delete [] temp_hb_type; - delete [] temp_hb_id; - delete [] temp_hb_energy; + delete[] temp_link; + delete[] temp_hb_type; + delete[] temp_hb_id; + delete[] temp_hb_energy; } /**********************************************************************/ - /**********************************************************************/ /* what does this do? */ /**********************************************************************/ -void list::check(void) -{ - int i,j,k,m,iflag,mlt,so,sf; - int tmp1,tmp2,tmp3,tmp4,tmp5; - int link_counter = 0; // To count links before flagging valency warning - Sameer +void list::check(void) { + int i, j, k, m, iflag, mlt, so, sf; + int tmp1, tmp2, tmp3, tmp4, tmp5; + int link_counter = + 0; // To count links before flagging valency warning - Sameer float tmp; //--------------------------------------------No groups in PDB file - if(no_atoms==0) - { - cout<r1.aname,p[sf]->r1.rname,p[sf]->r1.res_no, - p[sf]->r1.code,p[sf]->r1.chain,p[sf]->r1.aname,p[sf]->r1.aname, - p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname); - - //----------------------------------Remove that bond - for(k=j;k<=mult_net[so]-1;k++) - { - link_net[so][k]=link_net[so][k+1]; - } - link_net[so][mult_net[so]]=-1; - mult_net[so]--; - } - } + if (no_atoms == 0) { + cout << endl + << "STOP: Please check original PDB file! No atoms found!" << endl; + exit(11); + } + for (i = 1; i <= no_atoms; i++) { + for (j = 1; j <= mult_net[i]; j++) { + //-------------------------------------------Self connect error check + if (link_net[i][j] == i) { + so = i; + sf = link_net[i][j]; + cout << endl << "Self connection ignored!" << endl; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, sf, 0, p[sf]->r1.aname, p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + p[sf]->r1.aname, p[sf]->r1.aname, p[sf]->r1.aname, + p[sf]->r1.aname, p[sf]->r1.aname); + + //----------------------------------Remove that bond + for (k = j; k <= mult_net[so] - 1; k++) { + link_net[so][k] = link_net[so][k + 1]; + } + link_net[so][mult_net[so]] = -1; + mult_net[so]--; + } } - for(i=1;i<=no_atoms;i++) - { - mlt = 0; - for(j=1;j<=mult_net[i];j++) - { - //-------------------------------------------Degeneracy error check - iflag = -1; - for(k=j+1;k<=mult_net[i];k++) - { - if( link_net[i][j] == link_net[i][k] ) iflag = 1; - } - if( iflag < 0 ) - { - mlt++; - link_net[i][mlt]=link_net[i][j]; - } - else - { - so=i; - sf=link_net[i][j]; - if( so < sf ) - { - cout<r1.aname,p[so]->r1.rname,p[so]->r1.res_no, - p[so]->r1.code,p[so]->r1.chain,p[sf]->r1.aname, - p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code, - p[sf]->r1.chain); -//--------------------------------------------------- Remove H-bond from the list - m = 0; - iflag = -1; - for(k=1;k<=nhb;k++) - { - if( (so == hbond[k][2] && sf == hbond[k][3]) || - (sf == hbond[k][2] && so == hbond[k][3]) ) - { - if( iflag < 0 ) - { - iflag = 1; - m++; - hbond[m][1] = hbond[k][1]; - hbond[m][2] = hbond[k][2]; - hbond[m][3] = hbond[k][3]; - hb_energy[m] = hb_energy[k]; - hb_type[m] = hb_type[k]; - hb_id[m] = hb_id[k]; - } - } - else - { - m++; - hbond[m][1] = hbond[k][1]; - hbond[m][2] = hbond[k][2]; - hbond[m][3] = hbond[k][3]; - hb_energy[m] = hb_energy[k]; - hb_type[m] = hb_type[k]; - hb_id[m] = hb_id[k]; - } - } - nhb = m; - } - } - } - mult_net[i] = mlt; + } + for (i = 1; i <= no_atoms; i++) { + mlt = 0; + for (j = 1; j <= mult_net[i]; j++) { + //-------------------------------------------Degeneracy error check + iflag = -1; + for (k = j + 1; k <= mult_net[i]; k++) { + if (link_net[i][j] == link_net[i][k]) + iflag = 1; + } + if (iflag < 0) { + mlt++; + link_net[i][mlt] = link_net[i][j]; + } else { + so = i; + sf = link_net[i][j]; + if (so < sf) { + cout << endl << "\tHydrogen-bond overlap connection ignored!" << endl; + cout << "\t Atom# Atom Res Res# Chain" << endl; + write_output(1, so, sf, p[so]->r1.aname, p[so]->r1.rname, + p[so]->r1.res_no, p[so]->r1.code, p[so]->r1.chain, + p[sf]->r1.aname, p[sf]->r1.rname, p[sf]->r1.res_no, + p[sf]->r1.code, p[sf]->r1.chain); + //--------------------------------------------------- Remove H-bond + // from the list + m = 0; + iflag = -1; + for (k = 1; k <= nhb; k++) { + if ((so == hbond[k][2] && sf == hbond[k][3]) || + (sf == hbond[k][2] && so == hbond[k][3])) { + if (iflag < 0) { + iflag = 1; + m++; + hbond[m][1] = hbond[k][1]; + hbond[m][2] = hbond[k][2]; + hbond[m][3] = hbond[k][3]; + hb_energy[m] = hb_energy[k]; + hb_type[m] = hb_type[k]; + hb_id[m] = hb_id[k]; + } + } else { + m++; + hbond[m][1] = hbond[k][1]; + hbond[m][2] = hbond[k][2]; + hbond[m][3] = hbond[k][3]; + hb_energy[m] = hb_energy[k]; + hb_type[m] = hb_type[k]; + hb_id[m] = hb_id[k]; + } + } + nhb = m; + } + } } + mult_net[i] = mlt; + } int flag7 = 0; //------------------------------------------Valence check Begins - for(i=1;i<=no_atoms;i++) - { - /*--------------------------- Real Valency check ------------------*/ - /* The valency is taken as the no of bonds of an atom. This is fine, as long as we don't add - * up the bonds to pseudo atoms as well. This becoms a problem when re-using proflexdataset in a run - * as then bonds to psuedo atoms too leads FIRST to decide valency as incorrectly high, and - * give these warnings - Sameer - */ - - link_counter = 0; - for(j=1;j<=mult[i];j++) - { - sf=link_noHB[i][j]; - if( strcmp(p[sf]->r1.rname,"XXX") != 0 ) - link_counter++; - //cout<< "["<r1.rname<<" : " << link_counter<<"]\t"; - } - /*--------------------------- Real Valency check ends - Sameer ------------------*/ - if(p[i]->r1.aname[2]=='H' || p[i]->r1.aname[2]=='D') - { - if(link_counter > 1) - //if(mult[i]>1) - { - so=i; - if(flag7==0) - { - //system("clear"); - // cout<r1.aname,p[so]->r1.rname,p[so]->r1.res_no,p[so]->r1.code,p[so]->r1.chain,p[so]->r1.aname,p[so]->r1.aname,p[so]->r1.aname,p[so]->r1.aname,p[so]->r1.aname); - for(j=1;j<=mult[i];j++) - { - sf=link_noHB[i][j]; - write_output(1,sf,0,p[sf]->r1.aname,p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code,p[sf]->r1.chain,p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname); - } - //cout << endl; - } - } - else if(p[i]->r1.aname[2]=='O') - { - if(link_counter > 2) - //if(mult[i]>2) - { - so=i; - if(flag7==0) - { - //system("clear"); - //cout<r1.aname,p[so]->r1.rname,p[so]->r1.res_no,p[so]->r1.code,p[so]->r1.chain,p[so]->r1.aname,p[so]->r1.aname,p[so]->r1.aname,p[so]->r1.aname,p[so]->r1.aname); - for(j=1;j<=mult[i];j++) - { - sf=link_noHB[i][j]; - write_output(1,sf,0,p[sf]->r1.aname,p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code,p[sf]->r1.chain,p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname); - } - //cout << endl; - } - } - else if( p[i]->r1.aname[2]=='N' && - ( p[i]->r1.mod_res_no != 1 || ( p[i]->r1.mod_res_no == 1 && - strncmp(p[i]->r1.aname+1," N ",4)!=0 ) ) && - !(strcmp(p[i]->r1.rname,"LYS")==0 && - strncmp(p[i]->r1.aname+1," NZ ",4)==0) ) - { - if(link_counter > 3) - //if(mult[i]>3) - { - so=i; - if(flag7==0) - { - //system("clear"); - //cout<r1.aname,p[so]->r1.rname,p[so]->r1.res_no,p[so]->r1.code,p[so]->r1.chain,p[so]->r1.aname,p[so]->r1.aname,p[so]->r1.aname,p[so]->r1.aname,p[so]->r1.aname); - for(j=1;j<=mult[i];j++) - { - sf=link_noHB[i][j]; - write_output(1,sf,0,p[sf]->r1.aname,p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code,p[sf]->r1.chain,p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname); - } - //cout << endl; - } - } - else - { - if(link_counter > 4) - //if(mult[i]>4) - { - - so=i; - if(flag7==0) - { - //system("clear"); - //cout<r1.aname,p[so]->r1.rname,p[so]->r1.res_no,p[so]->r1.code,p[so]->r1.chain,p[so]->r1.aname,p[so]->r1.aname,p[so]->r1.aname,p[so]->r1.aname,p[so]->r1.aname); - for(j=1;j<=mult[i];j++) - { - sf=link_noHB[i][j]; - write_output(1,sf,0,p[sf]->r1.aname,p[sf]->r1.rname,p[sf]->r1.res_no,p[sf]->r1.code,p[sf]->r1.chain,p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname,p[sf]->r1.aname); - } - //cout << endl; - } - } - } // valence checks end - if(flag7==1) - { - cout<<"---------------------------------------------------------------"< continue) to stop: "; - cin.seekg(0,ios::end); - cin.clear(); - cin.get(answer,4); - cin.seekg(0,ios::end); - cin.clear(); - if( strlen(answer) == 1 ) ans = answer[0]; - else ans = '@@'; - if( ans == 's' ) ans = 'S'; - if(ans=='S') exit(-1); - */ - cout<r1.rname, "XXX") != 0) + link_counter++; + // cout<< "["<r1.rname<<" : " << link_counter<<"]\t"; + } + /*--------------------------- Real Valency check ends - Sameer + * ------------------*/ + if (p[i]->r1.aname[2] == 'H' || p[i]->r1.aname[2] == 'D') { + if (link_counter > 1) + // if(mult[i]>1) + { + so = i; + if (flag7 == 0) { + // system("clear"); + // cout<r1.aname, p[so]->r1.rname, + p[so]->r1.res_no, p[so]->r1.code, p[so]->r1.chain, + p[so]->r1.aname, p[so]->r1.aname, p[so]->r1.aname, + p[so]->r1.aname, p[so]->r1.aname); + for (j = 1; j <= mult[i]; j++) { + sf = link_noHB[i][j]; + write_output(1, sf, 0, p[sf]->r1.aname, p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + p[sf]->r1.aname, p[sf]->r1.aname, p[sf]->r1.aname, + p[sf]->r1.aname, p[sf]->r1.aname); + } + // cout << endl; + } + } else if (p[i]->r1.aname[2] == 'O') { + if (link_counter > 2) + // if(mult[i]>2) + { + so = i; + if (flag7 == 0) { + // system("clear"); + // cout<r1.aname, p[so]->r1.rname, + p[so]->r1.res_no, p[so]->r1.code, p[so]->r1.chain, + p[so]->r1.aname, p[so]->r1.aname, p[so]->r1.aname, + p[so]->r1.aname, p[so]->r1.aname); + for (j = 1; j <= mult[i]; j++) { + sf = link_noHB[i][j]; + write_output(1, sf, 0, p[sf]->r1.aname, p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + p[sf]->r1.aname, p[sf]->r1.aname, p[sf]->r1.aname, + p[sf]->r1.aname, p[sf]->r1.aname); + } + // cout << endl; + } + } else if (p[i]->r1.aname[2] == 'N' && + (p[i]->r1.mod_res_no != 1 || + (p[i]->r1.mod_res_no == 1 && + strncmp(p[i]->r1.aname + 1, " N ", 4) != 0)) && + !(strcmp(p[i]->r1.rname, "LYS") == 0 && + strncmp(p[i]->r1.aname + 1, " NZ ", 4) == 0)) { + if (link_counter > 3) + // if(mult[i]>3) + { + so = i; + if (flag7 == 0) { + // system("clear"); + // cout<r1.aname, p[so]->r1.rname, + p[so]->r1.res_no, p[so]->r1.code, p[so]->r1.chain, + p[so]->r1.aname, p[so]->r1.aname, p[so]->r1.aname, + p[so]->r1.aname, p[so]->r1.aname); + for (j = 1; j <= mult[i]; j++) { + sf = link_noHB[i][j]; + write_output(1, sf, 0, p[sf]->r1.aname, p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + p[sf]->r1.aname, p[sf]->r1.aname, p[sf]->r1.aname, + p[sf]->r1.aname, p[sf]->r1.aname); + } + // cout << endl; + } + } else { + if (link_counter > 4) + // if(mult[i]>4) + { + + so = i; + if (flag7 == 0) { + // system("clear"); + // cout<r1.aname, p[so]->r1.rname, + p[so]->r1.res_no, p[so]->r1.code, p[so]->r1.chain, + p[so]->r1.aname, p[so]->r1.aname, p[so]->r1.aname, + p[so]->r1.aname, p[so]->r1.aname); + for (j = 1; j <= mult[i]; j++) { + sf = link_noHB[i][j]; + write_output(1, sf, 0, p[sf]->r1.aname, p[sf]->r1.rname, + p[sf]->r1.res_no, p[sf]->r1.code, p[sf]->r1.chain, + p[sf]->r1.aname, p[sf]->r1.aname, p[sf]->r1.aname, + p[sf]->r1.aname, p[sf]->r1.aname); + } + // cout << endl; + } } + } // valence checks end + if (flag7 == 1) { + cout << "---------------------------------------------------------------" + << endl; + /* + cout<<"Type s (Default --> continue) to stop: "; + cin.seekg(0,ios::end); + cin.clear(); + cin.get(answer,4); + cin.seekg(0,ios::end); + cin.clear(); + if( strlen(answer) == 1 ) ans = answer[0]; + else ans = '@@'; + if( ans == 's' ) ans = 'S'; + if(ans=='S') exit(-1); + */ + cout << endl << endl; + } //--------------------------------------------Fix up hydrogen bond type - for(i=1;i<=nhb;i++) - { - so = hbond[i][1]; - sf = hbond[i][3]; - if(p[so]->r1.aname[2]=='S'||p[sf]->r1.aname[2]=='S') - { - hb_type[i]+=6; - } + for (i = 1; i <= nhb; i++) { + so = hbond[i][1]; + sf = hbond[i][3]; + if (p[so]->r1.aname[2] == 'S' || p[sf]->r1.aname[2] == 'S') { + hb_type[i] += 6; } -//------------------------------------Sort H-bonds from highest to lowest energy -// Use a Shell sort algorithm - hb_energy[0]=1e25; + } + //------------------------------------Sort H-bonds from highest to lowest + // energy + // Use a Shell sort + // algorithm + hb_energy[0] = 1e25; nhb++; - for(int gap = nhb/2; gap > 0; gap = gap == 2 ? 1 : (int)(gap/2.2)) - { - for(i=gap;i=gap && tmp > hb_energy[j-gap]; j-=gap) - { - hb_energy[j]=hb_energy[j-gap]; - hbond[j][1]=hbond[j-gap][1]; - hbond[j][2]=hbond[j-gap][2]; - hbond[j][3]=hbond[j-gap][3]; - hb_type[j]=hb_type[j-gap]; - hb_id[j]=hb_id[j-gap]; - } - hb_energy[j]=tmp; - hbond[j][1]=tmp1; - hbond[j][2]=tmp2; - hbond[j][3]=tmp3; - hb_type[j]=tmp4; - hb_id[j]=tmp5; - } + for (int gap = nhb / 2; gap > 0; gap = gap == 2 ? 1 : (int)(gap / 2.2)) { + for (i = gap; i < nhb; i++) { + tmp = hb_energy[i]; + tmp1 = hbond[i][1]; + tmp2 = hbond[i][2]; + tmp3 = hbond[i][3]; + tmp4 = hb_type[i]; + tmp5 = hb_id[i]; + j = i; + + for (; j >= gap && tmp > hb_energy[j - gap]; j -= gap) { + hb_energy[j] = hb_energy[j - gap]; + hbond[j][1] = hbond[j - gap][1]; + hbond[j][2] = hbond[j - gap][2]; + hbond[j][3] = hbond[j - gap][3]; + hb_type[j] = hb_type[j - gap]; + hb_id[j] = hb_id[j - gap]; + } + hb_energy[j] = tmp; + hbond[j][1] = tmp1; + hbond[j][2] = tmp2; + hbond[j][3] = tmp3; + hb_type[j] = tmp4; + hb_id[j] = tmp5; } + } nhb--; -//--------------------------------------------------------------Warning message - if(nhb < (no_atoms)/65) - { - cout< -void print_connections( FILE *, FILE *, int[] ); +void print_connections(FILE *, FILE *, int[]); #endif diff --git a/proflex/prog/hbdilute/include/graphs.h b/proflex/prog/hbdilute/include/graphs.h index 5a42cf6..9740231 100755 --- a/proflex/prog/hbdilute/include/graphs.h +++ b/proflex/prog/hbdilute/include/graphs.h @@ -24,7 +24,7 @@ #define _GRAPHS_ #include "types.h" - -void plot_data( FILE *, float[], float[], float[], float[], int ); +#include +void plot_data(FILE *, float[], float[], float[], float[], int); #endif diff --git a/proflex/prog/hbdilute/include/hbfunctions.h b/proflex/prog/hbdilute/include/hbfunctions.h index 1b89b6b..f0f2221 100755 --- a/proflex/prog/hbdilute/include/hbfunctions.h +++ b/proflex/prog/hbdilute/include/hbfunctions.h @@ -24,6 +24,7 @@ #define _HDFUNCTIONS_ #include "types.h" +#include void read_chem_file( atom_list **, FILE *, int[], int[], char[], int *, int *, int[], int[], char[], @@ -38,5 +39,3 @@ void clean_up( FILE *, int); int open_output_file( char [], FILE** ); #endif - - diff --git a/proflex/prog/hbdilute/include/postscript.h b/proflex/prog/hbdilute/include/postscript.h index 4c1dbf2..f891710 100755 --- a/proflex/prog/hbdilute/include/postscript.h +++ b/proflex/prog/hbdilute/include/postscript.h @@ -24,6 +24,7 @@ #define _POSTSCRIPT_ #include "types.h" +#include void print_header( FILE *, float ); void print_data_headings( FILE *, int, int, int, int[] ); diff --git a/proflex/prog/hbdilute/include/text_output.h b/proflex/prog/hbdilute/include/text_output.h index c640ee7..bf09012 100755 --- a/proflex/prog/hbdilute/include/text_output.h +++ b/proflex/prog/hbdilute/include/text_output.h @@ -20,7 +20,7 @@ * or see http://www.gnu.org/licenses/gpl.txt * *******************************************************************************/ -/* +/* * File: text_output.h * Author: Sameer Arora * @@ -28,11 +28,11 @@ */ #ifndef _text_output_H -#define _text_output_H +#define _text_output_H #include "types.h" +#include void print_text_decomp( clusters *[], int, int, FILE *, int [], int, int,float,float); #endif /* _text_output_H */ - diff --git a/proflex/prog/hbdilute/src/hbfunctions.c b/proflex/prog/hbdilute/src/hbfunctions.c index 782c8f3..71cae29 100755 --- a/proflex/prog/hbdilute/src/hbfunctions.c +++ b/proflex/prog/hbdilute/src/hbfunctions.c @@ -920,4 +920,3 @@ void clean_up( FILE *ps_file, int number_of_pages ){ return(1); } - diff --git a/proflex/prog/hbdilute/src/postscript.c b/proflex/prog/hbdilute/src/postscript.c index e08ac86..5d1571f 100755 --- a/proflex/prog/hbdilute/src/postscript.c +++ b/proflex/prog/hbdilute/src/postscript.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "../include/types.h" #define TRUE 1 diff --git a/proflex/prog/hbdilute/src/text_output.c b/proflex/prog/hbdilute/src/text_output.c index cd57cfe..c37082e 100755 --- a/proflex/prog/hbdilute/src/text_output.c +++ b/proflex/prog/hbdilute/src/text_output.c @@ -44,6 +44,29 @@ /* Outout is written to a text file instead of generating a postscript*/ /**********************************************************************/ +static void swap_colors(int array[MAX_CLUSTER_COUNT], int A, int B) { + int temp; + temp = array[A]; + array[A] = array[B]; + array[B] = temp; +} + +static void quick_sort(int *array, int start, int end) { + + int a = 0, last = 0; + + if (start >= end) + return; + swap_colors(array, start, (start + end) / 2); + last = start; + for (a = start + 1; a <= end; a++) { + if (array[a] < array[start]) + swap_colors(array, ++start, a); + } + swap_colors(array, start, last); + quick_sort(array, start, last - 1); + quick_sort(array, last + 1, end); +} void print_text_decomp( clusters *nc_count[120], int cluster_counter, int line_number, @@ -129,4 +152,3 @@ static int } - diff --git a/proflex/util/flex_index.cpp b/proflex/util/flex_index.cpp index dd94f77..b6b0f3f 100755 --- a/proflex/util/flex_index.cpp +++ b/proflex/util/flex_index.cpp @@ -1,36 +1,35 @@ /******************************************************************************* -* MSU ProFlex, formerly called FIRST, is a software developed to predict and * -* analyze protein flexibility. * -* This source file is a part of MSU ProFlex. * -* * -* Copyright (C) 1997 - 2008, Michigan State University. * -* * -* This program is free software; you can redistribute to academic users only, * -* it and/or modify it under the terms of the GNU General Public License, * -* version 2, as published by the Free Software Foundation. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, * -* or see http://www.gnu.org/licenses/gpl.txt * -*******************************************************************************/ + * MSU ProFlex, formerly called FIRST, is a software developed to predict and * + * analyze protein flexibility. * This source file is a part of MSU ProFlex. * + * * + * Copyright (C) 1997 - 2008, Michigan State University. * + * * + * This program is free software; you can redistribute to academic users only, + ** it and/or modify it under the terms of the GNU General Public License, * + * version 2, as published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * but + *WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General + *Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * along + *with this program; if not, write to the Free Software * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, * + * or see http://www.gnu.org/licenses/gpl.txt * + *******************************************************************************/ /*----------------------------------------------------------------------------- Written by S.K. Namilikonda 05/2008 This program reads in the "_allbonds" file and for each atom - it picks the bond with the least flexibility index over all bonds + it picks the bond with the least flexibility index over all bonds stemming from it and assign its value to that atom. This is a coarse - grained description of the flexibility index over the entire protein. - This value (which ranges between -1 (min flex) to +1 (max flex)) - is then transformed into a new number and put in the B-value column + grained description of the flexibility index over the entire protein. + This value (which ranges between -1 (min flex) to +1 (max flex)) + is then transformed into a new number and put in the B-value column of a PDB file ranging between 0 to 99, so that visualization tools - such as Insight II or PyMol can color code the protein in accordance + such as Insight II or PyMol can color code the protein in accordance to the flexibility index. In addition, this program also outputs PyMol-ready scripts for visualizing @@ -41,35 +40,34 @@ -----------------------------------------------------------------------------*/ -#include -#include -#include -#include #include -#include +#include #include +#include +#include +#include +#include using namespace std; #define MAX_FILENAME 80 -int main(int argc,char *argv[]) -{ -//-------------------------------------------------- declare variables - ifstream input; - ifstream input1; - ifstream input2; - ofstream output; - ofstream output1; - ofstream output2; - ofstream output3; // crude getaround for glibc error - char intro[10]; - int count,nHP=0; - const char error_open[] = "\n *** main(): unable to open file: "; -//-------------------------------------------------- preset names for now +int main(int argc, char *argv[]) { + //-------------------------------------------------- declare variables + ifstream input; + ifstream input1; + ifstream input2; + ofstream output; + ofstream output1; + ofstream output2; + ofstream output3; // crude getaround for glibc error + char intro[10]; + int count, nHP = 0; + const char error_open[] = "\n *** main(): unable to open file: "; + //-------------------------------------------------- preset names for now /* - * Note that only 20 colors are initialized + * Note that only 20 colors are initialized * Use bright colors that match the coloring scheme in hbdilute plot * Use pastale colors for flex clusters * R G B @@ -82,645 +80,616 @@ int main(int argc,char *argv[]) * magenta 1 0 1 * orange 1.0 0.5 0.0 * - wheat 0.99 0.82 0.65 - palegreen 0.65 0.9 0.65 - lightblue 0.75 0.75 1.0 - paleyellow 1.0 1.0 0.5 - lightpink 1.00 0.75 0.87 - palecyan 0.8 1.0 1.0 - lightorange 1.0 0.8 0.5 - bluewhite 0.85 0.85 1.00 - tv_orange 1.0 0.55 0.15 + wheat 0.99 0.82 0.65 + palegreen 0.65 0.9 0.65 + lightblue 0.75 0.75 1.0 + paleyellow 1.0 1.0 0.5 + lightpink 1.00 0.75 0.87 + palecyan 0.8 1.0 1.0 + lightorange 1.0 0.8 0.5 + bluewhite 0.85 0.85 1.00 + tv_orange 1.0 0.55 0.15 */ - string RCcolors[] = {"","red","cyan","green","yellow","purple","purpleblue",\ - "brightorange","tv_red","tv_green","olive",\ - "deeppurple","blue","tv_blue","grey70","limon",\ - "hotpink","violet","ruby","yelloworange","forest"}; - - string FCcolors[] = {"","wheat","palegreen","lightblue","paleyellow",\ - "lightpink","palecyan","lightorange","bluewhite",\ - "teal","limegreen","pink","slate","aquamarine",\ - "lightorange","sand","tv_orange","lime","marine",\ - "splitpea","salmon"}; - -//-------------------------------------------------- input/output files - - char file_weight[MAX_FILENAME]; // allbonds file - char file_chem[MAX_FILENAME]; // proflex dataset - - char file_flexibility[MAX_FILENAME]; // flex_index and RC analysis - // output in b-value and atom # - // columns respectively --- SN - - char file_flex_pml[MAX_FILENAME]; // PyMol script for visualizing - // the protein colored by - // flexindex values --- SN - - char file_RC_pml[MAX_FILENAME]; // PyMol script for visualizing - // the protein colored by - // RC values --- SN - - char file_FC_pml[MAX_FILENAME]; // PyMol script for visualizing - // the protein colored by - // FC values --- SN - - - char ans, answer[23]; - char sso[6],ssf[6]; + string RCcolors[] = {"", "red", "cyan", "green", + "yellow", "purple", "purpleblue", "brightorange", + "tv_red", "tv_green", "olive", "deeppurple", + "blue", "tv_blue", "grey70", "limon", + "hotpink", "violet", "ruby", "yelloworange", + "forest"}; + + string FCcolors[] = {"", "wheat", "palegreen", "lightblue", + "paleyellow", "lightpink", "palecyan", "lightorange", + "bluewhite", "teal", "limegreen", "pink", + "slate", "aquamarine", "lightorange", "sand", + "tv_orange", "lime", "marine", "splitpea", + "salmon"}; + + //-------------------------------------------------- input/output files + + char file_weight[MAX_FILENAME]; // allbonds file + char file_chem[MAX_FILENAME]; // proflex dataset + + char file_flexibility[MAX_FILENAME]; // flex_index and RC analysis + // output in b-value and atom # + // columns respectively --- SN + + char file_flex_pml[MAX_FILENAME]; // PyMol script for visualizing + // the protein colored by + // flexindex values --- SN + + char file_RC_pml[MAX_FILENAME]; // PyMol script for visualizing + // the protein colored by + // RC values --- SN + + char file_FC_pml[MAX_FILENAME]; // PyMol script for visualizing + // the protein colored by + // FC values --- SN + + char ans, answer[23]; + char sso[6], ssf[6]; std::string fend1 = "proflexdataset"; - std::string fend2 = ".pdb"; - std::string fend3 = ".pml"; // PyMol script ---- SN - short int num_full,num_base,num_PROFLEX; - int flagHP = -1; - short int noscaling = 0; - int max_atm_num,tmp,a1,a2,clust,i; - float wt; - char *line = new char [90]; - -//--------------------------------------------- initialize file-name arrays to NULL chars - - memset( (void*)file_weight , '\0', MAX_FILENAME); - memset( (void*)file_chem , '\0', MAX_FILENAME); - memset( (void*)file_flexibility , '\0', MAX_FILENAME); - memset( (void*)file_flex_pml , '\0', MAX_FILENAME); // 2008:04 - memset( (void*)file_RC_pml , '\0', MAX_FILENAME); // 2008:04 - memset( (void*)file_FC_pml , '\0', MAX_FILENAME); // 2008:05 - -//------------------------------------------------------------------- cosmetics - -// if (argc >= 2 && strcmp(argv[1], "-1") == 0) { - //Don't scale the output to 0 to 99 if "-1" is given as the command line argument -// noscaling = 1; -// } - - if ( argc != 2 ) - { - cout<<"\n\tUSAGE: flex_index \n"<= 2 && strcmp(argv[1], "-1") == 0) { + // Don't scale the output to 0 to 99 if "-1" is given as the command line + // argument + // noscaling = 1; + // } + + if (argc != 2) { + cout << "\n\tUSAGE: flex_index \n" << endl; exit(-1); } - /* OPEN INPUT FILES */ + /* OPEN INPUT FILES */ /* * Read-in all_bonds file */ - strcpy(file_weight,argv[1]); + strcpy(file_weight, argv[1]); num_full = strlen(file_weight); num_base = -1; - /* + /* * Output tether info to the flex*.pdb file by default */ flagHP = 0; + //--------------------- End Input file setup ----------------------- -//--------------------- End Input file setup ----------------------- - - - - /* Setup OUTPUT files */ + /* Setup OUTPUT files */ /* * Figure out the prefix of "allbonds" file */ - for(i=0; i> a1 >> a2 >> wt >> clust; - while( !input.eof() ) - { - count++; - - if(a1 > max_atm_num) - max_atm_num = a1; - if(a2 > max_atm_num) - max_atm_num = a2; - - input >> a1 >> a2 >> wt >> clust; - } + input >> a1 >> a2 >> wt >> clust; + while (!input.eof()) { + count++; + if (a1 > max_atm_num) + max_atm_num = a1; + if (a2 > max_atm_num) + max_atm_num = a2; - input1.open(file_weight, ios::in); - if( input1.fail() ) - { - cerr << error_open << file_weight << "\n\n"; - exit(-1); - } + input >> a1 >> a2 >> wt >> clust; + } + input1.open(file_weight, ios::in); + if (input1.fail()) { + cerr << error_open << file_weight << "\n\n"; + exit(-1); + } - // --- Now that we have the size of the input file, - // --- allocate memory to store all the records - int *atm1,*atm2,*clst,*label; // label stores atom-wise clst - int min_label=0,max_label=0; - float *abs_flex,*scaled_flex; - atm1 = new int [count]; - atm2 = new int [count]; - clst = new int [count]; - label = new int [max_atm_num]; - abs_flex = new float [count]; - scaled_flex = new float [max_atm_num]; - - -//-------------------------------------------------------- read data from allbonds file - - for(i = 0; i < count; i++) - { - input1 >> atm1[i] >> atm2[i] >> abs_flex[i] >> clst[i]; - if(i < max_atm_num) - { - scaled_flex[i] = 1.0; // initialize to max flex wt allowed (1.0) - label[i] = count; // initialize to max flex - } + // --- Now that we have the size of the input file, + // --- allocate memory to store all the records + int *atm1, *atm2, *clst, *label; // label stores atom-wise clst + int min_label = 0, max_label = 0; + float *abs_flex, *scaled_flex; + atm1 = new int[count]; + atm2 = new int[count]; + clst = new int[count]; + label = new int[max_atm_num]; + abs_flex = new float[count]; + scaled_flex = new float[max_atm_num]; + + //-------------------------------------------------------- read data from + //allbonds file + + for (i = 0; i < count; i++) { + input1 >> atm1[i] >> atm2[i] >> abs_flex[i] >> clst[i]; + if (i < max_atm_num) { + scaled_flex[i] = 1.0; // initialize to max flex wt allowed (1.0) + label[i] = count; // initialize to max flex } + } - -//------------------------------------------------- find min flexibility index - for(i = 0; i < count; i++) - { - if(abs_flex[i] < scaled_flex[atm1[i]-1]) - { - scaled_flex[atm1[i]-1] = abs_flex[i]; - } - if(abs_flex[i] < scaled_flex[atm2[i]-1]) - { - scaled_flex[atm2[i]-1] = abs_flex[i]; - } - -//------------------------------------------------- find min flexibility label - if((clst[i] < 0 && label[atm1[i]-1] >= 0) || \ - (label[atm1[i]-1] == count)) - { - label[atm1[i]-1] = clst[i]; - } - if((clst[i] < 0 && label[atm2[i]-1] >= 0) || \ - (label[atm2[i]-1] == count)) - { - label[atm2[i]-1] = clst[i]; - } - if(clst[i] < min_label) min_label = clst[i]; - if(clst[i] > max_label) max_label = clst[i]; + //------------------------------------------------- find min flexibility index + for (i = 0; i < count; i++) { + if (abs_flex[i] < scaled_flex[atm1[i] - 1]) { + scaled_flex[atm1[i] - 1] = abs_flex[i]; + } + if (abs_flex[i] < scaled_flex[atm2[i] - 1]) { + scaled_flex[atm2[i] - 1] = abs_flex[i]; } -//----------------------------------------------- Now, scale the weight factors -// from (-1,+1) to (0,99) - if(!noscaling) // Added as Kevin's StoneHinge fixes - { - for(i = 0; i < max_atm_num; i++) - { - scaled_flex[i] = (scaled_flex[i]+1)*49.5; - } - } - -//------------------------ End of flex_index calculation ----------------------------- + //------------------------------------------------- find min flexibility + //label + if ((clst[i] < 0 && label[atm1[i] - 1] >= 0) || + (label[atm1[i] - 1] == count)) { + label[atm1[i] - 1] = clst[i]; + } + if ((clst[i] < 0 && label[atm2[i] - 1] >= 0) || + (label[atm2[i] - 1] == count)) { + label[atm2[i] - 1] = clst[i]; + } + if (clst[i] < min_label) + min_label = clst[i]; + if (clst[i] > max_label) + max_label = clst[i]; + } + //----------------------------------------------- Now, scale the weight + //factors from (-1,+1) to (0,99) + if (!noscaling) // Added as Kevin's StoneHinge fixes + { + for (i = 0; i < max_atm_num; i++) { + scaled_flex[i] = (scaled_flex[i] + 1) * 49.5; + } + } + //------------------------ End of flex_index calculation + //----------------------------- - /* RIGID and FLEXIBLE CLUSTER IDENTIFICATION AND COLORING */ + /* RIGID and FLEXIBLE CLUSTER IDENTIFICATION AND COLORING */ -/* - * clst[] contains the cluster label for the various bonds in the allbonds file - * So, we first map the bond labels onto the atoms such that a -ve label implies - * that an atom belongs to a rigid cluster; +ve implies flexible cluster; and - * ZERO for uncorrelated motion. This info is in label[]. - * - * Just as the flex_index value is assigned, each atom is assigned to the - * most rigid cluster that it forms a part of. Now, we renumber the atoms - * such that each cluster is assigned to a range of atom numbers. The range - * of labels is given by min_label:max_label; The atom re-numbering proceeds - * in the order of labels => rigid clusters followed by flexible ones. - * - * Then, generate two PyMol scripts that create objects for each of the rigid - * (and flexible) clusters and colors them with a different color. - * Note that each cluster should at least have a size of 6 atoms! Further, the - * cluster boundaries have to be scanned carefully to determine the biggest - * RCs and FCs - */ + /* + * clst[] contains the cluster label for the various bonds in the allbonds + * file So, we first map the bond labels onto the atoms such that a -ve label + * implies that an atom belongs to a rigid cluster; +ve implies flexible + * cluster; and ZERO for uncorrelated motion. This info is in label[]. + * + * Just as the flex_index value is assigned, each atom is assigned to the + * most rigid cluster that it forms a part of. Now, we renumber the atoms + * such that each cluster is assigned to a range of atom numbers. The range + * of labels is given by min_label:max_label; The atom re-numbering proceeds + * in the order of labels => rigid clusters followed by flexible ones. + * + * Then, generate two PyMol scripts that create objects for each of the rigid + * (and flexible) clusters and colors them with a different color. + * Note that each cluster should at least have a size of 6 atoms! Further, the + * cluster boundaries have to be scanned carefully to determine the biggest + * RCs and FCs + */ int MAX_CLUST = max_label - min_label + 10; - int *atmIndex,*clstBoundary; - atmIndex = new int [max_atm_num]; - clstBoundary = new int [MAX_CLUST]; - char header_written_flag,ch; - int begin,end,size,j; - - for ( i = 0; i < MAX_CLUST; i++ ) - { - clstBoundary[i] = 0; // Initialize clstBndry - } + int *atmIndex, *clstBoundary; + atmIndex = new int[max_atm_num]; + clstBoundary = new int[MAX_CLUST]; + char header_written_flag, ch; + int begin, end, size, j; + + for (i = 0; i < MAX_CLUST; i++) { + clstBoundary[i] = 0; // Initialize clstBndry + } - /* + /* * Scan the label[] list and re-index the atoms! Start with rgd clusters. * Then, renumber FCs. Also, make a note of all the clusters' boundaries. */ - size = 0; // atm-index temp holder - j = min_label; // clust-index - while ( size < max_atm_num && j <= max_label ) - { - for ( i = 0; i < max_atm_num; i++ ) - { - if ( label[i] == j ) - { - size++; - atmIndex[i] = size; - } + size = 0; // atm-index temp holder + j = min_label; // clust-index + while (size < max_atm_num && j <= max_label) { + for (i = 0; i < max_atm_num; i++) { + if (label[i] == j) { + size++; + atmIndex[i] = size; + } } - clstBoundary[j-min_label] = size; - j++; // Next clust-index + clstBoundary[j - min_label] = size; + j++; // Next clust-index } + //----------------------- End of RC & FC Identification -------------------- -//----------------------- End of RC & FC Identification -------------------- - - - /* - * Write the flex.pdb with the revised atom-ids and b-value column with - * the re-scaled flex_index values - */ + /* + * Write the flex.pdb with the revised atom-ids and b-value column with + * the re-scaled flex_index values + */ + input2.open(file_chem, ios::in); + if (input2.fail()) { + cerr << error_open << file_chem << "\n\n"; + exit(-1); + } - input2.open(file_chem, ios::in); - if( input2.fail() ) - { - cerr << error_open << file_chem << "\n\n"; - exit(-1); - } + output.open(file_flex_pml, ios::out); + output1.open(file_flexibility, ios::out); + output2.open(file_RC_pml, ios::out); + output3.open(file_FC_pml, ios::out); + if (output1.fail()) { + cerr << error_open << file_flexibility << "\n\n"; + exit(-1); + } + count = 0; + while (!input2.eof() && !input2.fail()) { + input2.getline(line, 90); + + if (line != NULL && + (strncmp(line, "ATOM ", 6) == 0 || strncmp(line, "HETATM", 6) == 0)) { + if (flagHP && !strncmp(line + 13, "X ", 2) && + !strncmp(line + 17, "XXX", 3)) { + nHP++; + } else { + for (i = 0; i < 6; i++) + output1 << *(line + i); + output1 << setw(5) << setiosflags(ios::fixed | ios::right) + << atmIndex[count]; + for (i = 11; i < 54; i++) + output1 << *(line + i); + output1 << " 1.00 " << setw(5) << setprecision(2) + << setiosflags(ios::showpoint | ios::fixed | ios::right) + << *(scaled_flex + count) << endl; + } + count++; + } - output.open(file_flex_pml,ios::out); - output1.open(file_flexibility, ios::out); - output2.open(file_RC_pml,ios::out); - output3.open(file_FC_pml,ios::out); - - - if( output1.fail() ) - { - cerr << error_open << file_flexibility << "\n\n"; - exit(-1); - } - - count = 0; - while( !input2.eof() && !input2.fail()) - { - input2.getline(line,90); - - if(line != NULL && - (strncmp(line,"ATOM ",6) == 0 || strncmp(line,"HETATM",6) == 0)) - { - if(flagHP && !strncmp(line+13,"X ",2) && !strncmp(line+17,"XXX",3)) - { nHP++; } - else - { - for(i=0; i<6; i++) output1 << *(line+i); - output1 << setw(5) << setiosflags(ios::fixed | ios::right) - << atmIndex[count]; - for(i=11; i<54; i++) output1 << *(line+i); - output1 << " 1.00 " << setw(5) << setprecision(2) - << setiosflags(ios::showpoint | ios::fixed | ios::right) - << *(scaled_flex+count) << endl; - - } - count++; - } - - if(line != NULL && strncmp(line,"REMARK",6) == 0 && count > 0) - break; - - } - - if(!flagHP){ - cout << "\n\n\tThe number of ATOMS = " << count << endl; + if (line != NULL && strncmp(line, "REMARK", 6) == 0 && count > 0) + break; } - else if(flagHP) { - cout << "\n\n\tThe number of ATOMS = " << count - nHP << endl; - cout<<"\n\tThe number of Tethers omitted = " << nHP/3 << endl; + + if (!flagHP) { + cout << "\n\n\tThe number of ATOMS = " << count << endl; + } else if (flagHP) { + cout << "\n\n\tThe number of ATOMS = " << count - nHP << endl; + cout << "\n\tThe number of Tethers omitted = " << nHP / 3 << endl; } + /* #################################################################### */ + /* */ + /* Output PyMol Scripts */ + /* */ + /* #################################################################### */ -/* #################################################################### */ -/* */ -/* Output PyMol Scripts */ -/* */ -/* #################################################################### */ - -/* - * Now that the flexindex based PDB file has been written out, generate - * a pymol script to aid visualizing it. - */ - -// output.open(file_flex_pml,ios::out); - output<<"delete FlexIndexObj"< 40.0 and b< 42.0')"< 42.0 and b < 44.0')"< 44.0 and b < 46.0')"< 46.0 and b < 48.0')"< 48.0 and b < 49.0')"< 49.0 and b < 50.0')"< 50.0 and b < 52.0')"< 52.0 and b < 54.0')"< 54.0 and b < 56.0')"< 56.0 and b < 58.0')"< 58 and b < 60.0')"< 60.0')"< 40.0 and b< 42.0')" + << endl; + output << "cmd.color( 's200', 'FlexIndexObj and b= 42.0')" << endl; + output << "cmd.color('s225', 'FlexIndexObj and b> 42.0 and b < 44.0')" + << endl; + output << "cmd.color('s225', 'FlexIndexObj and b= 44.0')" << endl; + output << "cmd.color('s250', 'FlexIndexObj and b> 44.0 and b < 46.0')" + << endl; + output << "cmd.color('s250', 'FlexIndexObj and b= 46.0')" << endl; + output << "cmd.color('s280', 'FlexIndexObj and b> 46.0 and b < 48.0')" + << endl; + output << "cmd.color('s280', 'FlexIndexObj and b= 48.0')" << endl; + output << "cmd.color('s310', 'FlexIndexObj and b> 48.0 and b < 49.0')" + << endl; + output << "cmd.color('s310', 'FlexIndexObj and b= 49.0')" << endl; + + output << "cmd.color('grey', 'FlexIndexObj and b> 49.0 and b < 50.0')" + << endl; + output << "cmd.color('grey', 'FlexIndexObj and b= 50.0')" << endl; + + output << "cmd.color('s690', 'FlexIndexObj and b> 50.0 and b < 52.0')" + << endl; + output << "cmd.color('s690', 'FlexIndexObj and b= 52.0')" << endl; + output << "cmd.color('s730', 'FlexIndexObj and b> 52.0 and b < 54.0')" + << endl; + output << "cmd.color('s730', 'FlexIndexObj and b= 54.0')" << endl; + output << "cmd.color('s760', 'FlexIndexObj and b> 54.0 and b < 56.0')" + << endl; + output << "cmd.color('s760', 'FlexIndexObj and b= 56.0')" << endl; + output << "cmd.color('s790', 'FlexIndexObj and b> 56.0 and b < 58.0')" + << endl; + output << "cmd.color('s790', 'FlexIndexObj and b= 58.0')" << endl; + output << "cmd.color('s820', 'FlexIndexObj and b> 58 and b < 60.0')" << endl + << endl + << endl; + output << "cmd.color('s820', 'FlexIndexObj and b= 60.0')" << endl; + output << "cmd.color('s850', 'FlexIndexObj and b> 60.0')" << endl + << endl + << endl; // Show HPHOB as spheres - output<<"select HPHOB1, FlexIndexObj and resn \"XXX\" "< -1-min_label through 0 // Note that min_label is negative (at least -1). So, we have to // first start with the cluster that has label = -1 to label = min_label - for ( i = (min_label*-1)-1, j = 1; i >= 0; i--, j++ ) - { - if ( clstBoundary[i] - clstBoundary[i-1] > 6 ) - { - output2<<"\nselect RC"<= 0; i--, j++) { + if (clstBoundary[i] - clstBoundary[i - 1] > 6) { + output2 << "\nselect RC" << j << ", RigidClustObj and id " + << clstBoundary[i - 1] + 1 << "-" << clstBoundary[i]; + output2 << "\ncolor " << RCcolors[(j % 20) + 1] << ", RC" << j; -// output2<<"\npreset.ball_and_stick('RC"<= 0; i--, j++ ) - { - if ( clstBoundary[i] - clstBoundary[i-1] <= 6 ) - { - if(flag == 'F' ) - { - // The rest of the atoms will be colored with a default color - output2<<"\nselect smallRCs"<= 0; i--, j++) { + if (clstBoundary[i] - clstBoundary[i - 1] <= 6) { + if (flag == 'F') { + // The rest of the atoms will be colored with a default color + output2 << "\nselect smallRCs" << j / 50 << ", RigidClustObj and id " + << clstBoundary[i - 1] + 1 << "-" << clstBoundary[i]; + flag = 'T'; + } else { + output2 << "+" << clstBoundary[i - 1] + 1 << "-" << clstBoundary[i]; + } + } + if ((j + 1) % 50 == 0) { + flag = 'F'; // To prevent string overflow of clust indices in PyMol + output2 << "\ncolor brown, smallRCs" << j / 50; + output2 << "\nshow sticks, smallRCs" << j / 50 << endl; + } } - - output2< (min_label*-1) through (max_label-min_label) - // Note that min_label is negative (at least -1). So, we have to - // first start with the cluster that has label = -1 to label = min_label - - for ( i = (min_label*-1)+1, j = 1; i <= max_label - min_label ; i++, j++ ) - { - if ( clstBoundary[i] - clstBoundary[i-1] > 6 ) - { - output3<<"\nselect FC"< (min_label*-1) through + // (max_label-min_label) Note that min_label is negative (at least -1). So, we + // have to first start with the cluster that has label = -1 to label = + // min_label + + for (i = (min_label * -1) + 1, j = 1; i <= max_label - min_label; i++, j++) { + if (clstBoundary[i] - clstBoundary[i - 1] > 6) { + output3 << "\nselect FC" << j << ", FlexClustObj and id " + << clstBoundary[i - 1] + 1 << "-" << clstBoundary[i]; + output3 << "\ncolor " << FCcolors[(j % 20) + 1] << ", FC" << j; + + // output3<<"\npreset.ball_and_stick('RC"<