/*************************************************************************** mft_mod.cpp - description ------------------- begin : Tue May 15 08:10:32 2007 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 #include #ifdef __MFT__SC__ #include #include #include #include #include #endif #include using namespace Almost; #define ALMTOSTRING(s) \ template<> \ inline string to_string(const s & ){ \ return "<" #s ">"; \ } ALMTOSTRING(Molecules); extern vector aminoacids(); extern void prot2pdb(const Protein & prot, string ofile); extern void mol2pdb(const Molecules & prot, string ofile); namespace mft { #ifdef __MFT__SC__ vector get_atoms(const Molecules & molecules, string fname, string a1, string a2, string a3, string a4){ vector a; a.resize(4); for(int i=0;i<4;i++) a[i] = -1; { NameSelection s1(molecules,fname+"/"+a1); if(s1.result().size()==1) a[0] = *s1.result().begin(); else cout<<"Error in selection of "< a){ for(int i=0;i<4;i++) if(a[i]<0) return false; return true; } vector > get_rotamers_ala(const Molecules & molecules, string fname){ return vector >(); } vector > get_rotamers_gly(const Molecules & molecules, string fname){ return vector >(); } vector > get_rotamers_arg(const Molecules & molecules, string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","CG"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CA","CB","CG","CD"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CB","CG","CD","NE"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CG","CD","NE","CZ"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_asn(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","CG"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CA","CB","CG","OD1");//?? if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_asp(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","CG"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CA","CB","CG","OD1");//?? if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_cys(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","SG"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_gln(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","CG"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CA","CB","CG","CD"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CB","CG","CD","OE1"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_glu(const Molecules & molecules,string fname){ vector > res; vector a = get_atoms(molecules,fname,"N","CA","CB","CG"); if(is_ok(a)) res.push_back(a); { vector a = get_atoms(molecules,fname,"CA","CB","CG","CD"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CB","CG","CD","OE1"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_his(const Molecules & molecules,string fname){ vector > res; vector a = get_atoms(molecules,fname,"N","CA","CB","CG"); if(is_ok(a)) res.push_back(a); { vector a = get_atoms(molecules,fname,"CA","CB","CG","ND1"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_ile(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","CG1"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CA","CB","CG1","CD"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_leu(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","CG"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CA","CB","CG","CD1"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_lys(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","CG"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CA","CB","CG","CD"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CB","CG","CD","CE"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CG","CD","CE","NZ"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_met(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","CG"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CA","CB","CG","SD"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CB","CG","SD","CE"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_phe(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","CG"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CA","CB","CG","CD1"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_pro(const Molecules & molecules,string fname){ vector > res; return res; } vector > get_rotamers_ser(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","OG"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_thr(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","OG1"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_trp(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","CG"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CA","CB","CG","CD1"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_tyr(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","CG"); if(is_ok(a)) res.push_back(a); } { vector a = get_atoms(molecules,fname,"CA","CB","CG","CD1"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers_val(const Molecules & molecules,string fname){ vector > res; { vector a = get_atoms(molecules,fname,"N","CA","CB","CG1"); if(is_ok(a)) res.push_back(a); } return res; } vector > get_rotamers(const Molecules & m, string lname, string sname){ if(sname=="ALA") return get_rotamers_ala(m,lname); if(sname=="CYS") return get_rotamers_cys(m,lname); if(sname=="ASP") return get_rotamers_asp(m,lname); if(sname=="GLU") return get_rotamers_glu(m,lname); if(sname=="PHE") return get_rotamers_phe(m,lname); if(sname=="GLY") return get_rotamers_gly(m,lname); if(sname=="HIS") return get_rotamers_his(m,lname); if(sname=="ILE") return get_rotamers_ile(m,lname); if(sname=="LYS") return get_rotamers_lys(m,lname); if(sname=="LEU") return get_rotamers_leu(m,lname); if(sname=="MET") return get_rotamers_met(m,lname); if(sname=="ASN") return get_rotamers_asn(m,lname); if(sname=="PRO") return get_rotamers_pro(m,lname); if(sname=="GLN") return get_rotamers_gln(m,lname); if(sname=="ARG") return get_rotamers_arg(m,lname); if(sname=="SER") return get_rotamers_ser(m,lname); if(sname=="THR") return get_rotamers_thr(m,lname); if(sname=="VAL") return get_rotamers_val(m,lname); if(sname=="TRP") return get_rotamers_trp(m,lname); if(sname=="TYR") return get_rotamers_tyr(m,lname); return vector >(); } void assign_backbone(Protein &trg, const Protein & src){ int size = trg.fragment_size(); for(int aa=0;aa s1,s2; s1 = src.fragment_atoms(aa); s2 = trg.fragment_atoms(aa); int N1=-1,N2=-1,CA1=-1,CA2=-1,C1=-1,C2=-1,O1=-1,O2=-1; for(int q=0;q & opts, DunbrackLib & db, MDB & mdb, ostream &out){ int phi1 = m1.protein(0).phi()[aa1]*180.0/M_PI; int psi1 = m1.protein(0).psi()[aa1]*180.0/M_PI; string s1 = m1.fragment_name(aa1,Molecules::SHORT); { // stringstream str1; // str1<<"//"< seq; stringstream str; str< atm = m1.fragment_atoms(aa1); for(int i=0;i::reverse_iterator i1,i2,e1,e2; Coor coor(mols); stringstream str1; str1<<"//"< > r1 = get_rotamers(mols,str1.str(),s1); BondRotation br(mols,0); ForceField ff(mols,opts,mdb); i1 = db.rbegin(s1,phi1,psi1); e1 = db.rend(s1,phi1,psi1); if(r1.size()){ while(i1!=e1){ //set the first double *chi1 = i1->second.chi; for(int c = 0; c < r1.size();c++){ br.set_dihedral(coor, r1[c][0], r1[c][1], r1[c][2], r1[c][3], chi1[c]*(M_PI/180.0)); } EnergyData e = ff.energy(coor); out< e = ff.energy(coor); out< & opts, DunbrackLib & db, MDB & mdb, ostream &out){ //Build 2 facke proteins; Molecules mols; { Protein p1("P1"); string fpatch = "NONE"; string lpatch = "NONE"; if(aa1==0) fpatch = "DEFAULT"; if(aa1==m1.fragment_size()-1) lpatch = "DEFAULT"; vector seq; stringstream str; str< atm = m1.fragment_atoms(aa1); for(int i=0;i seq; stringstream str; str< atm = m2.fragment_atoms(aa2); // cout<<"DEBUG "< ff(mols,opts,mdb); // mol2pdb(mols,"db.pdb"); //Iterate thru rotamers BondRotation br(mols,0); int phi1 = m1.protein(0).phi()[aa1]*180.0/M_PI; int psi1 = m1.protein(0).psi()[aa1]*180.0/M_PI; string s1 = m1.fragment_name(aa1,Molecules::SHORT); int phi2 = m2.protein(0).phi()[aa2]*180.0/M_PI; int psi2 = m2.protein(0).psi()[aa2]*180.0/M_PI; string s2 = m2.fragment_name(aa2,Molecules::SHORT); //Remember to treat special cases with 0 rotames!!!! map::reverse_iterator i1,i2,e1,e2; Coor coor(mols); stringstream str1,str2; str1<<"//"< > r1 = get_rotamers(mols,str1.str(),s1); vector > r2 = get_rotamers(mols,str2.str(),s2); i1 = db.rbegin(s1,phi1,psi1); i2 = db.rbegin(s2,phi2,psi2); e1 = db.rend(s1,phi1,psi1); e2 = db.rend(s2,phi2,psi2); // cout<<"DEBUG apply rots"<second.chi; for(int c = 0; c < r1.size();c++){ br.set_dihedral(coor, r1[c][0], r1[c][1], r1[c][2], r1[c][3], chi1[c]*(M_PI/180.0)); } i2 = db.rbegin(s2,phi2,psi2); count2 = 0; while(i2!=e2){ //Apply double * chi2 = i2->second.chi; for(int c = 0; c < r2.size();c++){ br.set_dihedral(coor, r2[c][0], r2[c][1], r2[c][2], r2[c][3], chi2[c]*(M_PI/180.0)); } out< e = ff.energy(coor); out<second.chi; for(int c = 0; c < r2.size();c++){ br.set_dihedral(coor, r2[c][0], r2[c][1], r2[c][2], r2[c][3], chi2[c]*(M_PI/180.0)); } out< e = ff.energy(coor); out<second.chi; for(int c = 0; c < r1.size();c++){ br.set_dihedral(coor, r1[c][0], r1[c][1], r1[c][2], r1[c][3], chi1[c]*(M_PI/180.0)); } out< e = ff.energy(coor); out< e = ff.energy(coor); out< options, MDB & mdb, DunbrackLib & db, string outfile){ //1 Create fake polychains vector amino = aminoacids(); map mtemplate; for(int i=0;i seq; for(int a=0;a::iterator i1 = mtemplate.begin(), e1 = mtemplate.end(); while(i1!=e1){ int size = i1->second.fragment_size(); for(int aa1=0;aa1second,aa1,options,db,mdb,out); ++i1; } } out<<"EndSelf\n"; //inter { map::iterator i1 = mtemplate.begin(), i2 = mtemplate.begin(), e1 = mtemplate.end(), e2 = mtemplate.end(); while(i1!=e1){ i2 = mtemplate.begin(); while(i2!=e2){ int size = i1->second.fragment_size(); for(int aa1=0;aa1second,i2->second,aa1,aa2,options,db,mdb,out); } } ++i2; } ++i1; } } } class MFTSolve { //Data typedef map SiteDouble; typedef map > SiteVector; typedef map > SiteIVector; typedef map > > > SiteMatrix; vector W; // vector Size; vector E; vector Eref; vector > Eint; public: MFTSolve(){} void read_tables(string file){ ifstream in; in.open(file.c_str()); istream_iterator iter(in),end; while(iter!=end){ string tok = *iter; ++iter; if(tok=="EndSelf") break; string aa = *iter; ++iter; int pos = atoi(iter->c_str()); ++iter; if(pos>=W.size()){ W.resize(pos+1); E.resize(pos+1); } int size = atoi(iter->c_str()); ++iter; W[pos][aa].resize(size); E[pos][aa].resize(size); for(int i=0;ic_str()); ++iter; tmp = atof(iter->c_str()); ++iter; e += tmp; tmp = atof(iter->c_str()); ++iter; e += tmp; tmp = atof(iter->c_str()); ++iter; e += tmp; E[pos][aa][i] = e; } } cout<<"Site size "<first; i2=W[j].begin(); while(i2!=e2){ string aa2 = i2->first; // cout<<"DEBUG res Eint "<c_str()); ++iter; int rot1 = atoi(iter->c_str()); ++iter; string aa2 = *iter; ++iter; int pos2 = atoi(iter->c_str()); ++iter; int rot2 = atoi(iter->c_str()); ++iter; double e = 0; double tmp; tmp = atof(iter->c_str()); ++iter; tmp = atof(iter->c_str()); ++iter; e += tmp; tmp = atof(iter->c_str()); ++iter; e += tmp; tmp = atof(iter->c_str()); ++iter; e += tmp; // cout<<"DEB "<=Eint[pos1][pos2][aa1][aa2].size()){ cout<=Eint[pos1][pos2][aa1][aa2][rot1].size()){ cout<0) cout< > aa_prob; aa_prob.resize(W.size()); for(int i=0;ifirst; double w = 0; for(int qq=0;qqsecond.size();qq++){ w += iter->second[qq]; } cout<\n"; for(int i=0;isecond); } cout<<"\n"; // map seqs; // for(int i=0;i< } void solve(double T){ //init W init_W(); double error; int step = 0; double beta = 1/T; // { Eref = E; for(int i=0;isecond.size(); qref = T*log(qref); for(int q=0;qsecond.size();q++) iter->second[q] = qref; ++iter; } } } error = iterate_W(beta); ++step; while(error> 0.000001){ error = iterate_W(beta); ++step; aout<<"Step "<second.size(); double w = 1.0/(double)s; for(int q=0;qsecond[q] = w; ++iter; } } } double iterate_W(double beta){ int size = W.size(); double error =0; for(int i=0;i & e = iter->second; for(int i=0;isecond.size(); for(int q=0;qfirst][q]-logZ; iter->second[q]= exp(logw); error += (iter->second[q]-w_old[iter->first][q])* (iter->second[q]-w_old[iter->first][q]); // cout<<"DEBUG err "<second[q]<<" " // <first][q]<< // endl; } ++iter; } W[site] = w; return error; } } void compute_Ene( SiteVector & ene, int site){ init_site_vector(ene,site); int size = W.size(); SiteVector::iterator iter = ene.begin(), end = ene.end(); while(iter!=end){ string aa1 = iter->first; int rot_size1 = iter->second.size(); for(int r1 = 0;r1first; int rot_size2 = i2->second.size(); for(int r2=0;r2site) energy += W[qq][aa2][r2]*Eint[idx1][idx2][aa1][aa2][r1][r2]; else energy += W[qq][aa2][r2]*Eint[idx1][idx2][aa2][aa1][r2][r1]; } ++i2; } } ene[aa1][r1] = energy; } ++iter; } } void init_site_vector(SiteVector & ene,int site){ // ene = W[site]; SiteVector::iterator iter = W[site].begin(), end = W[site].end(); while(iter!=end){ ene[iter->first].resize(iter->second.size()); for(int i=0;isecond.size();i++){ ene[iter->first][i] = 0; } ++iter; } } }; #endif class MFTResSolve { typedef map SiteVector; typedef map > SiteMatrix; vector W; vector E; vector > Eint; public: MFTResSolve(string tbl){ read_tables(tbl); } void print_amino_frq(){ vector > aa_prob; aa_prob.resize(W.size()); for(int i=0;isecond)] = iter->first; ++iter; } } cout<<"\n\n"; for(int i=0;ifirst<<" "; printf("%4.4f ",iter->second); WW += iter->second; ++iter; } cout<<"("<\n"; for(int i=0;isecond); } cout<<"\n"; } void solve(double T){ //init W init_W(); double error; int step = 0; double beta = 1/T; error = iterate_W(beta); ++step; while(error> 0.000001){ error = iterate_W(beta); ++step; aout<<"Step "< init, vector pos){ set mut; for(int i=0;i seq = init; vector seq_buff = init; steps = steps/10; double e = mc_energy(seq); for(int qq=10;qq>=1;qq--){ for(int i=0;i nat){ double enat = mc_energy(nat); vector seq; vector seq_buff; steps = steps/10; seq.resize(E.size()); for(int i=0;i=1;qq--){ for(int i=0;i & seq){ double e = 0; for(int i=0;i qq = aminoacids(); vector seq; double e = 0; double e2; seq.resize(E.size()); for(int i=0;i & seq){ static vector qq = aminoacids(); for(int ww=0;ww<2;ww++){ int pos = lrand48()%seq.size(); int a = lrand48()%20; seq[pos] = qq[a]; } } void mc_move(vector & seq,set & pos){ static vector qq = aminoacids(); int p = lrand48()%pos.size(); int q = lrand48()%20; set::iterator iter = pos.begin(); int count = 0; while(count iter(in),end; //self //Site aa nsite double while(iter!=end){ string tok = *iter; ++iter; if(tok=="EndSelf") break; string aa = *iter; ++iter; int pos = atoi(iter->c_str()); ++iter; if(pos>=W.size()){ W.resize(pos+1); E.resize(pos+1); } double ene = atof(iter->c_str()); ++iter; E[pos][aa] = ene; } Eint.resize(W.size()); for(int i=0;ic_str());++iter; string aa1 = *iter; ++iter; int pos2 = atoi(iter->c_str());++iter; string aa2 = *iter; ++iter; double e = atof(iter->c_str());++iter; Eint[pos1][pos2][aa1][aa2] = e; Eint[pos2][pos1][aa2][aa1] = e; } } void init_W(){ W = E; int size = W.size(); for(int i=0;isecond = q; ++iter; } } } double iterate_W(double beta){ int size = W.size(); double error =0; for(int i=0;isecond; else logZ = logZ +log1p(exp(-beta*iter->second-logZ)); // cout<<"DEBUG energy "<second<<" "<< logZ<<" "<first]-logZ; iter->second= exp(logw); error += (iter->second-w_old[iter->first])* (iter->second-w_old[iter->first]); ++iter; } W[site] = w; return error; } } void compute_Ene( SiteVector & ene, int site){ init_site_vector(ene,site); int size = W.size(); SiteVector::iterator iter = ene.begin(), end = ene.end(); while(iter!=end){ string aa1 = iter->first; double energy = 0; double eneint = 0; energy = E[site][aa1]; //self energy for(int qq = 0; qq < size; qq++){ if(qq==site) continue; SiteVector::iterator i2 = W[qq].begin(), e2 = W[qq].end(); while(i2!=e2){ string aa2 = i2->first; eneint += W[qq][aa2]*Eint[site][qq][aa1][aa2]; ++i2; } } // cout<<"DEBUG "<first] = 0; ++iter; } } }; void read_res_map(map & aa,istream_iterator & iter){ while(1){ string s1 = *iter; ++iter; if(s1=="BEGIN"){// cout<<"BEGIN"<c_str()); ++iter; aa[s1] = p; } } void read_pair(map > & aa, istream_iterator & iter){ // cout<<"DEBUG READ_PAIR"<c_str()); ++iter; aa[s1][s2] = p; } } void to3(string &s){ for(int i=0;i > & cstat, istream_iterator & iter){ int n = -1; while(1){ string s1 = *iter;++iter; if(s1=="BEGIN"){ n = atoi(iter->c_str());++iter; cout<<"DEBUG BEGIN "<c_str());++iter; cout<<"DEBUG END "<c_str());++iter; cstat[n][s1] = p; } } } void count_n(const Molecules & m, vector &n){ vector seq = m.sequence(2); vector CA; for(int i=0;i=20) n[i]=19; } } void mkres_tables(const Molecules & m, string tbl_file, string file){ ifstream tbl; tbl.open(tbl_file.c_str()); istream_iterator iter(tbl),end; map > cstat; map aa; map aa_H; map aa_E; map aa_C; map > AA; map > d_1; map > d_2; map > d_3; map > d_4; map > d_1HH; map > d_2HH; map > d_3HH; map > d_4HH; map > d_1EE; map > d_2EE; map > d_3EE; map > d_4EE; map > d_1CC; map > d_2CC; map > d_3CC; map > d_4CC; map > d_1HC; map > d_2HC; map > d_3HC; map > d_4HC; map > d_1CH; map > d_2CH; map > d_3CH; map > d_4CH; map > d_1EC; map > d_2EC; map > d_3EC; map > d_4EC; map > d_1CE; map > d_2CE; map > d_3CE; map > d_4CE; map > d_1HE; map > d_2HE; map > d_3HE; map > d_4HE; map > d_1EH; map > d_2EH; map > d_3EH; map > d_4EH; read_cont_stat(cstat,iter); cout<<"AA"<<" "; read_res_map(aa,iter); cout<<"AA_H"<<" "; read_res_map(aa_H,iter); cout<<"AA_E"<<" "; read_res_map(aa_E,iter); cout<<"AA_C"<<" "; read_res_map(aa_C,iter); cout<<"AA"<<" "; read_pair(AA,iter); cout<<"d1"<<" "; read_pair(d_1,iter); cout<<"d2"<<" "; read_pair(d_2,iter); cout<<"d3"<<" "; read_pair(d_3,iter); cout<<"d4"<<" "; read_pair(d_4,iter); cout<<"d1_HH"<<" "; read_pair(d_1HH,iter); cout<<"d1_EE"<<" "; read_pair(d_1EE,iter); cout<<"d1_CC"<<" "; read_pair(d_1CC,iter); cout<<"d1_CH"<<" "; read_pair(d_1CH,iter); cout<<"d1_HC"<<" "; read_pair(d_1HC,iter); cout<<"d1_CE"<<" "; read_pair(d_1CE,iter); cout<<"d1_EC"<<" "; read_pair(d_1EC,iter); cout<<"d1_HE"<<" "; read_pair(d_1HE,iter); cout<<"d1_EH"<<" "; read_pair(d_1EH,iter); cout<<"d2_HH"<<" "; read_pair(d_2HH,iter); cout<<"d2_EE"<<" "; read_pair(d_2EE,iter); cout<<"d2_CC"<<" "; read_pair(d_2CC,iter); cout<<"d2_CH"<<" "; read_pair(d_2CH,iter); cout<<"d2_HC"<<" "; read_pair(d_2HC,iter); cout<<"d2_CE"<<" "; read_pair(d_2CE,iter); cout<<"d2_EC"<<" "; read_pair(d_2EC,iter); cout<<"d2_HE"<<" "; read_pair(d_2HE,iter); cout<<"d2_EH"<<" "; read_pair(d_2EH,iter); cout<<"d3_HH"<<" "; read_pair(d_3HH,iter); cout<<"d3_EE"<<" "; read_pair(d_3EE,iter); cout<<"d3_CC"<<" "; read_pair(d_3CC,iter); cout<<"d3_CH"<<" "; read_pair(d_3CH,iter); cout<<"d3_HC"<<" "; read_pair(d_3HC,iter); cout<<"d3_CE"<<" "; read_pair(d_3CE,iter); cout<<"d3_EC"<<" "; read_pair(d_3EC,iter); cout<<"d3_HE"<<" "; read_pair(d_3HE,iter); cout<<"d3_EH"<<" "; read_pair(d_3EH,iter); cout<<"d4_HH"<<" "; read_pair(d_4HH,iter); cout<<"d4_EE"<<" "; read_pair(d_4EE,iter); cout<<"d4_CC"<<" "; read_pair(d_4CC,iter); cout<<"d4_CH"<<" "; read_pair(d_4CH,iter); cout<<"d4_HC"<<" "; read_pair(d_4HC,iter); cout<<"d4_CE"<<" "; read_pair(d_4CE,iter); cout<<"d4_EC"<<" "; read_pair(d_4EC,iter); cout<<"d4_HE"<<" "; read_pair(d_4HE,iter); cout<<"d4_EH"<<" "; read_pair(d_4EH,iter); //Comp sec AlmSecStruct ss(m); Coor c(m); string s = ss.secstruct(c); to3(s); ofstream out; out.open(file.c_str()); //Self vector N; count_n(m,N); int n = s.size(); vector ax = aminoacids(); for(int i=0;i fra = m.fragment_atoms(i); for(int qq1=0;qq1 fra2 = m.fragment_atoms(j); for(int qq1=0;qq1=5){ P = d_2HH[a1][a2]; } else if(d<10&&d>=7.5){ P = d_2HH[a1][a2]; } else if(d<12&&d>=10){ P = d_2HH[a1][a2]; } else { P=1; } } else if(ss1=='E'&&ss2=='E'){ if(d<5){ P = d_1EE[a1][a2]; } else if(d<7.5&&d>=5){ P = d_2EE[a1][a2]; } else if(d<10&&d>=7.5){ P = d_2EE[a1][a2]; } else if(d<12&&d>=10){ P = d_2EE[a1][a2]; } else { P=1; } } else if(ss1=='C'&&ss2=='C'){ if(d<5){ P = d_1CC[a1][a2]; } else if(d<7.5&&d>=5){ P = d_2CC[a1][a2]; } else if(d<10&&d>=7.5){ P = d_2CC[a1][a2]; } else if(d<12&&d>=10){ P = d_2CC[a1][a2]; } else { P=1; } } else if(ss1=='H'&&ss2=='C'){ if(d<5){ P = d_1HC[a1][a2]; } else if(d<7.5&&d>=5){ P = d_2HC[a1][a2]; } else if(d<10&&d>=7.5){ P = d_2HC[a1][a2]; } else if(d<12&&d>=10){ P = d_2HC[a1][a2]; } else { P=1; } } if(ss1=='C'&&ss2=='H'){ if(d<5){ P = d_1CH[a1][a2]; } else if(d<7.5&&d>=5){ P = d_2CH[a1][a2]; } else if(d<10&&d>=7.5){ P = d_2CH[a1][a2]; } else if(d<12&&d>=10){ P = d_2CH[a1][a2]; } else { P=1; } } else if(ss1=='E'&&ss2=='C'){ if(d<5){ P = d_1EC[a1][a2]; } else if(d<7.5&&d>=5){ P = d_2EC[a1][a2]; } else if(d<10&&d>=7.5){ P = d_2EC[a1][a2]; } else if(d<12&&d>=10){ P = d_2EC[a1][a2]; } else { P=1; } } if(ss1=='C'&&ss2=='E'){ if(d<5){ P = d_1CE[a1][a2]; } else if(d<7.5&&d>=5){ P = d_2CE[a1][a2]; } else if(d<10&&d>=7.5){ P = d_2CE[a1][a2]; } else if(d<12&&d>=10){ P = d_2CE[a1][a2]; } else { P=1; } } else if(ss1=='E'&&ss2=='H'){ if(d<5){ P = d_1EH[a1][a2]; } else if(d<7.5&&d>=5){ P = d_2EH[a1][a2]; } else if(d<10&&d>=7.5){ P = d_2EH[a1][a2]; } else if(d<12&&d>=10){ P = d_2EH[a1][a2]; } else { P=1; } } if(ss1=='H'&&ss2=='E'){ if(d<5){ P = d_1HE[a1][a2]; } else if(d<7.5&&d>=5){ P = d_2HE[a1][a2]; } else if(d<10&&d>=7.5){ P = d_2HE[a1][a2]; } else if(d<12&&d>=10){ P = d_2HE[a1][a2]; } else { P=1; } } double Pss1,Pss2; if(ss1=='H') Pss1 = aa_H[a1]; else if(ss1=='E') Pss1 = aa_E[a1]; else if(ss1=='C') Pss1 = aa_C[a1]; if(ss2=='H') Pss2 = aa_H[a2]; else if(ss2=='E') Pss2 = aa_E[a2]; else if(ss2=='C') Pss2 = aa_C[a2]; // if(d<12) // cout<<"DEBUG 2"<<" "< env(m,1); // EnvPairConst envpair(m,1); // Coor coor(m); // ofstream out; // out.open(file.c_str()); // //Self // vector aa = aminoacids(); // int size = m.fragment_size(); // for(int i=0;i inline string to_string(const mft::MFTSolve & pdb){ return ""; } #endif template<> inline string to_string(const mft::MFTResSolve & pdb){ return ""; } extern "C" { void init_mft(){ //declarations here Module mod = Module("mft"); #ifdef __MFT__SC__ mod.def_function("mkenergy_tables","Creates mft energy tables",mft::mkenergy_tables); Class(mod.self(),"solver") .def_method("solve",&mft::MFTSolve::solve) .def_method("read_tables",&mft::MFTSolve::read_tables); #endif mod.def_function("mkres_tables","",mft::mkres_tables); Class >(mod.self(),"ressolver") .def_method("solve",&mft::MFTResSolve::solve) .def_method("mc_solve",&mft::MFTResSolve::mc_solve) .def_method("mc_solve_sub",&mft::MFTResSolve::mc_solve_sub) .def_method("energy",&mft::MFTResSolve::mc_energy) .def_method("random",&mft::MFTResSolve::random) ; } }