Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InterlockingAromaFilter.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/InterlockingAromaFilter.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 #include <core/chemical/AA.hh>
23 #include <core/scoring/Energies.hh>
26 #include <core/pose/Pose.hh>
29 
30 // Utility headers
31 #include <basic/Tracer.hh>
32 
33 // Parser headers
35 #include <utility/tag/Tag.hh>
36 
37 #include <core/kinematics/Jump.hh>
38 #include <utility/vector0.hh>
39 #include <utility/vector1.hh>
40 
41 //// C++ headers
42 static basic::Tracer tr("protocols.fldsgn.filters.InterlockingAromaFilter");
43 
44 namespace protocols {
45 namespace fldsgn {
46 namespace filters {
47 
48 // @brief default constructor
50  Filter( "InterlockingAroma" ),
51  filter_value_( 0 ),
52  contact_dist2_( numeric::square( 5.5 ) ),
53  input_ss_( "" ),
54  verbose_( true )
55 {}
56 
57 
58 // @brief value constructor
60  Filter( "InterlockingAroma" ),
61  filter_value_( 0 ),
62  contact_dist2_( numeric::square( 5.5 ) ),
63  input_ss_( ss ),
64  verbose_( true )
65 {}
66 
67 
68 // @brief copy constructor
70  Super( rval ),
71  filter_value_( rval.filter_value_ ),
72  contact_dist2_( rval.contact_dist2_ ),
73  input_ss_( rval.input_ss_ ),
74  verbose_( rval.verbose_ )
75 {}
76 
77 
78 // @brief set filter value ( defalt 0 )
79 void
81 {
82  filter_value_ = value;
83 }
84 
85 
86 // @brief set distance to judge contact ( defalt 4.5 )
87 void
89 {
91 }
92 
93 
94 // @brief set verbose on or off ( default on )
95 void
97 {
98  verbose_ = b;
99 }
100 
101 
102 /// @brief
105 {
106  return compute( pose );
107 }
108 
109 
110 /// @brief
111 void
112 InterlockingAromaFilter::report( std::ostream & out, Pose const & pose ) const
113 {
114  out << "InterlockingAroma: " << compute( pose ) << std::endl;
115 }
116 
117 /// @brief
118 bool
119 InterlockingAromaFilter::compute( Size const & res, Pose const & pose, SS_Info2_COP const ssinfo ) const
120 {
121  runtime_assert( pose.aa( res ) == core::chemical::aa_phe ||
122  pose.aa( res ) == core::chemical::aa_tyr ||
123  pose.aa( res ) == core::chemical::aa_trp );
124 
125  using core::Vector;
128 
129  Vector centroid;
130  Residue residue( pose.residue( res ) );
131  Size natom( 0 );
132  centroid.zero();
133  for ( Size iatm=1, iatm_end=residue.natoms(); iatm<=iatm_end; ++iatm ) {
134  if( residue.atom_type( int(iatm) ).atom_type_name() == "aroC" ||
135  residue.atom_type( int(iatm) ).atom_type_name() == "Ntrp" ) {
136  centroid += residue.atom( iatm ).xyz();
137  natom++;
138  }
139  }
140  runtime_assert( natom != 0 );
141  centroid = centroid/Real( natom );
142 
143  Size contact( 0 );
144  utility::vector1< Size > lockres;
145  TenANeighborGraph const & energy_graph( pose.energies().tenA_neighbor_graph() );
147  iru = energy_graph.get_node( res )->const_edge_list_begin(),
148  irue = energy_graph.get_node( res )->const_edge_list_end(); iru != irue; ++iru ) {
149 
150  Size stres( (*iru)->get_second_node_ind() );
151  if ( res == stres ) stres = (*iru)->get_first_node_ind();
152 
153  if( ssinfo->strand_id( stres ) == 0 ) continue;
154 
155  Vector cb( ssinfo->bb_pos().CB( stres ) );
156  Real const dsq( cb.distance_squared( centroid ) );
157 
158  if ( dsq <= contact_dist2_ ) {
159  contact++;
160  lockres.push_back( stres );
161  }
162 
163 
164 // if( stres+2 > pose.total_residue() ) continue;
165 // if( ssinfo->strand_id( stres ) == 0 && ssinfo->strand_id( stres+2 ) == 0 ) continue;
166 // Vector cb1( ssinfo->bb_pos().CB( stres ) );
167 // Real const dsq1( distance_squared( cb1, centroid ));
168 //
169 // Vector cb2( ssinfo->bb_pos().CB( stres+2 ) );
170 // Real const dsq2( distance_squared( cb2, centroid ));
171 // tr << res << " " << stres << " " << stres+2 << " " << dsq1 << " " << dsq2 << std::endl;
172 //
173 // if ( dsq1 <= contact_dist2_ ) {
174 // Vector cb2( ssinfo->bb_pos().CB( stres+2 ) );
175 // Real const dsq2( distance_squared( cb2, centroid ));
176 // if( dsq2 <= contact_dist2_ ) {
177 // if( verbose_ ) {
178 // tr << "Residue " << res << " is interlocking with " << stres << " & " << stres+2 << std::endl;
179 // }
180 // return true;
181 // }
182 // }
183  }
184 
185  if( contact >= 2 ) {
186 
187  tr << "Residue " << res << " is interlocking with ";
188  for( Size ii=1; ii<=lockres.size(); ii++ ) {
189  tr << lockres[ ii ] << " ";
190  }
191  tr << std::endl;
192  return true;
193 
194  } else {
195  return false;
196  }
197 
198 }
199 
200 
201 /// @brief
204 {
208 
209  String ss("");
210  if( ! input_ss_.empty() ) {
211  ss = input_ss_;
212  runtime_assert( input_ss_.length() == pose.total_residue() );
213  } else {
214  Dssp dssp( pose );
215  ss = dssp.get_dssp_secstruct();
216  }
217  SS_Info2_OP ssinfo = new SS_Info2( pose, ss );
218 
219  // calc number of interlocking aromatic residues
220  Size num_interlocked( 0 );
221  for( Size ii=1; ii<=pose.total_residue(); ++ii ) {
222  if( ss.at( ii-1 ) == 'E' ) continue;
223  if( pose.aa( ii ) == core::chemical::aa_phe ||
224  pose.aa( ii ) == core::chemical::aa_tyr ||
225  pose.aa( ii ) == core::chemical::aa_trp ) {
226  if( compute( ii, pose, ssinfo ) ) num_interlocked++;
227  }
228  }
229 
230  return Real(num_interlocked);
231 }
232 
233 
234 // @brief returns true if the given pose passes the filter, false otherwise.
235 // In this case, the test is whether the give pose is the topology we want.
236 bool InterlockingAromaFilter::apply( Pose const & pose ) const
237 {
238  Real value = compute( pose );
239  if( value > filter_value_ ){
240  tr << "Successfully filtered: " << value << std::endl;
241  return true;
242  }else{
243  tr << "Filter failed current/threshold=" << value << "/" << filter_value_ << std::endl;
244  return false;
245  }
246 } // apply_filter
247 
248 /// @brief parse xml
249 void
251  TagPtr const tag,
252  DataMap &,
253  Filters_map const &,
254  Movers_map const &,
255  Pose const & )
256 {
257  String const blueprint = tag->getOption<String>( "blueprint", "" );
258  if( blueprint != "" ) {
259  jd2::parser::BluePrint blue( blueprint );
260  input_ss_ = blue.secstruct();
261  }
262  // set threshold
263  filter_value( tag->getOption<Real>( "threshold", 0 ) );
264 
265  // set threshold
266  contact_distance( tag->getOption<Real>( "dist", 5.5 ) );
267 
268  // set threshold
269  verbose_ = tag->getOption<bool>( "verbose", 1 );
270 }
271 
274 
276 InterlockingAromaFilterCreator::keyname() const { return "InterlockingAroma"; }
277 
278 
279 } // filters
280 } // fldsgn
281 } // protocols