Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HbsPatcher.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 protocols/simple_moves/hbs/HbsPatcher.cc
11 /// @brief HbsPatcher methods implemented
12 /// @author Kevin Drew, kdrew@nyu.edu
13 
14 // Unit Headers
16 // Package Headers
17 
18 // Project Headers
27 #include <core/chemical/Patch.hh>
31 #include <core/pose/Pose.hh>
32 #include <core/id/AtomID.hh>
33 // Utility Headers
34 #include <numeric/xyz.functions.hh>
35 #include <basic/Tracer.hh>
36 #include <basic/basic.hh>
37 #include <core/types.hh>
38 
39 // C++ Headers
40 
41 using basic::T;
42 using basic::Error;
43 using basic::Warning;
44 
45 static basic::Tracer TR( "protocols.simple_moves.hbs.HbsPatcher" );
46 
47 
48 using namespace core;
49 using namespace conformation;
50 using namespace chemical;
51 using namespace core::id;
52 
53 namespace protocols {
54 namespace simple_moves {
55 namespace hbs {
56 
57 void add_hbs_constraint( core::pose::Pose & pose, core::Size hbs_pre_position )
58 {
59  add_hbs_constraint( pose, hbs_pre_position, 1.52, 0.05 );
60 }
62 {
63  using namespace core::id;
64  using namespace core::scoring;
65  using namespace core::scoring::constraints;
66 
67  //kdrew: add constraint
68  HarmonicFuncOP harm_func (new HarmonicFunc( distance, std ) );
69 
70  AtomID aidCYH( pose.residue( hbs_pre_position ).atom_index("CYH"), hbs_pre_position );
71  AtomID aidCZH( pose.residue( hbs_pre_position+2 ).atom_index("CZH"), hbs_pre_position+2 );
72 
73  ConstraintCOP atompair = new AtomPairConstraint( aidCYH, aidCZH, harm_func );
74 
75  pose.add_constraint( atompair );
76 
77  TR << "added atom pair constraint to hbs with distance: " << distance << " and std: "<< std << std::endl;
78 
79 }
80 
81 void HbsPatcher::apply( core::pose::Pose & pose )
82 {
83  TR<< "patching residues" <<std::endl;
84 
85  //kdrew: an hbs pre position cannot be last position
86  runtime_assert_msg ( hbs_pre_pos_ != pose.total_residue(), "beginning of hbs cannot be last residue" );
87  // I believe that this should be terminal, but since we're manually cutting off later residues
88  // I bet we can't require it that way, so we have to trust hbs creator not to be dumb.
89  //kdrew: an hbs post position cannot be first position
90  runtime_assert ( hbs_post_pos_ != 1 );
91 
93 
94  std::string const pre_base_name( core::chemical::residue_type_base_name( pose.residue_type( hbs_pre_pos_ ) ) );
95  std::string const post_base_name( core::chemical::residue_type_base_name( pose.residue_type( hbs_post_pos_ ) ) );
96  TR << "pre restype basename: " << pre_base_name << std::endl;
97  TR << "post restype basename: " << post_base_name << std::endl;
98 
99  //kdrew: check for proline
100  if ( pre_base_name == "PRO" || pre_base_name == "DPRO" ||
101  post_base_name == "PRO" || post_base_name == "DPRO" )
102  {
103  utility_exit_with_message("Cannot patch proline");
104  }
105  if ( pose.residue(hbs_pre_pos_).has_variant_type(chemical::HBS_POST) == 1)
106  {
107  utility_exit_with_message("Cannot patch HBS_PRE on an HBS_POST");
108  }
109  if ( pose.residue(hbs_post_pos_).has_variant_type(chemical::HBS_PRE) == 1)
110  {
111  utility_exit_with_message("Cannot patch HBS_POST on an HBS_PRE");
112  }
113 
114  //kdrew: check if already patched
115  if ( pose.residue(hbs_pre_pos_).has_variant_type(chemical::HBS_PRE) != 1)
116  {
117  TR<< "patching pre" <<std::endl;
118 
119  //kdrew: get base residue type
120  chemical::ResidueType const & pre_base_type = pose.residue(hbs_pre_pos_).type();
121  TR<< pre_base_type.name() << std::endl;
122 
123  //kdrew: add variant
124  conformation::Residue replace_res_pre( restype_set->get_residue_type_with_variant_added(pre_base_type, chemical::HBS_PRE), true );
125  TR<< replace_res_pre.name() << std::endl;
126 
127  replace_res_pre.set_all_chi(pose.residue(hbs_pre_pos_).chi());
128  //replace_res_pre.mainchain_torsions(pose.residue(hbs_pre_pos_).mainchain_torsions());
129 
130  pose.replace_residue( hbs_pre_pos_, replace_res_pre, true );
131  conformation::idealize_position( hbs_pre_pos_, pose.conformation() );
132  //pose.dump_pdb( "rosetta_out_hbs_post_patch.pdb" );
133 
134  }// if pre
135  if ( pose.residue(hbs_post_pos_).has_variant_type(chemical::HBS_POST) != 1 ) {
136  TR<< "patching post" <<std::endl;
137  //kdrew: get base residue type
138  chemical::ResidueType const & post_base_type = pose.residue(hbs_post_pos_).type();
139  TR<< post_base_type.name() << std::endl;
140 
141  //kdrew: add variant
142  conformation::Residue replace_res_post( restype_set->get_residue_type_with_variant_added(post_base_type, chemical::HBS_POST), true );
143 
144  replace_res_post.set_all_chi(pose.residue(hbs_post_pos_).chi());
145  //replace_res_post.mainchain_torsions(pose.residue(hbs_post_pos_).mainchain_torsions());
146 
147  pose.replace_residue( hbs_post_pos_, replace_res_post, true );
148  conformation::idealize_position( hbs_post_pos_, pose.conformation() );
149  //pose.dump_pdb( "rosetta_out_hbs_pre_pos_t_patch.pdb" );
150 
151  }// if post
152 
153  add_hbs_constraint( pose, hbs_pre_pos_ );
154 
155  //kdrew: need to do all at once at the end because occasionally will get error:
156  //kdrew: Unable to handle change in the number of residue connections in the presence of pseudobonds!
157  //pose.conformation().detect_bonds();
158  //pose.conformation().detect_pseudobonds();
159  //pose.conformation().update_polymeric_connection( hbs_pre_pos_ );
160  //pose.conformation().update_polymeric_connection( hbs_post_pos_ );
161 
162 }
163 
164 
166 HbsPatcher::get_name() const {
167  return "HbsPatcher";
168 }
169 
170 ///@brief
171 HbsPatcher::HbsPatcher(
172  core::Size hbs_seq_position
173  ): Mover(), hbs_pre_pos_(hbs_seq_position), hbs_post_pos_(hbs_seq_position+2)
174 {
175  Mover::type( "HbsPatcher" );
176 
177 }
178 
180 
181 }//hbs
182 }//simple_moves
183 }//protocols
184