/*************************************************************************** molecule.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 #include #include void Almost::Molecule::build(PDBSegment & segment,MDB & mdb, string fpatch, string lpatch) { try{ //Step 1: Find sequence from PDB vector data; { find_molecule_sequence(segment,mdb,data,fpatch,lpatch); } //Step 1: Done //Step 2 //Add fragments { add_segment_fragments(data); } //Step 2: Done //Step 3 //Add atoms { add_segment_atoms(segment,mdb,data); } //Step 3: Done //Step 4 //Add fixed exclusions { add_fixed_exclusions(mdb,data); } //Step 4: Done //Step 5 // Check heavy atoms { try{ check_heavy_atoms(mdb,fpatch,lpatch); } catch(AlmostException exc){ aout< data; { find_molecule_sequence(segment,mdb,data,fpatch,lpatch); } //Step 1: Done //Step 2 //Add fragments { add_segment_fragments(data); } //Step 2: Done //Step 3 //Add atoms { add_segment_atoms(segment,mdb,data); } //Step 3: Done //Step 4 //Add fixed exclusions { add_fixed_exclusions(mdb,data); } //Step 4: Done //Step 5 // Check heavy atoms { try{ check_heavy_atoms(mdb,fpatch,lpatch); } catch(AlmostException exc){ aout< data; vector sequ = segment.sequence(PDBSegment::ICODE); { find_molecule_sequence(sequ,mdb,data,fpatch,lpatch); } { add_segment_fragments(data); } { add_segment_atoms(sequ,mdb,data); define_known_atoms(segment,mdb,data); } { add_fixed_exclusions(mdb,data); } { try{ make_bonds(mdb,data); } catch(AlmostException exc){ aout< &sequ, MDB & mdb, string fpatch, string lpatch){ int error = 0; try{ vector data; { find_molecule_sequence(sequ,mdb,data,fpatch,lpatch); } { add_segment_fragments(data); } { add_segment_atoms(sequ,mdb,data); } { add_fixed_exclusions(mdb,data); } { try{ make_bonds(mdb,data); } catch(AlmostException exc){ aout< &sequ, MDB & mdb, string fpatch, string lpatch){ int error = 0; try{ vector data; { find_molecule_sequence(sequ,mdb,data,fpatch,lpatch); } { add_segment_fragments(data); } { add_segment_atoms(sequ,mdb,data); } { add_fixed_exclusions(mdb,data); } { try{ make_bonds(mdb,data); } catch(AlmostException exc){ aout< data; //data.resize(fragment_size()); for(int i = 0;i data; //data.resize(fragment_size()); for(int i = 0;i atom = tpatch.del_atoms(); // for(int i=0;i bond = tpatch.del_bond(); // for(int i=0;i angle = tpatch.del_angle(); // for(int i=0;i dihedral = tpatch.del_dihedral(); // for(int i=0;i na(4); // for(int j=0;j<4;j++){ // a[j] = frag+"/"+dihedral[i].atom(j); // na[j] = find_atom(a[j]); // if(na[j]<0){ // aout<<"Couldn't find dihedral "+a[j]< >::iterator iter = dihedrals_.find(na); // if(iter!=dihedrals_.end()) // dihedrals_.remove(iter); // else { // aout<<"Atoms: "; // for(int j=0;j<4;j++) aout< improper = tpatch.del_improper(); // for(int i=0;i na(4); // for(int j=0;j<4;j++){ // a[j] = frag+"/"+improper[i].atom(j); // na[j] = find_atom(a[j]); // if(na[j]<0){ // aout<<"Couldn't find improper "+a[j]< >::iterator iter = impropers_.find(na); // if(iter!=impropers_.end()) // impropers_.remove(iter); // else { // aout<<"Atoms: "; // for(int j=0;j<4;j++) aout< & data){ for(int i=0;i & data){ char buff[16]; for(int i=0;i & sequ, MDB & mdb, vector & data){ for(int i=0;i atoms; string _fpatch; string _lpatch; _fpatch="NONE"; _lpatch="NONE"; if(i==0){ if(data[i].fpatch=="DEFAULT"){ _fpatch = mdb.fragment(resName).def_first_patch(); }else{ _fpatch=data[i].fpatch; } } if(i==(data.size()-1)){ if(data[i].lpatch=="DEFAULT"){ _lpatch = mdb.fragment(resName).def_last_patch(); }else{ _lpatch=data[i].lpatch; } } atoms = mdb.atoms(fragment_[i], MDB::ALL_ATOMS, _fpatch,_lpatch); for(int j=0;j< atoms.size();j++){ TAtom tatom = mdb.atom(resName+"/"+atoms[j], data[i].fpatch,data[i].lpatch); AtomT atomt = mdb.atomT(tatom.type_name()); Atom atom(atoms[j],tatom.type_name(), 9999,9999,9999, atomt.mass(), tatom.charge()); atom.set_canonical_name(tatom.canonical_name()); int atomd = add_atom(atom,fragd); if(atomd<0){ aout<<"FATAL ERROR: couldn't add atom "< & data){ for(int i=0;i excl = mdb.atom(name, data[fd].fpatch, data[fd].lpatch).exclusion_list(); set::iterator iter = excl.begin(); while(iter!=excl.end()){ int indx = find_atom_by_canonical_name(data[fd].fragment+string("/")+(*iter)); if(indx<0){ aout<<"FATAL ERROR: couldn't find atom " < heavy_atoms; for(int i=0;i heavy_atoms; for(int i=0;i h_atoms = mdb.bonds(fragment_[i]+"/"+heavy_atoms[j], MDB::H_BONDS,_fpatch,_lpatch); for(int k=0;k & data){ for(int i=0;i atoms = mdb.atoms(fragment_[i], MDB::ALL_ATOMS, data[i].fpatch, data[i].lpatch); for(int j = 0; j< atoms.size();j++){ vector bond_atoms = mdb.bonds(fragment_[i]+"/"+atoms[j], MDB::OUT_BONDS, data[i].fpatch,data[i].lpatch); vector bond_kind = mdb.bonds_kind(fragment_[i]+"/"+atoms[j], MDB::OUT_BONDS, data[i].fpatch,data[i].lpatch); int atomd1 = find_atom(fragment_[i]+"/"+ atoms[j]); if(atomd1<=-1){ aout<< "WARNING 1: "<< "Atom " < & data){ angle_generate(); // aout<<"DEBUG ANGLES ...\n"; // for(int i=0;i & data){ //auto generate //WHAT ??? for(int i=0;i dihe; dihe = mdb.dihedrals(fragment_[i], data[i].fpatch, data[i].lpatch); //register for(int j=0;j dihe_; for(int k=0;k<4;k++) { if(index[k]==-1){ aout<<"Couldn't find atom "<< k+1<< " of dihedral "< & data){ for(int i=0;i imph; imph = mdb.impropers(fragment_[i], data[i].fpatch, data[i].lpatch); //register //aout< imph_; for(int k=0;k<4;k++) { if(index[k]==-1){ aout<<"Couldn't find atom "<< k+1<< " of improper "< & data){ for(int i=0;i group; group = mdb.groups(fragment_[i], data[i].fpatch, data[i].lpatch); //register for(int j=0;j tmp; set::const_iterator iter = group[j].atoms().begin(), end = group[j].atoms().end(); while(iter!=end){ string name = *iter; ++iter; int index; name = fragment_[i]+"/"+name; index = find_atom_by_canonical_name(name); tmp.push_back(index); } sort(tmp.begin(),tmp.end()); group_.push_back(tmp); } } } void Almost::Molecule::generate_coor(MDB & mdb, vector & data){ ICManager ic_man; for(int i=0;i ic = mdb.ic(data[i].fragment, data[i].fpatch, data[i].lpatch); for(int j= 0;j known; { for(int i=0;iatomd[1]].coor(), atom_[ic->atomd[2]].coor(), atom_[ic->atomd[3]].coor(), ic); atom_[ic->atomd[0]][0] = coor[0]; atom_[ic->atomd[0]][1] = coor[1]; atom_[ic->atomd[0]][2] = coor[2]; known.insert(ic->atomd[0]); ic->used = true; } else { known.insert(ic->atomd[3]); double coor[3]; build_right(coor, atom_[ic->atomd[0]].coor(), atom_[ic->atomd[1]].coor(), atom_[ic->atomd[2]].coor(), ic); atom_[ic->atomd[3]][0] = coor[0]; atom_[ic->atomd[3]][1] = coor[1]; atom_[ic->atomd[3]][2] = coor[2]; ic->used = true; } } //2nd try ... // if(known.size()!=atom_.size()){ // aout<<"\t>> Generating synthetic internal coordinates.\n"; // set unkn; // for(int i=0;i > & dd = dihedral_.dihedrals(); // set::iterator iter = unkn.begin(), // end = unkn.end(); // while(iter!=end){ // int aa = *iter; // //find a dihe for aa // int stop = 0; // aout<<">> Searching for "<> synthetic internal coordinates generated for:\n\t "; // for(int zz=0;zz<4;zz++){ // aout<> Adding other atoms...\n"; // while(known.size()!=atom_.size()){ // bool stop; // bool left; // ICManager::IC * ic = ic_man.next(known,left,stop); // if(stop) break; // //build // if(left){ // double coor[3]; // build_left(coor, // atom_[ic->atomd[1]].coor(), // atom_[ic->atomd[2]].coor(), // atom_[ic->atomd[3]].coor(), // ic); // atom_[ic->atomd[0]][0] = coor[0]; // atom_[ic->atomd[0]][1] = coor[1]; // atom_[ic->atomd[0]][2] = coor[2]; // known.insert(ic->atomd[0]); // ic->used = true; // } // else { // known.insert(ic->atomd[3]); // double coor[3]; // build_right(coor, // atom_[ic->atomd[0]].coor(), // atom_[ic->atomd[1]].coor(), // atom_[ic->atomd[2]].coor(), // ic); // atom_[ic->atomd[3]][0] = coor[0]; // atom_[ic->atomd[3]][1] = coor[1]; // atom_[ic->atomd[3]][2] = coor[2]; // ic->used = true; // } // } // } // } //end of 2nd try if(almost::verbose()) if(known.size()==atom_.size()) aout<<"\t>> Generation of molecule coor done \n"; else { aout<<"\t\t>> Missing coordinates!!!"< & data){ char buff[16]; int def = 0; for(int i=0;i> Segment contains "< & data, string fpatch, string lpatch){ vector sequ = segment.sequence(PDBSegment::ICODE); for(int i=0;i & sequ, MDB & mdb, vector & data, string fpatch, string lpatch){ for(int i=0;i> Build details:"<<"\n\n"; aout<<"\t>> Number of fragments: "<> Number of atoms: "<> Number of bonds: "; int nbonds= 0; for(int i=0;i> Number of angles: "<> Number of dihedrals: "<> Number of impropers: "<> Number of groups: "<> Number of fixed excl.: "< > M; vector > U; vector > S; vector > I; double tmp[3]; //Init matrices ... M.resize(3); U.resize(3); S.resize(3); I.resize(3); for(int i=0;i<3;i++){ M[i].resize(3); U[i].resize(3); S[i].resize(3); I[i].resize(3); } for(int i=0;i<3;i++) for(int j=0;j<3;j++){ if(i!=j) I[i][j]=0; else I[i][j]=1; } Coor3D n = axis; double norm= 0; for(int i=0;i<3;i++) norm +=n[i]*n[i]; norm = sqrt(norm); for(int i=0;i<3;i++) n[i] /=norm; for(int i =0; i<3;++i){ for(int j = 0;j<3;++j){ U[i][j]=n[i]*n[j]; S[i][j]=0; } } S[0][1] = -n[2]; S[1][0] = -S[0][1]; S[0][2] = n[1]; S[2][0] =-S[0][2]; S[1][2] = -n[0]; S[2][1] = -S[1][2]; double cosv = cos(angle); double sinv = sin(angle); for(int i =0; i<3;++i){ for(int j = 0;j<3;++j){ M[i][j] = U[i][j]+ cosv*(I[i][j]-U[i][j])+sinv*S[i][j]; } } for(int i=0;i> Missing atom "<> WARNING: no SASA parameters for atom: "<> WARNING: no EEF1 parameters for atom: "< & tmp_bonds = bonds(i); string name1 = p[i].type_name(); for(int j=0;j aa(i,tmp_bonds[j]); bond_data_[aa].set_bond_const(bt.bond_const()); bond_data_[aa].set_equ_length(bt.equ_length()); } } } //Angles { int size = angles().size(); Molecule & p = * this; for(int i=0;i at = mdb.angleT(name1,name2,name3); for(int aa=0;aa at = mdb.dihedralT(name1,name2,name3,name4); for(int aa=0;aa at = mdb.improperT(name1,name2,name3,name4); for(int aa=0;aa reg_types; Molecule &p = *this; int b = atom_offset(); int e = b + atom_size(); for(int i=b;i>WARNING atom type "<::iterator iter1 = reg_types.begin(), iter2 = reg_types.begin(), end = reg_types.end(); while(iter1!=end){ iter2 = reg_types.begin(); while(iter2!=end){ if(mdb.is_nbfixed(*iter1,*iter2)){ NBFix nbfix = mdb.nbfix(*iter1,*iter2); nbdata_.set_emin_fix(*iter1,*iter2,nbfix.e_min()); nbdata_.set_emin14_fix(*iter1,*iter2,nbfix.e_min14()); nbdata_.set_sigma_fix(*iter1,*iter2,nbfix.r_vdw()); nbdata_.set_sigma14_fix(*iter1,*iter2,nbfix.r_vdw14()); } ++iter2; } ++iter1; } } } // Local Variables: // mode:C++ // End: