/*************************************************************************** dcd.cpp - description ------------------- begin : Thu Jul 3 00:23:53 2003 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 using namespace Almost; class MaxSubClusterDistance { Almost::MaxSub ms; float val; public: MaxSubClusterDistance(const Molecules & m,float cutoff,float v): ms(m,cutoff), val(v){ ms.set_verbose(false);} bool in_cluster(double v){ if(v>=val) return true; return false; } string description(){ return "MAXSUB";} float distance(const Coor & c1_, const Coor & c2_){ int atoms = c1_.size(); Coor c1; c1.resize(atoms); Coor c2; c2.resize(atoms); for(int a=0;a::DIM; c1.coor[apos] = c1_.coor[apos]; c1.coor[apos+1] = c1_.coor[apos+1]; c1.coor[apos+2] = c1_.coor[apos+2]; } for(int a=0;a::DIM; c2.coor[apos] = c2_.coor[apos]; c2.coor[apos+1] = c2_.coor[apos+1]; c2.coor[apos+2] = c2_.coor[apos+2]; } ms.apply(c1,c2); return ms.score(); } }; template<> inline string to_string(const DCDTrj & dcd){ return dcd.get_comment(); } template<> inline string to_string(const MaxSubClusterDistance & dcd){ return "MaxSubDistance"; } ostream & operator<<(ostream & out,const Coor & ){ out<<""; return out; } template inline string to_string(const Coor & data){ return "Coor"; } template<> inline string to_string(const ContactGroup &gr){ char buff[256]; sprintf(buff," %i",gr.size()); return gr.name()+buff; } template<> inline string to_string(const Contact &c){ return c.name(); } template<> inline string to_string(const NameSelection & ns){ return to_string(ns.size()); } template<> inline string to_string(const DCDMonitorSet &){ return "monitor_set"; } template void add_monitor( DCDMonitorSet & c, ConstType & cg){ c.add_monitor(cg); } // void go_energy(const Molecules molecules, const DCDTrj & dcd, // string file, // const DefGoOptions & options, const MDB & mdb){ // MOD_SWITCH = ENERGY; // set_prompt(); // DefGoForceField *ff; // bool native_map = (options.native_map!="none"); // bool const_file = (options.const_file!="none"); // if(native_map&&const_file) // ff = new DefGoForceField(options.native_map, // molecules, // options, // options.const_file, // mdb); // else if(native_map&&(!const_file)) // ff = new DefGoForceField(options.native_map, // molecules, // options, // mdb); // else if((!native_map)&&const_file) // ff = new DefGoForceField(molecules, // options, // options.const_file, // mdb); // else if((!native_map)&&(!const_file)) // ff = new DefGoForceField(molecules, // options, // mdb); // int natoms = dcd.get_natoms(); // if(natoms!=molecules.atom_size()){ // delete ff; // throw "Molecules and DCD do not contain the same number of atoms"; // } // //coordinates // vector atomCoor; // for(int i=0; iopen(file.c_str()); // out = fout; // } // else { // out = &cout; // } // (*out)<<"# frame energy native non-native Q const\n"; // for(int i=0;ienergy(atomCoor); // data = ff->data(); // sprintf(buff,"%-10i %-10.4f %-10i %-10i %-10.4f %-10.4f\n", // i+1, // data.energy, // data.n_native, // data.n_non_native, // ((double)data.n_native)/((double)data.n_cont_max), // data.const_energy // ); // (*out)<flush(); // if(file!="stdout"){delete out;} // } // void vdw_go_energy(const Molecules molecules, // const DCDTrj & dcd, // string file, // const DefIGoOptions & options, const MDB & mdb){ // MOD_SWITCH = ENERGY; // set_prompt(); // DefIGoForceField *ff; // bool native_map = (options.native_map!="none"); // bool const_file = (options.const_file!="none"); // if(native_map&&const_file) // ff = new DefIGoForceField(options.native_map, // molecules, // options, // options.const_file, // mdb); // else if(native_map&&(!const_file)) // ff = new DefIGoForceField(options.native_map, // molecules, // options, // mdb); // else if((!native_map)&&const_file) // ff = new DefIGoForceField(molecules, // options, // options.const_file, // mdb); // else if((!native_map)&&(!const_file)) // ff = new DefIGoForceField(molecules, // options, // mdb); // int natoms = dcd.get_natoms(); // if(natoms!=molecules.atom_size()){ // delete ff; // throw "Molecules and DCD do not contain the same number of atoms"; // } // //coordinates // vector atomCoor; // for(int i=0; iopen(file.c_str()); // out = fout; // } // else { // out = &cout; // } // (*out)<<"# frame energy native non-native Q const\n"; // for(int i=0;ienergy(atomCoor); // data = ff->data(); // sprintf(buff,"%-10i %-10.4f %-10i %-10i %-10.4f %-10.4f\n", // i+1, // data.energy, // data.n_native, // data.n_non_native, // ((double)data.n_native)/((double)data.n_cont_max), // data.const_energy // ); // (*out)<flush(); // if(file!="stdout"){delete out;} // } // void c19_energy(const Molecules molecules, // const DCDTrj & dcd, // string file, // const DefC19Options & options, const MDB & mdb){ // MOD_SWITCH = ENERGY; // set_prompt(); // DefC19ForceField ff(molecules,options,mdb);; // int natoms = dcd.get_natoms(); // if(natoms!=molecules.atom_size()){ // throw "Molecules and DCD do not contain the same number of atoms"; // } // //coordinates // vector atomCoor; // for(int i=0; iopen(file.c_str()); // out = fout; // } // else { // out = &cout; // } // (*out)<<"# frame energy bond angle dihe imph elec vdw sasa const pairs\n"; // for(int i=0;iflush(); // if(file!="stdout"){delete out;} // } // void c22_energy(const Molecules molecules, // const DCDTrj & dcd, // string file, // const DefC22Options & options, const MDB & mdb){ // MOD_SWITCH = ENERGY; // set_prompt(); // DefC22ForceField ff(molecules,options,mdb);; // int natoms = dcd.get_natoms(); // if(natoms!=molecules.atom_size()){ // throw "Molecules and DCD do not contain the same number of atoms"; // } // //coordinates // vector atomCoor; // for(int i=0; iopen(file.c_str()); // out = fout; // } // else { // out = &cout; // } // (*out)<<"# frame energy bond angle dihe imph elec vdw sasa const pairs\n"; // for(int i=0;iflush(); // if(file!="stdout"){delete out;} // } // void pbcc19_energy(const Molecules molecules, // const DCDTrj & dcd, // string file, // const PBCC19Options & options, const MDB & mdb){ // MOD_SWITCH = ENERGY; // set_prompt(); // PBCC19ForceField ff(molecules,options,mdb);; // int natoms = dcd.get_natoms(); // if(natoms!=molecules.atom_size()){ // throw "Molecules and DCD do not contain the same number of atoms"; // } // //coordinates // vector atomCoor; // for(int i=0; iopen(file.c_str()); // out = fout; // } // else { // out = &cout; // } // (*out)<<"# frame energy bond angle dihe imph elec vdw sasa const pairs\n"; // for(int i=0;iflush(); // if(file!="stdout"){delete out;} // } // void pbcc22_energy(const Molecules molecules, // const DCDTrj & dcd, // string file, // const PBCC22Options & options, const MDB & mdb){ // MOD_SWITCH = ENERGY; // set_prompt(); // PBCC22ForceField ff(molecules,options,mdb);; // int natoms = dcd.get_natoms(); // if(natoms!=molecules.atom_size()){ // throw "Molecules and DCD do not contain the same number of atoms"; // } // //coordinates // vector atomCoor; // for(int i=0; iopen(file.c_str()); // out = fout; // } // else { // out = &cout; // } // (*out)<<"# frame energy bond angle dihe imph elec vdw sasa const pairs\n"; // for(int i=0;iflush(); // if(file!="stdout"){delete out;} // } template<> inline string to_string(const Molecules & molecules){ return ""; } template<> inline string to_string(const MDB & mdb){ return ""; } template<> inline string to_string(const RMSD & rmsd){ return ""; } template<> inline string to_string(const Fit & rmsd){ return ""; } template<> inline string to_string(const Energy & c19_e){ return ""; } template<> inline string to_string(const RGYR & rmsd){ return ""; } template<> inline string to_string(const Bond & rmsd){ return ""; } template<> inline string to_string(const Angle & rmsd){ return ""; } template<> inline string to_string(const Dihedral & rmsd){ return ""; } template<> inline string to_string(const Cluster & rmsd){ return ""; } template<> inline string to_string(const HBondFinderOpts & rmsd){ return ""; } extern "C" { void init_dcd(){ Module mod = Module("dcd","Trajectory Tools") .def_const("begin",1) .def_const("eof",-1) .def_function("dcd2pdb","Write coor to pdb bundle.",&dcd2pdb) .def_function("hbond_finder","Find HBonds between proteins and wather.",&hbond_finder) // .def_function("go_energy",go_energy) // .def_function("vdw_go_energy",vdw_go_energy) // .def_function("c19_energy",c19_energy) // .def_function("c22_energy",c22_energy) // .def_function("pbc_c19_energy",pbcc19_energy) // .def_function("pbc_c22_energy",pbcc22_energy); ; Class< HBondFinderOpts>(mod.self(),"hbond_finder_options") .def_attribute("X",&HBondFinderOpts::X,"Undocumented") .def_attribute("Y",&HBondFinderOpts::Y,"Undocumented") .def_attribute("Z",&HBondFinderOpts::Z,"Undocumented") .def_attribute("dist",&HBondFinderOpts::d,"Undocumented") .def_attribute("angle",&HBondFinderOpts::angle,"Undocumented") ; Class(mod.self(),"dcd") .def_method("type",&DCDTrj::get_type) .def_method("add",&DCDTrj::add) .def_method("natoms",&DCDTrj::get_natoms) .def_method("nfix",&DCDTrj::get_nfix) .def_method("nfree",&DCDTrj::get_nfree) .def_method("version",&DCDTrj::get_version) .def_method("nframes",&DCDTrj::get_nframes) .def_method("first",&DCDTrj::get_first) .def_method("set_first",&DCDTrj::set_first) .def_method("nsteps",&DCDTrj::get_nsteps) .def_method("set_nsteps",&DCDTrj::set_nsteps) .def_method("dt",&DCDTrj::get_dt) .def_method("sex",&DCDTrj::get_sex) .def_method("comment",&DCDTrj::get_comment) .def_method("set_comment",&DCDTrj::set_comment) .def_method("from",&DCDTrj::get_from) .def_method("to",&DCDTrj::get_to) .def_method("step",&DCDTrj::get_step) .def_method("nsaved",&DCDTrj::get_nsaved) .def_method("read",&DCDTrj::read) .def_method("write",&DCDTrj::write) .def_method("append",&DCDTrj::append) .def_method("print_header",&DCDTrj::print_header) .def_method("print_save_info",&DCDTrj::print_save_info) .def_method("coor",&DCDTrj::coor) .def_method("X",&DCDTrj::X) .def_method("Y",&DCDTrj::Y) .def_method("Z",&DCDTrj::Z) ; Class >(mod.self(),"contact") .def_method("eval",&Contact::eval); Class >(mod.self(),"contact_group") .def_method("add",&ContactGroup::add) .def_method("eval",&ContactGroup::eval); Class >(mod.self(),"RMSD") .def_method("eval",&RMSD::eval) .def_method("eval2",&RMSD::eval2) .def_method("eval_two",&RMSD::eval_two) ; Class &, const MDB &> >(mod.self(),"energy") .def_method("eval",&Energy::evalf) ; Class >(mod.self(),"Fit") .def_method("eval",&Fit::eval); Class >(mod.self(),"RGYR") .def_method("eval",&RGYR::eval); Class >(mod.self(),"bond") .def_method("eval",&Bond::eval); Class >(mod.self(),"angle") .def_method("eval",&Angle::eval); Class >(mod.self(),"dihedral") .def_method("eval",&Dihedral::eval); Class(mod.self(),"monitor_set") .def_method("clear_monitors",&DCDMonitorSet::clear_monitors) .def_method("size",&DCDMonitorSet::size) .def_method("apply",&DCDMonitorSet::apply) .def_method("export",&DCDMonitorSet::export_ds) ; mod.def_function("add_rmsd","Adds an RMSD monitor to the monitor_set",add_monitor); mod.def_function("add_rgyr","Adds a RGYR monitor to the monitor_set",add_monitor); mod.def_function("add_bond","Adds a Bond monitor to the monitor_set",add_monitor); mod.def_function("add_angle","Adds a Angle monitor to the monitor_set",add_monitor); mod.def_function("add_dihedral","Adds a Dihedral monitor to the monitor_set",add_monitor); // Class,MDB> >(mod.self(), // "c19_energy") // .def_method("eval",&Energy::eval); Class >(mod.self(),"cluster") .def_method("leader",&Cluster::leader) .def_method("leader_maxsub",&Cluster::leader_with_distance) .def_method("graph",&Cluster::graph) .def_method("neighbors",&Cluster::neighbors); Class >(mod.self(),"maxsub_dist"); } }