/*************************************************************************** constraint_mod.cpp - description ------------------- begin : Wed Nov 17 16:56:21 2004 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 #include #include #include #include #include #ifdef BUILD_SHXCONST #include #endif #ifdef BUILD_PECONST #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace Almost; //CamShift const double CamShift::cutOffSmoothingExp = 8.0; #define ALMTOSTRING(s) \ template<> \ inline string to_string(const s & ){ \ return "<" #s ">"; \ } ALMTOSTRING(Coor3D); ALMTOSTRING(Molecules); ALMTOSTRING(NameSelection); ALMTOSTRING(MDB); ALMTOSTRING(Coor); ALMTOSTRING(Coor); // takes a constraint and returns a string template<> inline string to_string(const ConstraintCollection & sp){ return ""; } template<> inline string to_string(const RGYRConst & sp){ return ""; } template<> inline string to_string(const SphereConst & sp){ return ""; } template<> inline string to_string(const Shell & sp){ return ""; } template<> inline string to_string(const Fix & sp){ return " >"; } template<> inline string to_string(const BondConst & sp){ return ""; } template<> inline string to_string(const AngleConst & sp){ return ""; } template<> inline string to_string(const DihedralConst & sp){ return ">"; } template<> inline string to_string(const DihedralConst & sp){ return ">"; } template<> inline string to_string(const ImproperConst & sp){ return ""; } template<> inline string to_string(const JCoupling & sp){ return ""; } template<> inline string to_string(const RdcConst & sp){ return ""; } template<> inline string to_string(const XRdcConst & sp){ return ""; } template<> inline string to_string(const RdcOpts & sp){ return ""; } #ifdef BUILD_SHXCONST template<> inline string to_string(const ShiftConst & sp){ return ""; } template<> inline string to_string(const ShiftOpts & sp){ return ""; } #endif #ifdef BUILD_PECONST template<> inline string to_string(const PEConst & sp){ return ""; } #endif template<> inline string to_string(const NConst & sp){ return ""; } template<> inline string to_string(const NOEConst & sp){ return ""; } template<> inline string to_string(const MENoe & sp){ return ""; } template<> inline string to_string(const VdWNoe & sp){ return ""; } template<> inline string to_string(const QVdW & sp){ return ""; } template<> inline string to_string(const AmbNOEConst & sp){ return ""; } template<> inline string to_string(const AmbNOEConstDyn & sp){ return ""; } template<> inline string to_string(const RoseNOEConst & sp){ return ""; } template<> inline string to_string(const RoseNOEGroupConst & sp){ return ""; } template<> inline string to_string(const HBConst & sp){ return ""; } template<> inline string to_string(const BHB & sp){ return ""; } template<> inline string to_string(const XNOEConst & sp){ return ""; } template<> inline string to_string(const S2Const & sp){ return ""; } template<> inline string to_string(const S2RMSDConst & sp){ return ""; } template<> inline string to_string(const S2MRMSDConst & sp){ return ""; } template<> inline string to_string(const APMF & sp){ return ""; } template<> inline string to_string(const DOPE & sp){ return ""; } template<> inline string to_string(const DPMF & sp){ return ""; } template<> inline string to_string(const SSDPMF & sp){ return ""; } template<> inline string to_string(const EnvConst & sp){ return ""; } template<> inline string to_string(const EnvPairConst & sp){ return ""; } template<> inline string to_string(const PosConst & sp){ return ""; } template<> inline string to_string(const ContMap & sp){ return ""; } template<> inline string to_string(const CamShift & sp){ return ""; } template<> inline string to_string(const ShiftXConst & sp){ return ""; } template<> inline string to_string(const ShxConst & sp){ return ""; } // template function: the parameter is the constraint type, the arguments are the constraint // collector and the actual constraint: this is therefore a function that adds a constraint to // the constraint collection template void add_const( ConstraintCollection & c, ConstType & cg){ c.add(cg); } APMF mkapmf(const Molecules & m, string db, int k ,double l){ return APMF(m,db,k,l); } extern "C" { void init_constraint(){ // function that is called when the constraints are initialized //constraint declarations here Module mod = Module("const","Molecular Dynamics and Monte Carlo Restraints"); // a object of class Module is constructed Class >(mod.self(),"sphere"); Class,ArgList5 >(mod.self(),"shell") .def_method("set_timestep", &Shell::set_timestep) ; Class , ArgList1 > (mod.self(),"hb") .def_method("set_lambda",&HBConst::set_lambda) .def_method("lambda",&HBConst::lambda) ; Class , ArgList4 >(mod.self(),"bhb") .def_method("energy",&BHB::energy) .def_method("hblist",&BHB::hblist) .def_attribute("W_bb_bb", &BHB::W_bb_bb, "Weight of the backbone-backbone h-bond energy term") .def_attribute("W_sc_sc_sp2", &BHB::W_sc_sc_sp2, "Weight of the sidechain-sidechain-sp2 h-bond energy term") .def_attribute("W_bb_sc_sp2",&BHB::W_bb_sc_sp2, "Weight of the backbone-sidechain-sp2 h-bond energy term") .def_attribute("W_sc_sc_sp3",&BHB::W_sc_sc_sp3, "Weight of the sidechain-sidechain-sp3 h-bond energy term") .def_attribute("W_bb_sc_sp3",&BHB::W_bb_sc_sp3, "Weight of the backbone-sidechain-sp2 h-bond energy term") .def_attribute("sc_hb",&BHB::sc_hb, "If different from 0, compute sidechain contributions.") ; Class , ArgList5 > (mod.self(),"apmf") .def_method("pmf",&APMF::pmf) .def_method("energy",&APMF::energy) .def_method("dump_type_map",&APMF::dump_type_map); Class, ArgList3 >(mod.self(),"dope") .def_method("energy",&DOPE::energy) ; Class , ArgList3 > (mod.self(),"dpmf") .def_method("energy",&DPMF::energy) ; Class , ArgList2 > (mod.self(),"ssdpmf") .def_method("energy",&SSDPMF::energy) ; Class, ArgList2 >(mod.self(),"env") .def_method("energy",&EnvConst::energy) .def_method("site_energy",&EnvConst::site_energy) ; Class, ArgList2 >(mod.self(),"envpair") .def_method("energy",&EnvPairConst::energy) .def_method("site_energy",&EnvPairConst::site_energy) ; Class ,ArgList4 >(mod.self(),"fix"); Class >(mod.self(),"rgyr") .def_method&)>("energy",&RGYRConst::energy) .def_method("energy2",&RGYRConst::energy2) ; Class,ArgList1 >(mod.self(),"bond") .def_method("assign",&BondConst::assign) .def_method("add",&BondConst::add) .def_method("clear",&BondConst::clear); Class,ArgList1 >(mod.self(),"angle") .def_method("assign",&AngleConst::assign) .def_method("clear",&AngleConst::clear); Class, ArgList1 >(mod.self(),"dihedral") .def_method("assign",&DihedralConst::assign) .def_method("clear",&DihedralConst::clear) .def_method::*)(const Coor&)>("energy",&DihedralConst::energy) ; Class, ArgList1 >(mod.self(),"fdihedral") .def_method("assign",&DihedralConst::assign) .def_method("clear",&DihedralConst::clear) .def_method::*)(const Coor&)>("energy",&DihedralConst::energy) ; Class,ArgList1 >(mod.self(),"improper") .def_method("assign",&ImproperConst::assign) .def_method("clear",&ImproperConst::clear) ; Class >(mod.self(),"jcoupling") .def_method("set_coefficients",&JCoupling::set_coefficients) .def_method("add_const",&JCoupling::add_const) .def_method("assign",&JCoupling::assign) .def_method("check",&JCoupling::check) .def_method("clear",&JCoupling::clear); #ifdef BUILD_SHXCONST Class(mod.self(),"shift_options") .def_attribute("weight",&ShiftOpts::weight) .def_attribute("tol",&ShiftOpts::tol) .def_attribute("logfile",&ShiftOpts::logfile) .def_attribute("logfile_zero",&ShiftOpts::logfile_zero) .def_attribute("nprint",&ShiftOpts::nprint) .def_attribute("flag_h",&ShiftOpts::flag_h) .def_attribute("flag_ha",&ShiftOpts::flag_ha) .def_attribute("flag_n",&ShiftOpts::flag_n) .def_attribute("flag_ca",&ShiftOpts::flag_ca) .def_attribute("flag_cb",&ShiftOpts::flag_cb) .def_attribute("flag_c",&ShiftOpts::flag_c) ; Class >(mod.self(),"shiftconst") .def_method("add_const",&ShiftConst::add_const) .def_method("score",&ShiftConst::score) ; #endif Class >(mod.self(), "shifx") .def_method("use_ha",&ShiftXConst::use_ha) .def_method("use_h",&ShiftXConst::use_h) .def_method("use_n",&ShiftXConst::use_n) .def_method("use_ca",&ShiftXConst::use_ca) .def_method("use_cb",&ShiftXConst::use_cb) .def_method("use_c",&ShiftXConst::use_c) .def_method("ha_tol",&ShiftXConst::ha_tol) .def_method("h_tol",&ShiftXConst::h_tol) .def_method("n_tol",&ShiftXConst::n_tol) .def_method("ca_tol",&ShiftXConst::ca_tol) .def_method("cb_tol",&ShiftXConst::cb_tol) .def_method("c_tol",&ShiftXConst::c_tol) .def_method("tol_cutoff",&ShiftXConst::tol_cutoff) .def_method("ha_tol_cutoff",&ShiftXConst::ha_tol_cutoff) .def_method("weight",&ShiftXConst::weight) .def_method("linearslope",&ShiftXConst::linearslope) .def_method("energy",&ShiftXConst::energy) .def_method("cheshire_energy",&ShiftXConst::cheshire_energy) .def_method("set_log",&ShiftXConst::set_log) ; #ifdef BUILD_PECONST Class >(mod.self(),"peconst"); #endif Class & > >(mod.self(),"nconst"); Class,ArgList1 >(mod.self(),"menoe") .def_method("assign",&MENoe::assign) .def_method("add",&MENoe::add) .def_method("clear",&MENoe::clear) ; Class,ArgList1 >(mod.self(),"vdwnoe") .def_method("assign",&VdWNoe::assign) .def_method("add",&VdWNoe::add) .def_method("clear",&VdWNoe::clear) .def_method("set_tol",&VdWNoe::set_tol) .def_method("set_update",&VdWNoe::set_update) ; Class,ArgList2 >(mod.self(),"qvdw") ; Class >(mod.self(),"noe") .def_method("assign",&NOEConst::assign) .def_method("clear",&NOEConst::clear) .def_method("set",&NOEConst::set_const) .def_method("scale",&NOEConst::scale) ; Class, ArgList3 >(mod.self(),"ambnoe") // .def_method("assign",&AmbNOEConst::assign) .def_method("clear",&AmbNOEConst::clear) // .def_method("set",&AmbNOEConst::set_const) .def_method("scale",&AmbNOEConst::scale) .def_method("set_omega",&AmbNOEConst::set_omega) .def_method("from_file",&AmbNOEConst::from_file) .def_method("assign",&AmbNOEConst::assign) .def_method("energy",&AmbNOEConst::energy) .def_method("set",&AmbNOEConst::set_const) .def_method("check",&AmbNOEConst::check) ; Class, ArgList3 >(mod.self(),"dynambnoe") // .def_method("assign",&AmbNOEConstDyn::assign) .def_method("clear",&AmbNOEConstDyn::clear) // .def_method("set",&AmbNOEConstDyn::set_const) .def_method("scale",&AmbNOEConstDyn::scale) .def_method("set_omega",&AmbNOEConstDyn::set_omega) .def_method("set_mult",&AmbNOEConstDyn::set_mult) .def_method("set_safe",&AmbNOEConstDyn::set_safe) .def_method("set_tol",&AmbNOEConstDyn::set_tol) .def_method("set_update",&AmbNOEConstDyn::set_update) .def_method("from_file",&AmbNOEConstDyn::from_file) .def_method("assign",&AmbNOEConstDyn::assign) .def_method("energy",&AmbNOEConstDyn::energy) .def_method("set",&AmbNOEConstDyn::set_const) .def_method("check",&AmbNOEConstDyn::check) .def_method("active",&AmbNOEConstDyn::active) ; Class, ArgList1 >(mod.self(),"rosenoe") .def_method("from_file",&RoseNOEConst::from_file) .def_method("name_from_file",&RoseNOEConst::name_from_file) .def_method("energy",&RoseNOEConst::energy) .def_method("violation",&RoseNOEConst::violation) ; Class, ArgList1 >(mod.self(),"rosenoegroup") .def_method("from_file",&RoseNOEGroupConst::from_file) .def_method("to_file",&RoseNOEGroupConst::to_file) .def_method("name_from_file",&RoseNOEGroupConst::name_from_file) .def_method("energy",&RoseNOEGroupConst::energy) .def_method("violation",&RoseNOEGroupConst::violation) ; // Rdc constraints // options Class(mod.self(),"rdc_options") .def_attribute("weight",&RdcOpts::weight,"Undocumented") .def_attribute("tol",&RdcOpts::tol,"Undocumented") .def_attribute("n1",&RdcOpts::n1,"Undocumented") .def_attribute("n2",&RdcOpts::n2,"Undocumented") .def_attribute("nprint",&RdcOpts::nprint,"Undocumented") .def_attribute("S_align",&RdcOpts::S_align,"Undocumented") .def_attribute("vf",&RdcOpts::vf,"Undocumented") .def_attribute("res",&RdcOpts::res,"Undocumented") .def_attribute("only_ca",&RdcOpts::only_ca,"Undocumented") .def_attribute("r_ca",&RdcOpts::r_ca,"Undocumented") .def_attribute("bw",&RdcOpts::bw,"Undocumented"); // actual constraints typedef double (RdcConst::*ene)(const Coor &); Class >(mod.self(),"rdcconst") .def_method("add_const",&RdcConst::add_const) .def_method("energy",&RdcConst::energy) .def_method("print_saupe",&RdcConst::print_saupe) .def_method("print_rdc",&RdcConst::print_rdc) ; Class >(mod.self(),"xrdcconst") .def_method("add_const",&XRdcConst::add_const) ; //X Constrains Class >(mod.self(),"xnoe") .def_method("assign",&XNOEConst::assign) .def_method("clear",&XNOEConst::clear); Class >(mod.self(),"s2") .def_method("assign",&S2Const::assign) .def_method("clear",&S2Const::clear); Class,ArgList2 >(mod.self(),"s2rmsd") .def_method("assign",&S2RMSDConst::assign) .def_method("clear",&S2RMSDConst::clear); Class,ArgList3 >(mod.self(),"s2rmsd") .def_method("assign",&S2MRMSDConst::assign) .def_method("clear",&S2MRMSDConst::clear); { typedef double (PosConst::*ene)(const Coor &); Class >(mod.self(),"pos") .def_method("energy",&PosConst::energy); } Class,ArgList5 >(mod.self(), "contmap") .def_method("build_cm",&ContMap::build_cm) .def_method("add",&ContMap::add) .def_method("energy",&ContMap::energy) ; Class &, const vector &> >(mod.self(), "camshift") .def_method("energy",&CamShift::energy) .def_method("force",&CamShift::force) .def_method("energy_force",&CamShift::energy_force) // .def_method("shifts",&CamShift::shifts) .def_method("set_lambda",&CamShift::set_lambda) .def_method("lambda",&CamShift::lambda) .def_method("set_flatBottomConst",&CamShift::set_flatBottomConst) .def_method("get_flatBottomConst",&CamShift::get_flatBottomConst) .def_method("set_shiftcutoff",&CamShift::set_shiftcutoff) .def_method("get_shiftcutoff",&CamShift::get_shiftcutoff) .def_method("set_debugatoms",&CamShift::set_debugatoms) .def_method("get_debugatom1",&CamShift::get_debugatom1) .def_method("get_debugatom2",&CamShift::get_debugatom2) .def_method("set_forcecutoff",&CamShift::set_forcecutoff) .def_method("get_forcecutoff",&CamShift::get_forcecutoff) .def_method("set_distcutoff",&CamShift::set_distcutoff) .def_method("get_distcutoff",&CamShift::get_distcutoff) .def_method("print_force",&CamShift::print_force) .def_method("printChemicalShifts",&CamShift::printChemicalShifts) ; Class >(mod.self(), "shx"); Class(mod.self(),"collection"); mod.def_function("add_rgyr", "Add RGYR restraint to contraints collection", add_const); mod.def_function("add_sphere", "Add spherical restraint to contraints collection", add_const); mod.def_function("add_shell", "Add shell restraint to contraints collection", add_const >); mod.def_function("add_fix", "Add fix restraint to contraints collection", add_const >); mod.def_function("add_hb", "Add hb restraint to contraints collection", add_const >); mod.def_function("add_apmf", "Add APMF restraint to contraints collection", add_const >); mod.def_function("add_dope", "Add DOPE restraint to contraints collection", add_const >); mod.def_function("add_dpmf", "Add DPMF restraint to contraints collection", add_const >); mod.def_function("add_ssdpmf", "Add SSDPMF restraint to contraints collection", add_const >); mod.def_function("add_bond", "Add bond restraint to contraints collection", add_const >); mod.def_function("add_angle", "Add angle restraint to contraints collection", add_const >); mod.def_function("add_dihedral", "Add dihedral restraint to contraints collection", add_const >); mod.def_function("add_improper", "Add improper restraint to contraints collection", add_const >); mod.def_function("add_jcoupling","Add J-Coupling restraints to contraints collection", add_const); #ifdef BUILD_SHXCONST mod.def_function("add_shift","Add ShiftX restraints to contraints collection", add_const); #endif #ifdef BUILD_PECONST mod.def_function("add_pe","Add PE restraints to contraints collection", add_const); #endif mod.def_function("add_n","Add N restraints to contraints collection", add_const); mod.def_function("add_noe","Add NOE restraints to contraints collection", add_const); mod.def_function("add_menoe","Add ME NOE restraints to contraints collection", add_const >); mod.def_function("add_vdwnoe","Add VdW NOE restraints to contraints collection", add_const >); mod.def_function("add_qvdw","Add qVdW restraints to contraints collection", add_const >); mod.def_function("add_ambnoe","Add AmbNOE restraints to contraints collection", add_const >); mod.def_function("add_dynambnoe","Add AmbNOEDyn restraints to contraints collection", add_const >); mod.def_function("add_rosenoe","Add RoseNOE restraints to contraints collection", add_const >); mod.def_function("add_rosenoegroup","Add RoseNOEGroup restraints to contraints collection", add_const >); mod.def_function("add_xnoe","Add XNOE restraints to contraints collection", add_const); mod.def_function("add_s2","Add S2 restraints to contraints collection", add_const); mod.def_function("add_s2rmsd","Add S2RMSD restraints to contraints collection", add_const >); mod.def_function("add_s2mrmsd","Add S2RMSD restraints to contraints collection", add_const >); // adding the rdc constraints mod.def_function("add_rdc","Add RDC restraints to contraints collection", add_const); mod.def_function("add_xrdc","Add XRDC restraints to contraints collection", add_const); mod.def_function("add_pos","Add position restraints to contraints collection", add_const); mod.def_function("add_conymap","Add contact map restraints to contraints collection", add_const >); mod.def_function("add_env","Add env restraints to contraints collection", add_const >); mod.def_function("add_envpair","Add envpair restraints to contraints collection", add_const >); mod.def_function("add_camshift","Add CamShift restraints to contraints collection", add_const); mod.def_function("add_shiftx","Add sihftx restraints to contraints collection", add_const); mod.def_function("mkapmf","",mkapmf); mod .def_const("ALL",(int)APMF::ALL) .def_const("BB",(int)APMF::BB) .def_const("HBOND",(int)APMF::HBOND); mod.def_function("add_shx","",add_const); } }