Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OopPatcher.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/oop/OopPatcher.cc
11 /// @brief OopPatcher 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.oop.OopPatcher" );
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 oop {
56 
57 void add_oop_constraint( core::pose::Pose & pose, core::Size oop_seq_position )
58 {
59  add_oop_constraint( pose, oop_seq_position, 1.5, 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 aidCYP( pose.residue( oop_seq_position ).atom_index("CYP"), oop_seq_position );
71  AtomID aidCZP( pose.residue( oop_seq_position+1 ).atom_index("CZP"), oop_seq_position+1 );
72 
73  ConstraintCOP atompair = new AtomPairConstraint( aidCYP, aidCZP, harm_func );
74 
75  pose.add_constraint( atompair );
76 
77 
78  TR << "added atom pair constraint to oop at residue: " << oop_seq_position << " with distance: " << distance << " and std: "<< std << std::endl;
79 
80 }
81 
82 void OopPatcher::apply( core::pose::Pose & pose )
83 {
84  TR<< "patching residues" <<std::endl;
85 
86  //kdrew: an oop pre position cannot be last position
87  runtime_assert_msg ( oop_pre_pos_ != pose.total_residue(), "beginning of oop cannot be last residue" );
88  //kdrew: an oop post position cannot be first position
89  runtime_assert ( oop_post_pos_ != 1 );
90 
92 
93  std::string const pre_base_name( core::chemical::residue_type_base_name( pose.residue_type( oop_pre_pos_ ) ) );
94  std::string const post_base_name( core::chemical::residue_type_base_name( pose.residue_type( oop_post_pos_ ) ) );
95  TR << "pre restype basename: " << pre_base_name << std::endl;
96  TR << "post restype basename: " << post_base_name << std::endl;
97 
98  //kdrew: check for proline
99  if ( pre_base_name == "PRO" || pre_base_name == "DPRO" ||
100  post_base_name == "PRO" || post_base_name == "DPRO" )
101  {
102  utility_exit_with_message("Cannot patch proline");
103  }
104  if ( pose.residue(oop_pre_pos_).has_variant_type(chemical::OOP_POST) == 1)
105  {
106  utility_exit_with_message("Cannot patch OOP_PRE on an OOP_POST");
107  }
108  if ( pose.residue(oop_post_pos_).has_variant_type(chemical::OOP_PRE) == 1)
109  {
110  utility_exit_with_message("Cannot patch OOP_POST on an OOP_PRE");
111  }
112 
113  //kdrew: check if already patched
114  if ( pose.residue(oop_pre_pos_).has_variant_type(chemical::OOP_PRE) != 1)
115  {
116  TR<< "patching pre" <<std::endl;
117 
118  //kdrew: get base residue type
119  chemical::ResidueType const & pre_base_type = pose.residue(oop_pre_pos_).type();
120  TR<< pre_base_type.name() << std::endl;
121 
122  //kdrew: add variant
123  conformation::Residue replace_res_pre( restype_set->get_residue_type_with_variant_added(pre_base_type, chemical::OOP_PRE), true );
124  TR<< replace_res_pre.name() << std::endl;
125 
126  replace_res_pre.set_all_chi(pose.residue(oop_pre_pos_).chi());
127  //replace_res_pre.mainchain_torsions(pose.residue(oop_pre_pos_).mainchain_torsions());
128 
129  pose.replace_residue( oop_pre_pos_, replace_res_pre, true );
130  conformation::idealize_position( oop_pre_pos_, pose.conformation() );
131  //pose.dump_pdb( "rosetta_out_oop_post_patch.pdb" );
132 
133  }// if pre
134  if ( pose.residue(oop_post_pos_).has_variant_type(chemical::OOP_POST) != 1 ) {
135  TR<< "patching post" <<std::endl;
136  //kdrew: get base residue type
137  chemical::ResidueType const & post_base_type = pose.residue(oop_post_pos_).type();
138  TR<< post_base_type.name() << std::endl;
139 
140  //kdrew: add variant
141  conformation::Residue replace_res_post( restype_set->get_residue_type_with_variant_added(post_base_type, chemical::OOP_POST), true );
142 
143  replace_res_post.set_all_chi(pose.residue(oop_post_pos_).chi());
144  //replace_res_post.mainchain_torsions(pose.residue(oop_post_pos_).mainchain_torsions());
145 
146  pose.replace_residue( oop_post_pos_, replace_res_post, true );
147  conformation::idealize_position( oop_post_pos_, pose.conformation() );
148  //pose.dump_pdb( "rosetta_out_oop_pre_pos_t_patch.pdb" );
149 
150  }// if post
151 
152  add_oop_constraint( pose, oop_pre_pos_ );
153 
154  //kdrew: need to do all at once at the end because occasionally will get error:
155  //kdrew: Unable to handle change in the number of residue connections in the presence of pseudobonds!
156  //pose.conformation().detect_bonds();
157  //pose.conformation().detect_pseudobonds();
158  //pose.conformation().update_polymeric_connection( oop_pre_pos_ );
159  //pose.conformation().update_polymeric_connection( oop_post_pos_ );
160 
161 }
162 
163 
165 OopPatcher::get_name() const {
166  return "OopPatcher";
167 }
168 
169 ///@brief
170 OopPatcher::OopPatcher(
171  core::Size oop_seq_position
172  ): Mover(), oop_pre_pos_(oop_seq_position), oop_post_pos_(oop_seq_position+1)
173 {
174  Mover::type( "OopPatcher" );
175 
176 }
177 
179 
180 }//oop
181 }//simple_moves
182 }//protocols
183