Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResidueBurialFilter.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/ResidueBurialFilter.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarelf@u.washington.edu), Jacob Corn (jecorn@u.washington.edu)
13 
16 
17 #include <core/types.hh>
18 #include <core/pose/Pose.hh>
21 #include <utility/tag/Tag.hh>
24 #include <core/pose/selection.hh>
25 #include <boost/foreach.hpp>
26 #define foreach BOOST_FOREACH
27 
28 #include <basic/Tracer.hh>
30 
31 namespace protocols{
32 namespace simple_filters {
33 
34 static basic::Tracer residue_burial_filter_tracer( "protocols.simple_filters.ResidueBurialFilter" );
35 
37  Filter( "ResidueBurial" ),
38  target_residue_( 0 ),
39  neighbors_( 1 ),
40  distance_threshold_( 8.0 ),
41  task_factory_( NULL ) {}
42 
43 ResidueBurialFilter::ResidueBurialFilter( core::Size const target_residue, core::Size const neighbors, core::Real const distance_threshold ) :
44  Filter( "ResidueBurial" ),
45  target_residue_( target_residue ),
46  neighbors_( neighbors ),
47  distance_threshold_( distance_threshold ),
48  task_factory_( NULL ) {}
49 
52 
54 ResidueBurialFilterCreator::keyname() const { return "ResidueBurial"; }
55 
57 
58 void
60  task_factory_ = tf;
61 }
62 
65 
66 bool
68  if( task_factory() ){//taskfactory is on, iterate over all designable residues and check whether any one passes the filter
69 /// This looks like recursion but is really quite limited, b/c the call below to rbf.apply uses the functionality where task_factory() is off, so it goes by a different route, and could never go to a depth of more than 2
70  utility::vector1< core::Size > const target_residues( protocols::rosetta_scripts::residue_packer_states( pose, task_factory(), true/*designable*/, false/*packable*/ ) );
71  core::Size const total_designable( target_residues.size() );
72  residue_burial_filter_tracer<<"total target residues: "<<total_designable<<". At least "<<(core::Real)total_designable * (core::Real)residue_fraction_buried()<<" should be buried to pass."<<std::endl;
73  core::Size count_buried( 0 );
74  foreach( core::Size const resi, target_residues ){
75  ResidueBurialFilter const rbf( resi/*target_residue*/, neighbors_, distance_threshold_ );
76  if( rbf.apply( pose ) ){
77  count_buried++;
78  if( (core::Real ) ( (core::Real) count_buried / (core::Real) total_designable ) >= residue_fraction_buried() )
79  return true;
80  }
81  }
82  return false;
83  }
84 
85  core::Size const count_neighbors( compute( pose ) );
86 
87  residue_burial_filter_tracer<<"Number of interface neighbors of residue "<<pose.residue( target_residue_ ).name3()<<target_residue_<<" is "<<count_neighbors<<std::endl;
88  return( count_neighbors >= neighbors_ );
89 }
90 
91 void
93 {
94  if( tag->hasOption( "res_num" ) || tag->hasOption( "pdb_num" ) )
96  distance_threshold_ = tag->getOption<core::Real>( "distance", 8.0 );
97  neighbors_ = tag->getOption<core::Size>( "neighbors", 1 );
98  residue_fraction_buried( tag->getOption< core::Real >( "residue_fraction_buried", 0.0001 ) );
99  if( tag->hasOption( "task_operations" ) )
101 
102  residue_burial_filter_tracer<<"ResidueBurialFilter with distance threshold of "<<distance_threshold_<<" around residue "<<target_residue_<<" residue_fraction_buried "<<residue_fraction_buried()<<" with "<<neighbors_<<" neighbors."<<std::endl;
103 }
104 
105 void
106 ResidueBurialFilter::report( std::ostream & out, core::pose::Pose const & pose ) const {
107  if( !task_factory() ){
108  core::Size const count_neighbors( compute( pose ) );
109 
110  out<<"Number of interface neighbors of residue "<<pose.residue( target_residue_ ).name3()<<target_residue_<<" is "<<count_neighbors<<'\n';
111  }
112 }
113 
116  if( !task_factory() ){
117  core::Size const count_neighbors( compute( pose ) );
118 
119  return( count_neighbors );
120  }
121  else return( 0 );
122 }
123 
124 /// @details counts the number of residues to target_residue_ across all chains in the pose, other than the one containing target_residue_
127  core::Size chain( 1 );
128  for( ; chain <= pose.conformation().num_chains(); ++chain )
129  if( pose.conformation().chain_begin( chain ) <= target_residue_ && pose.conformation().chain_end( chain ) >= target_residue_ ) break;
130 
131  core::Size const chain_begin( pose.conformation().chain_begin( chain ) );
132  core::Size const chain_end( pose.conformation().chain_end( chain ) );
133 
134 residue_burial_filter_tracer<<"chain span "<<chain_begin<< " "<<chain_end<<std::endl;
135  core::Size count_neighbors( 0 );
136  core::conformation::Residue const res_target( pose.conformation().residue( target_residue_ ) );
137  for( core::Size i=1; i<=pose.total_residue(); ++i ){
138  if( i>=chain_begin && i<=chain_end ) continue;
139  core::conformation::Residue const resi( pose.residue( i ) );
140  core::Real const distance( resi.xyz( resi.nbr_atom() ).distance( res_target.xyz( res_target.nbr_atom() ) ) );
141  if( distance <= distance_threshold_ ) ++count_neighbors;
142  }
143  return( count_neighbors);
144 }
145 
148  return new ResidueBurialFilter( *this );
149 }
150 
153  return new ResidueBurialFilter();
154 }
155 
156 
157 }
158 }