Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LoopsExplicitDefiner.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/loops_definers/LoopsExplicitDefiner.cc
11 /// @brief A loops definer is creates a serialized loops list
12 /// @author Matthew O'Meara (mattjomear@gmail.com)
13 
14 // Unit Headers
16 #include <protocols/loops/Loop.hh>
17 
18 // Project Headers
19 #include <basic/Tracer.hh>
20 #include <core/pose/Pose.hh>
22 
23 
24 // Utility Headers
25 #include <utility/tag/Tag.hh>
26 #include <utility/vector0.hh>
27 
28 // Boost Headers
29 #include <boost/foreach.hpp>
30 
31 // C++ Headers
32 #include <string>
33 #include <utility/excn/Exceptions.hh>
34 #include <sstream>
35 
36 /// Macros are not properly caught and passed along by my #inclusion
37 /// cleanup script
38 #define foreach BOOST_FOREACH
39 
40 
41 
42 using std::string;
43 using std::endl;
44 using std::stringstream;
45 using core::Real;
46 using core::pose::Pose;
49 using utility::vector0;
50 using basic::Tracer;
51 
52 namespace protocols {
53 namespace loops {
54 namespace loops_definers {
55 
56 
57 static Tracer TR("protocols.loops.loops_definers.LoopsExplicitDefiner");
58 
59 
61  loop_list_()
62 {}
63 
65 
67  LoopsExplicitDefiner const & src
68 ) :
69  loop_list_(src.loop_list_)
70 {}
71 
72 /// @brief Create another loops definer of the type matching the most-derived
73 /// version of the class.
76 ) const {
77  return new LoopsExplicitDefiner(*this);
78 }
79 
82  TagPtr const tag,
83  string const & loops_name
84 ) {
85 
86  SerializedLoop loop;
87 
88  if(tag->hasOption("start")){
89  loop.start = tag->getOption<Size>("start");
90  } else {
91  stringstream err_msg;
92  err_msg
93  << "Tag " << tag->getName() << " with name "
94  << "'" << loops_name << "' does not have the expected 'start' field." << endl;
95  utility_exit_with_message(err_msg.str());
96  }
97 
98  if(tag->hasOption("stop")){
99  loop.stop = tag->getOption<Size>("stop");
100  } else {
101  stringstream err_msg;
102  err_msg
103  << "Tag " << tag->getName() << " with name "
104  << "'" << loops_name << "' does not have the expected 'stop' field." << endl;
105  utility_exit_with_message(err_msg.str());
106  }
107 
108  loop.cut = tag->getOption<Size>("cut", 0);
109  loop.skip_rate = tag->getOption<Real>("skip_rate", 0.0);
110  loop.extended = tag->getOption<bool>("extended", false);
111 
112  return loop;
113 }
114 
115 
116 /// @brief Used to parse an xml-like tag to load parameters and properties.
117 void
119  TagPtr const tag,
120  DataMap const &,
121  Pose const &
122 ) {
123 
124  if(!tag->hasOption("name")){
125  throw utility::excn::EXCN_RosettaScriptsOption(
126  "Unable to create unnamed LoopsDefiner (type: Loops)" );
127  }
128  string const loops_name(tag->getOption<string>("name"));
129 
130 
131  vector0< TagPtr >::const_iterator begin=tag->getTags().begin();
132  vector0< TagPtr >::const_iterator end=tag->getTags().end();
133 
134  for(; begin != end; ++begin){
135  TagPtr loop_tag= *begin;
136 
137  if(loop_tag->getName() != "loop"){
138  TR.Error
139  << "Please include only tags with name 'loop' "
140  << "as subtags of a 'Loops' tag" << endl
141  << "Tag with name '" << loop_tag->getName() << "' is invalid" << endl;
142  throw utility::excn::EXCN_RosettaScriptsOption("");
143  }
144 
145  SerializedLoop loop = parse_loop_tag(loop_tag, loops_name);
146  loop_list_.push_back(loop);
147  }
148 }
149 
152  Pose const &
153 ) {
154  return loop_list_;
155 }
156 
157 
158 } //namespace
159 } //namespace
160 } //namespace