Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ExtraScoreEvaluatorCreator.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/ExtraScoreEvaluatorCreator.hh
11 /// @brief Header for ExtraScoreEvaluatorCreator
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>
29 
31 
33 
36 
37 
38 // ObjexxFCL Headers
39 #include <ObjexxFCL/string.functions.hh>
40 
41 // Utility headers
42 #include <utility/pointer/ReferenceCount.hh>
43 #include <utility/vector1.hh>
44 
45 #include <utility/file/FileName.hh>
46 
47 #include <basic/options/option.hh>
48 #include <basic/Tracer.hh>
49 
50 
51 // due to template function
53 
54 
55 // option key includes
56 #include <basic/options/option_macros.hh>
57 #include <basic/options/keys/evaluation.OptionKeys.gen.hh>
58 #include <utility/vector0.hh>
59 
60 
61 #ifdef WIN32
63 #endif
64 
65 
66 static basic::Tracer tr("protocols.evalution.ExtraScoreEvaluatorCreator");
67 
68 namespace protocols {
69 namespace simple_filters {
70 
72 
74  using namespace basic::options;
75  if ( options_registered_ ) return;
76  options_registered_ = true;
77 
78  OPT( evaluation::extra_score );
79  OPT( evaluation::extra_score_column );
80  OPT( evaluation::extra_score_patch );
81  OPT( evaluation::extra_score_select );
82 
83 }
84 
86  using namespace core;
87  using namespace basic::options;
88  using namespace basic::options::OptionKeys;
89 
90 
91  if ( option[ OptionKeys::evaluation::extra_score ].user() ) {
92  using namespace core::scoring;
93  utility::vector1< std::string > const& extra_scores( option[ OptionKeys::evaluation::extra_score ]() );
94  utility::vector1< std::string > const& extra_score_names( option[ OptionKeys::evaluation::extra_score_column]() );
95  if ( extra_scores.size() != extra_score_names.size() ) {
96  utility_exit_with_message("-extra_score: you need to provide as much extra_score_names as extra_scores! ");
97  }
98  for ( Size ct = 1; ct <= extra_scores.size(); ct ++ ) {
99  std::string const& tag = extra_score_names[ ct ];
100  std::string patch( "NOPATCH" );
101  if ( option[ OptionKeys::evaluation::extra_score_patch ].user() ) {
102  if ( option[ OptionKeys::evaluation::extra_score_patch ]().size() != extra_scores.size() ) {
103  utility_exit_with_message("-extra_score: you need to provide as much extra_score_patch(es) as \
104  extra_scores! use NOPATCH as placeholder");
105  }
106  patch = option[ OptionKeys::evaluation::extra_score_patch ]()[ ct ];
107  }
108  ScoreFunctionOP scfxn( NULL );
109 
110  if ( patch != "NOPATCH" ) {
111  scfxn = ScoreFunctionFactory::create_score_function( extra_scores[ ct ], patch );
112  } else {
113  scfxn = ScoreFunctionFactory::create_score_function( extra_scores[ ct ] );
114  }
115 
116  std::string name( extra_scores[ ct ] );
117  if ( (name == "score0") ||
118  (name == "score2") ||
119  (name == "score3") ||
120  (name == "score5") ) {
122  } else {
124  }
125 
126  std::string select_string( "SELECT_ALL" );
127  if ( option[ OptionKeys::evaluation::extra_score_select ].user() ) {
128  if ( option[ OptionKeys::evaluation::extra_score_select ]().size() != extra_scores.size() ) {
129  utility_exit_with_message("-extra_score: you need to provide as much extra_score_patch(es) as \
130  extra_scores! use SELECT_ALL as placeholder");
131  }
132  select_string = option[ OptionKeys::evaluation::extra_score_select ]()[ ct ];
133  }
134  if ( select_string != "SELECT_ALL" ) {
135  std::ifstream is( select_string.c_str() );
136 
137  if (!is.good()) {
138  utility_exit_with_message( "[ERROR] Error opening RBSeg file '" + select_string + "'" );
139  }
140 
143  loops::SerializedLoopList loops = reader.read_pose_numbered_loops_file( is, select_string, false /*no strict checking */ );
144  loops::Loops core( loops );
145 
146  utility::vector1< Size> selection;
147  core.get_residues( selection );
148  eval.add_evaluation( new simple_filters::TruncatedScoreEvaluator( tag, selection, scfxn ) );
149  } else {
150  eval.add_evaluation( new ScoreEvaluator( tag, scfxn ) );
151  }
152  }
153  }
154 
155 
156 }
157 
159  return "ExtraScoreEvaluatorCreator";
160 }
161 
162 } //namespace
163 } //namespace