/*************************************************************************** fragments_mod.cpp - description ------------------- begin : Thu May 12 09:02:53 2005 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 #include #include #include #include #include #include #include #include #include #include #include #include #define NHATOMS 43 #include #undef NHATOMS #include #include #include #include using namespace Almost; #define ALMTOSTRING(s) \ template<> \ inline string to_string(const s & ){ \ return "<" #s ">"; \ } ALMTOSTRING(Molecules); ALMTOSTRING(MDB); static inline vector split(string s,char c=' '){ string t; vector r; int i=0; while(i N,C,CA; vector< vector > const_seeds; public: CBMC(const Molecules & molecules,string file){ ifstream in; in.open(file.c_str()); if(!in){ cout<<"FATAL ERROR: no such file "< seq = molecules.protein(0).sequence(1); vector current_seq; vector PHI; vector PSI; //first 5 { for(int i=0;i<5;i++) current_seq.push_back(seq[i]); Protein p("st5"); PHI.resize(5); PSI.resize(5); for(int i=0;i<5;i++) getrama(i,PHI[i],PSI[i]); p.build_sequ(current_seq,mdb,"DEFAULT","DEFAULT"); setrama(p,PHI,PSI); EnergyOptions opts; // opts.solv = 0; { Molecules tmp; tmp.add_protein(p); sd(tmp,opts,mdb,10000,0.001); mesurerama(tmp,PHI,PSI); } } for(int i = 5;i opts; // opts.solv = 0; Molecules tmp; tmp.add_protein(p); sd(tmp,opts,mdb,10000,0.001); mesurerama(tmp,PHI,PSI); char buff[25]; sprintf(buff,"cbmc_%i.pdb",i); mol2pdb(tmp, buff); } } private: void parse(const Molecules & molecules, ifstream & in){ const_seeds.resize(molecules.fragment_size()); istream_iterator iter(in),end; //Format num phi psi omega while(iter!=end){ int num = atoi((*iter).c_str()); ++iter; if((num<1)||(num>molecules.fragment_size())){ cout<<"FATAL ERROR: invalid fragment number!"< &PHI, vector &PSI){ BondRotation bond_rotation(p,1); vector coor; for(int i= p.atom_offset(); i(p[i].coor())); //first int prev = -1; int curr = 0; int next = 1; int size = p.fragment_size(); if(PSI[0]!=999) bond_rotation.set_dihedral(coor,N[curr],CA[curr],C[curr],N[next],PSI[0]); for(int i=1;i1){ int q = const_seeds[i].size(); ResidueConst &rc = const_seeds[i][lrand48()%q]; if(rc.phi!=999){ phi = M_PI/180.0*rc.phi+5.0*(drand48()-0.5); } else phi = 999; if(rc.psi!=999){ psi = M_PI/180.0*rc.psi+5.0*(drand48()-0.5); } else psi = 999; } else { phi =999; psi =999;} } void mesurerama(const Molecules & m, vector & PHI, vector & PSI){ //0 PSI[0] = Kernel::Geometry::dihedral(m[N[0]].coor(), m[CA[0]].coor(), m[C[0]].coor(), m[N[1]].coor()); int size = m.fragment_size(); for(int i=1;i > const_seeds; vector current_const; vector N,CA,C; map, vector > cm; public: Dihe2ContactMap(const Molecules & molecules, const MDB & mdb, string file) { ifstream in; in.open(file.c_str()); if(!in){ cout<<"FATAL ERROR: no such file "< bond_rotation(molecules.protein(0)); EnergyOptions ene_opts; for(int i=0;i(molecules, ene_opts, mdb,500, 0.001); if(steps%100){ char buffer[256]; sprintf(buffer,"test_%i.pdb",i); mol2pdb(molecules,buffer); } for(int a=0;a p(a,b); double d = molecules.distance(CA[a],CA[b]); cm[p].push_back(d); } } } ofstream out; out.open("CM.dat"); map, vector >::iterator iter=cm.begin(),end=cm.end(); while(iter!=end){ out<first.first<<" "<first.second<<" : "; for(int i=0;isecond.size();i++) out<second[i]<<" "; out<<"\n"; ++iter; } } private: void parse(const Molecules & molecules, ifstream & in){ const_seeds.resize(molecules.fragment_size()); istream_iterator iter(in),end; //Format num phi psi omega while(iter!=end){ int num = atoi((*iter).c_str()); ++iter; if((num<1)||(num>molecules.fragment_size())){ cout<<"FATAL ERROR: invalid fragment number!"< &bond_rotation){ for(int k=0;k0){ int r = lrand48(); r = r%const_seeds[k].size(); rc = const_seeds[k][r]; if(rc.phi!=999){ set_torsion2(molecules.protein(0),C[k-1],N[k],CA[k],C[k], rc.phi*(M_PI/180.0),bond_rotation); } if(rc.psi!=999){ set_torsion2(molecules.protein(0),N[k],CA[k],C[k],N[k+1], rc.psi*(M_PI/180.0),bond_rotation); } } } } }; void dump_rdbp(const RoseDBProtein & p){ cout<0.005) continue; ++data; for(int q=0;q<25;q++){ //Print //Input for each amino-acid // 20 profiles 20 for type 4 chemical-shift 1 termini // total (20+20+5)*25 = 1125 (!) for(int pos =0;pos<20;pos++){ out<0.2) continue; ++data; for(int q=-12;q<=12;q++){ //Print //Input for each amino-acid // 20 profiles 1 termini // total (20+20+5)*25 = 1125 (!) if(k+q>=0&&k+q=end) out<<0<<" "; else out<<1<<" "; } out<<"\n"; //Output // for(int q=0;q<25;q++){ char c = p.ss[k]; if(c=='H'||c=='G'||c=='I') out<<1<<" "<<0<<" "<<0<<" "; else if(c=='E'||c=='B') out<<0<<" "<<1<<" "<<0<<" "; else out<<0<<" "<<0<<" "<<1<<" "; // } out<<"\n"; } cerr<<"Number of data sets: "< > mtx; Utils::read_mtx(mtxf,mtx); ofstream out; out.open(outf.c_str()); if(!out) throw "Unable to open file."; int s = ss.size(); int end = s; out<=0&&k+q=end) out<<0<<" "; else out<<1<<" "; } out<<"\n"; //Output // for(int q=0;q<25;q++){ char c = ss[k]; if(c=='H'||c=='G'||c=='I') out<<1<<" "<<0<<" "<<0<<" "; else if(c=='E'||c=='B') out<<0<<" "<<1<<" "<<0<<" "; else out<<0<<" "<<0<<" "<<1<<" "; // } out<<"\n"; } } #undef logistic //Scoring functions // class REM { // // // public: // void run(); // }; void rc_cs(string seq, const RoseDB & rosedb){ // if(seq.size()<3) return; vector n; vector HA; vector N; vector CA; vector CB; vector n_c; vector HA_c; vector N_c; vector CA_c; vector CB_c; int size = seq.size()-1; { n.resize(size); HA.resize(size); N.resize(size); CA.resize(size); CB.resize(size); n_c.resize(size); HA_c.resize(size); N_c.resize(size); CA_c.resize(size); CB_c.resize(size); } for(int p=0;p inline string to_string(const CBMC &){ return ""; } template<> inline string to_string(const Dihe2ContactMap &){ return ""; } template<> inline string to_string(const Rosetta &){ return ""; } template<> inline string to_string(const RoseDBProtein & p){ return ""; } template<> inline string to_string(const RoseDB& p){ return ""; } extern "C" { void init_fragments(){ //declarations here Module mod = Module("fragments","Fragment replacement tools"); Class >(mod.self(),"cbmc") .def_method("build",&CBMC::build) ; Class >(mod.self(),"dihe2cm") .def_method("run",&Dihe2ContactMap::run); Class >(mod.self(),"rosetta") .def_method("stone",&Rosetta::stone) //OK .def_method("shx",&Rosetta::shx) //OK (compiles) .def_method("shx_talos",&Rosetta::shx_talos) //OK (comp) // .def_method("talos",&Rosetta::talos) todo .def_method("prf",&Rosetta::prf) //OK .def_method("prf_monitor",&Rosetta::prf_monitor) //OK .def_method("best",&Rosetta::best) //OK .def_method("shx_prf",&Rosetta::shx_prf) .def_method("shx_prf_talos",&Rosetta::shx_prf_talos) .def_method("reref_ha",&Rosetta::reref_ha) .def_method("reref_h",&Rosetta::reref_h) .def_method("reref_n",&Rosetta::reref_n) .def_method("reref_ca",&Rosetta::reref_ca) .def_method("reref_cb",&Rosetta::reref_cb) .def_method("reref_c",&Rosetta::reref_c) .def_method("topos_prf",&Rosetta::topos_prf) .def_attribute("use_HA",&Rosetta::use_HA,"Undocumented") .def_attribute("use_H",&Rosetta::use_H,"Undocumented") .def_attribute("use_N",&Rosetta::use_N,"Undocumented") .def_attribute("use_CA",&Rosetta::use_CA,"Undocumented") .def_attribute("use_CB",&Rosetta::use_CB,"Undocumented") .def_attribute("use_C",&Rosetta::use_C,"Undocumented") .def_attribute("C_ref",&Rosetta::C_ref,"Undocumented") .def_attribute("N_ref",&Rosetta::N_ref,"Undocumented") .def_attribute("H_ref",&Rosetta::H_ref,"Undocumented") .def_attribute("keep",&Rosetta::keep,"Undocumented") ; Class(mod.self(),"rosedbprotein"); Class(mod.self(),"rosedb") .def_method("add_protein",&RoseDB::add_protein) .def_method("from_files",&RoseDB::from_files) .def_method("from_file",&RoseDB::from_file) .def_method("from_file_lists",&RoseDB::from_file_lists) .def_method("dump",&RoseDB::dump) ; mod.def_function("dump","dump",&dump_rdbp); mod.def_function("rose_db_protein_from_files","Read roses",&rose_db_protein_from_files); mod.def_function("dump_fann","Generates fann trainig file.",&dump_fann); mod.def_function("dump_psipred","Generates fann trainig file.",&dump_psipred); mod.def_function("dump_psipred_test","Generates fann testing file.",&dump_psipred_test); mod.def_function("rc_cs","Computer random coil chemical shifts.",&rc_cs); mod .def_const("SHORT",(int)Rosetta::SHORT) .def_const("LONG",(int)Rosetta::LONG) ; } }