Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MaxSeqSepConstraintSet.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 MaxSeqSepConstraintSet.cc
11 /// @brief
12 /// @detailed
13 /// @author Oliver Lange
14 ///
15 
16 
17 // Unit Headers
19 
20 // Package Headers
21 //#include <protocols/jumping/JumpSetup.fwd.hh>
22 
23 // Project Headers
25 #include <core/pose/Pose.hh>
27 #include <core/types.hh>
33 /*
34 #include <core/scoring/ScoreFunction.fwd.hh>
35 #include <core/scoring/ScoreFunctionFactory.hh>
36 #include <core/scoring/EnergyMap.fwd.hh>
37 */
38 /*
39 #include <protocols/moves/Mover.hh>
40 #include <protocols/moves/MoverContainer.hh> // SequenceMover
41 #include <protocols/moves/TrialMover.hh>
42 */
43 
44 // ObjexxFCL Headers
45 // AUTO-REMOVED #include <ObjexxFCL/format.hh>
46 
47 // Utility headers
48 #include <utility/vector1.fwd.hh>
49 #include <utility/pointer/ReferenceCount.hh>
50 #include <numeric/numeric.functions.hh>
51 
52 // AUTO-REMOVED #include <basic/prof.hh>
53 #include <basic/Tracer.hh>
54 // AUTO-REMOVED #include <basic/options/option.hh>
55 // AUTO-REMOVED #include <basic/options/keys/OptionKeys.hh>
56 
57 
58 //// C++ headers
59 #include <cstdlib>
60 #include <string>
61 // AUTO-REMOVED #include <fstream>
62 
65 #include <utility/vector1.hh>
66 
67 
68 static basic::Tracer tr("protocols.constraints_additional.MaxSeqSepConstraintSet",basic::t_info);
69 
74 
75 namespace protocols {
76 namespace constraints_additional {
77 
78 using namespace core;
79 
80 /// @brief a ConstraintsSet whose constraints can be switched off, according to sequence separation in residues
81 /// between residue pair constraints.
84  ConstraintSet( other )
85 {
86  tr.Trace << f ;
87  // if ( f.size() > 2 ) { //assuming simple fold-tree has eges 1 1 -1 and 1 nres -1
89  //} else {
90  //shortest_path_ = NULL;
91  // }
92 }
93 
94 /// @copy constructor. Does nothing.
96  : ConstraintSet( other ),
97  max_seq_sep_ ( other.max_seq_sep_ ),
98  shortest_path_( other.shortest_path_ )
99 { }
100 
102  ConstraintSet( other ),
103  shortest_path_( sp )
104 {}
105 
107  core::pose::Pose const& src,
108  core::pose::Pose const& dest,
110 ) const {
112  clone_ptr->set_max_seq_sep( max_seq_sep() );
113  return clone_ptr;
114 }
115 
116 /*void
117 MaxSeqSepConstraintSet::eval_atom_derivative_for_residue_pairs (
118  id::AtomID const & atom_id,
119  pose::Pose const & pose,
120  scoring::ScoreFunction const &,
121  scoring::EnergyMap const & weights,
122  Vector & F1,
123  Vector & F2
124 ) const
125 {
126  using scoring::constraints::ResidueConstraints;
127  // residue pair constraints:
128  Size const seqpos( atom_id.rsd() );
129  for ( ResidueConstraints::const_iterator
130  it= residue_pair_constraints_begin( seqpos ), ite = residue_pair_constraints_end( seqpos );
131  it != ite; ++it ) {
132  Size const seqpos2( it->first );
133  if ( !too_far( seqpos2, seqpos ) ) {
134  // trDebug << "evaluate " << seqpos << " " << seqpos2; it->second->show(trDebug); trDebug << "\n";
135  it->second->eval_atom_derivative( atom_id, pose.conformation(), weights, F1, F2 );
136  }
137  }
138 }*/
139 
140 
141 ///
142 void
144  Residue const & rsd1,
145  Residue const & rsd2,
146  Pose const & pose,
147  core::scoring::ScoreFunction const & scorefxn,
149 ) const
150 {
151  int const pos1( rsd1.seqpos() ), pos2 ( rsd2.seqpos() );
152  // if ( tr.Trace.visible() ) tr.Trace << "max_seq_sep(): " << max_seq_sep() << " check seqsep for residues " << rsd1.seqpos() << " and " << rsd2.seqpos() << "....";
153  if ( too_far( pos1, pos2 ) ) {
154  //if ( tr.Trace.visible() ) tr.Trace << "\n";
155  return; //cast avoids warning
156  }
157  // if ( tr.Trace.visible() ) tr.Trace << "evaluated\n";
158  ConstraintSet::residue_pair_energy( rsd1, rsd2, pose, scorefxn, emap );
159 }
160 
161 void
163  conformation::Residue const & rsd1,
164  conformation::Residue const & rsd2,
165  pose::Pose const & pose,
166  core::scoring::ScoreFunction const & sfxn,
167  kinematics::MinimizerMapBase const & minmap,
168  core::scoring::ResSingleMinimizationData const & res1_data_cache,
169  core::scoring::ResSingleMinimizationData const & res2_data_cache,
170  core::scoring::ResPairMinimizationData & respair_data_cache
171 ) const
172 {
173  if ( too_far( rsd1.seqpos(), rsd2.seqpos() ) ) return;
174  Parent::setup_for_minimizing_for_residue_pair( rsd1, rsd2, pose, sfxn, minmap, res1_data_cache, res2_data_cache, respair_data_cache );
175 }
176 
177 
178 Size
179 MaxSeqSepConstraintSet::show_violations( std::ostream& out, pose::Pose& pose, Size verbose_level, Real threshold ) {
180  out << " total constr: " << get_all_constraints().size() << " ";
181  out << " max_seq_sep: " << max_seq_sep() << " ";
182  return Parent::show_violations( out, pose, verbose_level, threshold );
183 }
184 
185 bool
186 MaxSeqSepConstraintSet::too_far( int const pos1, int const pos2 ) const {
187  if ( shortest_path_ ) return max_seq_sep() < shortest_path_->dist( pos1, pos2 );
188  return max_seq_sep() < (core::Size) std::abs( pos1 - pos2 );
189 }
190 
191 Size
193  if ( shortest_path_ ) return shortest_path_->max_dist();
194  return pose.total_residue();
195 }
196 
197 /// Does *NOT* zero the emap values, just adds the additional contribution to the
198 /// existing emap energies (so can be called inside finalize_total_energies)
199 void
201  core::pose::Pose const & pose,
202  core::scoring::ScoreFunction const & sfxn,
204 ) const
205 {
206  //non_residue_pair_constraints_.conformation_energy( pose.conformation(), sfxn.weights(), emap );
209  for ( core::scoring::constraints::ConstraintCOPs::const_iterator it=csts.begin(), ite = csts.end(); it != ite; ++it ) {
210  core::scoring::constraints::Constraint const & cst( **it );
211  if ( cst.effective_sequence_separation( shortest_path() ) < max_seq_sep() ) cst.score( xyz_func, sfxn.weights(), emap );
212  }
213 }
214 
215 
216 
217 
218 } //abinitio
219 } //protocols
220 
221