Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
disulfide_util.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 sw=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/util/disulfide_util.cc
10 /// @brief A collection of procedures for manipulating disulfide bonds
11 /// @author Spencer Bliven <blivens@u.washington.edu>
12 /// @date 4/30/2009
13 
14 // Unit Headers
16 
17 // Project Headers
18 // Package Headers
19 #include <core/types.hh>
20 #include <core/pose/Pose.hh>
21 
22 // AUTO-REMOVED #include <core/conformation/Interface.hh>
23 // AUTO-REMOVED #include <core/conformation/Conformation.hh>
26 // AUTO-REMOVED #include <core/conformation/ResidueFactory.hh>
27 // AUTO-REMOVED #include <core/chemical/ChemicalManager.hh>
28 // AUTO-REMOVED
29 // AUTO-REMOVED #include <core/chemical/ResidueTypeSet.hh>
30 
36 
41 
42 #include <basic/Tracer.hh>
43 
44 // Utility Headers
45 #include <utility/vector1.hh>
46 
47 // C++ headers
48 // AUTO-REMOVED #include <utility>
49 
50 #include <core/kinematics/Jump.hh>
51 #include <utility/vector0.hh>
52 
53 
54 namespace core {
55 namespace util {
56 
57 using namespace core;
58 using namespace std;
59 
60 using utility::vector1;
61 using core::pose::Pose;
62 using core::pose::PoseOP;
63 using namespace core::conformation;
68 static basic::Tracer TR( "protocols.toolbox.disulfide_util" );
69 
70 /// @details A convenience function for calling \c core::util:: rebuild_disulfide() with
71 /// only a single disulfide bond
72 void
73 rebuild_disulfide( Pose & pose, Size lower_res, Size upper_res,
74  PackerTaskOP packer_task, ScoreFunctionOP packer_score,
75  MoveMapOP mm, ScoreFunctionOP minimizer_score )
76 {
77  vector1< pair<Size,Size> > disulfides;
78  disulfides.push_back(std::make_pair(lower_res,upper_res));
79  core::util:: rebuild_disulfide(pose, disulfides, packer_task, packer_score, mm, minimizer_score);
80 }
81 
82 
83 /// @details
84 /// @pre The two residues specified should already be cysteines with a bond
85 /// defined between the SG atoms. This can be accomplished by first calling
86 /// protocols::toolbox::form_disulfide().
87 ///
88 /// To provide the most flexibility, this function does not restrict
89 /// the degrees of freedom in the repacking and minimization steps. This is
90 /// needed in some cases where the backbone position is not optimal for making
91 /// a disulfide bond. However, if this function needs to be reasonably fast
92 /// you should prevent repacking on all residues except the two targets.
93 ///
94 /// @param pose[in,out] The pose to modify with a disulfides
95 /// @param lower_res[in] The first residue of the disulfide
96 /// @param upper_res[in] The second residue of the disulfide
97 /// @param packer_task[in] A task to control repacking. Defaults to repacking
98 /// lower_res \& upper_res if ommitted or NULL.
99 /// @param packer_score[in] A scoring function to use while repacking. Defaults
100 /// to score12 if ommitted or NULL.
101 /// @param mm[in] A MoveMap to control minimization. Defaults to full degrees
102 /// of freedom if ommitted or NULL.
103 /// @param minimizer_score[in] The score to use for minimization. Defaults to
104 /// packer_score if ommitted or NULL.
105 void
107  utility::vector1<std::pair<core::Size, core::Size> > disulfides,
108  core::pack::task::PackerTaskOP packer_task,
109  core::scoring::ScoreFunctionOP packer_score,
111  core::scoring::ScoreFunctionOP minimizer_score )
112 //void core::util:: rebuild_disulfide( Pose & pose, vector1<pair<Size, Size> > const& disulfides,
113 // PackerTaskOP packer_task, ScoreFunctionOP packer_score,
114 // MoveMapOP mm, ScoreFunctionOP minimizer_score )
115 {
116  // Quick lookup of whether a residue is a disulfide or not
117  vector1<bool> is_disulf(pose.total_residue(), false);
118 
119  for(vector1<pair<Size, Size> >::const_iterator
120  disulf(disulfides.begin()), end_disulf(disulfides.end());
121  disulf != end_disulf; ++disulf)
122  {
123  is_disulf[disulf->first] = true;
124  is_disulf[disulf->second] = true;
125 
126  // Verify precondition
127  if( ! core::conformation::is_disulfide_bond(pose.conformation(), disulf->first, disulf->second) ) {
128  TR.Error << "Disulfide bond required between " << disulf->first
129  << " and " << disulf->second << "." << std::endl;
130  utility_exit();
131  }
132  }
133 
134  // Set up any NULL parameters
135  if( !packer_task ) {
137  packer_task->initialize_from_command_line().or_include_current( true );
138  packer_task->restrict_to_repacking();
139 
140  // Restrict repacking to the targets
141  for( Size i(1); i <= pose.total_residue(); ++i )
142  {
143  if( !is_disulf[i] ) {
144  packer_task->nonconst_residue_task(i).prevent_repacking();
145  }
146  }
147  }
148  if( !packer_score ) {
149  packer_score = scoring::getScoreFunction();
150  }
151  if( !mm ) {
152  mm = MoveMapOP(new MoveMap);
153  mm->set_bb( true );
154  mm->set_chi( true );
155  }
156  if( !minimizer_score ) {
157  minimizer_score = packer_score;
158  }
159 
160  // Extend rotamers for the disulfide
161  for(vector1<pair<Size, Size> >::const_iterator
162  disulf(disulfides.begin()), end_disulf(disulfides.end());
163  disulf != end_disulf; ++disulf)
164  {
165  packer_task->nonconst_residue_task(disulf->first).and_extrachi_cutoff( 0 );
166  packer_task->nonconst_residue_task(disulf->second).and_extrachi_cutoff( 0 );
167  packer_task->nonconst_residue_task(disulf->first).or_ex1_sample_level(
169  packer_task->nonconst_residue_task(disulf->second).or_ex1_sample_level(
171  }
172 
173  // REPACK
174  (*packer_score)(pose); // structure must be scored before rotamer_trials can be called
175  pack::pack_rotamers(pose, *packer_score, packer_task );
176 
177  using namespace core::optimization;
178  AtomTreeMinimizer().run( pose, *mm, *minimizer_score,
179  MinimizerOptions( "dfpmin_armijo_nonmonotone", 0.01, true/*nblist*/, false/*deriv_check*/ ) );
180 
181  // update score
183  (*minimizer_score)( pose );
184 
185 }
186 
187 } // util
188 } // core