/*************************************************************************** sandy.cpp - description ------------------- begin : Tue Nov 18 01:45:35 2003 copyright : (C) 1999-2008 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 #include namespace Almost { struct Peak2D { double w1; double w2; double Vol; double Vol2; vector n1; vector n2; vector > _12; vector > _13; vector > _14; int gmin; int gmax; vector > Upper; vector > Lower; vector > W; void init_w(){ W.clear(); W.resize(n1.size()); Upper.clear(); Upper.resize(n1.size()); for(int i=0;i6) W[i][j] = 0; } // if(_12.size()||_13.size()||_14.size()){ // bool a = is_12(n1[i],n2[j]); // bool b = is_13(n1[i],n2[j]); // bool c = is_14(n1[i],n2[j]); // if(!(a||b||c)) // W[i][j] = 0; // } W_tot += W[i][j]; } } W_tot = 1.0/W_tot; for(int i=0;i & atm){ for(int i=0;i q(a1,a2); return find(_14.begin(),_14.end(),q)!=_14.end(); } bool is_13(int a1, int a2){ pair q(a1,a2); return find(_13.begin(),_13.end(),q)!=_13.end(); } bool is_12(int a1, int a2){ pair q(a1,a2); return find(_12.begin(),_12.end(),q)!=_12.end(); } bool is_assignment(int a1, int a2, bool both = true){ if(find(n1.begin(),n1.end(),a1)!=n1.end() && find(n2.begin(),n2.end(),a2)!=n2.end()) return true; if(both) if(find(n1.begin(),n1.end(),a2)!=n1.end() && find(n2.begin(),n2.end(),a1)!=n2.end()) return true; return false; } }; Protein mkprot(vector seq){ MDB mdb("all19_eef1.mdb"); Protein p("BLT"); p.build_sequ(seq,mdb,"DEFAULT","DEFAULT"); return p; } vector read_peak(char * file){ ifstream in(file); if(!in){ string error = string("\t>> FATAL ERROR: unable to open file: ")+file +string("\n"); cout< peak; while(in.good()){ char line[256]; in.getline(line,256); cout<>id; ss>> p.w1; ss>> p.w2; ss>>id; ss>> c; ss>> p.Vol; ss>> p.Vol2; peak.push_back(p); } return peak; } vector read_seq(char * file){ ifstream in(file); if(!in){ string error = string("\t>> FATAL ERROR: unable to open file: ")+file +string("\n"); cout< seq; while(in.good()){ char line[256]; in.getline(line,256); stringstream ss(line); string s,n; ss>>s; if(s.size()<3) continue; ss>>n; n="_"+n; if(s.size()==3) seq.push_back(s+n); else if(s.size()>3) seq.push_back(string(s.begin(),s.begin()+3)+n); else { cout<<"\t>> Error in reading sequence file: "<> Error in reading sequence"; } } return seq; } map read_shifts(char * file, const Protein &p){ map cs; ifstream in(file); if(!in){ string error = string("\t>> FATAL ERROR: unable to open file: ")+file +string("\n"); cout< seq = p.sequence(Protein::LONG); while(in.good()){ char line[256]; in.getline(line,256); if(in.gcount()<10) continue; stringstream ss(line); int id; double w; double err; string atm; int nres; ss>>id; ss>>w; ss>>err; ss>>atm; ss>>nres; --nres; cout<<"\t>> Chemical shift for atom "<> Atom not in protein\n"; } if(natm!=-1){ cs[natm] = w; cout<<"\t>> CS assignment "< & p1, const Protein & p, const map &cs, double tol = 0.25){ map::const_iterator iter = cs.begin(), end = cs.end(); while(iter!=end){ for(int i=0;isecond)first); if(abs(p1[i].w2-iter->second)first); } ++iter; } for(int i=0;ip1[i].gmax) p1[i].gmax = q; if(q::iterator iter= p1.begin(), end = p1.end(); while(iter!=p1.end()){ if(iter->n1.size()==0||iter->n2.size()==0) iter = p1.erase(iter); else ++iter; } } for(int i=0;i &p1, const Protein & pp ){ ofstream out; out.open("dump.peaks"); for(int i=0;i2||p1[i].n2.size()>2) continue; // if(p1[i].gmax>10||p1[i].gmin<2) continue; out<<">> Peak "< > > read_topos(char * file){ map > > tps; ifstream in; in.open(file); if(!in){ string error = string("\t>> FATAL ERROR: unable to open file: ")+file +string("\n"); cout< iter(in),end; while(iter!=end){ int n = atoi(iter->c_str())-1; ++iter; ++iter; double phi = atof(iter->c_str()); ++iter; double psi = atof(iter->c_str()); ++iter; pair p(phi,psi); tps[n].push_back(p); } return tps; } bool have_topos(int m, int M, map > > &topos){ for(int i=m;i<=M;i++) if(topos.find(i)== topos.end()) return false; return true; } void check_dist(BondRotation & bond_rotation, Protein & p, map > > &topos, int m, int M, int a1, int a2, int f1, int f2, double & D_m, double &D_M){ vector > phi = p.phi_atoms(); vector > psi = p.psi_atoms(); Coor c; c.resize(p.atom_size()); for(int i=0;i::DIM*i] = p[i][0]; c.coor[Coor::DIM*i+1] = p[i][1]; c.coor[Coor::DIM*i+2] = p[i][2]; } double d_min = 100000; double d_max = -1; for(int q=0;q<(M-m+1)*1000;q++){ for(int i=m;i<=M;i++){ double phi_a = topos[i][lrand48()%topos[i].size()].first*M_PI/180.0 +(drand48()-0.5)*M_PI/180.0*25.0; double psi_a = topos[i][lrand48()%topos[i].size()].second*M_PI/180.0+(drand48()-0.5)*M_PI/180.0*25.0; if(phi[i].size()<4||psi[i].size()<4) continue; bond_rotation.set_dihedral(c, phi[i][0], phi[i][1], phi[i][2], phi[i][3], phi_a); bond_rotation.set_dihedral(c, psi[i][0], psi[i][1], psi[i][2], psi[i][3], psi_a); } double d = 0; for(int i=0;i<3;i++){ double dd = c.coor[Coor::DIM*a1+i] - c.coor[Coor::DIM*a2+i]; d +=dd*dd; } d = sqrt(d); if(dd_max) d_max = d; } // cout<<"Distance "< & peak, map > > &topos, Protein &p){ BondRotation bond_rotation(p); int count = 0; for(int i=0;i> Challenging peak "<> Atom "<12){ continue;}; if(!have_topos(m,M,topos)){ continue;} double D_Min = 0, D_Max = 0; // if(n1!="CA"&&n1!="CB"&&n1!="C") continue; // if(n2!="CA"&&n2!="CB"&&n2!="C") continue; check_dist(bond_rotation,p,topos,m,M,peak[i].n1[a],peak[i].n2[b],f1,f2,D_Min,D_Max); peak[i].Lower[a][b] = D_Min; peak[i].Upper[a][b] = D_Max; cout<<"Real "< p1; vector seq; map cs; map,vector > peak_connection; map > > topos_rest; vector > mat_12; vector > mat_13; vector > mat_14; p1 = Almost::read_peak(argv[1]); cout<<"\t>> Read "<> Read "<(a1,a2)); } } } } for(int i=0;i(a1,a2)); } } } } for(int i=0;i(a1,a2)); } } } } cout<<">> Connecting....\n"; for(int i=0;i p(p1[i].n1[a1],p1[i].n2[a2]); peak_connection[p].push_back(i); } } } { map,vector >::iterator iter = peak_connection.begin(), end = peak_connection.end(); while(iter!=end){ cout<<">> Atoms "<first.first<<" " <first.second<<" "<<" "; for(int i=0;isecond.size();i++) cout<second[i]<<" "; cout<<"\n"; ++iter; } } Almost::challange_peaks(p1,topos_rest,pp); //should use LINEAR P!!! Almost::dump(p1, pp); } // Local Variables: // mode:C++ // End: