Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AlaScan.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_filters/AlaScan.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarelf@u.washington.edu), Jacob Corn (jecorn@u.washington.edu)
13 // Project Headers
14 
15 #include <ObjexxFCL/FArray1D.fwd.hh>
16 #include <ObjexxFCL/FArray1D.hh>
17 #include <ObjexxFCL/format.hh>
18 #include <basic/MetricValue.hh>
19 #include <basic/Tracer.hh>
20 #include <core/chemical/AA.hh>
30 #include <core/pose/PDBInfo.hh>
31 #include <core/pose/Pose.hh>
33 #include <core/scoring/Energies.hh>
39 #include <core/types.hh>
41 #include <map>
42 #include <numeric/random/random.hh>
53 #include <string>
54 #include <utility/exit.hh>
55 #include <utility/tag/Tag.hh>
56 #include <utility/vector0.hh>
57 #include <utility/vector1.hh>
58 
59 
60 namespace protocols {
61 namespace simple_filters {
62 
63 static basic::Tracer TR( "protocols.simple_filters.AlaScan" );
64 
67 
69 AlaScanFilterCreator::keyname() const { return "AlaScan"; }
70 
71 
72 void
74 {
76 }
77 
78 AlaScan::AlaScan( bool const chain1, bool const chain2, core::Size const repeats, core::Real const dist, core::scoring::ScoreFunctionCOP scorefxn, core::Size const jump=1, bool const symmetry=false ) : Filter( "AlaScan" ),
79  chain1_( chain1 ),
80  chain2_( chain2 ),
81  repeats_( repeats ),
82  distance_threshold_( dist ),
83  jump_( jump ),
84  symmetry_( symmetry ),
85  repack_( true )
86 {
88  else scorefxn_ = scorefxn->clone();
89 }
90 
92 
93 bool
95 {
96  return repack_;
97 }
98 
99 void
100 AlaScan::repack( bool const repack )
101 {
102  repack_ = repack;
103 }
104 
105 void
107 {
108  distance_threshold_ = tag->getOption<core::Real>( "interface_distance_cutoff", 8.0 );
109  chain1_ = tag->getOption< bool >( "partner1", 0 );
110  chain2_ = tag->getOption< bool >( "partner2", 1 );
111  jump_ = tag->getOption< Size >( "jump", 1 );
112  runtime_assert( chain1_ || chain2_ );
113  std::string const scorefxn_name( tag->getOption< std::string >( "scorefxn", "score12" ));
114  repeats_ = tag->getOption< core::Size >( "repeats", 1 );
115  symmetry_ = tag->getOption< bool >( "symmetry", 0 );
116  repack( tag->getOption< bool >( "repack", 1 ) );
117 
118  if ( symmetry_ ) {
119  using namespace core::scoring::symmetry;
120  scorefxn_ = new SymmetricScoreFunction( *data.get< core::scoring::ScoreFunction * >( "scorefxns", scorefxn_name ) );
121  TR<<"Symmetric AlaScan with distance threshold of "<<distance_threshold_<<" Ang "<<". jump="<<jump_<<" partner1="<<chain1_<<", partner2="<<chain2_<<" using "<<repeats_<<" repeats."<<std::endl;
122  return;
123  }
124  using namespace core::scoring;
125  scorefxn_ = new ScoreFunction( *(data.get< core::scoring::ScoreFunction * >( "scorefxns", scorefxn_name )) );
126  TR<<"AlaScan with distance threshold of "<<distance_threshold_<<" Ang "<<". jump="<<jump_<<" partner1="<<chain1_<<", partner2="<<chain2_<<" using "<<repeats_<<" repeats repack "<<repack()<<std::endl;
127 }
128 
129 
131 AlaScan::ddG_for_single_residue( core::pose::Pose const & const_pose, core::Size const resi ) const
132 {
133  if( !const_pose.residue( resi ).is_protein() ){
134  TR<<"WARNING: Non-protein residue "<< resi<<" was requested for ala-scan. Returning 0"<<std::endl;
135  return 0.0;
136  }
137  core::Size const rb_jump( jump_ );
138  core::pose::Pose pose( const_pose );
139 
140  simple_filters::DdgFilter ddg_filter( 100/*ddg_threshold*/, scorefxn_, rb_jump, 1 /*repeats*/ );
141  if( repack() )
142  TR<<"Energy calculations are carried out with repacking in the bound and unbound states (ddG)\n";
143  else
144  TR<<"Energy calculations are carried out without repackign in the bound and unbound states (dG)\n";
145  ddg_filter.repack( repack() );
147 
148  utility::vector1< bool > allowed_aas;
149  allowed_aas.assign( core::chemical::num_canonical_aas, false );
150  allowed_aas[ core::chemical::aa_ala ] = true;
151  using namespace core::pack::task;
152 
153  PackerTaskOP task = TaskFactory::create_packer_task( pose );
154  task->initialize_from_command_line().or_include_current( true );
155  for( core::Size resj=1; resj<=pose.total_residue(); ++resj ){
156  if( resi == resj )
157  task->nonconst_residue_task( resi ).restrict_absent_canonical_aas( allowed_aas );
158  else
159  task->nonconst_residue_task( resj ).prevent_repacking();
160  }
161  core::pack::pack_rotamers( pose, *scorefxn_, task );
162  core::Real accumulate_ddg = 0;
163 
164  for( core::Size r=1; r<=repeats_; ++r )
165  accumulate_ddg += (rb_jump==0 ? energy_filter.compute( pose ) : ddg_filter.compute( pose ) );;
166  core::Real const mut_ddg( accumulate_ddg / repeats_ );
167 
168  TR.flush();
169  return( mut_ddg );
170 }
171 
172 void
173 AlaScan::report( std::ostream & out, core::pose::Pose const & const_pose ) const
174 {
175  if ( symmetry_ ) {
176  report_symmetry( out, const_pose );
177  return;
178  }
179 
180  core::Size const rb_jump( jump_ );
181  core::pose::Pose pose( const_pose );
182 
183  core::kinematics::FoldTree const fold_tree = pose.conformation().fold_tree();
184 
185  core::Size upstream_jump_res, downstream_jump_res;
186  upstream_jump_res = fold_tree.upstream_jump_residue( jump_ );
187  downstream_jump_res = fold_tree.downstream_jump_residue( jump_ );
188 
189  core::Size const chain_begin( chain1_ ? 1 : downstream_jump_res );
190  core::Size const chain_end ( chain2_ ? pose.total_residue() : upstream_jump_res );
191 
192  protocols::scoring::Interface interface_obj;
193  interface_obj.jump( rb_jump == 0 ? 1 : rb_jump ); // 0 plays badly with interface obj.
194  pose.update_residue_neighbors(); // o/w fails assertion `graph_state_ == GOOD`
195  interface_obj.distance( distance_threshold_ );
196  interface_obj.calculate( pose );
197 
198  simple_filters::DdgFilter const ddg_filter( 100/*ddg_threshold*/, scorefxn_, rb_jump, 1 /*repeats*/ );
200 
201  core::Real accumulate_ddg( 0 );
202  for( core::Size r=1; r<=repeats_; ++r )
203  accumulate_ddg += (rb_jump==0 ? energy_filter.compute( const_pose ) : ddg_filter.compute( const_pose ) );
204 
205  core::Real const wt_ddg( accumulate_ddg / repeats_ );
206  for( core::Size resi = chain_begin; resi <= chain_end; ++resi ){
207  if( !pose.residue( resi ).is_protein() ) continue;
208  if( interface_obj.is_interface( resi ) ){
209  core::Real const mut_ddg( ddG_for_single_residue( const_pose, resi ) );
210  core::Real const diff_ddg( mut_ddg - wt_ddg );
211 
212  core::pose::PDBInfoCOP pose_info( const_pose.pdb_info() );
213  char const chain( pose_info->chain( resi ) );
214  core::Size const number( pose_info->number( resi ) );
215  std::string const res_type( const_pose.residue( resi ).name3() );
216  out<<" "<<res_type<<" "<<number<<" "<<chain<<" : "<< ObjexxFCL::fmt::F (9,4,diff_ddg)<<'\n';
217  }
218  }
219  out<<std::endl;
220 }
221 
222 void
223 AlaScan::report_symmetry( std::ostream & out, core::pose::Pose const & const_pose ) const
224 {
225  core::pose::Pose pose( const_pose );
226 
227  assert( core::pose::symmetry::is_symmetric( pose ));
229  dynamic_cast<core::conformation::symmetry::SymmetricConformation & > ( pose.conformation()) );
230 
231  protocols::scoring::Interface interface_obj(1);
232  pose.update_residue_neighbors(); // o/w fails assertion `graph_state_ == GOOD`
233  interface_obj.distance( distance_threshold_ );
234  interface_obj.calculate( pose );
235 
236  simple_filters::DdgFilter const ddg( 100/*ddg_threshold*/, scorefxn_, 1, 1 /*repeats*/, true /*symmetry*/ );
237  core::Real accumulate_ddg( 0 );
238  for( core::Size r=1; r<=repeats_; ++r )
239  accumulate_ddg += ddg.compute( const_pose );
240  core::Real const wt_ddg( accumulate_ddg / repeats_ );
241 
242  //core::Real const wt_ddg( ddg.compute( const_pose ) );
243  utility::vector1< bool > allowed_aas;
244  allowed_aas.assign( core::chemical::num_canonical_aas, false );
245  allowed_aas[ core::chemical::aa_ala ] = true;
246  for( core::Size resi = 1; resi <= pose.total_residue(); ++resi ){
247  if ( !symm_conf.Symmetry_Info()->bb_is_independent(resi) ) continue;
248  if( !pose.residue( resi ).is_protein() ) continue;
249  if( interface_obj.is_interface( resi ) ){
250  using namespace core::pack::task;
251 
252  PackerTaskOP task = TaskFactory::create_packer_task( pose );
253  task->initialize_from_command_line().or_include_current( true );
254  for( core::Size resj=1; resj<=pose.total_residue(); ++resj ){
255  if( !pose.residue( resi ).is_protein() ) continue;
256  if( resi == resj )
257  task->nonconst_residue_task( resi ).restrict_absent_canonical_aas( allowed_aas );
258  else
259  task->nonconst_residue_task( resj ).prevent_repacking();
260  }
261  core::pack::pack_rotamers( pose, *scorefxn_, task );
262  accumulate_ddg = 0;
263  for( core::Size r=1; r<=repeats_; ++r ) accumulate_ddg += ddg.compute( pose );
264  core::Real const mut_ddg( accumulate_ddg / repeats_ );
265  //core::Real const mut_ddg( ddg.compute( const_pose ) );
266  core::Real const diff_ddg( mut_ddg - wt_ddg );
267 
268  core::pose::PDBInfoCOP pose_info( const_pose.pdb_info() );
269  //char const chain( pose_info->chain( resi ) );
270  //core::Size const number( pose_info->number( resi ) );
271  std::string const res_type( const_pose.residue( resi ).name3() );
272  //out<<" "<<res_type<<" "<<number<<" "<<chain<<" : "<< F (9,4,diff_ddg)<<'\n';
273  out<<" "<<res_type<<" "<< resi <<" : "<< ObjexxFCL::fmt::F (9,4,diff_ddg)<<'\n';
274  pose=const_pose;
275  }
276  }
277 }
278 
279 
280 }
281 }