Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InterchainPotential.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
11 /// @brief Statistically derived rotamer pair potentials
12 /// @detailed For docking (or between chains) only those residues at the interface
13 /// and between the two interfaces need to be evaluated
14 /// @author Monica Berrondo
15 
16 
17 // Unit headers
20 
21 #include <core/scoring/AtomVDW.hh>
24 
25 // Package headers
26 
27 // AUTO-REMOVED #include <core/scoring/EnergyGraph.hh>
28 
29 // Project headers
30 #include <core/chemical/AA.hh>
31 // AUTO-REMOVED #include <core/chemical/VariantType.hh>
32 // AUTO-REMOVED #include <core/chemical/ChemicalManager.hh>
35 // AUTO-REMOVED #include <core/kinematics/FoldTree.hh>
36 #include <basic/database/open.hh>
37 #include <core/pose/Pose.hh>
39 #include <basic/datacache/BasicDataCache.hh>
40 
41 // Utility headers
42 #include <utility/io/izstream.hh>
43 // AUTO-REMOVED #include <utility/utility.functions.hh>
44 
45 // just for debugging
46 //#include <ObjexxFCL/format.hh>
47 
48 #include <basic/Tracer.hh>
49 
51 #include <utility/vector1.hh>
52 
53 using basic::T;
54 using basic::Error;
55 using basic::Warning;
56 
57 static basic::Tracer TC("protocols.scoring.InterchainPotential");
58 
59 
60 
61 // C++
62 
63 namespace protocols {
64 namespace scoring {
65 
66 
67 InterchainPotential * InterchainPotential::instance_( 0 );
68 
70  if ( instance_ == 0 ) {
72  }
73  return instance_;
74 }
75 
76 
78  core::scoring::EnvPairPotential(),
79  atom_vdw_( core::scoring::ScoringManager::get_instance()->get_AtomVDW( core::chemical::CENTROID ) ) // need to make the table choice configurable
80 {
81 
82  using core::Size;
83  // load the data
84  Size const max_aa( 20 ); // just the standard aa's for now
85  Size const env_log_table_size( 4 );
86 
87  std::string tag,line;
89 
90  { // interchain_env_log
91  interchain_env_log_.dimension( max_aa, env_log_table_size );
92 
93  utility::io::izstream stream;
94  basic::database::open( stream, "scoring/score_functions/InterchainPotential/interchain_env_log.txt" );
95  while ( getline( stream, line ) ) {
96  std::istringstream l(line);
97  l >> tag >> aa;
98  for ( Size i=1; i<= env_log_table_size; ++i ){
99  l >> interchain_env_log_(aa,i);
100  }
101  if ( l.fail() || tag != "INT_CHAIN_ENV_LOG:" ) utility_exit_with_message("bad format for scoring/score_functions/InterchainPotential/interchain_env_log.txt");
102  }
103  }
104  { // interchain_pair_log
105  interchain_pair_log_.dimension( max_aa, max_aa );
106 
107  utility::io::izstream stream;
108  basic::database::open( stream, "scoring/score_functions/InterchainPotential/interchain_pair_log.txt" );
109  while ( getline( stream, line ) ) {
110  std::istringstream l(line);
111  l >> tag >> aa;
112  for ( Size i=1; i<= max_aa; ++i ) {
113  l >> interchain_pair_log_(aa,i);
114  }
115  if ( l.fail() || tag != "INT_CHAIN_PAIR_LOG:" ) utility_exit_with_message("bad format for scoring/score_functions/InterchainPotential/interchain_pair_log.txt");
116  }
117  }
118 }
119 
120 void
122  core::pose::Pose & pose
123  ) const
124 {
125  InterfaceInfo & interface( nonconst_interface_from_pose( pose ) );
126 
127  /// initialize the cenlist info:
128  /// only if they have not been calculated since the last score
129  if ( !interface.calculated() ) {
130 
131  // initialize values
132  interface.initialize();
133 
134  // compute interpolated number of neighbors at various distance cutoffs
135  interface.calculate( pose );
136  }
137 
138  interface.calculated() = true;
139 }
140 
141 void
143 {
145  CenListInfo & cenlist( nonconst_cenlist_from_pose( pose ));
146  cenlist.calculated() = false;
147 
148  InterfaceInfo & interface( nonconst_interface_from_pose( pose ) );
149  interface.calculated() = false;
150 }
151 
152 ////////////////////////////////////////////////////////////////////////////////////
153 void
155  core::pose::Pose const & pose,
156  core::conformation::Residue const & rsd,
157  core::Real & env_score
158 ) const
159 {
160  int env;
161  using core::Real;
162  Real const fcen10 ( cenlist_from_pose( pose ).fcen10(rsd.seqpos()) );
163 
164  InterfaceInfo const & interface( interface_from_pose( pose ) );
165 
166  //reset env_score
167  env_score = 0.0;
168 
169  if (rsd.is_protein() == false) return;
170 
171  bool is_interface = interface.is_interface( rsd );
172 
173  if ( is_interface ) {
174  if ( fcen10 > 16 )
175  env = 1;
176  else
177  env = 2;
178  } else {
179  if ( fcen10 > 16 )
180  env = 3;
181  else
182  env = 4;
183  }
184 
185  env_score = interchain_env_log_( rsd.aa(), env );
186  //std::cout << " residue: " << rsd.seqpos() << " res(i) " << rsd.aa()
187  // << " env " << env << " score " << env_score << "\n";
188 }
189 
190 ///////////////////////////////////////////////////////////////////////////////////////////////
191 void
193  core::pose::Pose const & pose,
194  core::Real & contact_score
195 ) const
196 {
197  protocols::scoring::InterfaceInfo const & interface( interface_from_pose( pose ) );
198 
199  //reset contact score
200  contact_score = 0;
201 
202  //calculate contact score for each jump, sum total is contact score
203  using core::Size;
204  using core::Real;
205  for (Size i = 1; i <= interface.num_jump(); i++){
206  int interface_residues = interface.interface_nres(i);
207 
208  Real contact_score_jump = ( 20 - interface_residues ) * 0.5;
209  if ( interface_residues == 0 ) contact_score_jump += 2.0;
210  if ( interface_residues == 1 ) contact_score_jump += 1.0;
211  if ( interface_residues == 2 ) contact_score_jump += 0.5;
212 
213  contact_score += contact_score_jump;
214  }
215 }
216 
217 ///////////////////////////////////////////////////////////////////////////////////////////////
218 
219 void
221  core::pose::Pose const & pose,
222  core::conformation::Residue const & rsd1,
223  core::conformation::Residue const & rsd2,
224  core::Real & pair_contribution,
225  core::Real & vdw_contribution
226 ) const
227 {
228  InterfaceInfo const & interface( interface_from_pose( pose ) );
229 
230  pair_contribution = 0.0;
231  vdw_contribution = 0.0;
232 
233  if ( !rsd1.is_protein() || !rsd2.is_protein() ) return;
234 
235  if (interface.is_pair( rsd1, rsd2) == false) return;
236 
237  //fpd to match pre-48179 only compute when centroids are within 12.05A
238  core::conformation::Atom const & cen1 ( rsd1.atom( rsd1.nbr_atom() ) ), cen2 (rsd2.atom( rsd2.nbr_atom() ) );
239  core::Real const cendist = cen1.xyz().distance_squared( cen2.xyz() );
240  if (cendist > 12.05*12.05) return;
241 
242  pair_contribution = interchain_pair_log_( rsd1.aa(), rsd2.aa() );
243 
244  using namespace core;
245  // calculation for vdw?
246  // atoms between two chains are guaranteed to not be bonded
247  // no countpair!
248  for ( Size i=1, i_end = rsd1.natoms(); i<= i_end; ++i ) {
249  Vector const & i_xyz( rsd1.xyz(i) );
250  Size const i_type( rsd1.atom_type_index(i) );
251  utility::vector1< Real > const & i_atom_vdw( atom_vdw_( i_type ) );
252  for ( Size j=1, j_end = rsd2.natoms(); j<= j_end; ++j ) {
253  Real const bump_dis( i_atom_vdw[ rsd2.atom_type_index(j) ] );
254  Real const clash( bump_dis - i_xyz.distance_squared( rsd2.xyz(j) ) );
255  if ( clash > 0.0 ) {
256  vdw_contribution += ( clash * clash ) / bump_dis;
257  }
258  }
259  }
260 }
261 
262 /// @details Pose must already contain a Interface object or this method will fail
263 InterfaceInfo const &
265 {
266  //using core::pose::datacache::CacheableDataType::INTERFACE_INFO;
267  return *( static_cast< InterfaceInfo const * >(pose.data().get_const_ptr( core::pose::datacache::CacheableDataType::INTERFACE_INFO )() ) );
268 }
269 
270 /// @details Either returns a non-const reference to the Interface object that already exists
271 /// in the pose, or creates a new Interface object, places it in the pose, and then returns
272 /// a non-const reference to it
275 {
276  //using core::pose::datacache::CacheableDataType::INTERFACE_INFO;
277 
279  return *( static_cast< InterfaceInfo * >(pose.data().get_ptr( core::pose::datacache::CacheableDataType::INTERFACE_INFO )() ) );
280  }
281  // else
282  InterfaceInfoOP interface = new InterfaceInfo;
284  return *interface;
285 }
286 
287 }
288 }