Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SecondaryStructureFilter.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/SecondaryStructureFilter.cc
11 /// @brief filter structures by sheet topology
12 /// @detailed
13 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
14 
15 // Unit Headers
18 
19 // Project Headers
21 #include <core/types.hh>
22 #include <core/pose/Pose.hh>
24 // AUTO-REMOVED #include <protocols/fldsgn/topology/HSSTriplet.hh> // REQUIRED FOR WINDOWS
25 
26 // Utility headers
27 #include <basic/Tracer.hh>
28 
29 // Parser headers
31 #include <utility/tag/Tag.hh>
32 
33 #include <utility/vector0.hh>
34 #include <utility/vector1.hh>
35 
36 
37 //// C++ headers
38 static basic::Tracer tr("protocols.fldsgn.filters.SecondaryStructureFilter");
39 
40 namespace protocols {
41 namespace fldsgn {
42 namespace filters {
43 
44 // @brief default constructor
46  Filter( "SecondaryStructure" ),
47  filtered_ss_( "" ),
48  use_abego_( false )
49 {}
50 
51 
52 // @brief constructor with arguments
54  Filter( "SecondaryStructure" ),
55  filtered_ss_( ss ),
56  use_abego_( false )
57 {}
58 
59 // @brief copy constructor
61  //utility::pointer::ReferenceCount(),
62  Super( rval ),
63  filtered_ss_( rval.filtered_ss_ ),
64  filtered_abego_( rval.filtered_abego_ ),
65  use_abego_( rval.use_abego_ )
66 {}
67 
68 // @brief set filtered secondary structure
70 {
71  filtered_ss_ = s;
72 }
73 
74 // @brief set filtered secondary structure
76 {
77  filtered_abego_.clear();
78  for( Size ii=1; s.length(); ++ii ) {
79  filtered_abego_.push_back( s.substr( ii-1, 1 ) );
80  }
81  use_abego_ = true;
82 }
83 
84 // @brief returns true if the given pose passes the filter, false otherwise.
85 // In this case, the test is whether the give pose is the topology we want.
86 bool SecondaryStructureFilter::apply( Pose const & pose ) const
87 {
88 
89  if( pose.total_residue() != filtered_ss_.length() ) {
90  utility_exit_with_message("Length of input ss is not same as total residue of pose.");
91  }
92  if( filtered_abego_.size() >= 1 && pose.total_residue() != filtered_abego_.size() ) {
93  utility_exit_with_message("Length of input abego is not same as total residue of pose.");
94  }
95 
96  core::util::ABEGOManager abego_manager;
97 
98  for( Size i=1; i<=pose.total_residue(); i++ ){
99  String sec = filtered_ss_.substr( i-1, 1 );
100  if( *sec.c_str() == 'D' ){
101  continue;
102  }else{
103  if( *sec.c_str() != pose.secstruct( i ) ){
104  tr << "SS filter fail: current/filterd = "
105  << pose.secstruct( i ) << '/' << sec << " at position " << i << std::endl;
106  return false;
107  }
108  }
109 
110  if( filtered_abego_.size() >= 1 && use_abego_ ) {
111  String abego( filtered_abego_[ i ] );
112  bool flag( false );
113  for( Size j=1; j<=abego.size(); j++ ) {
114  if( abego_manager.check_rama( *abego.substr( j-1, 1 ).c_str(), pose.phi( i ), pose.psi( i ), pose.omega( i ) )) {
115  flag = true;
116  }
117  }
118  if( !flag ) {
119  tr << "Abego filter fail current(phi,psi,omega)/filtered = "
120  << pose.phi( i ) << "," << pose.psi( i ) << "," << pose.omega( i ) << "/" << abego
121  << " at position " << i << std::endl;
122  return false;
123  }
124  }
125  }
126 
127  tr << "Successfully " << filtered_ss_ << " was filtered. " << std::endl;
128  if( filtered_abego_.size() >= 1 && use_abego_ ) {
129  tr << "Successfully " << abego_manager.get_abego_string( filtered_abego_ ) << " was filtred. " << std::endl;
130  }
131 
132  return true;
133 
134 } // apply_filter
135 
136 /// @brief parse xml
137 void
139  TagPtr const tag,
140  DataMap &,
141  Filters_map const &,
142  Movers_map const &,
143  Pose const & )
144 {
146 
147  filtered_ss_ = tag->getOption<String>( "ss", "" );
148 
149  String abego( tag->getOption<String>( "abego", "" ) );
150  filtered_abego_.clear();
151  for( Size ii=1; abego.length(); ++ii ) {
152  filtered_abego_.push_back( abego.substr( ii-1, 1 ) );
153  }
154  if( filtered_abego_.size() >= 1 ) {
155  use_abego_ = true;
156  }
157 
158  // use blueprint as input
159  String blueprint = tag->getOption<String>( "blueprint", "" );
160  if( blueprint != "" ) {
161 
162  if( filtered_ss_ != "" || filtered_abego_.size() > 1 ) {
163  tr << "ss and abego definition in xml will be ignored, and blueprint info is used. " << std::endl;
164  filtered_ss_ = "";
165  filtered_abego_.clear();
166  }
167 
168  BluePrint blue( blueprint );
169  filtered_ss_ = blue.secstruct();
170  filtered_abego_ = blue.abego();
171  use_abego_ = tag->getOption<bool>( "use_abego", 0 );
172  }
173 
174  if( filtered_ss_ == "" ){
175  tr.Error << "Error!, option of topology is empty." << std::endl;
176  runtime_assert( false );
177  }
178  tr << filtered_ss_ << " is filtred." << std::endl;
179 
180  core::util::ABEGOManager abego_manager;
181  if( filtered_abego_.size() >= 1 && use_abego_ ) {
182  tr << abego_manager.get_abego_string( filtered_abego_ ) << " is filtred " << std::endl;
183  }
184 }
185 
188 
190 SecondaryStructureFilterCreator::keyname() const { return "SecondaryStructure"; }
191 
192 
193 } // filters
194 } // fldsgn
195 } // protocols