/*************************************************************************** solvent.cpp - description ------------------- begin : Mon Jan 27 06:38:48 2003 copyright : (C) 2002 by Cavalli Andrea email : cavalli@bioc.unizh.ch **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include #include #include #include #include #include #include void Almost::Solvent::build(PDBSegment & segment,MDB & mdb, string fpatch, string lpatch) { try{ //Step 1: Find sequence from PDB vector data; { find_solvent_sequence(segment,mdb,data,fpatch,lpatch); } //Step 1: Done //Step 2 //Add fragments { add_segment_fragments(data); } //Step 2: Done //Step 3 //Add atoms { add_segment_atoms(segment,mdb,data); } //Step 3: Done //Step 4 //Add fixed exclusions { add_fixed_exclusions(mdb,data); } //Step 4: Done //Step 5 // Check heavy atoms { try{ check_heavy_atoms(mdb,fpatch,lpatch); } catch(AlmostException exc){ aout< &sequ, MDB & mdb, string fpatch, string lpatch){ try{ vector data; { find_solvent_sequence(sequ,mdb,data,fpatch,lpatch); } { add_segment_fragments(data); } { add_segment_atoms(sequ,mdb,data); } { add_fixed_exclusions(mdb,data); } { try{ make_bonds(mdb,data); } catch(AlmostException exc){ aout< & data){ for(int i=0;i & data){ char buff[16]; for(int i=0;i & sequ, MDB & mdb, vector & data){ // char buff[16]; for(int i=0;i atoms; string _fpatch; string _lpatch; _fpatch="NONE"; _lpatch="NONE"; if(data[i].fpatch=="DEFAULT"){ _fpatch = mdb.fragment(resName).def_first_patch(); }else{ _fpatch=data[i].fpatch; } if(data[i].lpatch=="DEFAULT"){ _lpatch = mdb.fragment(resName).def_last_patch(); }else{ _lpatch=data[i].lpatch; } atoms = mdb.atoms(fragment_[i], MDB::ALL_ATOMS, _fpatch,_lpatch); for(int j=0;j & data){ for(int i=0;i excl = mdb.atom(name, data[fd].fpatch, data[fd].lpatch).exclusion_list(); set::iterator iter = excl.begin(); while(iter!=excl.end()){ int indx = find_atom(data[fd].fragment+string("/")+(*iter)); if(indx<0){ aout<<"FATAL ERROR: couldn't find atom " < heavy_atoms; for(int i=0;i heavy_atoms; for(int i=0;i h_atoms = mdb.bonds(fragment_[i]+"/"+heavy_atoms[j], MDB::H_BONDS,_fpatch,_lpatch); for(int k=0;k & data){ for(int i=0;i atoms = mdb.atoms(fragment_[i], MDB::ALL_ATOMS, data[i].fpatch, data[i].lpatch); for(int j = 0; j< atoms.size();j++){ vector bond_atoms = mdb.bonds(fragment_[i]+"/"+atoms[j], MDB::OUT_BONDS, data[i].fpatch,data[i].lpatch); vector bond_kind = mdb.bonds_kind(fragment_[i]+"/"+atoms[j], MDB::OUT_BONDS, data[i].fpatch,data[i].lpatch); int atomd1 = find_atom(fragment_[i]+"/"+ atoms[j]); if(atomd1<=-1){ throw AlmostException(__FILE__,__LINE__,__PRETTY_FUNCTION__, "Atom "+fragment_[i]+"/"+ atoms[j]+ " not found in fragment "+ fragment_[i]); } for(int k=0;k & data){ logMsg(Almost::SolventPr,"No angle generation for solvent"); return; angle_generate(); } void Almost::Solvent::add_dihedrals(MDB & mdb,vector & data){ logMsg(Almost::SolventPr,"No dihedral generation for solvent"); return; //auto generate //WHAT ??? for(int i=0;i dihe; dihe = mdb.dihedrals(fragment_[i], data[i].fpatch, data[i].lpatch); //register for(int j=0;j dihe_; for(int k=0;k<4;k++) { if(index[k]==-1){ aout<<"Couldn't find atom "<< k+1<< " of dihedral "< & data){ for(int i=0;i imph; imph = mdb.impropers(fragment_[i], data[i].fpatch, data[i].lpatch); //register for(int j=0;j imph_; for(int k=0;k<4;k++) { if(index[k]==-1){ aout<<"Couldn't find atom "<< k+1<< " of improper "< & data){ for(int i=0;i group; group = mdb.groups(fragment_[i], data[i].fpatch, data[i].lpatch); //register for(int j=0;j tmp; set::const_iterator iter = group[j].atoms().begin(), end = group[j].atoms().end(); while(iter!=end){ string name = *iter; ++iter; int index; // int frag; name = fragment_[i]+"/"+name; index = find_atom(name); tmp.push_back(index); } sort(tmp.begin(),tmp.end()); group_.push_back(tmp); } } } void Almost::Solvent::generate_coor(MDB & mdb, vector & data){ ICManager ic_man; for(int i=0;i ic = mdb.ic(data[i].fragment, data[i].fpatch, data[i].lpatch); for(int j= 0;j known; if((ic_man.ic.size()==0)&&(known.size()!=atom_.size())){ aout<<"\t\t WARNING: Undefined atoms\n"; return; } ICManager::IC & ic = ic_man.ic[0]; if(!ic.improper){ //build first 3 atoms atom_[ic.atomd[0]][0] = 0; atom_[ic.atomd[0]][1] = 0; atom_[ic.atomd[0]][2] = 0; known.insert(ic.atomd[0]); atom_[ic.atomd[1]][0] = ic.data[0]; atom_[ic.atomd[1]][1] = 0; atom_[ic.atomd[1]][2] = 0; known.insert(ic.atomd[1]); // double d = mdb.bondT(ic.atom_type[0], ic.atom_type[1]).equ_length(); double a = ic.data[1]; atom_[ic.atomd[2]][0] = ic.data[0] + d*cos(M_PI-a); atom_[ic.atomd[2]][1] = d*sin(M_PI-a); atom_[ic.atomd[2]][2] = 0; known.insert(ic.atomd[2]); } else { //build first 3 atoms atom_[ic.atomd[0]][0] = 0; atom_[ic.atomd[0]][1] = 0; atom_[ic.atomd[0]][2] = 0; known.insert(ic.atomd[0]); atom_[ic.atomd[2]][0] = ic.data[0]; atom_[ic.atomd[2]][1] = 0; atom_[ic.atomd[2]][2] = 0; known.insert(ic.atomd[2]); // double d = mdb.bondT(ic.atom_type[1], ic.atom_type[2]).equ_length(); double a = ic.data[1]; atom_[ic.atomd[1]][0] = ic.data[0] + d*cos(M_PI-a); atom_[ic.atomd[1]][1] = d*sin(M_PI-a); atom_[ic.atomd[1]][2] = 0; known.insert(ic.atomd[1]); } while(known.size()!=atom_.size()){ bool stop; bool left; ICManager::IC * ic = ic_man.next(known,left,stop); if(stop) break; //build if(left){ double coor[3]; build_left(coor, atom_[ic->atomd[1]].coor(), atom_[ic->atomd[2]].coor(), atom_[ic->atomd[3]].coor(), ic); atom_[ic->atomd[0]][0] = coor[0]; atom_[ic->atomd[0]][1] = coor[1]; atom_[ic->atomd[0]][2] = coor[2]; known.insert(ic->atomd[0]); ic->used = true; } else { known.insert(ic->atomd[3]); double coor[3]; build_right(coor, atom_[ic->atomd[0]].coor(), atom_[ic->atomd[1]].coor(), atom_[ic->atomd[2]].coor(), ic); atom_[ic->atomd[3]][0] = coor[0]; atom_[ic->atomd[3]][1] = coor[1]; atom_[ic->atomd[3]][2] = coor[2]; ic->used = true; } } if(almost::verbose()) if(known.size()==atom_.size()) aout<<"\t\t>> Generation of protein coor done \n"; else { aout<<"\t\t>> Missing coordinates!!!"< & data, string fpatch, string lpatch){ vector sequ = segment.sequence(); for(int i=0;i & sequ, MDB & mdb, vector & data, string fpatch, string lpatch){ for(int i=0;i> Build details:"<<"\n\n"; aout<<"\t>> Number of fragments: "<> Number of atoms: "<> Number of bonds: "; int nbonds= 0; for(int i=0;i> Number of angles: "<> Number of dihedrals: "<> Number of impropers: "<> Number of groups: "<> Number of fixed excl.: "< > M; vector > U; vector > S; vector > I; double tmp[3]; //Init matrices ... M.resize(3); U.resize(3); S.resize(3); I.resize(3); for(int i=0;i<3;i++){ M[i].resize(3); U[i].resize(3); S[i].resize(3); I[i].resize(3); } for(int i=0;i<3;i++) for(int j=0;j<3;j++){ if(i!=j) I[i][j]=0; else I[i][j]=1; } Coor3D n = axis; double norm= 0; for(int i=0;i<3;i++) norm +=n[i]*n[i]; norm = sqrt(norm); for(int i=0;i<3;i++) n[i] /=norm; for(int i =0; i<3;++i){ for(int j = 0;j<3;++j){ U[i][j]=n[i]*n[j]; S[i][j]=0; } } S[0][1] = -n[2]; S[1][0] = -S[0][1]; S[0][2] = n[1]; S[2][0] =-S[0][2]; S[1][2] = -n[0]; S[2][1] = -S[1][2]; double cosv = cos(angle); double sinv = sin(angle); for(int i =0; i<3;++i){ for(int j = 0;j<3;++j){ M[i][j] = U[i][j]+ cosv*(I[i][j]-U[i][j])+sinv*S[i][j]; } } for(int i=0;i> WARNING: no SASA parameters for atom: "<> WARNING: no EEF1 parameters for atom: "< & tmp_bonds = bonds(i); string name1 = p[i].type_name(); for(int j=0;j aa(i,tmp_bonds[j]); bond_data_[aa].set_bond_const(bt.bond_const()); bond_data_[aa].set_equ_length(bt.equ_length()); } } } //Angles { int size = angles().size(); Solvent & p = * this; for(int i=0;i at = mdb.angleT(name1,name2,name3); for(int aa=0;aa at = mdb.dihedralT(name1,name2,name3,name4); for(int aa=0;aa at = mdb.improperT(name1,name2,name3,name4); for(int aa=0;aa reg_types; Solvent &p = *this; int b = atom_offset(); int e = b + atom_size(); for(int i=b;i>WARNING atom type "<::iterator iter1 = reg_types.begin(), iter2 = reg_types.begin(), end = reg_types.end(); while(iter1!=end){ iter2 = reg_types.begin(); while(iter2!=end){ if(mdb.is_nbfixed(*iter1,*iter2)){ NBFix nbfix = mdb.nbfix(*iter1,*iter2); nbdata_.set_emin_fix(*iter1,*iter2,nbfix.e_min()); nbdata_.set_emin14_fix(*iter1,*iter2,nbfix.e_min14()); nbdata_.set_sigma_fix(*iter1,*iter2,nbfix.r_vdw()); nbdata_.set_sigma14_fix(*iter1,*iter2,nbfix.r_vdw14()); } ++iter2; } ++iter1; } } }