/*************************************************************************** dyna_mod.cpp - description ------------------- begin : Mon Jan 12 05:20:12 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 using namespace Almost; #define ALMTOSTRING(s) \ template<> \ inline string to_string(const s & ){ \ return "<" #s ">"; \ } ALMTOSTRING(MoveSet); ALMTOSTRING(ConstraintCollection); // struct DynaTraits { // typedef floattype float_type; // typedef coorman CoorManagerType; // typedef coormanopts CoorManOpts; // typedef forcefield ForceFieldType; // typedef forcefieldopts FFOptions; // typedef movesettype MoveSetType; // typedef metropolistype MetropolisType; // typedef datatype DataType; // typedef options Options; // }; typedef DynaData, DynaGoOptions, ENERGY> GoData; typedef DynaTraits, CoorManagerOptions, DefGoForceField, DefGoOptions, MoveSet, Metropolis, GoData, DynaGoOptions > GoTraits; //spec for go namespace Almost { template<> void ForceFieldFactory::create(DefGoForceField ** force_field, const Molecules & molecules, const DynaGoOptions &options, const MDB & mdb, ConstraintCollection & constraints, const string & ff_pr){ logMsg(ff_pr, "Initializing "+ DefGoOptions::ff_name()+" force field"); *force_field = new DefGoForceField(molecules, options.ff_options(), mdb, constraints); logMsg(ff_pr,"Done\n"); } } typedef DynaData, DynaIGoOptions, ENERGY> IGoData; typedef DynaTraits, CoorManagerOptions, DefIGoForceField, DefIGoOptions, MoveSet, Metropolis, IGoData, DynaIGoOptions > IGoTraits; namespace Almost { template<> void ForceFieldFactory::create(DefIGoForceField ** force_field, const Molecules & molecules, const DynaIGoOptions &options, const MDB & mdb, ConstraintCollection & constraints, const string & ff_pr){ logMsg(ff_pr, "Initializing "+ DefIGoOptions::ff_name()+" force field"); *force_field = new DefIGoForceField(molecules, options.ff_options(), mdb, constraints); logMsg(ff_pr,"Done\n"); } } template<> inline string to_string(const DynaGoOptions & opt){ stringstream s; s< inline string to_string(const DynaIGoOptions & opt){ stringstream s; s< > * (Dyna::*mc_factory_19)(const Molecules & molecules, const DynaOptions & options, const MDB & mdb); #if (__GNUC__ >= 3) template<> #endif map Dyna::factory #if (__GNUC__ >= 3) = map(); #endif ; template<> inline string to_string(const DynaOptions & opt){ stringstream s; s< inline string to_string(const DynaImplementation &){ return ""; } template<> inline string to_string(const DynaImplementation &){ return ""; } template<> inline string to_string(const Dyna &){ return ""; } //operators for GO template DynaLogStream & operator<<(DynaLogStream &log, const DynaData, DynaGoOptions, ENERGY> &data){ char buff[256]; string prmpt=Almost::DynaStatPr; log.stream()< DynaDataStream & operator<<(DynaDataStream &dat, const DynaData, DynaGoOptions, ENERGY> &data){ dat.stream()< struct OperatorHelperDynaSolv; template struct OperatorHelperDynaSolv { template static typename FF::FloatType helper(const DynaOptionsType & data){ // cout<<"NO SOLV"< struct OperatorHelperDynaSolv { template static typename FF::FloatType helper(const DynaDataType & data){ // cout<<"SOLV"< struct OperatorHelperDynaSolv { template static typename FF::FloatType helper(const DynaDataType & data){ // cout<<"SOLV"< struct OperatorHelperDynaUb; template<> struct OperatorHelperDynaUb<0> { template static typename FF::FloatType helper(const DynaData & data){ // cout<<"NO UB"< struct OperatorHelperDynaUb<1> { template static typename FF::FloatType helper(const DynaData & data){ // cout<<"UB"< struct OperatorHelperDynaElec; template struct OperatorHelperDynaElec { template static typename FF::FloatType helper(const DynaOptionsType & data){ // cout<<"NO ELEC"< struct OperatorHelperDynaElec { template static typename FF::FloatType helper(const DynaDataType & data){ // cout<<"ELEC"< DynaLogStream & operator<<(DynaLogStream &log, const DynaData & data){ char buff[256]; string prmpt=Almost::DynaStatPr; log.stream()<::helper(data), data.ff_data.vdw_energy, OperatorHelperDynaSolv::helper(data), OperatorHelperDynaUb::helper(data)); log.stream()< DynaDataStream & operator<<(DynaDataStream & dat, const DynaData & data){ dat.stream()<::helper(data)<<" " <::helper(data)<<" " <::helper(data)<<" " < template<> DynaLogStream & operator<< , DynaIGoOptions, ENERGY> (DynaLogStream &log, const DynaData, DynaIGoOptions, ENERGY> &data){ char buff[256]; string prmpt=Almost::DynaStatPr; log.stream()< template<> DynaDataStream & operator<<(DynaDataStream &dat, const DynaData, DynaIGoOptions, ENERGY> &data){ dat.stream()< inline string to_string(const Molecules & molecules){ return ""; } template<> inline string to_string(const MDB & mdb){ return ""; } template DynaType const_dyna(MoveSet & ms, ConstraintCollection & cc){ return DynaType(ms,cc); } DynaOptions c19_defaults__(int FF){ DynaOptions opts(DynaOptions::C19); if(FF==DynaOptions::EEF1){ opts.elec = DynaOptions::RDIE; opts. elec_cutoff = DynaOptions::SWITCH; opts.vdw = DynaOptions::LJ; opts.vdw_cutoff = DynaOptions::SWITCH; opts.eps = 1.0; opts.solv = DynaOptions::EEF1; opts.cut_on = 7.0; opts.cut_off = 9.0; opts.cut_nb = 10.0; } else if(FF!=DynaOptions::SASA) opts.solv = DynaOptions::NONE; return opts; } DynaOptions c19_options(){ return DynaOptions(DynaOptions::C19); } DynaOptions c22_options(){ return DynaOptions(DynaOptions::C22); } extern "C" { void init_dyna(){ //declarations here Module mod = Module("dyna","Monte Carlo simulations"); Class >(mod.self(),"go_options") .def_attribute("e_native",&DynaGoOptions::e_native, "Undocumented") .def_attribute("e_non_native",&DynaGoOptions::e_non_native, "Undocumented") .def_attribute("alpha",&DynaGoOptions::alpha, "Undocumented") .def_attribute("lambda",&DynaGoOptions::lambda,"Undocumented") .def_attribute("ignore_mode",&DynaGoOptions::ignore_mode,"Undocumented") .def_attribute("native_map",&DynaGoOptions::native_map,"Undocumented") .def_attribute("trj",&DynaGoOptions::trj,"Undocumented") .def_attribute("rst",&DynaGoOptions::rst,"Undocumented") .def_attribute("log",&DynaGoOptions::log,"Undocumented") .def_attribute("dat",&DynaGoOptions::dat,"Undocumented") .def_attribute("steps",&DynaGoOptions::steps,"Undocumented") .def_attribute("nprint",&DynaGoOptions::nprint,"Undocumented") .def_attribute("nsave",&DynaGoOptions::nsave,"Undocumented") .def_attribute("temp",&DynaGoOptions::temp,"Undocumented") .def_attribute("seed",&DynaGoOptions::seed,"Undocumented") .def_attribute("selection",&DynaGoOptions::selection,"Undocumented") .def_attribute("save_fitted",&DynaGoOptions::save_fitted,"Undocumented"); Class >(mod.self(),"vdw_go_options") .def_attribute("nn_factor",&DynaIGoOptions::nn_factor,"Undocumented") .def_attribute("alpha",&DynaIGoOptions::alpha,"Undocumented") .def_attribute("lambda",&DynaIGoOptions::lambda,"Undocumented") .def_attribute("ignore_mode",&DynaIGoOptions::ignore_mode,"Undocumented") .def_attribute("native_map",&DynaIGoOptions::native_map,"Undocumented") .def_attribute("trj",&DynaIGoOptions::trj,"Undocumented") .def_attribute("rst",&DynaIGoOptions::rst,"Undocumented") .def_attribute("log",&DynaIGoOptions::log,"Undocumented") .def_attribute("dat",&DynaIGoOptions::dat,"Undocumented") .def_attribute("steps",&DynaIGoOptions::steps,"Undocumented") .def_attribute("nprint",&DynaIGoOptions::nprint,"Undocumented") .def_attribute("nsave",&DynaIGoOptions::nsave,"Undocumented") .def_attribute("temp",&DynaIGoOptions::temp,"Undocumented") .def_attribute("seed",&DynaIGoOptions::seed,"Undocumented") .def_attribute("selection",&DynaIGoOptions::selection,"Undocumented") .def_attribute("save_fitted",&DynaIGoOptions::save_fitted,"Undocumented"); Class >(mod.self(),"dyna_go") .def_method("run", &DynaImplementation::run) .def_method("run_from_mol", &DynaImplementation::run_from_mol) .def_method("cont",&DynaImplementation::cont) .def_method("restart", &DynaImplementation::restart) ; Class >(mod.self(),"dyna_vdw_go") .def_method("run", &DynaImplementation::run) .def_method("run_from_mol", &DynaImplementation::run_from_mol) .def_method("cont",&DynaImplementation::cont) .def_method("restart", &DynaImplementation::restart) ; Class >(mod.self(),"options") .def_attribute("kind",&DynaOptions::kind,"Undocumented") .def_attribute("elec",&DynaOptions::elec,"Undocumented") .def_attribute("elec_cutoff",&DynaOptions::elec_cutoff,"Undocumented") .def_attribute("vdw",&DynaOptions::vdw,"Undocumented") .def_attribute("vdw_cutoff",&DynaOptions::vdw_cutoff,"Undocumented") .def_attribute("solv",&DynaOptions::solv,"Undocumented") .def_attribute("solv_ignore_h",&DynaOptions::solv_ignore_h,"Undocumented") .def_attribute("cut_on",&DynaOptions::cut_on,"Undocumented") .def_attribute("cut_off",&DynaOptions::cut_off,"Undocumented") .def_attribute("e_zero",&DynaOptions::e_zero,"Undocumented") .def_attribute("e_14",&DynaOptions::e_14,"Undocumented") .def_attribute("eps",&DynaOptions::eps,"Undocumented") .def_attribute("r_water",&DynaOptions::r_water,"Undocumented") .def_attribute("vect",&DynaOptions::vect,"Undocumented") .def_attribute("trj",&DynaOptions::trj,"Undocumented") .def_attribute("rst",&DynaOptions::rst,"Undocumented") .def_attribute("log",&DynaOptions::log,"Undocumented") .def_attribute("dat",&DynaOptions::dat,"Undocumented") .def_attribute("steps",&DynaOptions::steps,"Undocumented") .def_attribute("nprint",&DynaOptions::nprint,"Undocumented") .def_attribute("nsave",&DynaOptions::nsave,"Undocumented") .def_attribute("temp",&DynaOptions::temp,"Undocumented") .def_attribute("seed",&DynaOptions::seed,"Undocumented") .def_attribute("selection",&DynaOptions::selection,"Undocumented") .def_attribute("save_fitted",&DynaOptions::save_fitted,"Undocumented"); Class,ArgList1 & > >(mod.self(),"dyna") .def_method("run", &Dyna::run) .def_method("run_from_mol", &Dyna::run_from_mol) .def_method("cont",&Dyna::cont) .def_method("restart", &Dyna::restart) ; mod.def_function("const_dyna","Run a constrained MC simulation", const_dyna >); mod .def_const("C19",(int)DynaOptions::C19) .def_const("C22",(int)DynaOptions::C22) .def_const("NONE",(int)DynaOptions::NONE) .def_const("SASA",(int)DynaOptions::SASA) .def_const("EEF1",(int)DynaOptions::EEF1) ; mod .def_function("c19_defaults","Return options with right defaults",c19_defaults__) .def_function("c19_options","Return options with right defaults",c19_options) .def_function("c22_options","Return options with right defaults",c22_options); } }