Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ChainbreakEnergy.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/ScoreFunction.cc
11 /// @brief Atom pair energy functions
12 /// @author Stuart G. Mentzer (Stuart_Mentzer@objexx.com)
13 /// @author Kevin P. Hinshaw (KevinHinshaw@gmail.com)
14 
15 
16 // Unit headers
19 
20 // Package headers
21 
22 
23 // Project headers
24 #include <core/pose/Pose.hh>
27 //#include <core/scoring/ScoringManager.hh>
30 
34 
35 #include <core/id/AtomID.hh>
36 #include <utility/vector1.hh>
37 
38 
39 // Numeric headers
40 
41 
42 namespace core {
43 namespace scoring {
44 namespace methods {
45 
46 
47 /// @details This must return a fresh instance of the ChainbreakEnergy class,
48 /// never an instance already in use
52 ) const {
53  return new ChainbreakEnergy;
54 }
55 
58  ScoreTypes sts;
59  sts.push_back( chainbreak );
60  return sts;
61 }
62 
63 
66 {}
67 
68 /// called at the end of energy evaluation
69 /// In this case (ChainbreakEnergy), all the calculation is done here
70 
71 void
73  pose::Pose & pose,
74  ScoreFunction const &,
75  EnergyMap & totals
76 ) const
77 {
78  Size max_res = pose.n_residue();
79  if ( core::pose::symmetry::is_symmetric( pose ) ) {
80  using namespace core::conformation::symmetry;
81  SymmetricConformation const & symm_conf(dynamic_cast< SymmetricConformation const & > ( pose.conformation() ) );
82  SymmetryInfoCOP symm_info( symm_conf.Symmetry_Info() );
83  max_res = symm_info->num_independent_residues() - 1;
84  }
85 
87  Real total_dev(0.0);
88  for ( int n=1; n<= pose.fold_tree().num_cutpoint(); ++n ) {
89  int const cutpoint( pose.fold_tree().cutpoint( n ) );
90  if(cutpoint > (int)max_res) continue;
91  Residue const & lower_rsd( pose.residue( cutpoint ) );
92  if ( !lower_rsd.has_variant_type( chemical::CUTPOINT_LOWER ) ) continue;
93 
94  Residue const & upper_rsd( pose.residue( cutpoint+1 ) );
95  assert( upper_rsd.has_variant_type( chemical::CUTPOINT_UPPER ) );
96  Size const nbb( lower_rsd.mainchain_atoms().size() );
97  total_dev +=
98  ( upper_rsd.atom( upper_rsd.mainchain_atoms()[ 1] ).xyz().distance_squared( lower_rsd.atom( "OVL1" ).xyz() ) +
99  upper_rsd.atom( upper_rsd.mainchain_atoms()[ 2] ).xyz().distance_squared( lower_rsd.atom( "OVL2" ).xyz() ) +
100  lower_rsd.atom( lower_rsd.mainchain_atoms()[nbb] ).xyz().distance_squared( upper_rsd.atom( "OVU1" ).xyz() ) );
101  }
102  assert( std::abs( totals[ chainbreak ] ) < 1e-3 );
103  totals[ chainbreak ] = total_dev;
104 }
105 
106 
107 
108  /// called during gradient-based minimization inside dfunc
109  /**
110  F1 and F2 are not zeroed -- contributions from this atom are
111  just summed in
112  **/
113 
114 void
116  id::AtomID const & id,
117  pose::Pose const & pose,
118  kinematics::DomainMap const &, // domain_map,
119  ScoreFunction const &, // sfxn,
120  EnergyMap const & weights,
121  Vector & F1,
122  Vector & F2
123 ) const
124 {
125  using conformation::Residue;
128 
129  Size max_res = pose.n_residue();
130  if ( core::pose::symmetry::is_symmetric( pose ) ) {
131  using namespace core::conformation::symmetry;
132  SymmetricConformation const & symm_conf(dynamic_cast< SymmetricConformation const & > ( pose.conformation() ) );
133  SymmetryInfoCOP symm_info( symm_conf.Symmetry_Info() );
134  max_res = symm_info->num_independent_residues() - 1;
135  if( id.rsd() > max_res ) return;
136  }
137 
138  if ( pose.fold_tree().is_cutpoint( id.rsd() ) && pose.residue(id.rsd() ).has_variant_type( CUTPOINT_LOWER ) ) {
139  Residue const & lower_rsd( pose.residue( id.rsd() ) );
140  Residue const & upper_rsd( pose.residue( id.rsd() + 1 ) );
141  Vector const & xyz_moving( pose.xyz( id ) );
142  bool match( true );
143  Vector xyz_fixed;
144  Size const nbb( lower_rsd.mainchain_atoms().size() );
145  if ( id.atomno() == lower_rsd.mainchain_atoms()[nbb] ) {
146  xyz_fixed = upper_rsd.atom( "OVU1" ).xyz();
147  } else if ( lower_rsd.atom_name( id.atomno() ) == "OVL1" ) {
148  xyz_fixed = upper_rsd.atom( upper_rsd.mainchain_atoms()[1] ).xyz();
149  } else if ( lower_rsd.atom_name( id.atomno() ) == "OVL2" ) {
150  xyz_fixed = upper_rsd.atom( upper_rsd.mainchain_atoms()[2] ).xyz();
151  } else {
152  match = false;
153  }
154 
155  if ( match ) {
156  // deriv = 2 * r
157  // factor = deriv / r = 2
158  F1 += weights[ chainbreak ] * 2 * cross( xyz_moving, xyz_fixed );
159  F2 += weights[ chainbreak ] * 2 * ( xyz_moving - xyz_fixed );
160  }
161  }
162 
163  if ( id.rsd() > 1 && pose.fold_tree().is_cutpoint( id.rsd()-1 ) &&
164  pose.residue(id.rsd() ).has_variant_type( CUTPOINT_UPPER ) ) {
165  Residue const & lower_rsd( pose.residue( id.rsd() - 1 ) );
166  Residue const & upper_rsd( pose.residue( id.rsd() ) );
167  Vector const & xyz_moving( pose.xyz( id ) );
168  bool match( true );
169  Vector xyz_fixed;
170  Size const nbb( lower_rsd.mainchain_atoms().size() );
171  if ( id.atomno() == upper_rsd.mainchain_atoms()[1] ) {
172  xyz_fixed = lower_rsd.atom( "OVL1" ).xyz();
173  } else if ( id.atomno() == upper_rsd.mainchain_atoms()[2] ) {
174  xyz_fixed = lower_rsd.atom( "OVL2" ).xyz();
175  } else if ( upper_rsd.atom_name( id.atomno() ) == "OVU1" ) {
176  xyz_fixed = lower_rsd.atom( lower_rsd.mainchain_atoms()[nbb] ).xyz();
177  } else {
178  match = false;
179  }
180 
181  if ( match ) {
182  // deriv = 2 * r
183  // factor = deriv / r = 2
184  F1 += weights[ chainbreak ] * 2 * cross( xyz_moving, xyz_fixed );
185  F2 += weights[ chainbreak ] * 2 * ( xyz_moving - xyz_fixed );
186  }
187  }
188 }
189 
190 /// @brief Chainbreak Energy is context independent and thus indicates that no context graphs need to
191 /// be maintained by class Energies
192 void
194  utility::vector1< bool > & /*context_graphs_required*/
195 ) const
196 {}
199 {
200  return 1; // Initial versioning
201 }
202 
203 
204 } // namespace methods
205 } // namespace scoring
206 } // namespace core