Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SelectResiduesByLayer.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/toolbox/SelectResiduesByLayer.cc
11 /// @brief select residues depending on layer: core, boundary, and surface
12 /// The layer of residues are defined by accessible sufrace area of CB + mainchain
13 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
14 
15 // Unit Headers
17 
18 // Project Headers
19 #include <core/id/AtomID_Map.hh>
20 #include <core/pose/Pose.hh>
21 #include <core/scoring/sasa.hh>
23 #include <basic/Tracer.hh>
24 
25 // Utility Headers
26 #include <utility/vector1.hh>
27 #include <utility/string_util.hh>
29 #include <core/pose/util.hh>
30 #include <fstream>
31 
32 //Auto Headers
33 #include <core/pose/util.tmpl.hh>
34 using basic::T;
35 using basic::Error;
36 using basic::Warning;
37 
38 
39 static basic::Tracer TR("protocols.toolbox.SelectResiduesByLayer");
40 
41 namespace protocols {
42 namespace toolbox {
43 
44 /// @brief default constructor
45 SelectResiduesByLayer::SelectResiduesByLayer() : utility::pointer::ReferenceCount(),
46  pick_core_( false ),
47  pick_boundary_( false ),
48  pick_surface_( false ),
49  pore_radius_( 2.0 ),
50  make_rasmol_format_file_( false )
51 {
52  initialize( 20.0, 40.0 );
53 }
54 
55 
56 /// @brief value constructor
58  bool const pick_core,
59  bool const pick_boundary,
60  bool const pick_surface ) : utility::pointer::ReferenceCount(),
61  pick_core_( pick_core ),
62  pick_boundary_( pick_boundary ),
63  pick_surface_( pick_surface ),
64  pore_radius_( 2.0 ),
65  make_rasmol_format_file_( false )
66 {
67  initialize( 20.0, 40.0 );
68 }
69 
70 /// @brief value constructor
71 SelectResiduesByLayer::SelectResiduesByLayer( String const pick ) : utility::pointer::ReferenceCount(),
72  pick_core_( false ),
73  pick_boundary_( false ),
74  pick_surface_( false ),
75  pore_radius_( 2.0 ),
76  make_rasmol_format_file_( false )
77 {
78  initialize( 20.0, 40.0 );
79  utility::vector1< String > layers( utility::string_split( pick, '_' ) );
80  for( utility::vector1< String >::const_iterator iter = layers.begin(); iter != layers.end() ; ++iter) {
81  String layer(*iter);
82  if ( layer == "core" ) {
83  pick_core_ = true;
84  } else if ( layer == "surface" ) {
85  pick_surface_ = true;
86  } else if ( layer == "boundary" ) {
87  pick_boundary_ = true;
88  } else {
89  TR << "Error!, wrong specification of layer_mode " << layer << std::endl;
90  runtime_assert( false );
91  }
92  } // utility::vector1
93 }
94 
95 /// @brief destructor
97 
98 /// @brief copy constructor
99 SelectResiduesByLayer::SelectResiduesByLayer( SelectResiduesByLayer const & rval ) : utility::pointer::ReferenceCount(),
100  pick_core_( rval.pick_core_ ),
101  pick_boundary_( rval.pick_boundary_ ),
102  pick_surface_( rval.pick_surface_ ),
103  pore_radius_( rval.pore_radius_ ),
104  burial_( rval.burial_ ),
105  surface_( rval.surface_ ),
106  excluded_aatypes_for_selection_( rval.excluded_aatypes_for_selection_ ),
107  selected_core_residues_( rval.selected_core_residues_ ),
108  selected_boundary_residues_( rval.selected_boundary_residues_ ),
109  selected_surface_residues_( rval.selected_surface_residues_ ),
110  make_rasmol_format_file_( rval.make_rasmol_format_file_ ),
111  rsd_sasa_( rval.rsd_sasa_ ),
112  rsd_layer_( rval.rsd_layer_ )
113 {}
114 
115 /// @brief accessible surface for evaluating residues are in surface or not
116 void
118 {
119  if ( ss == "" ) {
120  surface_[ 'H' ] = r;
121  surface_[ 'L' ] = r;
122  surface_[ 'E' ] = r;
123  } else {
124  runtime_assert( ss.length() == 1 );
125  runtime_assert( ss.at( 0 ) == 'L' || ss.at( 0 ) == 'E' || ss.at( 0 ) == 'H' );
126  surface_[ ss.at( 0 ) ] = r;
127  }
128 }
129 
130 /// @brief accessible surface for evaluating residues are in core or not
131 void
133 {
134  if ( ss == "" ) {
135  burial_[ 'H' ] = r;
136  burial_[ 'L' ] = r;
137  burial_[ 'E' ] = r;
138  } else {
139  runtime_assert( ss.length() == 1 );
140  runtime_assert( ss.at( 0 ) == 'L' || ss.at( 0 ) == 'E' || ss.at( 0 ) == 'H' );
141  burial_[ ss.at( 0 ) ] = r;
142  }
143 }
144 
145 /// @brief
146 void
148 {
149  surface_.insert( std::map< char, Real >::value_type( 'H', surface ) );
150  surface_.insert( std::map< char, Real >::value_type( 'L', surface ) );
151  surface_.insert( std::map< char, Real >::value_type( 'E', surface ) );
152  burial_.insert( std::map< char, Real >::value_type( 'H', burial ) );
153  burial_.insert( std::map< char, Real >::value_type( 'L', burial ) );
154  burial_.insert( std::map< char, Real >::value_type( 'E', burial ) );
155 }
156 
157 
158 /// @brief amino acid types excluded for selection
159 void
161 {
163 }
164 
165 
166 /// @brief amino acid types restricted for selection
167 void
169 {
171 }
172 
173 
174 /// @brief accessbile surface are of each residue
177 {
178  return rsd_sasa_[ i ];
179 }
180 
181 /// @brief return defined layer for each residue
184 {
185  return rsd_layer_[ i ];
186 }
187 
188 /// @brief selected residues on boundary
191 {
193 }
194 
195 
196 /// @brief selected residues in core
199 {
201 }
202 
203 
204 /// @brief selected residues on surface
207 {
209 }
210 
211 
212 /// @brief return accessible surface area for each residue
215 
216  // define atom_map for main-chain and CB
218  core::pose::initialize_atomid_map( atom_map, pose, false );
219  for ( Size ir = 1; ir <= pose.total_residue(); ++ir ) {
220  for ( Size j = 1; j<=5; ++j ) {
221  core::id::AtomID atom( j, ir );
222  atom_map.set( atom, true );
223  }
224  }
225 
226  // calc sasa
229  core::scoring::calc_per_atom_sasa( pose, atom_sasa, rsd_sasa, pore_radius_, false, atom_map );
230 
231  return rsd_sasa;
232 } // calc_residue_sasa
233 
234 
235 /// @brief
237 SelectResiduesByLayer::compute( Pose const & pose, String secstruct )
238 {
239  // define secstruct if it is empty
240  if( secstruct == "" ) {
241  // calc dssp
242  core::scoring::dssp::Dssp dssp( pose );
243  dssp.dssp_reduced();
244  secstruct = dssp.get_dssp_secstruct();
245  }
246  runtime_assert( pose.total_residue() == secstruct.length() );
247 
248  // clear
249  rsd_sasa_.clear();
250  rsd_layer_.clear();
251  selected_core_residues_.clear();
254 
255  std::ofstream output;
257  output.open( "srb.ras" ,std::ios::out );
258  }
259 
260  TR << " pore_radius : " << pore_radius_ << std::endl;
261  TR << " core ( E, L, H ): " << burial_[ 'E' ] << ' ' << burial_[ 'L' ] << ' ' << burial_[ 'H' ] << std::endl;
262  TR << " surface (E, L, H ): " << surface_[ 'E' ] << ' ' << surface_[ 'L' ] << ' ' << surface_[ 'H' ] << std::endl;
263 
264  rsd_sasa_ = calc_rsd_sasa( pose );
265  rsd_layer_.resize( pose.total_residue() );
266 
267  utility::vector1< Size > selected_residues;
268  for( Size iaa=1; iaa<=pose.total_residue(); iaa++ ) {
269 
270  char ss = secstruct.at( iaa-1 );
271  runtime_assert( ss == 'L' || ss =='E' || ss=='H' );
272 
273  rsd_layer_[ iaa ] = "";
274 
275  bool flag( false );
276  for( Size i=1; i<=excluded_aatypes_for_selection_.size(); i++ ) {
277  if( pose.aa( iaa ) == excluded_aatypes_for_selection_[ i ] ) {
278  flag = true;
279  break;
280  }
281  }
282  if( flag ) continue;
283 
284  if( restricted_aatypes_for_selection_.size() > 0 ) flag = true;
285  for( Size i=1; i<=restricted_aatypes_for_selection_.size(); i++ ) {
286  if( pose.aa( iaa ) == restricted_aatypes_for_selection_[ i ] ) {
287  flag = false;
288  break;
289  }
290  }
291  if( flag ) continue;
292 
293  if ( rsd_sasa_[ iaa ] <= burial_[ ss ] && pick_core_ ) {
294 
295  selected_core_residues_.push_back( iaa );
296  selected_residues.push_back( iaa );
297 
299  output << "select " << iaa << std::endl;
300  output << "color blue " << std::endl;
301  }
302 
303  rsd_layer_[ iaa ] = "core";
304 
305  } else if ( rsd_sasa_[ iaa ] >= surface_[ ss ] && pick_surface_ ) {
306 
307  selected_surface_residues_.push_back( iaa );
308  selected_residues.push_back( iaa );
309 
311  output << "select " << iaa << std::endl;
312  output << "color red " << std::endl;
313  }
314 
315  rsd_layer_[ iaa ] = "surface";
316 
317  } else if ( rsd_sasa_[ iaa ] < surface_[ ss ] && rsd_sasa_[ iaa ] > burial_[ ss ] && pick_boundary_ ) {
318 
319  selected_boundary_residues_.push_back( iaa );
320  selected_residues.push_back( iaa );
321 
323  output << "select " << iaa << std::endl;
324  output << "color green " << std::endl;
325  }
326 
327  rsd_layer_[ iaa ] = "boundary";
328 
329  }
330 
331  }
332 
333  return selected_residues;
334 
335 } // compute
336 
337 
338 
339 } // flxbb
340 } // protocols