Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HelixPairingFilter.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/HelixPairingFilter.cc
11 /// @brief filter structures by sheet topology
12 /// @detailed
13 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
14 
15 // Unit Headers
18 
19 // Package Headers
24 
25 // Project Headers
26 #include <core/types.hh>
27 #include <core/pose/Pose.hh>
28 
29 // Utility headers
30 #include <basic/Tracer.hh>
31 
32 // Parser headers
33 #include <utility/tag/Tag.hh>
34 
35 #include <utility/vector0.hh>
36 #include <utility/vector1.hh>
37 
38 #ifdef WIN32
40 #endif
41 
42 
43 //// C++ headers
44 static basic::Tracer TR("protocols.fldsgn.filters.HelixPairingFilter");
45 
46 namespace protocols {
47 namespace fldsgn {
48 namespace filters {
49 
50 // @brief default constructor
52  Filter( "HelixPairing" ),
53  secstruct_( "" ),
54  dist_cutoff_( 15.0 ),
55  bend_angle_( 20.0 ),
56  cross_angle_( 45.0 ),
57  align_angle_( 25.0 )
58 {}
59 
60 // @Brief constructor with arguments
62  Filter( "HelixPairing" ),
63  secstruct_( "" ),
64  dist_cutoff_( 15.0 ),
65  bend_angle_( 20.0 ),
66  cross_angle_( 45.0 ),
67  align_angle_( 25.0 ),
68  hpairset_( new HelixPairingSet( hpairs ) )
69 {}
70 
71 // @brief constructor with arguments
73  Filter( "HelixPairing" ),
74  secstruct_( "" ),
75  dist_cutoff_( 15.0 ),
76  bend_angle_( 20.0 ),
77  cross_angle_( 45.0 ),
78  align_angle_( 25.0 )
79 {
80  hpairset_ = new HelixPairingSet( hpairs );
81 }
82 
83 // @brief copy constructor
85  //utility::pointer::ReferenceCount(),
86  Super( rval ),
87  secstruct_( rval.secstruct_ ),
88  dist_cutoff_( rval.dist_cutoff_ ),
89  bend_angle_( rval.bend_angle_ ),
90  cross_angle_( rval.cross_angle_ ),
91  align_angle_( rval.align_angle_ ),
92  hpairset_( rval.hpairset_ )
93 {}
94 
95 // @brief set filtered sheet_topology by HelixPairings
97 {
98  hpairset_ = new HelixPairingSet( hpairs );
99 }
100 
101 // @brief set filtered sheet_topology by SrandPairingSetOP
103 {
104  hpairset_ = new HelixPairingSet( hpairs );
105 }
106 
107 /// @brief
109 {
110  secstruct_ = ss;
111 }
112 
113 /// @brief
115 HelixPairingFilter::report_sm( Pose const & pose ) const
116 {
117  return compute( pose );
118 }
119 
120 /// @brief
121 bool
122 HelixPairingFilter::apply( Pose const & pose ) const
123 {
124  using core::Vector;
130 
131 
132  HelixPairingSet hpairset( *hpairset_ );
134 
135  //
136  runtime_assert( ! helix_pairings.empty() );
137 
138  // set secondary structure
139  if( secstruct_ == "" ) {
140  Dssp dssp( pose );
141  secstruct_ = dssp.get_dssp_secstruct();
142  }
143  runtime_assert( secstruct_.length() == pose.total_residue() );
144 
145  // set SS_Info
146  SS_Info2_OP ss_info = new SS_Info2( pose, secstruct_ );
147  Helices const & helices( ss_info->helices() );
148 
149  // calc geometry of helixpairing
150  hpairset.calc_geometry( ss_info );
151 
152  // check conformation of helical pairings
153  bool filter( true );
154  for( HelixPairings::const_iterator it=helix_pairings.begin(), ite=helix_pairings.end(); it != ite; ++it ) {
155  HelixPairing const & hpair( **it );
156 
157  if( helices.size() < hpair.h1() ) {
158  TR << "Helix " << hpair.h1() << " does not exist ! " << std::endl;
159  return false;
160  }
161 
162  if( helices.size() < hpair.h2() ) {
163  TR << "Helix " << hpair.h2() << " does not exist ! " << std::endl;
164  return false;
165  }
166 
167  // bend check
168  if( bend_angle_ >= 0.0 ) {
169  if ( helices[ hpair.h1() ]->bend() > bend_angle_ ) {
170  TR << "Helix " << hpair.h1() << "is bend, angle=" << helices[ hpair.h1() ]->bend() << std::endl;
171  filter=false;
172  }
173  if ( helices[ hpair.h2() ]->bend() > bend_angle_ ) {
174  TR << "Helix bend " << hpair.h2() << " " << helices[ hpair.h2() ]->bend() << std::endl;
175  filter=false;
176  }
177  }
178 
179  //
180  if( hpair.dist() > dist_cutoff_ && dist_cutoff_ >= 0 ) filter = false;
181  if( hpair.cross_angle() > cross_angle_ && cross_angle_ >= 0 ) filter = false;
182 
183  if( hpair.align_angle() < 0 ) continue;
184  if( hpair.align_angle() > align_angle_ && align_angle_ >= 0 ) filter = false;
185 
186  if( filter == false ) break;
187  }
188 
189  TR << " Filter condition: " << std::endl;
190  TR << " bend ( intra helix ) <= " << bend_angle_ << std::endl;
191  TR << " dist <= " << dist_cutoff_ << std::endl;
192  TR << " cross <= " << cross_angle_ << std::endl;
193  TR << " align <= " << align_angle_ << std::endl;
194 
195  TR << hpairset;
196 
197  if( filter ) {
198  TR << " Filter success ! " << std::endl;
199  } else {
200  TR << " Filter failed ! " << std::endl;
201  }
202 
203  return filter;
204 
205 }
206 
207 // @brief returns true if the given pose passes the filter, false otherwise.
209 HelixPairingFilter::compute( Pose const & pose ) const
210 {
211  using core::Vector;
217 
218  HelixPairingSet hpairset( *hpairset_ );
220 
221  //
222  runtime_assert( ! helix_pairings.empty() );
223 
224  // set secondary structure
225  if( secstruct_ == "" ) {
226  Dssp dssp( pose );
227  secstruct_ = dssp.get_dssp_secstruct();
228  }
229  runtime_assert( secstruct_.length() == pose.total_residue() );
230 
231  // set SS_Info
232  SS_Info2_OP ss_info = new SS_Info2( pose, secstruct_ );
233  // Helices const & helices( ss_info->helices() ); // Unused variable causes warning.
234 
235  // calc geometry of helixpairing
236  hpairset.calc_geometry( ss_info );
237 
238  Real value( 0.0 );
239  if ( output_type_ == "dist" ) {
240  value = hpairset.helix_pairing( output_id_ )->dist();
241  } else if ( output_type_ == "cross" ) {
242  value = hpairset.helix_pairing( output_id_ )->cross_angle();
243  } else if ( output_type_ == "align" ) {
244  value = hpairset.helix_pairing( output_id_ )->align_angle();
245  } else {
246  TR << "Invalid type for output_type, choose either dist or cross or align. " << std::endl;
247  runtime_assert( false );
248  }
249 
250  return value;
251 
252 }
253 
254 /// @brief parse xml
255 void
257  TagPtr const tag,
258  DataMap &,
259  Filters_map const &,
260  Movers_map const &,
261  Pose const & )
262 {
264 
265  // set filtered helix_pairings
266  String const hpairs = tag->getOption<String>( "helix_pairings", "" );
267  if( hpairs != "" ) helix_pairings( hpairs );
268 
269  // Blueprint is for giving secondary structure information, otherwise dssp will run for ss definition
270  // HHPAIR line is read for the topology of helix pairings
271  String const blueprint = tag->getOption<String>( "blueprint", "" );
272  if( blueprint != "" ) {
273  BluePrint blue( blueprint );
274  secstruct_ = blue.secstruct();
275 
276  if( ! blue.helix_pairings().empty() ) {
277  if( hpairs == "" ) {
278  helix_pairings( blue.helix_pairings() );
279  } else {
280  TR << " HHPAIR in blueprint will be igonared " << std::endl;
281  }
282  }
283  }
284 
285  if( hpairset_->helix_pairings().empty() ){
286  TR.Error << "Error!, Option of helix_pairings is empty." << std::endl;
287  runtime_assert( false );
288  }
289 
290  dist_cutoff_ = tag->getOption<Real>( "dist", 15 );
291  bend_angle_ = tag->getOption<Real>( "bend", 20 );
292  cross_angle_ = tag->getOption<Real>( "cross", 45 );
293  align_angle_ = tag->getOption<Real>( "align", 25 );
294 
295  output_id_ = tag->getOption<Size>( "output_id", 1 );
296  output_type_ = tag->getOption<String>( "output_type", "dist" );
297 
298  if( output_type_ != "dist" && output_type_ != "cross" && output_type_ != "align" ) {
299  TR << "Invalid type for output_type, choose among dist or cross or align. " << std::endl;
300  } else {
301  TR << "HelixPairing " << *hpairset_->helix_pairing( output_id_ ) << ", "
302  << output_type_ << " is used for output value. " << std::endl;
303  }
304 
305 }
306 
309 
311 HelixPairingFilterCreator::keyname() const { return "HelixPairing"; }
312 
313 } // filters
314 } // fldsgn
315 } // protocols