/*************************************************************************** cheshire_mod.cpp - description ------------------- begin : Mon Dec 17 11:23:57 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 #include #include #include using namespace Almost; using namespace std; extern Coor mols_coor(const Molecules & molecules); void cheshire_bootstrap_pdb(string name, string shx_file, string pdb_file, string mdb_file){ //Make fasta MDB mdb(mdb_file.c_str()); PDB pdb(pdb_file.c_str()); Protein p(name); p.build_missing(pdb[0][0],mdb,"DEFAULT","DEFAULT"); vector seq = p.sequence(Protein::SHORT); string fasta_seq; for(int i=0;i> Sequence "<"<> FATAL ERROR: can't open "+name+".fasta"; } } string sec; { Molecules m; m.add_protein(p); //Secondary structure AlmSecStruct ss(m); sec = ss.secstruct(mols_coor(m)); aout<<">> Secondary structure: "< ha,h,n,ca,cb,c; { ifstream in; in.open(shx_file.c_str()); if(!in) throw ">> FATAL ERROR: can't open "+shx_file; istream_iterator iter(in),end; while(iter!=end){ ++iter;++iter; ha.push_back(atof(iter->c_str()));++iter; h.push_back(atof(iter->c_str()));++iter; n.push_back(atof(iter->c_str()));++iter; ca.push_back(atof(iter->c_str()));++iter; cb.push_back(atof(iter->c_str()));++iter; c.push_back(atof(iter->c_str()));++iter; } } vector phi = p.phi(); vector psi = p.psi(); vector omega = p.omega(); ofstream mrg; mrg.open((name+".mrg").c_str()); for(int i=0;i> FATAL ERROR: can't open "+fasta_file; istream_iterator iter(f),end; while(iter!=end){ if((*iter)[0]!='>') fasta_seq += *iter; ++iter; } } aout<<">> Sequence "< ha,h,n,ca,cb,c; { ifstream in; in.open(shx_file.c_str()); if(!in) throw ">> FATAL ERROR: can't open "+shx_file; istream_iterator iter(in),end; while(iter!=end){ ++iter;++iter; ha.push_back(atof(iter->c_str()));++iter; h.push_back(atof(iter->c_str()));++iter; n.push_back(atof(iter->c_str()));++iter; ca.push_back(atof(iter->c_str()));++iter; cb.push_back(atof(iter->c_str()));++iter; c.push_back(atof(iter->c_str()));++iter; } } ofstream mrg; mrg.open((name+".mrg").c_str()); for(int i=0;i & m, int nbest){ map mm; map::iterator iter= m.begin(), end = m.end(); while(iter!=end){ mm[iter->second] = iter->first; ++iter; } int pos = lrand48()%(min(nbest,(int)mm.size())); { map::iterator iter= mm.begin(), end = mm.end(); int count = 0; while(iter!=end){ if(count==pos) return iter->second; ++iter; ++count; } //?? Should never get here return mm.begin()->second; } } extern "C" { void init_cheshire(){ //declarations here Module mod = Module("cheshire","Chemocal shift restraints"); mod.def_function("bootstrap_pdb","",cheshire_bootstrap_pdb); mod.def_function("bootstrap","",cheshire_bootstrap); mod.def_function("best_random","",che_random_path); } }