Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LoopsFileFallbackConfiguration.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/loops/LoopsFileFallbackConfiguration.cc
11 /// @author Brian D. Weitzner brian.weitzner@gmail.com
12 
13 // Unit Headers
16 
17 
18 // Platform Headers
19 #include <core/types.hh>
20 #include <utility/vector1.hh>
21 
22 // basic headers
23 #include <basic/resource_manager/ResourceOptions.hh>
24 #include <basic/options/option.hh>
25 #include <basic/options/keys/loops.OptionKeys.gen.hh>
26 
27 // numeric headers
28 #include <numeric/random/random.hh>
29 
30 //utility headers
31 #include <utility/excn/Exceptions.hh>
32 #include <utility/file/FileName.hh>
33 #include <utility/file/PathName.hh>
34 
35 //C++ Headers
36 #include <string>
37 #include <map>
38 
39 
40 namespace protocols {
41 namespace loops {
42 
43 using basic::resource_manager::LoaderType;
44 using basic::resource_manager::LocatorID;
45 using basic::resource_manager::LocatorTag;
46 using basic::resource_manager::ResourceDescription;
47 using basic::resource_manager::ResourceTag;
48 using basic::resource_manager::ResourceOptionsTag;
49 
50 static numeric::random::RandomGenerator RG(1337);
51 
52 
54 {}
55 
56 bool
58 {
59  return basic::options::option[ basic::options::OptionKeys::loops::loop_file ].user();
60 }
61 
62 basic::resource_manager::LoaderType
64 {
65  return "LoopsFile";
66 }
67 
68 basic::resource_manager::LocatorID
70 {
72 }
73 
74 basic::resource_manager::ResourceOptionsOP
76 {
77  // use the default loops file options.
78  return 0;
79 }
80 
83 {
84  return "The LoopsFileFallbackConfiguration requires that the flag '-loops:loop_file' be set on the command line.";
85 }
86 
87 basic::resource_manager::LocatorID
89 {
90  // the next line uses value_or to avoid a call to std::exit in the options class. I can test things that throw exceptions. Just sayin'.
91  utility::vector1< std::string > loops_files = basic::options::option[ basic::options::OptionKeys::loops::loop_file ].value_or( utility::vector1< std::string >() );
92  if ( ! loops_files.size() )
93  {
94  throw utility::excn::EXCN_Msg_Exception("The fallback LoopsFile resource option has no loops files associated with it! Was the option omitted from the command line?");
95  }
96  core::Size const which_loops_file( loops_files.size() == 1 ? 1 : core::Size( RG.random_range(1,( loops_files.size() ))));
97  return loops_files[ which_loops_file ];
98 }
99 
100 basic::resource_manager::FallbackConfigurationOP
102 {
104 }
105 
108 {
109  return "LoopsFile";
110 }
111 
112 } // namespace loops
113 } // namespace protocols