Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DatabaseOccSolEne.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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file core/scoring/geometric_solvation/DatabaseOccSolEne.cc
10 /// @brief Database containing params for OccludedHbondSolEnergy
11 /// @author John Karanicolas
12 
13 
14 // Unit Headers
16 
17 // Package headers
18 
19 
20 // Project headers
24 
25 // AUTO-REMOVED #include <basic/database/open.hh>
26 #include <basic/Tracer.hh>
27 
28 // Utility headers
29 #include <utility/io/izstream.hh>
30 
31 
32 #include <cmath>
33 
34 #include <utility/vector1.hh>
35 
36 
37 namespace core {
38 namespace scoring {
39 namespace geometric_solvation {
40 
41 static basic::Tracer tr("core.scoring.DatabaseOccSolEne");
42 
43 
44 /// @details ctor, reads data file. Need to configure to allow alternate tables/atom_sets
45 DatabaseOccSolEne::DatabaseOccSolEne( std::string const & etable_name, Real const & min_occ_energy ):
46  min_occ_energy_(min_occ_energy)
47 {
48 
49  if ( etable_name != scoring::FA_STANDARD_DEFAULT ) {
50  utility_exit_with_message( "cannot presently use OccludedHbondSolEnergy in any mode but FA_STANDARD_DEFAULT, current mode is " + etable_name );
51  }
52 
53  // get the relevant atomset
54  chemical::AtomTypeSet const & atom_set
56 
58  tr << "reading params" << std::endl;
59  read_datafile( atom_set, atom_set.directory() + "/occluded_hbond_solvation_params.donors.txt", donor_occ_data_, true );
60  read_datafile( atom_set, atom_set.directory() + "/occluded_hbond_solvation_params.acceptors.txt", acc_occ_data_, false );
61 
62 }
63 
64 
65 void
67  chemical::AtomTypeSet const & atom_set,
68  std::string const & database_name,
70  bool const process_donors // needed solely to distinguish OH's in reweighting, can go away once reweighting goes into the param files
71 )
72 {
73 
74  // initialize the values
75  Size const n_atom_types( atom_set.n_atomtypes() );
76  occ_data_.clear();
77  occ_data_.resize( n_atom_types );
78  for ( Size j=1; j <= n_atom_types; ++j ) {
79  occ_data_[j].resize( n_atom_types );
80  for ( Size k=1; k <= n_atom_types; ++k ) {
81  // initialize to an unreasonable value, so we can assert lookups are valid
82  occ_data_[j][k].resize( OccFitParam_num_params, -2. );
83  }
84  }
85 
86  utility::io::izstream stream;
87  stream.open( database_name );
88  if ( !stream.good() ) {
89  utility_exit_with_message( "Unable to open " + database_name );
90  }
91 
92  // skip header line
93  std::string line;
94  // no header for now...
95  // getline( stream, line );
96 
97  // process lines containing data
98  // Note: file format is: polar_atom_name occ_atom_name 5 params (amp, 2x mu, 2x sigma)
99  while ( getline( stream, line ) ) {
100  std::istringstream l(line);
101  // get the atom types from the names - will fail if name is not recognized
102  std::string polar_atom_type_name, occ_atom_type_name;
103  l >> polar_atom_type_name;
104  Size const polar_atom_type_index( atom_set.atom_type_index( polar_atom_type_name ) );
105  l >> occ_atom_type_name;
106  Size const occ_atom_type_index( atom_set.atom_type_index( occ_atom_type_name ) );
107 
108  // this term reweights to the exact model to account for lack of actual pairwise additivity
109  Real amp_reweighting(0.387829);
110  if ( process_donors ) {
111  if ( polar_atom_type_name == "NH2O" ) {
112  amp_reweighting *= 0.8534;
113  } else if ( polar_atom_type_name == "Narg" ) {
114  amp_reweighting *= 0.9365;
115  } else if ( polar_atom_type_name == "Nbb" ) {
116  amp_reweighting *= 0.7724;
117  } else if ( polar_atom_type_name == "Nlys" ) {
118  amp_reweighting *= 0.8122;
119  } else if ( polar_atom_type_name == "Ntrp" ) {
120  amp_reweighting *= 0.9530;
121  } else if ( polar_atom_type_name == "OH" ) {
122  amp_reweighting *= 0.8968;
123  } else {
124  utility_exit_with_message( "unrecognized donor polar atom type " + polar_atom_type_name );
125  }
126  } else {
127  if ( polar_atom_type_name == "Nhis" ) {
128  amp_reweighting *= 1.0727;
129  } else if ( polar_atom_type_name == "OCbb" ) {
130  amp_reweighting *= 1.1669;
131  } else if ( polar_atom_type_name == "OH" ) {
132  amp_reweighting *= 1.0333;
133  } else if ( polar_atom_type_name == "ONH2" ) {
134  amp_reweighting *= 0.9672;
135  } else if ( polar_atom_type_name == "OOC" ) {
136  amp_reweighting *= 0.8558;
137  } else {
138  utility_exit_with_message( "unrecognized donor polar atom type " + polar_atom_type_name );
139  }
140  }
141 
142  // read data
143  Real amp, dist_mu, twice_dist_sigma_sq, cos_angle_mu, twice_cos_angle_sigma_sq;
144  l >> amp; l >> dist_mu; l >> twice_dist_sigma_sq; l >> cos_angle_mu; l >> twice_cos_angle_sigma_sq;
145  if ( l.fail() ) utility_exit_with_message( "bad format in " + database_name);
146 
147  // store data
148  occ_data_[ polar_atom_type_index ][ occ_atom_type_index ][ OccFitParam_amp ] = amp * amp_reweighting;
149  occ_data_[ polar_atom_type_index ][ occ_atom_type_index ][ OccFitParam_dist_mu ] = dist_mu;
150  occ_data_[ polar_atom_type_index ][ occ_atom_type_index ][ OccFitParam_twice_dist_sigma_sq ] = twice_dist_sigma_sq;
151  occ_data_[ polar_atom_type_index ][ occ_atom_type_index ][ OccFitParam_cos_angle_mu ] = cos_angle_mu;
152  occ_data_[ polar_atom_type_index ][ occ_atom_type_index ][ OccFitParam_twice_cos_angle_sigma_sq ] = twice_cos_angle_sigma_sq;
153 
154  // set jumpout conditions (and atomic_interaction_cutoff_)
155  // at what difference from dist_mu will the distance lead to an energy of min_occ_energy_ (assuming perfect cos_angle)?
156  Real dist_away_from_mu = compute_jumpout_diff( amp, twice_dist_sigma_sq );
157  Real max_dist_to_compute = dist_mu + dist_away_from_mu;
158  occ_data_[ polar_atom_type_index ][ occ_atom_type_index ][ OccFitParam_max_sq_dist ] = max_dist_to_compute * max_dist_to_compute;
159  if ( max_dist_to_compute > atomic_interaction_cutoff_ ) atomic_interaction_cutoff_ = max_dist_to_compute;
160 
161  // at what difference from cos_angle_mu will the cosine lead to an energy of min_occ_energy_ (assuming perfect dist)?
162  Real cos_angle_away_from_mu = compute_jumpout_diff( amp, twice_cos_angle_sigma_sq );
163  Real min_cos_angle_to_compute = cos_angle_mu - cos_angle_away_from_mu;
164  if ( min_cos_angle_to_compute < -1. ) min_cos_angle_to_compute = -1.;
165  occ_data_[ polar_atom_type_index ][ occ_atom_type_index ][ OccFitParam_min_cos_angle ] = min_cos_angle_to_compute;
166 
167  }
168 
169 }
170 
171 
172 Real
173 DatabaseOccSolEne::compute_jumpout_diff( Real const & amp, Real const & twice_sigma_sq )
174 {
175 
176  // At what difference from mu will this gaussian (passed in) give a value less than min_occ_energy_ ?
177  assert ( amp > min_occ_energy_ );
178  assert ( twice_sigma_sq > 0. );
179  return sqrt ( - twice_sigma_sq * log( min_occ_energy_ / amp ) );
180 
181 }
182 
183 
184 } // geometric_solvation
185 } // namespace scoring
186 } // namespace core
187