Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SetupPoissonBoltzmannPotential.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/moves/SetupAPBSMover.hh
11 /// @brief Setup for Poisson-Boltzmann energy term use in scorefunction
12 /// This mover assumes you have a path to the APBS (Adaptive Poisson-Boltzmann Solver) program
13 /// in the system PATH. The executable name must be "apbs", case-sensitive.
14 /// @author Sachko Honda (honda@apl.washington.edu)
15 
16 // basic
17 #include <basic/Tracer.hh>
18 #include <basic/options/option.hh>
19 #include <basic/options/keys/out.OptionKeys.gen.hh>
20 #include <basic/options/keys/corrections.OptionKeys.gen.hh>
21 
25 #include <core/pose/Pose.hh>
30 #include <basic/datacache/CacheableData.hh>
31 #include <basic/datacache/BasicDataCache.hh>
32 #include <utility/vector1.hh>
33 #include <utility/tag/Tag.hh>
34 #include <utility/string_util.hh>
37 
38 // command line options
39 #include <basic/options/option.hh>
40 #include <basic/options/keys/pb_potential.OptionKeys.gen.hh>
41 
42 #include <string>
43 #include <fstream> // for ifstream
44 #include <cstdio> // for remove()
45 
46 namespace protocols{
47 namespace pb_potential{
48 
51 typedef core::Size Size;
52 
53 static basic::Tracer TR ("protocols.pb_potential.SetupPoissonBoltzmannPotential");
54 
56 {}
58 {}
61 {
63 }
66 {
68 }
71 {
72  return "SetupPoissonBoltzmannPotential";
73 }
74 
76 
78 {}
79 
81 
82 void
84 
85  using namespace core;
86  using namespace scoring;
87  using namespace methods;
88 
89  // Register the empty cache holder if not done so yet.
90  if( !pose.data().has( pose::datacache::CacheableDataType::PB_LIFETIME_CACHE ) ){
92  pose.data().set( pose::datacache::CacheableDataType::PB_LIFETIME_CACHE, new_cache );
93  }
94 
95  // Cache the "which chain" info
97  static_cast< PoissonBoltzmannEnergy::PBLifetimeCacheOP >(pose.data().get_ptr< PoissonBoltzmannEnergy::PBLifetimeCache>(pose::datacache::CacheableDataType::PB_LIFETIME_CACHE ));
98  pose.data().set( pose::datacache::CacheableDataType::PB_LIFETIME_CACHE, cached_data );
99 
100 
101  // Let's clean up the previous run's mess.
102  remove("*.dx");
103  remove("*.in");
104  remove("*.pqr");
105 
106  // Prescore to cache bound/unbound poses. This is necessary for filters.
107  // Bound, unbound
108  ddg_->apply(pose);
109 
110 }
111 
114  return "SetupPoissonBoltzmannPotential";
115 }
117 SetupPB::clone() const {
118  return new SetupPoissonBoltzmannPotential( *this );
119 }
120 
121 void
123  protocols::moves::DataMap & data_map,
124  protocols::filters::Filters_map const & filters_map,
125  protocols::moves::Movers_map const & movers_map,
126  core::pose::Pose const & pose ) {
127  // This param is required when the app is NOT linked against the apbs libraries.
128  // Validate only when it is a requirement, but register in any way.
129  std::string apbs_path; // path to the apbs executable.
130  if( tag->hasOption( "apbs_path" ) ) {
131  apbs_path = tag->getOption<std::string>("apbs_path");
132  }
133 #ifdef LINK_APBS_LIBS
134  std::ifstream apbsstream( apbs_path.c_str() );
135  if( !apbsstream.good() ){
136  TR << "APBS not found. Check the path: " << apbs_path << std::endl;
137  TR.flush();
138  runtime_assert(false);
139  }
140  apbsstream.close();
141 #endif
142  basic::options::option[basic::options::OptionKeys::pb_potential::apbs_path](apbs_path);
143 
144  utility::vector1<Size> charged_chains;
145  if( tag->hasOption( "charged_chains" )) {
146  // comma delimited list of residue numbers in string (e.g. "1,2" for chain 1 and chain 2).
147  utility::vector1<std::string> temp = utility::string_split( tag->getOption< std::string >( "charged_chains" ), ',');
148  for( core::Size i=1; i<=temp.size(); ++i ) {
149  charged_chains.push_back(atoi(temp[i].c_str()));
150  }
151  }
152  else{
153  TR << "No user defined charged chains. Default to : 1" << std::endl;
154  charged_chains.push_back(1);
155  }
156  basic::options::option[basic::options::OptionKeys::pb_potential::charged_chains](charged_chains);
157 
158  utility::vector1<Size> revamp_near_chain;
159  if( tag->hasOption("revamp_near_chain") ) {
160  utility::vector1<std::string> temp = utility::string_split( tag->getOption< std::string >( "revamp_near_chain" ), ',');
161  for( core::Size i=1; i<=temp.size(); ++i ) {
162  revamp_near_chain.push_back(atoi(temp[i].c_str()));
163  }
164  basic::options::option[basic::options::OptionKeys::pb_potential::revamp_near_chain]( revamp_near_chain);
165  }
166 
167  core::Real potential_cap;
168  if( tag->hasOption("potential_cap") ) {
169  potential_cap = tag->getOption<core::Real>( "potential_cap" );
170  basic::options::option[basic::options::OptionKeys::pb_potential::potential_cap]( potential_cap );
171  }
172 
173  bool sidechain_only;
174  if( tag->hasOption("sidechain_only") ) {
175  sidechain_only = tag->getOption<bool>( "sidechain_only" );
176  basic::options::option[basic::options::OptionKeys::pb_potential::sidechain_only]( sidechain_only );
177  }
178 
179  core::Real epsilon;
180  if( tag->hasOption("epsilon") ) {
181  epsilon = tag->getOption<core::Real>( "epsilon" );
182  basic::options::option[basic::options::OptionKeys::pb_potential::epsilon]( epsilon );
183  }
184  bool calcenergy;
185  if( tag->hasOption("calcenergy") ) {
186  calcenergy = tag->getOption<bool>( "calcenergy" );
187  basic::options::option[basic::options::OptionKeys::pb_potential::calcenergy]( calcenergy );
188  }
189  int apbs_debug;
190  if( tag->hasOption("apbs_debug") ) {
191  apbs_debug = tag->getOption<int>( "apbs_debug" );
192  basic::options::option[basic::options::OptionKeys::pb_potential::apbs_debug]( apbs_debug );
193  }
194  //-------------------------------------------------------------------------
195  // Initialize DDG for pre-scoring, which compute bound & unbound energies.
196  //-------------------------------------------------------------------------
198  // Must turn this ON to enable caculation of bound/unbound states.
199  tag->setOption<bool>("repack",1);
200  std::string scorefxn_name = tag->getOption<std::string>("scorefxn");
201  if( scorefxn_name != "" ) {
202  core::scoring::ScoreFunction * scorefxn = data_map.get<core::scoring::ScoreFunction*>("scorefxns", scorefxn_name);
203  TR << "Scorefxn weigths: " << scorefxn->serialize_weights() << std::endl;
204  if( scorefxn->get_weight(core::scoring::PB_elec) == 0. ){
205  TR.Error << "PB_elec term is required. Not found in the scorefxn. Terminating the program..." << std::endl;
206  TR.Error.flush();
207 runtime_assert(false);
208  }
209  }
210  ddg_->parse_my_tag( tag, data_map, filters_map, movers_map, pose );
211 
212 }
215 
216  return new SetupPoissonBoltzmannPotential();
217 }
218 }
219 }