Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SelectBySASAOperation.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 /// @brief Restrict design to residues matching user-specified SASA criteria in the monomeric, bound, or unbound state.
11 /// @author Jacob Bale (balej@uw.edu)
12 
13 // Unit Headers
16 
17 // Project Headers
21 #include <core/pose/Pose.hh>
23 #include <core/pose/util.hh>
24 #include <core/scoring/sasa.hh>
25 #include <core/types.hh>
26 #include <core/id/AtomID_Map.hh>
28 
29 // Utility Headers
30 #include <basic/Tracer.hh>
31 #include <ObjexxFCL/format.hh>
32 #include <utility/string_util.hh>
33 #include <utility/tag/Tag.hh>
34 #include <utility/vector1.hh>
35 #include <utility/exit.hh>
36 
37 // C++ Headers
38 
39 static basic::Tracer TR("protocols.toolbox.task_operations.SelectBySASAOperation" );
40 
41 namespace protocols {
42 namespace toolbox {
43 namespace task_operations {
44 
47 {
48  return new SelectBySASAOperation;
49 }
50 
51 SelectBySASAOperation::SelectBySASAOperation( std::string mode, std::string state, core::Real probe_radius, core::Real core_asa, core::Real surface_asa, std::string jump_nums, std::string sym_dof_names, bool core, bool boundary, bool surface, bool verbose ):
52  mode_(mode),
53  state_(state),
54  probe_radius_(probe_radius),
55  core_asa_(core_asa),
56  surface_asa_(surface_asa),
57  jump_nums_(jump_nums),
58  sym_dof_names_(sym_dof_names),
59  core_(core),
60  boundary_(boundary),
61  surface_(surface),
62  verbose_(verbose)
63 {}
64 
66 
68 {
69  return new SelectBySASAOperation( *this );
70 }
71 
72 void
74 {
75  using core::id::AtomID;
76  std::string layername = "";
77  bool prev = 0;
78  if( core_ ){
79  layername.append("core");
80  prev = 1;
81  }
82  if( boundary_ ){
83  if( prev ){
84  layername.append("_boundary");
85  } else {
86  layername.append("boundary");
87  }
88  prev = 1;
89  }
90  if( surface_ ){
91  if( prev ){
92  layername.append("_surface");
93  } else {
94  layername.append("surface");
95  }
96  prev = 1;
97  }
98 
99  if( !prev ) {
100  utility_exit_with_message("The layers are not set properly. Core, boundary, and surface are all set to false. At least one layer needs to be selected.");
101  }
102 
103  std::string selected_pos("select " + layername + ", resi ");
104  std::string core_pos("select core, resi ");
105  std::string boundary_pos("select boundary, resi ");
106  std::string surface_pos("select surface, resi ");
107  core::pose::Pose mono, sasa_pose;
108 
109  core::Size nsubposes = 1;
110  if( state_ == "monomer") {
112  core::pose::symmetry::extract_asymmetric_unit( pose, mono , false );
113  } else {
114  mono = pose;
115  }
116  nsubposes = mono.conformation().num_chains();
117  }
118 
119  core::Size res_count = 0;
120  for (core::Size i = 1; i <= nsubposes; i++) {
121  utility::vector1<bool> indy_resi;
122 
123  if( state_ == "monomer" ) {
124  sasa_pose = mono.split_by_chain(i);
125  } else {
126  sasa_pose = pose;
127  if (core::pose::symmetry::is_symmetric(sasa_pose)) {
128  indy_resi = core::pose::symmetry::symmetry_info(sasa_pose)->independent_residues();
129  }
130  }
131 
132  if( state_ == "unbound" ) {
133  int sym_aware_jump_id = 0;
134  if ( sym_dof_names_ != "" ) {
135  utility::vector1<std::string> sym_dof_name_list = utility::string_split( sym_dof_names_ , ',' );
136  for (Size i = 1; i <= sym_dof_name_list.size(); i++) {
137  sym_aware_jump_id = core::pose::symmetry::sym_dof_jump_num( sasa_pose, sym_dof_name_list[i] );
139  translate->step_size( 1000.0 );
140  translate->apply( sasa_pose );
141  }
142  } else {
143  utility::vector1<core::Size> jump_list = utility::string_split( jump_nums_ , ',',core::Size());
144  for (Size i = 1; i <= jump_list.size(); i++) {
145  sym_aware_jump_id = core::pose::symmetry::get_sym_aware_jump_num( sasa_pose, jump_list[i] );
147  translate->step_size( 1000.0 );
148  translate->apply( sasa_pose );
149  }
150  }
151  }
152 
153  //Loop over the independent residues or the residues in the monomer(s), calculate SASA for each, and assign each to core, boundary, or surface.
154  // Define atom_map for main-chain and CB, or for sidechains depending on mode.
157  utility::vector1< core::Real > sasas, final_sasas;
158  core::pose::initialize_atomid_map( atom_mask, sasa_pose, false );
159  core::pose::initialize_atomid_map( atom_sasa, sasa_pose, 0.0);
160  core::Size itype;
161 
162  for ( core::Size i = 1; i <= sasa_pose.n_residue(); ++i ) {
163  if ( sasa_pose.residue(i).name3()=="GLY") { // Don't try CBs with GLYs
164  itype = 4;
165  } else {
166  itype = 5;
167  }
168  for ( core::Size j = 1; j<=sasa_pose.residue(i).nheavyatoms(); ++j ) {
169  if ((mode_ == "mc") && (j > itype)) {
170  continue;
171  } else {
172  core::id::AtomID atom( j, i );
173  atom_mask.set( atom, true );
174  }
175  }
176  }
177 
178  // calc sasa
179  core::scoring::calc_per_atom_sasa( sasa_pose, atom_sasa, sasas, probe_radius_, false, atom_mask );
180 
181  if ( mode_ == "sc" ) {
182  utility::vector1<core::Real> sc_sasas(sasa_pose.n_residue(),0.0);
183  for(Size i = 1; i <= sasa_pose.n_residue(); i++) {
184  // Use CA as the side chain for Glys
185  if(sasa_pose.residue(i).name3()=="GLY") sc_sasas[i] += atom_sasa[AtomID(2,i)];
186  for(Size j = 5; j <= sasa_pose.residue(i).nheavyatoms(); j++) {
187  sc_sasas[i] += atom_sasa[AtomID(j,i)];
188  }
189  }
190  final_sasas = sc_sasas;
191  } else {
192  final_sasas = sasas;
193  }
194 
195  // Prevent repacking at resis that do match the user-specified parameters.
196  bool prevent_repacking;
197  for( Size iaa=1; iaa<=sasa_pose.n_residue(); iaa++ ) {
198  prevent_repacking = 1;
199  if (core::pose::symmetry::is_symmetric(sasa_pose)) {
200  if (!indy_resi[iaa]) {
201  continue;
202  }
203  }
204  if (sasa_pose.residue( iaa ).is_protein()) {
205  res_count++;
206  TR.Debug << iaa << " res_count = " << res_count << " sasa = " << final_sasas[iaa] << std::endl;
207  if (final_sasas[ iaa ] <= core_asa_) {
208  if( core_ ){
209  selected_pos.append(ObjexxFCL::string_of(res_count) + "+");
210  prevent_repacking = 0;
211  }
212  core_pos.append(ObjexxFCL::string_of(res_count) + "+");
213  } else if (final_sasas[iaa] >= surface_asa_) {
214  if( surface_ ){
215  selected_pos.append(ObjexxFCL::string_of(res_count) + "+");
216  prevent_repacking = 0;
217  }
218  surface_pos.append(ObjexxFCL::string_of(res_count) + "+");
219  } else if ((final_sasas[iaa] >= core_asa_) && (final_sasas[iaa] <= surface_asa_)) {
220  if( boundary_ ){
221  selected_pos.append(ObjexxFCL::string_of(res_count) + "+");
222  prevent_repacking = 0;
223  }
224  boundary_pos.append(ObjexxFCL::string_of(res_count) + "+");
225  }
226  if( prevent_repacking ){
227  task.nonconst_residue_task(res_count).prevent_repacking();
228  }
229  }
230  }
231  }
232  if( verbose_ ){
233  TR << selected_pos << std::endl;
234  TR << core_pos << std::endl;
235  TR << boundary_pos << std::endl;
236  TR << surface_pos << std::endl;
237  }
238 }
239 
240 void
242 {
243  mode_ = tag->getOption< std::string >("mode", "sc" );
244  state_ = tag->getOption< std::string >("state", "monomer" );
245  probe_radius_ = tag->getOption<core::Real>("probe_radius", 2.2);
246  core_asa_ = tag->getOption<core::Real>("core_asa", 0);
247  surface_asa_ = tag->getOption<core::Real>("surface_asa", 30);
248  jump_nums_ = tag->getOption<std::string>("jumps", "1");
249  sym_dof_names_ = tag->getOption<std::string>("sym_dof_names","");
250  core_ = tag->getOption< bool >("core", 0 );
251  boundary_ = tag->getOption< bool >("boundary", 0 );
252  surface_ = tag->getOption< bool >("surface", 0 );
253  verbose_ = tag->getOption< bool >("verbose", 0 );
254 }
255 
256 void
257 SelectBySASAOperation::parse_def( utility::lua::LuaObject const & def)
258 {
259  mode_ = def["mode"] ? def["mode"].to<std::string>() : "sc";
260  state_ = def["state"] ? def["state"].to<std::string>() : "monomer";
261  probe_radius_ = def["probe_radius"] ? def["probe_radius"].to<core::Real>() : 2.2;
262  core_asa_ = def["core_asa"] ? def["core_asa"].to<core::Real>() : 0;
263  surface_asa_ = def["surface_asa"] ? def["surface_asa"].to<core::Real>() : 30;
264  jump_nums_ = def["jumps"] ? def["jumps"].to<std::string>() : "1";
265  sym_dof_names_ = def["sym_dof_names"] ? def["sym_dof_names"].to<std::string>() : "";
266  core_ = def["core"] ? def["core"].to< bool >() : 0;
267  boundary_ = def["boundary"] ? def["boundary"].to< bool >() : 0;
268  surface_ = def["surface"] ? def["surface"].to< bool >() : 0;
269  verbose_ = def["verbose"] ? def["verbose"].to< bool >() : 0;
270 }
271 
272 } //namespace task_operations
273 } //namespace toolbox
274 } //namespace protocols