Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FullatomDisulfideEnergy.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 core/scoring/disulfides/FullatomDisulfideEnergy.cc
11 /// @brief Disulfide Energy class implementation
12 /// @author Andrew Leaver-Fay
13 
14 // Unit headers
17 
18 // Package headers
22 
23 // Project headers
24 #include <core/pose/Pose.hh>
29 #include <core/scoring/Energies.hh>
30 // AUTO-REMOVED #include <core/scoring/ScoreFunction.hh>
34 #include <basic/datacache/CacheableData.hh>
35 
37 #include <utility/vector1.hh>
38 
39 
40 namespace core {
41 namespace scoring {
42 namespace disulfides {
43 
44 class DisulfMinData : public basic::datacache::CacheableData
45 {
46 public:
47  typedef basic::datacache::CacheableDataOP CacheableDataOP;
48 public:
49  DisulfMinData( conformation::Residue const & res1, conformation::Residue const & res2 );
50  virtual ~DisulfMinData();
51  CacheableDataOP clone() const;
52 
53  /// @brief which_res should be 1 or 2
54  void set_res_inds( Size which_res, DisulfideAtomIndices const & dais );
55  DisulfideAtomIndices const & res_inds( Size which_res ) const;
56 
57 private:
60 };
61 
64 
65 
67  conformation::Residue const & res1,
68  conformation::Residue const & res2
69 ) :
70  res1_inds_( res1 ),
71  res2_inds_( res2 )
72 {}
73 
75 
77 
78 /// @brief which_res should be 1 or 2
79 void DisulfMinData::set_res_inds( Size which_res, DisulfideAtomIndices const & dais )
80 {
81  assert( which_res == 1 || which_res == 2 );
82  if ( which_res == 1 ) res1_inds_ = dais;
83  else res2_inds_ = dais;
84 }
85 
87 DisulfMinData::res_inds( Size which_res ) const
88 {
89  assert( which_res == 1 || which_res == 2 );
90  return which_res == 1 ? res1_inds_ : res2_inds_;
91 }
92 
93 
94 /// @details This must return a fresh instance of the FullatomDisulfideEnergy class,
95 /// never an instance already in use
99 ) const {
100  return new FullatomDisulfideEnergy( ScoringManager::get_instance()->get_FullatomDisulfidePotential() );
101 }
102 
105  ScoreTypes sts;
106  sts.push_back( dslf_ss_dst );
107  sts.push_back( dslf_cs_ang );
108  sts.push_back( dslf_ss_dih );
109  sts.push_back( dslf_ca_dih );
110  sts.push_back( dslf_cbs_ds );
111  return sts;
112 }
113 
114 
115 
117 :
119  potential_( potential )
120 {}
121 
123 {}
124 
125 // EnergyMethod Methods:
126 
129 {
130  return new FullatomDisulfideEnergy( potential_ );
131 }
132 
133 void
135  pose::Pose & pose
136 ) const
137 {
138  using namespace methods;
139 
140  if ( pose.energies().long_range_container( fa_disulfide_energy ) == 0 ) {
143  } else {
145  static_cast< FullatomDisulfideEnergyContainer * > (
147  dec->update( pose );
148  if ( dec->num_residues() != pose.conformation().size() ) {
151  }
152  }
153 }
154 
155 void
157  pose::Pose & pose,
158  ScoreFunction const & ) const
159 {
161 }
162 
163 void
165  pose::Pose & pose,
166  utility::vector1< bool > const & ,
168 ) const
169 {
171 }
172 
173 /// @details returns true if both residues are cys, if both are disulfide-cys, and then
174 /// if all of these conditions have been satisfied, if residue1's SG atom connects to residue 2,
175 /// and if residue 2's SG atom connects to residue 1
176 bool
178  conformation::Residue const & res1,
179  conformation::Residue const & res2,
180  bool res_moving_wrt_eachother
181 ) const
182 {
183  using namespace chemical;
184  return res_moving_wrt_eachother && res1.aa() == aa_cys && res2.aa() == aa_cys &&
186  res1.type().has_atom_name( "SG" ) &&
187  res1.connect_map( res1.type().residue_connection_id_for_atom( res1.atom_index( "SG" ) ) ).resid() == res2.seqpos() &&
188  res2.type().has_atom_name( "SG" ) &&
189  res2.connect_map( res2.type().residue_connection_id_for_atom( res2.atom_index( "SG" ) ) ).resid() == res1.seqpos();
190 }
191 
192 bool
194 
195 bool
197 
198 void
200  conformation::Residue const & rsd1,
201  conformation::Residue const & rsd2,
202  ResPairMinimizationData const & min_data,
203  pose::Pose const &,
204  ScoreFunction const &,
205  EnergyMap & emap
206 ) const
207 {
208  // ignore scoring residues which have been marked as "REPLONLY" residues (only the repulsive energy will be calculated)
210  return;
211  }
212 
213  conformation::Residue const & rsdl( rsd1.seqpos() < rsd2.seqpos() ? rsd1 : rsd2 );
214  conformation::Residue const & rsdu( rsd1.seqpos() < rsd2.seqpos() ? rsd2 : rsd1 );
215 
216  assert( dynamic_cast< DisulfMinData const * > ( min_data.get_data( fa_dslf_respair_data )() ) );
217  DisulfMinData const & disulf_inds = static_cast< DisulfMinData const & > ( *min_data.get_data( fa_dslf_respair_data ) );
218 
219  Energy distance_score_this_disulfide;
220  Energy csangles_score_this_disulfide;
221  Energy dihedral_score_this_disulfide;
222  Energy ca_dihedral_sc_this_disulf;
223  bool truefalse_fa_disulf;
224 
226  rsdl, rsdu,
227  disulf_inds.res_inds( 1 ),
228  disulf_inds.res_inds( 2 ),
229  distance_score_this_disulfide,
230  csangles_score_this_disulfide,
231  dihedral_score_this_disulfide,
232  ca_dihedral_sc_this_disulf,
233  truefalse_fa_disulf
234  );
235 
236  emap[ dslf_ss_dst ] += distance_score_this_disulfide;
237  emap[ dslf_cs_ang ] += csangles_score_this_disulfide;
238  emap[ dslf_ss_dih ] += dihedral_score_this_disulfide;
239  emap[ dslf_ca_dih ] += ca_dihedral_sc_this_disulf;
240 
241 }
242 
243 void
245  conformation::Residue const & rsd1,
246  conformation::Residue const & rsd2,
247  pose::Pose const &,
248  ScoreFunction const &,
252  ResPairMinimizationData & data_cache
253 ) const
254 {
255  // ignore scoring residues which have been marked as "REPLONLY" residues (only the repulsive energy will be calculated)
257  return;
258  }
259 
260  conformation::Residue const & rsdl( rsd1.seqpos() < rsd2.seqpos() ? rsd1 : rsd2 );
261  conformation::Residue const & rsdu( rsd1.seqpos() < rsd2.seqpos() ? rsd2 : rsd1 );
262 
263  DisulfMinDataOP disulf_inds = new DisulfMinData( rsdl, rsdu );
264 
265  data_cache.set_data( fa_dslf_respair_data, disulf_inds );
266 }
267 
268 void
270  conformation::Residue const & rsd1,
271  conformation::Residue const & rsd2,
274  ResPairMinimizationData const & min_data,
275  pose::Pose const &,
276  EnergyMap const & weights,
277  utility::vector1< DerivVectorPair > & r1_atom_derivs,
278  utility::vector1< DerivVectorPair > & r2_atom_derivs
279 ) const
280 {
281  // ignore scoring residues which have been marked as "REPLONLY" residues (only the repulsive energy will be calculated)
283  return;
284  }
285 
286  assert( dynamic_cast< DisulfMinData const * > ( min_data.get_data( fa_dslf_respair_data )() ) );
287  DisulfMinData const & disulf_inds = static_cast< DisulfMinData const & > ( *min_data.get_data( fa_dslf_respair_data ) );
288 
289  /// this could be substantially more efficient, but there are only ever a handful of disulfides in proteins,
290  /// so there's basically no point in spending time making this code faster
292  rsd1, rsd2, disulf_inds.res_inds( 1 ), disulf_inds.res_inds( 2 ),
293  disulf_inds.res_inds(1).c_alpha_index(), weights,
294  r1_atom_derivs[ disulf_inds.res_inds(1).c_alpha_index() ].f1(),
295  r1_atom_derivs[ disulf_inds.res_inds(1).c_alpha_index() ].f2() );
296 
298  rsd1, rsd2, disulf_inds.res_inds( 1 ), disulf_inds.res_inds( 2 ),
299  disulf_inds.res_inds(1).c_beta_index(), weights,
300  r1_atom_derivs[ disulf_inds.res_inds(1).c_beta_index() ].f1(),
301  r1_atom_derivs[ disulf_inds.res_inds(1).c_beta_index() ].f2() );
302 
304  rsd1, rsd2, disulf_inds.res_inds( 1 ), disulf_inds.res_inds( 2 ),
305  disulf_inds.res_inds(1).disulf_atom_index(), weights,
306  r1_atom_derivs[ disulf_inds.res_inds(1).disulf_atom_index() ].f1(),
307  r1_atom_derivs[ disulf_inds.res_inds(1).disulf_atom_index() ].f2() );
308 
310  rsd2, rsd1, disulf_inds.res_inds( 2 ), disulf_inds.res_inds( 1 ),
311  disulf_inds.res_inds(2).c_alpha_index(), weights,
312  r2_atom_derivs[ disulf_inds.res_inds(2).c_alpha_index() ].f1(),
313  r2_atom_derivs[ disulf_inds.res_inds(2).c_alpha_index() ].f2() );
314 
316  rsd2, rsd1, disulf_inds.res_inds( 2 ), disulf_inds.res_inds( 1 ),
317  disulf_inds.res_inds(2).c_beta_index(), weights,
318  r2_atom_derivs[ disulf_inds.res_inds(2).c_beta_index() ].f1(),
319  r2_atom_derivs[ disulf_inds.res_inds(2).c_beta_index() ].f2() );
320 
322  rsd2, rsd1, disulf_inds.res_inds( 2 ), disulf_inds.res_inds( 1 ),
323  disulf_inds.res_inds(2).disulf_atom_index(), weights,
324  r2_atom_derivs[ disulf_inds.res_inds(2).disulf_atom_index() ].f1(),
325  r2_atom_derivs[ disulf_inds.res_inds(2).disulf_atom_index() ].f2() );
326 
327 }
328 
329 /*void
330 FullatomDisulfideEnergy::eval_atom_derivative_for_residue_pair(
331  Size const atom_index,
332  conformation::Residue const & rsd1,
333  conformation::Residue const & rsd2,
334  ResSingleMinimizationData const &,
335  ResSingleMinimizationData const &,
336  ResPairMinimizationData const & minpair_data,
337  pose::Pose const &, // provides context
338  kinematics::DomainMap const &,
339  ScoreFunction const &,
340  EnergyMap const & weights,
341  Vector & F1,
342  Vector & F2
343 ) const
344 {
345  Size my_ind( rsd1.seqpos() < rsd2.seqpos() ? 1 : 2 );
346  Size other_ind( rsd1.seqpos() < rsd2.seqpos() ? 2 : 1 );
347 
348  assert( dynamic_cast< DisulfMinData const * > ( minpair_data.get_data( fa_dslf_respair_data )() ) );
349  DisulfMinData const & disulf_inds = static_cast< DisulfMinData const & > ( *minpair_data.get_data( fa_dslf_respair_data ) );
350 
351  Vector f1( 0.0 ), f2( 0.0 );
352  potential_.get_disulfide_derivatives(
353  rsd1, rsd2,
354  disulf_inds.res_inds( my_ind ),
355  disulf_inds.res_inds( other_ind ),
356  atom_index,
357  weights,
358  f1, f2 );
359 
360  F1 += f1;
361  F2 += f2;
362 }*/
363 
364 void
366  id::AtomID const & atomid,
367  pose::Pose const & pose,
368  kinematics::DomainMap const &,
369  ScoreFunction const &,
370  EnergyMap const & weights,
371  Vector & F1,
372  Vector & F2
373 ) const
374 {
375  // ignore scoring residues which have been marked as "REPLONLY" residues (only the repulsive energy will be calculated)
376  if ( pose.residue( atomid.rsd() ).has_variant_type( core::chemical::REPLONLY )){
377  return;
378  }
379 
381  static_cast< FullatomDisulfideEnergyContainer const * > (
383  if ( ! dec->residue_forms_disulfide( atomid.rsd() ) ) return;
384 
385  if ( dec->disulfide_atom_indices( atomid.rsd() ).atom_gets_derivatives( atomid.atomno() ) ) {
386  conformation::Residue const & res( pose.residue( atomid.rsd() ));
387  //if ( res.atom_name( atomid.atomno() ) == " CA " ||
388  // res.atom_name( atomid.atomno() ) == " CB " ||
389  // res.atom_name( atomid.atomno() ) == " SG " ) {
390  Vector f1( 0.0 ), f2( 0.0 );
392  res,
393  pose.residue( dec->other_neighbor_id( atomid.rsd()) ),
394  dec->disulfide_atom_indices( atomid.rsd() ),
395  dec->other_neighbor_atom_indices( atomid.rsd() ),
396  atomid.atomno(),
397  weights,
398  f1, f2 );
399  F1 += f1;
400  F2 += f2;
401  }
402 
403 }
404 
405 
406 
407 Real
409  id::DOF_ID const &,
410  id::TorsionID const &,
411  pose::Pose const &,
412  ScoreFunction const &,
413  EnergyMap const &
414 ) const
415 {
416  return 0.0;
417 }
418 
419 void
421 {}
422 
423 
424 // TwoBodyEnergy Methods:
425 
426 void
428  conformation::Residue const & rsd1,
429  conformation::Residue const & rsd2,
430  pose::Pose const & pose,
431  ScoreFunction const &,
432  EnergyMap & emap
433 ) const
434 {
435  // ignore scoring residues which have been marked as "REPLONLY" residues (only the repulsive energy will be calculated)
437  return;
438  }
439 
440  if ( rsd1.aa() != chemical::aa_cys || rsd2.aa() != chemical::aa_cys ) return;
441 
442  Energy distance_score_this_disulfide;
443  Energy csangles_score_this_disulfide;
444  Energy dihedral_score_this_disulfide;
445  Energy ca_dihedral_sc_this_disulf;
446  bool truefalse_fa_disulf;
447 
449  static_cast< FullatomDisulfideEnergyContainer const * > (
451 
452  if ( ! dec->residue_forms_disulfide( rsd1.seqpos() ) ||
453  dec->other_neighbor_id( rsd1.seqpos() ) != (Size) rsd2.seqpos() ){
454  return;
455  }
456 
458  rsd1, rsd2,
459  dec->disulfide_atom_indices( rsd1.seqpos() ),
460  dec->other_neighbor_atom_indices( rsd1.seqpos() ), //The function change from the above line changes which index we get; if we also change which rsd we use then it turns everything upside down twice and the disulfide_atom_indices inappropriately match
461  distance_score_this_disulfide,
462  csangles_score_this_disulfide,
463  dihedral_score_this_disulfide,
464  ca_dihedral_sc_this_disulf,
465  truefalse_fa_disulf
466  );
467 
468  /*
469  Energy cbs_sc_this_disulf( 0.0 );
470 
471  if ( ! sfxn.has_zero_weight( dslf_cbs_ds ) ) {
472  potential_.get_cbs_sc_this_disulf(
473  rsd1, rsd2, cbs_sc_this_disulf
474  );
475  }
476  */
477 
478  //if ( truefalse_fa_disulf ) { // this just allows the packer to unwittingly break a disulfide bond, what is its point?
479  emap[ dslf_ss_dst ] += distance_score_this_disulfide;
480  emap[ dslf_cs_ang ] += csangles_score_this_disulfide;
481  emap[ dslf_ss_dih ] += dihedral_score_this_disulfide;
482  emap[ dslf_ca_dih ] += ca_dihedral_sc_this_disulf;
483 
484  //emap[ dslf_cbs_ds ] = cbs_sc_this_disulf;
485  //}
486 }
487 
488 
489 bool
491 {
492  return false;
493 }
494 
495 
496 void
498  conformation::Residue const &,
499  pose::Pose const &,
500  ScoreFunction const &,
501  EnergyMap &
502 ) const
503 {
504 }
505 
506 // LongRangeTwoBodyEnergy methods
509 {
511 }
512 
513 
514 bool
516  pose::Pose const & pose,
517  Size res1,
518  Size res2
519 ) const
520 {
521 
522  using namespace methods;
523  if ( ! pose.energies().long_range_container( fa_disulfide_energy )) return false;
524 
526  static_cast< FullatomDisulfideEnergyContainer const * > (
528  return dec->disulfide_bonded( res1, res2 );
529 } core::Size
531 {
532  return 1; // Initial versioning
533 }
534 
535 
536 } // namespace disulfides
537 } // namespace scoring
538 } // namespace core
539