Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HSSTripletFilter.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/HSSTripletFilter.cc
11 /// @brief filter structures by hsstriplets angle and distance
12 /// @detailed
13 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
14 
15 // Unit Headers
18 
19 // Package Headers
25 
26 // Project Headers
27 #include <core/types.hh>
28 #include <core/pose/Pose.hh>
29 
30 // Utility headers
31 #include <basic/Tracer.hh>
32 
33 // Parser headers
34 #include <utility/tag/Tag.hh>
35 
36 #include <utility/vector0.hh>
37 #include <utility/vector1.hh>
38 
39 //// C++ headers
40 static basic::Tracer TR("protocols.fldsgn.filters.HSSTripletFilter");
41 
42 namespace protocols {
43 namespace fldsgn {
44 namespace filters {
45 
46 // @Brief default constructor
48  Filter( "HSSTriplet" ),
49  hss3set_( new HSSTripletSet ),
50  secstruct_( "" ),
51  filter_min_dist_( 7.5 ),
52  filter_max_dist_( 13.0 ),
53  filter_min_angle_( -12.5 ),
54  filter_max_angle_( 90.0 ),
55  output_id_( 1 ),
56  output_type_( "dist" ),
57  output_value_( -990.0 )
58 {}
59 
60 // @brief constructor with arguments
62  Filter( "HSSTriplet" ),
63  hss3set_( new HSSTripletSet( hss3s ) ),
64  secstruct_( "" ),
65  filter_min_dist_( 7.5 ),
66  filter_max_dist_( 13.0 ),
67  filter_min_angle_( -12.5 ),
68  filter_max_angle_( 90.0 ),
69  output_id_( 1 ),
70  output_type_( "dist" ),
71  output_value_( -990.0 )
72 {}
73 
74 // @brief constructor with arguments
76  Filter( "HSSTriplet" ),
77  hss3set_( new HSSTripletSet( hss3s ) ),
78  secstruct_( "" ),
79  filter_min_dist_( 7.5 ),
80  filter_max_dist_( 13.0 ),
81  filter_min_angle_( -2.5 ),
82  filter_max_angle_( 90.0 ),
83  output_id_( 1 ),
84  output_type_( "dist" ),
85  output_value_( -990.0 )
86 {}
87 
88 // @brief copy constructor
90  //utility::pointer::ReferenceCount(),
91  Super( rval ),
92  hss3set_( rval.hss3set_ ),
93  secstruct_( rval.secstruct_ ),
94  filter_min_dist_( rval.filter_min_dist_ ),
95  filter_max_dist_( rval.filter_max_dist_ ),
96  filter_min_angle_( rval.filter_min_angle_ ),
97  filter_max_angle_( rval.filter_max_angle_ ),
98  output_id_( rval.output_id_ ),
99  output_type_( rval.output_type_ ),
100  output_value_( rval.output_value_ )
101 {}
102 
103 // @brief set filtered HSSTriplets
105 {
106  hss3set_->add_hsstriplets( hss3s );
107 }
108 
109 // @brief set secondary structure
111 {
112  secstruct_ = ss;
113 }
114 
115 // @brief minimum distance for filtering
116 void
118 {
119  filter_min_dist_ = r;
120 }
121 
122 /// @brief maximum distance for filtering
123 void
125 {
126  filter_max_dist_ = r;
127 }
128 
129 /// @brief miniimum angle for filtering
130 void
132 {
133  filter_min_angle_ = r;
134 }
135 
136 /// @brief maximum angle for filtering
137 void
139 {
140  filter_max_angle_ = r;
141 }
142 
143 /// @brief maximum angle for filtering
144 void
146 {
147  output_id_ = i;
148 }
149 
150 /// @brief
151 void
153 {
154  output_type_ = s;
155 }
156 
157 /// @brief
159 HSSTripletFilter::report_sm( Pose const & pose ) const
160 {
161  return compute( pose );
162 }
163 
164 // @brief returns true if the given pose passes the filter, false otherwise.
165 bool
166 HSSTripletFilter::apply( Pose const & pose ) const
167 {
168  using core::Vector;
178 
179  // set secondary structure
180  if( secstruct_ == "" ) {
181  Dssp dssp( pose );
182  secstruct_ = dssp.get_dssp_secstruct();
183  }
184  runtime_assert( secstruct_.length() == pose.total_residue() );
185 
186  // set SS_Info
187  SS_Info2_OP ss_info = new SS_Info2( pose, secstruct_ );
188  Helices const & helices( ss_info->helices() );
189  Strands const & strands( ss_info->strands() );
190 
191  // check conformation hsstriplets
192  bool filter( true );
193  Size current_id( 0 );
194  for( HSSTriplets::const_iterator
195  it=hss3set_->hss_triplets().begin(), ite=hss3set_->hss_triplets().end(); it != ite; ++it ) {
196 
197  current_id ++;
198  HSSTripletOP const & hssop( *it );
199 
200  if( ! helices.size() >= hssop->helix() || helices[ hssop->helix() ]->length() < 5 ) {
201  TR << "Helix " << hssop->helix() << " dones not exist, or is too short. " << std::endl;
202  return false;
203  }
204  if( ! strands.size() >= hssop->strand1() || strands[ hssop->strand1() ]->length() < 2 ) {
205  TR << "Strand1 " << hssop->strand1() << " dones not exist, or is too short. " << std::endl;
206  return false;
207  }
208  if( ! strands.size() >= hssop->strand2() || strands[ hssop->strand2() ]->length() < 2 ) {
209  TR << "Strand2 " << hssop->strand2() << " dones not exist, or is too short. " << std::endl;
210  return false;
211  }
212 
213  TR << *hssop << " ";
214  hssop->calc_geometry( ss_info );
215 
216  TR << "hsheet_dist=" << hssop->hsheet_dist() << ", hs_angle=" << hssop->hs_angle()
217  << ", hs_dist1=" << hssop->hs1_dist() << ", hs_dist2=" << hssop->hs2_dist() << std::endl;
218 
219  if( hssop->hsheet_dist() < filter_min_dist_ || hssop->hsheet_dist() > filter_max_dist_ ) {
220  filter = false;
221  }
222  if( hssop->hs_angle() < filter_min_angle_ || hssop->hs_angle() > filter_max_angle_ ) {
223  filter = false;
224  }
225 
226  if( output_id_ == current_id ) {
227  if ( output_type_ == "dist" ) {
228  output_value_ = hssop->hsheet_dist();
229  } else if ( output_type_ == "angle" ) {
230  output_value_ = hssop->hs_angle();
231  }
232  }
233 
234  }
235 
236  if( filter ) {
237  TR << " Filter success ! " << std::endl;
238  } else {
239  TR << " Filter failed ! " << std::endl;
240  }
241 
242  return filter;
243 
244 } // apply_filter
245 
246 // @brief returns computed value
248 HSSTripletFilter::compute( Pose const & pose ) const
249 {
250  apply( pose );
251  return output_value_;
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 hss3s = tag->getOption<String>( "hsstriplets", "" );
267  if( hss3s != "" ) {
268  HSSTripletSet hss3set( hss3s );
269  add_hsstriplets( hss3set.hss_triplets() );
270  } else {
271  TR << "[ERROR] no input of hsstriplets in xml " << std::endl;
272  runtime_assert( false );
273  }
274 
275  // secondary strucuture info
276  String const blueprint = tag->getOption<String>( "blueprint", "" );
277  if( blueprint != "" ) {
278  BluePrint blue( blueprint );
279  secstruct_ = blue.secstruct();
280  }
281 
282  filter_min_dist_ = tag->getOption<Real>( "min_dist", 7.5 );
283  filter_max_dist_ = tag->getOption<Real>( "max_dist", 13.0);
284  filter_min_angle_ = tag->getOption<Real>( "min_angle", -12.5 );
285  filter_max_angle_ = tag->getOption<Real>( "max_angle", 90.0 );
286 
287  output_id_ = tag->getOption<Size>( "output_id", 1 );
288  output_type_ = tag->getOption<String>( "output_type", "dist" );
289 
290  if( output_type_ != "dist" && output_type_ != "angle" ) {
291 
292  TR << "Invalid type of output_type, choose either dist or angle. " << std::endl;
293 
294  } else {
295 
296  if( output_id_ > hss3set_->hss_triplets().size() ) {
297  TR << "[ERROR] The value of output_id is more than the number of input hsstriplets " << std::endl;
298  runtime_assert( false );
299  }
300 
301  TR << "HSSTriplet " << hss3set_->hss_triplet( output_id_ ) << ", "
302  << output_type_ << " is used for output value. " << std::endl;
303  }
304 
305 }
306 
309 
311 HSSTripletFilterCreator::keyname() const { return "HSSTriplet"; }
312 
313 } // filters
314 } // fldsgn
315 } // protocols