/*************************************************************************** bmbr_mod.cpp - description ------------------- begin : Thu Nov 23 15:06:49 2006 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 using namespace Almost; using namespace std; class BMBR { int data_set; map , map > data; bool cs_reference; bool cs_list; public: BMBR(string file, string pdbfile){ ifstream in; in.open(file.c_str()); if(!in){ string err = "File not found: "+file; throw err.c_str(); } cs_reference = false; cs_list = false; parse(in); //Dump data map seq; map ha; map h; map n; map ca; map cb; map c; map , map >::iterator iter = data.begin(), end = data.end(); while(iter!=end){ int aa = iter->first.second; seq[aa] = iter->first.first; map::iterator i1 = iter->second.begin(), e1 = iter->second.end(); while(i1!=e1){ if(i1->first=="HA"||i1->first=="HA2") ha[aa] = i1->second; if(i1->first=="H") h[aa] = i1->second; if(i1->first=="N") n[aa] = i1->second; if(i1->first=="CA") ca[aa] = i1->second; if(i1->first=="CB") cb[aa] = i1->second; if(i1->first=="C") c[aa] = i1->second; ++i1; } ++iter; } PDB pdb(pdbfile); vector pdbseq = pdb[0][0].sequence(PDBSegment::ICODE); for(int i=0;i > data; map::iterator i1 = seq.begin(),e1 = seq.end(); while(i1!=e1){ char buff[256]; int aa = i1->first; sprintf(buff,"%s_%i", i1->second.c_str(), i1->first); data[buff].push_back(ha[aa]); data[buff].push_back(h[aa]); data[buff].push_back(n[aa]); data[buff].push_back(ca[aa]); data[buff].push_back(cb[aa]); data[buff].push_back(c[aa]);; cerr<first<<" " <second<<" " < iter(in),end; string tok; tok = *iter; ++iter; if(string(tok.begin(),tok.begin()+4)=="data"){ data_set = atoi(string(tok.begin()+5,tok.end()).c_str()); cerr<<"DEBUG data "<>tok; while(tok!="save_") in>>tok; cerr<<"DEBUG end : "<> tok; in >> tok; in >> tok; if(tok!="loop_"){ cerr<<"ERROR in chemical_shift_referencing frame"< entry; in >> tok; while(tok[0]=='_'){ entry.push_back(tok); in>>tok; } int count = 0; while(tok!="stop_"){ cerr<> tok; if(tok[0]=='\"'){ string t; in >> t; tok +=" "+t; while(tok[tok.size()-1]!='\"'){ in >> t; tok +=" "+t; } } ++count; } cs_reference = true; } void process_save_chem_shift_list(ifstream & in){ cerr<<"DEBUG process_save_chem_shift_list\n"; string tok; in >> tok; in >> tok; in >> tok; bool extra_loop = false; if(tok=="loop_"){ in >> tok; if(tok=="_Experiment_label") extra_loop = true; while(tok!="stop_") in >> tok; } else { cerr<<"Unexpected token"<> tok; while(tok!="stop_") in >> tok; } in >> tok; while(tok!="loop_") in >> tok; if(tok=="loop_"){ int count = 0; vector content; in>>tok; while(tok[0]=='_'){ ++count; content.push_back(tok); in>>tok; } //Now lines vector lines; lines.push_back(tok); in>>tok; while(tok!="stop_"){ lines.push_back(tok); in >> tok; } pair current; string atom; double shift; for(int i=0;i>tok; } } void process_save_entry_information(ifstream &in){ cerr<<"DEBUG process_save_entry_information"<>tok; while(tok!="save_"){ cerr<>tok; } } }; inline string to_string(const BMBR & p){ return ""; } extern "C" { void init_bmbr(){ //declarations here Module mod = Module("bmbr","Parse BMRB files (incomplete)); Class >(mod.self(),"bmbr") ; } }