Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
rotamer_recovery.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 apps/performance_benchmark/scientific/rotamer_recovery.cc
11 /// @brief this determines the percent of rotamers correctly predictied during a repack
12 /// @author Matthew O'Meara (mattjomeara@gmail.com)
13 
14 
15 // Unit Headers
16 #include <protocols/jd2/JobDistributor.hh>
17 #include <protocols/rotamer_recovery/RotamerRecoveryMover.hh>
18 #include <protocols/rotamer_recovery/RotamerRecovery.hh>
19 #include <protocols/rotamer_recovery/RotamerRecoveryFactory.hh>
20 
21 
22 // Project Headers
23 #include <devel/init.hh>
24 #include <basic/options/keys/in.OptionKeys.gen.hh>
25 #include <basic/options/keys/packing.OptionKeys.gen.hh>
27 #include <basic/Tracer.hh>
28 #include <core/import_pose/import_pose.hh>
29 #include <core/pack/task/TaskFactory.hh>
30 #include <core/pack/task/operation/TaskOperations.hh>
31 #include <core/scoring/ScoreFunction.hh>
32 #include <core/scoring/ScoreFunctionFactory.hh>
33 
34 // Utility Headers
37 #include <utility/exit.hh>
38 #include <utility/vector0.hh>
39 #include <utility/vector1.hh>
40 
41 // c++ Headers
42 #include <fstream>
43 
44 using std::endl;
45 using std::ofstream;
46 using std::string;
47 using basic::Tracer;
48 using core::pose::PoseOP;
49 using core::import_pose::pose_from_pdb;
50 using core::pack::task::TaskFactory;
51 using core::pack::task::TaskFactoryOP;
52 using core::pack::task::operation::InitializeFromCommandline;
53 using core::pack::task::operation::ReadResfile;
54 using core::pack::task::operation::RestrictToRepacking;
55 using core::scoring::get_score_function;
56 using core::scoring::ScoreFunctionOP;
57 using protocols::rotamer_recovery::RotamerRecoveryOP;
58 using protocols::rotamer_recovery::RotamerRecoveryFactory;
59 using protocols::rotamer_recovery::RotamerRecoveryMover;
60 using protocols::rotamer_recovery::RotamerRecoveryMoverOP;
61 using protocols::jd2::JobDistributor;
63 
64 static Tracer TR("apps.benchmark.scientific.rotamer_recovery");
65 
68 OPT_1GRP_KEY( String, rotamer_recovery, reporter )
69 //OPT_2GRP_KEY( File, rotamer_recovery, native_vs_decoy )
70 //OPT_2GRP_KEY( File, out, rotamer_recovery, method )
71 OPT_2GRP_KEY( File, out, file, rotamer_recovery )
72 
73 void
75  using namespace basic::options;
76  using namespace basic::options::OptionKeys;
77  OPT( in::file::s );
78  OPT( in::file::l );
81  OPT( packing::use_input_sc );
82  OPT( packing::resfile );
83  NEW_OPT( rotamer_recovery::protocol, "Rotamer Recovery Protocol component.", "RRProtocolMinPack");
84  NEW_OPT( rotamer_recovery::comparer, "Rotamer Recovery Comparer component.", "RRComparerAutomorphicRMSD");
85  NEW_OPT( rotamer_recovery::reporter, "Rotamer Recovery Reporter component.", "RRReporterHuman");
86  // NEW_OPT( rotamer_recovery::native_vs_decoy, "Table of describing which native structures the decoys are modeling. The first column is native pdb filename and the second column is the decoy pdb filename.", "");
87  NEW_OPT( out::file::rotamer_recovery, "Output File Name for reporters that write their results to a file.", "");
88 
89 }
90 
91 int
92 main( int argc, char * argv [] )
93 {
94  try{
96 
97  devel::init(argc, argv);
98 
99  using namespace basic::options;
100  using namespace basic::options::OptionKeys;
101  using namespace basic::options::OptionKeys::out::file;
102  using namespace core::pack::task::operation;
103 
104  string const & protocol( option[ rotamer_recovery::protocol ].value() );
105  string const & reporter( option[ rotamer_recovery::reporter ].value() );
106  string const & output_fname( option[ out::file::rotamer_recovery ].value() );
107  string const & comparer( option[ rotamer_recovery::comparer ].value() );
108  ScoreFunctionOP scfxn( get_score_function() );
109  TaskFactoryOP task_factory( new TaskFactory );
110  task_factory->push_back( TaskOperationCOP( new InitializeFromCommandline ) );
111  if ( option.has(OptionKeys::packing::resfile) && option[OptionKeys::packing::resfile].user() ) {
112  task_factory->push_back( TaskOperationCOP( new ReadResfile ) );
113  }
114  task_factory->push_back( TaskOperationCOP( new RestrictToRepacking ) );
115 
116  RotamerRecoveryOP rotamer_recovery(
117  RotamerRecoveryFactory::get_instance()->get_rotamer_recovery(
118  protocol, comparer, reporter));
119 
120  RotamerRecoveryMoverOP rotamer_recovery_mover( new RotamerRecoveryMover(rotamer_recovery, scfxn, task_factory) );
121 
122 
123  try{
124  JobDistributor::get_instance()->go( rotamer_recovery_mover );
125 
126  rotamer_recovery_mover->show();
127 
128  // if requsted write output to disk
130  ofstream fout;
131  fout.open( output_fname.c_str(), std::ios::out );
132  if ( !fout.is_open() ) {
133  TR << "Unable to open output file '" << output_fname << "'." << endl;
134  utility_exit();
135  }
136  rotamer_recovery_mover->show( fout );
137  fout.close();
138  }
139  } catch (EXCN_Base & excn ) {
140  TR.Error << "Exception: " << endl;
141  excn.show( TR.Error );
142 
143  TR << "Exception: " << endl;
144  excn.show( TR ); //so its also seen in a >LOG file
145  }
146 
147  } catch ( utility::excn::EXCN_Base const & e ) {
148  std::cout << "caught exception " << e.msg() << std::endl;
149  return -1;
150  }
151 
152  return 0;
153 }
virtual std::string const msg() const
Definition: EXCN_Base.hh:70
void register_options()
std::string String
Definition: remodel.cc:69
vector0: std::vector with assert-checked bounds
void init(int argc, char *argv[])
Command line init() version.
Definition: init.cc:23
BooleanOptionKey const user("options:user")
Definition: OptionKeys.hh:40
BooleanOptionKey const rotamer_recovery("sequence_recovery::rotamer_recovery")
common derived classes for thrown exceptions
#define OPT_2GRP_KEY(type, grp1, grp2, key)
member1 value
Definition: Tag.cc:296
virtual void show(std::ostream &) const =0
static THREAD_LOCAL basic::Tracer TR("basic.options")
Program exit functions and macros.
Tracer IO system.
#define utility_exit()
Macro function wrappers for utility::exit.
Definition: exit.hh:41
TracerProxy Error
Definition: Tracer.hh:262
rule< Scanner, options_closure::context_t > options
Definition: Tag.cc:377
utility::options::OptionCollection option
OptionCollection global.
Definition: option.cc:45
list native
Definition: ContactMap.py:108
#define NEW_OPT(akey, help, adef)
ocstream cout(std::cout)
Wrapper around std::cout.
Definition: ocstream.hh:287
vector1: std::vector with 1-based indexing
base class for Exception system
Class for handling user debug/warnings/errors. Use instance of this class instead of 'std::cout' for ...
Definition: Tracer.hh:134
#define OPT_1GRP_KEY(type, grp, key)
#define OPT(akey)
static Tracer TR("apps.benchmark.scientific.rotamer_recovery")
int const silent
Named verbosity levels.
bool has(BooleanOptionKey const &key) const
Is there an option with a BooleanOptionKey?
int main(int argc, char *argv[])