/*************************************************************************** rosemc.cpp - description ------------------- begin : Tue Nov 18 01:45:35 2003 copyright : (C) 1999-2006 by Cavalli Andrea author : : cavalli $ date : : 2003/12/09 11:10:33 $ id : : coor.h,v 1.1.2.2 2003/12/09 11:10:33 cavalli Exp $ email : cavalli@bioc.unizh.ch amc82@cam.ac.uk **************************************************************************/ /*************************************************************************** * * * 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 extern double score_silent(const Almost::Molecules & mols, string file); extern int sys_bflock(string f, int s); extern int sys_uflock(string f, int fd); namespace Almost { void RoseMC::thread(const Molecules & molecules, string mrg_file){ vector phi; vector psi; string SS; { //Read MRG file ifstream in; in.open(mrg_file.c_str()); istream_iterator iter(in),end; while(iter!=end){ ++iter; ++iter; phi.push_back(atof(iter->c_str())*M_PI/180.0);++iter; psi.push_back(atof(iter->c_str())*M_PI/180.0);++iter; ++iter; for(int i=0;i<6;i++) ++iter; SS += *iter;++iter; } } Coor coor; Protein p = molecules.protein(0); int size = p.fragment_size(); coor.resize(p.atom_size()); BondRotation br(p); vector N; vector C; vector CA; int b = p.atom_offset(); int e = p.atom_size()+p.atom_offset(); for(int i = b; iSize){ cout<<"Source protein to small ..."<::DIM*a; coor.coor[ipos] = p[a][0]; coor.coor[ipos+1] = p[a][1]; coor.coor[ipos+2] = p[a][2]; } //Ene double env = rose_ff->env_energy(coor); double pair= rose_ff->pair_energy(coor); // double ff = rose_ff->ff_energy(coor); //SS string ss_sub = string(SS.begin()+i,SS.begin()+i+size); double ss = rose_ff->ss_energy(coor,ss_sub); double bhb = rose_ff->bhb_energy(coor,ss_sub); cout<<"Energy thread "<1) // add_scramble(0.1,1,1213334); // } // srand48(options.seed); // bond_rot = new BondRotation(molecules); // steps = options.steps; // nprint = options.nprint; // ndump = options.ndump; // p_plain = options.p_plain; // p_3 = options.p_3; // begin_temp = options.begin_temp; // end_temp = options.end_temp; // sa_steps = options.sa_steps; // pdb = options.pdb; // best_pdb = options.best_pdb; // setup(molecules,true); // setup_rosemoves(molecules,options); // prot.resize(molecules.fragment_size()); // prot_buffer.resize(molecules.fragment_size()); // monte_carlo(mols); // cout<<"Run done"<1) // add_scramble(0.1,1,1213334); // } // srand48(options.seed); // bond_rot = new BondRotation(molecules); // steps = options.steps; // nprint = options.nprint; // ndump = options.ndump; // p_plain = options.p_plain; // p_3 = options.p_3; // begin_temp = options.begin_temp; // end_temp = options.end_temp; // sa_steps = options.sa_steps; // pdb = options.pdb; // setup(molecules); // setup_rosemoves(molecules,options); // prot.resize(molecules.fragment_size()); // prot_buffer.resize(molecules.fragment_size()); // monte_carlo(mols,ref_mol); // cout<<"Run done"<1) // add_scramble(0.1,1,1213334); // } // srand48(options.seed); // bond_rot = new BondRotation(molecules); // steps = options.steps; // nprint = options.nprint; // ndump = options.ndump; // p_plain = options.p_plain; // p_3 = options.p_3; // begin_temp = options.begin_temp; // end_temp = options.end_temp; // sa_steps = options.sa_steps; // pdb = options.pdb; // vdw_full = options.vdw_full; // setup(molecules); // setup_rosemoves(molecules,options); // prot.resize(molecules.fragment_size()); // prot_buffer.resize(molecules.fragment_size()); // monte_carlo_shx(mols,sh_file,ss,t); // cout<<"Run done"<apply(coor,secstruct,prot); } else { if(q<0.25) apply(coor); else{ double qq = drand48(); if(qq<0.5) f9->apply(coor,secstruct,prot); else{ if(f15){ f15->apply(coor,secstruct,prot); } else f9->apply(coor,secstruct,prot); } } } } else{ double q = drand48(); if(q<0.5) f3->apply_turn(coor,coor_buffer,secstruct,prot); else if(q<0.75) f9->apply_turn(coor,coor_buffer,secstruct,prot); else{ if(!sc_){ double qq = drand48(); if(qq<0.5) f9->apply(coor,secstruct,prot); else{ if(f15) f15->apply(coor,secstruct,prot); else f9->apply(coor,secstruct,prot); } } else apply(coor); } } if(rose_move==100) break; if(!check_ss()){ secstruct = secstruct_buffer; coor.assign(coor_buffer); } else break; } //Energy init_energy(current_ene); if(rose_metropolis(current_ene.energy,ene.energy,temp)){ //Accept if(was_rose) ++acc_rose; coor_buffer.assign(coor); if(dcd) dcd->write(coor_buffer); secstruct_buffer = secstruct; prot_buffer = prot; ene = current_ene; rej = 0; ++acc; if(ene.energywrite(coor_buffer); secstruct = secstruct_buffer; prot = prot_buffer; ++rej; acc = 0; } if((i%nprint)==0){ assign(molecules,coor_buffer); cout<<"Status "<ss_match){ cout<<"Equal "<<((double)c)/sec.size()<<" "<disable_hb(); ene.hb_energy = current_ene.hb_energy = best_ene.hb_energy = 0; } cout<<"DEBUG init done\n"; for(int KK=0;KK(sa_steps/2))&&(move_switchapply_turn(coor,secstruct,prot); f3->apply_turn(coor,coor_buffer,secstruct,prot); } else { f3->apply(coor,secstruct,prot); } if(rose_move==100) break; if(!check_ss()){ secstruct = secstruct_buffer; coor.assign(coor_buffer); } else break; } } //Energy rose_energy(current_ene,4);//From almost-0.99.2 if(rose_metropolis(current_ene.energy,ene.energy,temp)){ //Accept if(was_rose) ++acc_rose; coor_buffer.assign(coor); if(dcd) dcd->write(coor_buffer); secstruct_buffer = secstruct; prot_buffer = prot; ene = current_ene; rej = 0; ++acc; if(ene.energywrite(coor_buffer); secstruct = secstruct_buffer; prot = prot_buffer; ++rej; } if((i%nprint)==0){ assign(molecules,coor_buffer); cout<<"almost@rose> "< ref_coor(ref_mols); // double r[3][3]; // int rej = 0; // int acc = 0; // int rose = 0; // int acc_rose = 0; // bool was_rose = false; // double energy = rose_energy()+20*rmsd2_mat(coor,ref_coor,s1.result(),s2.result(),r); // double current_energy = energy; // int best_counter = 0; // best_energy = 10000; // coor_best.assign(coor_buffer); // double dT = (begin_temp-end_temp)/sa_steps; // for(int s=0;sapply(coor,secstruct,prot); // } // else { // f9->apply(coor,secstruct,prot); // } // if(rose_move==100) break; // if(!check_ss()){ // secstruct = secstruct_buffer; // coor.assign(coor_buffer); // } // else break; // } // } // //Energy // double rmsd = rmsd2_mat(coor,ref_coor,s1.result(),s2.result(),r); // current_energy = rose_energy()+20*rmsd; // if(rose_metropolis(current_energy,energy,temp)//&& // //(rmsd=1000){ // // best_counter= 0; // // coor_buffer.assign(coor_best); // // secstruct_buffer = secstruct_best; // // energy = best_energy; // // coor.assign(coor_best); // // secstruct = secstruct_best; // // current_energy = best_energy; // // cout<<"Resetting best"<<"\n"; // // } // } // // if((p_plain!=1)&&((double)acc_rose/(double)rose<0.01)){ // // p_plain =1; // // cout<<"p_plain set to 1"<(sa_steps/2))&&(move_switchapply(coor,secstruct,prot); // } // else { // f9->apply(coor,secstruct,prot); // } // if(rose_move==100) break; // if(!check_ss()){ // secstruct = secstruct_buffer; // coor.assign(coor_buffer); // } // else break; // } // } // //Energy // current_energy = rose_energy_ref(); // assign(buff_mol,coor); // double sc = score_silent(buff_mol,file); // double sc_old = sc; // sc = max(sc,t); // current_energy = current_energy/log(1+0.01*sc); // if(rose_metropolis(current_energy,energy,temp)){ // //Accept // if(was_rose) ++acc_rose; // coor_buffer.assign(coor); // secstruct_buffer = secstruct; // energy = current_energy; // rej = 0; // ++acc; // //cout<<"DEB HB "<=1000){ // // best_counter= 0; // // coor_buffer.assign(coor_best); // // secstruct_buffer = secstruct_best; // // energy = best_energy; // // coor.assign(coor_best); // // secstruct = secstruct_best; // // current_energy = best_energy; // // cout<<"Resetting best"<<"\n"; // // } // } // if((i%nprint)==0){ // cout<<"Debug "<(molecules,*bond_rot, options.seed3, options.frg3); f9 = new Fragment9(molecules,*bond_rot, options.seed9, options.frg9); if(options.frg15!="none") f15 = new Fragment15(molecules,*bond_rot, options.seed9, options.frg15); // lf9 = new LocalFragment(molecules,*bond_rot, // options.seed9, // options.frg9); } double RoseMC::init_energy(RoseMCEnergy & mc_energy){ mc_energy.clear(); // mc_energy.vdw_energy = max(0.0,rose_ff->ff_energy(coor)); mc_energy.cc_energy = 0; for(int i=0;ienergy(coor); } mc_energy.hb_energy = rose_ff->hb_energy(coor,secstruct); mc_energy.ss_energy = 4*rose_ff->ss_energy(coor,secstruct); mc_energy.summ(); return mc_energy.energy; } double RoseMC::rose_energy(RoseMCEnergy & mc_energy,double k){ mc_energy.clear(); mc_energy.vdw_energy = max(0.0,rose_ff->ff_energy(coor)); //APMF mc_energy.apmf_energy = rose_ff->apmf_energy(coor); mc_energy.cc_energy = 0; for(int i=0;ienergy(coor); } mc_energy.hb_energy = rose_ff->hb_energy(coor,secstruct); mc_energy.bhb_energy = rose_ff->bhb_energy(coor,secstruct); mc_energy.rgyr_energy = rose_ff->rgyr_energy(coor); mc_energy.ss_energy = k*rose_ff->ss_energy(coor,secstruct); mc_energy.summ(); return mc_energy.energy; } double RoseMC::rose_energy_ref(RoseMCEnergy & mc_energy){ mc_energy.clear(); mc_energy.vdw_energy = rose_ff->ff_energy(coor); //APMF mc_energy.apmf_energy = rose_ff->apmf_energy(coor); mc_energy.cc_energy = 0; for(int i=0;ienergy(coor); } mc_energy.hb_energy = rose_ff->hb_energy(coor,secstruct); mc_energy.bhb_energy = 0; mc_energy.bhb_energy = rose_ff->bhb_energy(coor,secstruct); mc_energy.rgyr_energy = rose_ff->rgyr_energy(coor); mc_energy.summ(); return mc_energy.energy; } } // Local Variables: // mode:C++ // End: