Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CoreDunbrackFilter.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/filters/CoreDunbrackFilter.cc
11 /// @brief filter structures by packstat score
12 /// @detailed
13 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
14 
15 // Unit Headers
18 
19 // Project Headers
20 
21 #include <core/chemical/AA.hh>
23 #include <core/scoring/Energies.hh>
24 
25 #include <core/pose/Pose.hh>
26 #include <core/scoring/sasa.hh>
27 #include <core/id/AtomID_Map.hh>
31 // AUTO-REMOVED #include <core/scoring/ScoringManager.hh>
32 #include <core/types.hh>
33 
34 
35 
36 // Utility headers
37 #include <basic/Tracer.hh>
38 
39 // Parser headers
41 #include <utility/tag/Tag.hh>
42 
43 #include <core/pose/util.hh>
44 #include <utility/vector0.hh>
45 #include <utility/vector1.hh>
46 
47 //Auto Headers
48 #include <core/pose/util.tmpl.hh>
49 //// C++ headers
50 static basic::Tracer tr("protocols.fldsgn.filters.CoreDunbrackFilter");
51 
52 namespace protocols {
53 namespace fldsgn {
54 namespace filters {
55 
56 // @brief default constructor
58  Filter( "CoreDunbrack" ),
59  filter_value_( 100.0 ),
60  type_( "average" ),
61  fa_dun_danger_( 1.0 )
62 {}
63 
64 // @brief constructor with arguments
65 CoreDunbrackFilter::CoreDunbrackFilter( String const & type, Real const value ):
66  Filter( "CoreDunbrack" ),
67  filter_value_( value ),
68  type_( type ),
69  fa_dun_danger_( 1.0 )
70 {}
71 
72 // @brief copy constructor
74  //utility::pointer::ReferenceCount(),
75  Super( rval ),
76  filter_value_( rval.filter_value_ ),
77  type_( rval.type_ ),
78  fa_dun_danger_( rval.fa_dun_danger_ )
79 {}
80 
81 // @brief set filter value
83 {
84  filter_value_ = value;
85 }
86 
87 // @brief set filter type
89 {
90  type_ = value;
91 }
92 
93 /// @brief
95 CoreDunbrackFilter::report_sm( Pose const & pose ) const
96 {
97  return compute( pose );
98 }
99 
100 /// @brief
101 void
102 CoreDunbrackFilter::report( std::ostream & out, Pose const & pose ) const
103 {
104  out << "CoreDunbrack: " << compute( pose ) << std::endl;
105 }
106 
107 /// @brief
109 CoreDunbrackFilter::compute( Pose const & pose ) const
110 {
111 
112  // define atom_map for main-chain and CB
114  core::pose::initialize_atomid_map( atom_map, pose, false );
115  for ( Size ir = 1; ir <= pose.total_residue(); ++ir ) {
116  for ( Size j = 1; j<=5; ++j ) {
117  core::id::AtomID atom( j, ir );
118  atom_map.set( atom, true );
119  }
120  }
121 
122  // calc sasa
123  Real pore_radius( 2.0 );
125  utility::vector1< Real > rsd_sasa;
126  core::scoring::calc_per_atom_sasa( pose, atom_sasa, rsd_sasa, pore_radius, false, atom_map );
127 
128  // store working pose
129  Pose copy_pose( pose );
131  (*sfxn)( copy_pose );
132 
133  Real asa_core( 40.0 );
134  Real frustration( 0.0 );
135  Size num_frustrated_residue( 0 );
136  Size rnum_core( 0 );
137  // take dunbrack score
138  for( Size i=1; i<=pose.total_residue(); i++ ) {
139  if( rsd_sasa[ i ] < asa_core ) {
140  if( name_from_aa( pose.aa( i ) ) == "TRP" ||
141  name_from_aa( pose.aa( i ) ) == "TYR" ||
142  name_from_aa( pose.aa( i ) ) == "MET" ||
143  name_from_aa( pose.aa( i ) ) == "PHE" ||
144  name_from_aa( pose.aa( i ) ) == "ILE" ||
145  name_from_aa( pose.aa( i ) ) == "LEU" ||
146  name_from_aa( pose.aa( i ) ) == "VAL" ) {
147 
149  if( fa_dun > fa_dun_danger_ ) {
150  tr << "CAUTION high dubrack score " << i << " " << name_from_aa( pose.aa( i ) ) << " " << rsd_sasa[ i ] << " "
151  << fa_dun << std::endl;
152  num_frustrated_residue ++;
153  }
154 
155  frustration += fa_dun;
156  rnum_core ++;
157 
158  }
159  }
160  }
161 
162 
163  Real ave = Real( frustration )/Real( rnum_core );
164  tr << "Frustration: " << frustration << " ,num_hydrophobic_in_core: " << rnum_core
165  << "average: " << ave << " ,num_frustrated_residue: " << num_frustrated_residue << std::endl;
166 
167  Real value( 0.0 );
168  if( type_ == "average" ) {
169  value = ave;
170  } else if( type_ == "num_frustrated_residue" ) {
171  value = num_frustrated_residue;
172  } else if( type_ == "total" ) {
173  value = frustration;
174  } else {
175  tr << "improper type specification " << type_ << std::endl;
176  runtime_assert( false );
177  }
178 
179  return value;
180 }
181 
182 
183 // @brief returns true if the given pose passes the filter, false otherwise.
184 // In this case, the test is whether the give pose is the topology we want.
185 bool CoreDunbrackFilter::apply( Pose const & pose ) const
186 {
187  Real value = compute( pose );
188  if( value < filter_value_ ){
189  tr << "Successfully filtered: " << type_ << " " << value << std::endl;
190  return true;
191  }else{
192  tr << "Filter failed current/threshold=" << value << "/" << filter_value_ << std::endl;
193  return false;
194  }
195 } // apply_filter
196 
197 /// @brief parse xml
198 void
200  TagPtr const tag,
201  DataMap &,
202  Filters_map const &,
203  Movers_map const &,
204  Pose const & pose )
205 {
206  // set filter type
207  type_ = tag->getOption<String>( "type", "average" );
208 
209  // set threshold
210  filter_value_ = tag->getOption<Real>( "threshold", Real( pose.total_residue() ) );
211  if( type_ == "average" ) {
212  } else if ( type_ == "num_frustrated_residue" ) {
213  } else if ( type_ == "total" ) {
214  } else {
215  tr << "invalid type specification, slect from average, num_frustrated_residue, or total" << std::endl;
216  runtime_assert( false );
217  }
218 
219 }
220 
223 
225 CoreDunbrackFilterCreator::keyname() const { return "CoreDunbrack"; }
226 
227 
228 } // filters
229 } // fldsgn
230 } // protocols