Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ChiWellRmsdEvaluatorCreator.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/ChiWellRmsdEvaluatorCreator.hh
11 /// @brief Header for ChiWellRmsdEvaluatorCreator
12 /// @author Matthew O'Meara
13 
14 // Unit Headers
16 
17 // Package Headers
19 
20 // Package Headers
24 
25 #include <protocols/loops/Loop.hh>
26 #include <protocols/loops/Loops.hh>
28 
30 #include <core/pose/Pose.hh>
31 
32 // ObjexxFCL Headers
33 #include <ObjexxFCL/string.functions.hh>
34 
35 // Utility headers
36 #include <utility/pointer/ReferenceCount.hh>
37 #include <utility/vector1.hh>
38 #include <utility/string_util.hh>
39 #include <utility/file/FileName.hh>
40 
41 #include <basic/options/option.hh>
42 #include <basic/Tracer.hh>
43 
44 // due to template function
46 
47 
48 // option key includes
49 #include <basic/options/option_macros.hh>
50 #include <basic/options/keys/evaluation.OptionKeys.gen.hh>
51 #include <basic/options/keys/in.OptionKeys.gen.hh>
53 #include <utility/vector0.hh>
54 
55 
56 #ifdef WIN32
58 #endif
59 
60 
61 static basic::Tracer tr("protocols.evaluation.ChiWellRmsdEvaluatorCreator");
62 
63 namespace protocols {
64 namespace simple_filters {
65 
67 
69  using namespace core;
70  using namespace basic::options;
71  using namespace basic::options::OptionKeys;
72  tr.Info << "Evaluation Creator active ... " << std::endl;
73  if ( option[ OptionKeys::evaluation::chirmsd ].user() ) {
74 
75  core::pose::PoseOP native_pose = NULL;
76  if ( option[ in::file::native ].user() ) {
77  native_pose = new core::pose::Pose;
78  core::import_pose::pose_from_pdb( *native_pose, option[ in::file::native ]() );
79  }
80 
81  typedef utility::vector1< std::string > RmsdVector;
82  RmsdVector const& rmsd( option[ OptionKeys::evaluation::chirmsd ]() );
83 
84  //the ultimate in RMSD technology:
85  //you can have any number of tripletts:
86  // each triplett contains the
87  // target: file or special tags: NATIVE (use in:file:native ) IRMS (use structure in Job object)
88  /// columnname: XXX creates: rms_XXX gdtmm_XXX
89  /// selection: file or special tag: FULL
90  /// modifier: EXCLUDE ( take the inverse of the selection )
91  /// INLINE r1 r2 r3 ... rm END_INLINE -- select residues r1, r2, r3, ..., rm
92  for ( RmsdVector::const_iterator it=rmsd.begin(); it!=rmsd.end(); ++it ) {
93  core::pose::PoseOP target_pose = NULL;
94  std::string fname( *it );
95  std::string column;
96  std::string selection_file;
97  bool invert( false );
98  core::Size nchi_max( 4 );
99  core::Real sasa_max( 10000.0 );
100  ++it;
101  while ( it != rmsd.end() && (*it).find('=')!=std::string::npos ) {
102  Size pos( it->find('=') );
103  std::string key=it->substr(0,pos);
104  std::string value=it->substr(pos+1);
105  if ( key=="nchi") {
106  nchi_max=utility::string2int( value );
107  } else if ( key =="sasa" ) {
108  sasa_max=utility::string2float( value );
109  } else {
110  utility_exit_with_message( "key not recognized: "+key+" possible keys: { heavy, sasa }" );
111  }
112  tr.Info << "detected option: " << key << " : " << value << std::endl;
113  ++it;
114  }
115 
116  if ( it != rmsd.end() ) {
117  column = *it;
118  } else {
119  utility_exit_with_message(
120  "need to specify tripletts <target> [key/value pairs] <column> <selection/FULL> with option -evaluation:rmsd last read: "+fname );
121  }
122  ++it;
123  if ( it != rmsd.end() ) {
124  selection_file = *it;
125  } else {
126  utility_exit_with_message(
127  "need to specify tripletts <target> <column> <selection/FULL> with option -evaluation:rmsd last read: "+column );
128  }
129  if ( fname == "NATIVE" ) target_pose = native_pose;
130  else if ( fname != "IRMS" ) {
131  target_pose = new pose::Pose;
132  core::import_pose::pose_from_pdb( *target_pose, fname );
133  }
134 
135  if ( selection_file == "EXCLUDE" ) {
136  invert = true;
137  ++it;
138  if ( it != rmsd.end() ) {
139  selection_file = *it; //read next tag
140  } else {
141  utility_exit_with_message(
142  "need to specify a <selection/FULL> after 'EXCLUDE' with option -evaluation:rmsd last read: "+column );
143  }
144  }
145  loops::Loops loops;
146  utility::vector1< Size> selection; //figure out selection
147  if ( selection_file == "INLINE" ) {
148  std::string next_tag( "" );
149  ++it;
150  if ( it != rmsd.end() ) {
151  next_tag = *it;
152  } else {
153  utility_exit_with_message(
154  "need to find END_INLINE after INLINE in option -evaluation:rmsd last read: "+column );
155  } //error condition
156  while( next_tag != "END_INLINE" ) {
157  selection.push_back( utility::string2int( next_tag ) );
158  ++it;
159  if ( it != rmsd.end() ) {
160  next_tag = *it;
161  } else {
162  utility_exit_with_message(
163  "need to find END_INLINE after INLINE in option -evaluation:rmsd last read: "+column );
164  } //error condition
165  }
166  } else if ( selection_file != "FULL" ) {
167  std::ifstream is( selection_file.c_str() );
168 
169  if (!is.good()) {
170  utility_exit_with_message( "[ERROR] Error opening RBSeg file '" + selection_file + "'" );
171  }
172 
175  loops::SerializedLoopList loops = reader.read_pose_numbered_loops_file( is, selection_file, false /*no strict checking */ );
176  loops::Loops core( loops );
177  core.get_residues( selection );
178  }
179  if ( invert ) {
180  utility::vector1< Size > inverted_selection;
181  for ( Size i = 1; i<=target_pose->total_residue(); ++i) {
182  bool found( false );
183  for ( Size j = 1; j<=selection.size() && !found; ++j ) {
184  if ( selection[ j ]==i ) {
185  found = true;
186  }
187  }
188  if ( !found) inverted_selection.push_back( i );
189  }
190  selection = inverted_selection;
191  }
192  if ( selection_file != "FULL" ) {
193  eval.add_evaluation( new simple_filters::ChiWellRmsdEvaluator( target_pose, nchi_max, sasa_max, selection, column) );
194  } else {
195  eval.add_evaluation( new simple_filters::ChiWellRmsdEvaluator( target_pose, nchi_max, sasa_max, column ) );
196  }
197  } // iterate over tripletts in option -rmsd
198  } // option -rmsd
199 }
200 
202  return "ChiWellRmsdEvaluatorCreator";
203 }
204 
205 } //namespace
206 } //namespace