Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BuriedUnsatHbondFilter.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/BuriedUnsatHbondFilter.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarelf@u.washington.edu), Jacob Corn (jecorn@u.washington.edu)
13 
16 
17 #include <core/pose/Pose.hh>
18 #include <basic/Tracer.hh>
19 #include <utility/tag/Tag.hh>
25 #include <basic/MetricValue.hh>
28 #include <utility/string_util.hh>
29 #include <boost/foreach.hpp>
30 #define foreach BOOST_FOREACH
31 
32 namespace protocols {
33 namespace simple_filters {
34 
35 static basic::Tracer buried_unsat_hbond_filter_tracer( "protocols.simple_filters.BuriedUnsatHbondFilter" );
36 
39 
41 BuriedUnsatHbondFilterCreator::keyname() const { return "BuriedUnsatHbonds"; }
42 
43 BuriedUnsatHbondFilter::BuriedUnsatHbondFilter( core::Size const upper_threshold, core::Size const jump_num ) :
44  Filter( "BuriedUnsatHbonds" ),
45  upper_threshold_( upper_threshold ),
46  jump_num_( jump_num ),
47  task_factory_( NULL )
48 { }
49 
50 BuriedUnsatHbondFilter::BuriedUnsatHbondFilter() : filters::Filter( "BuriedUnsatHbonds" ) {}
51 
53 
54 void
56 {
57  jump_num_ = tag->getOption<core::Size>( "jump_number", 1 );
58  upper_threshold_ = tag->getOption<core::Size>( "cutoff", 20 );
59 
60  std::string const scorefxn_key( tag->getOption<std::string>("scorefxn", "score12" ) );
61  if ( datamap.has( "scorefxns", scorefxn_key ) ) {
62  sfxn_ = datamap.get< core::scoring::ScoreFunction* >( "scorefxns", scorefxn_key );
63  } else {
65  }
67 
68  buried_unsat_hbond_filter_tracer<<"Buried Unsatisfied Hbond filter over jump number " << jump_num_ << " with cutoff " << upper_threshold_ << std::endl;
69 }
70 
71 bool
73  core::Real const unsat_hbonds( compute( pose ) );
74 
75  buried_unsat_hbond_filter_tracer<<"# unsatisfied hbonds: "<<unsat_hbonds<<". ";
76  if( unsat_hbonds <= upper_threshold_ ){
77  buried_unsat_hbond_filter_tracer<<"passing." <<std::endl;
78  return true;
79  }
80  else {
81  buried_unsat_hbond_filter_tracer<<"failing."<<std::endl;
82  return false;
83  }
84 }
85 
86 void
87 BuriedUnsatHbondFilter::report( std::ostream & out, core::pose::Pose const & pose ) const {
88  core::Real const unsat_hbonds( compute( pose ));
89  out<<"# unsatisfied hbonds: "<< unsat_hbonds<<'\n';
90 }
91 
94  core::Real const unsat_hbonds( compute( pose ));
95  return( unsat_hbonds );
96 }
97 
100 
101  runtime_assert( jump_num_ <= pose.num_jump() );
102 
103  // score the pose to populate the 10A neighborgraph
104  core::pose::Pose bound( pose );
105 
107  ( *scorefxn )( bound );
108  bound.update_residue_neighbors();
109 
110  core::pose::Pose unbound( bound );
111  if( jump_num_ ) {
112  core::Real const unbound_dist = 1000.0;
113  protocols::rigid::RigidBodyTransMover trans_mover( unbound, jump_num_ );
114  trans_mover.trans_axis( trans_mover.trans_axis() );
115  trans_mover.step_size(unbound_dist);
116  trans_mover.apply( unbound );
117  //unbound.update_residue_neighbors();
118  (*sfxn_)(unbound ); // score the new pose, or we get assertion erros.
119  }
120 
121  basic::MetricValue< core::Size > mv_bound, mv_unbound;
122  basic::MetricValue< std::string > mv_bound_str, mv_unbound_str;
123 
124  using namespace protocols::toolbox::pose_metric_calculators;
125  // Despite the name, it's counting H-bonders, not any old polars.
126  BuriedUnsatisfiedPolarsCalculator calc_bound("default", "default"), calc_unbound("default", "default");
127  calc_bound.get("all_bur_unsat_polars", mv_bound, bound);
128  std::string bound_string(""), unbound_string("");
129  bound_string = calc_bound.get( "residue_bur_unsat_polars", bound );
130  buried_unsat_hbond_filter_tracer << "BOUND: " << bound_string << std::endl;
131 
132  core::Real unsat_hbonds( 0.0 );
133  if( jump_num_ ) {
134  calc_unbound.get("all_bur_unsat_polars", mv_unbound, unbound);
135  unsat_hbonds = mv_bound.value() - mv_unbound.value();
136  buried_unsat_hbond_filter_tracer << "unbound_unsat=" << mv_unbound.value() << " " << "bound_unsat=" << mv_bound.value() << std::endl;
137  unbound_string = calc_unbound.get( "residue_bur_unsat_polars", unbound );
138  buried_unsat_hbond_filter_tracer << "UNBOUND: " << unbound_string << std::endl;
139  }
140  else unsat_hbonds = mv_bound.value();
141  if( task_factory_() != NULL ){
142  std::string unbound_tmp, bound_tmp;
143 
144 /// clean the silly stuff in the string. Unfortunately the calculators are organized in such a way that there's no direct access to the values they report so this hack uses the string output...
145  for( core::Size i=0; i<unbound_string.length(); ++i ){
146  if( unbound_string.c_str()[ i ]<='9' && unbound_string.c_str()[ i ]>='0' )
147  unbound_tmp+=unbound_string.c_str()[i];
148  }
149  for( core::Size i=0; i<bound_string.length(); ++i ){
150  if( bound_string.c_str()[ i ]<='9' && bound_string.c_str()[ i ]>='0' )
151  bound_tmp+=bound_string.c_str()[i];
152  }
153 /// which residues does the taskfactory mention
154  utility::vector1< core::Size > const selected_residues( protocols::rosetta_scripts::residue_packer_states( pose, task_factory(), true/*designable*/, true/*packable*/ ) );
155  core::Size total_in_selected_residues( 0 );
156  if( selected_residues.size() == 0 )
157  return 0;
158  foreach( core::Size const sr, selected_residues ){
159 // buried_unsat_hbond_filter_tracer<<sr<<": "<<(bound_tmp[ sr-1 ])<<" "<<(unbound_tmp[ sr-1 ])<<" "<<(bound_tmp[ sr-1 ]) - (unbound_tmp[ sr-1 ])<<std::endl;
160  total_in_selected_residues += std::max( (bound_tmp[ sr-1 ]) - (unbound_tmp[ sr-1 ]), 0 );
161  }
162  return( total_in_selected_residues );
163  }
164 
165  return( unsat_hbonds );
166 }
167 
169  return new BuriedUnsatHbondFilter( *this );
170 }
171 
173  return new BuriedUnsatHbondFilter();
174 }
175 
176 void
178  task_factory_ = tf;
179 }
180 
183  return task_factory_;
184 }
185 
186 }
187 }