Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VallLibrarian.hh
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 core/fragment/picking_old/vall/VallLibrarian.hh
11 /// @brief Librarian that picks fragments from the Vall
12 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
13 
14 #ifndef INCLUDED_core_fragment_picking_old_vall_VallLibrarian_hh
15 #define INCLUDED_core_fragment_picking_old_vall_VallLibrarian_hh
16 
17 // AUTO-REMOVED #include <time.h>
18 
19 // unit headers
21 
22 // type headers
23 #include <core/types.hh>
24 
25 // package headers
29 // AUTO-REMOVED #include <core/fragment/picking_old/vall/util.hh>
34 
35 // project headers
36 #include <basic/Tracer.hh>
37 
38 // utility headers
39 #include <utility/pointer/owning_ptr.hh>
40 // AUTO-REMOVED #include <utility/vector1.hh>
41 
42 // C++ headers
43 #include <functional>
44 
45 #include <utility/vector1.hh>
46 
47 #ifdef WIN32
48  #include <ctime>
49 #endif
50 
51 
52 namespace core {
53 namespace fragment {
54 namespace picking_old {
55 namespace vall {
56 
57 
58 /// @brief Librarian that picks fragments from the Vall
59 class VallLibrarian : public core::fragment::picking_old::concepts::Librarian< scores::VallFragmentScore, eval::VallFragmentEval, gen::VallFragmentGen, VallLibrary > {
60 
61 
62 private: // typedefs
63 
64 
66 
67 
68 public: // typedefs
69 
70 
71  typedef core::Size Size;
72 
76 
79 
80 
81 public: // concept typedefs
82 
83 
95 
98 
99 
100 public: // concept translation typedefs
101 
102 
107  typedef Bookmarks Scores;
110 
111 
112 protected: // concept translation typedefs
113 
114 
121 
122 
123 public: // construct/destruct
124 
125 
126  /// @brief default constructor
127  VallLibrarian();
128 
129 
130  /// @brief default destructor
131  virtual
132  ~VallLibrarian();
133 
134 
135 private: // disallow copy
136 
137 
138  /// @brief disallow copy constructor
139  // NOTE: If implementing copy in the future, remember to clone OPs.
140  VallLibrarian( VallLibrarian const & rval );
141 
142 
143  /// @brief disallow copy assignment
144  // NOTE: If implementing copy in the future, remember to clone OPs.
145  VallLibrarian & operator =( VallLibrarian const & rval );
146 
147 
148 public: // accessors
149 
150 
151  /// @brief preallocate scores container prior to catalog() to attempt
152  /// speedup?, default true
153  inline
154  bool preallocate() const {
155  return preallocate_;
156  }
157 
158 
159 public: // mutators
160 
161 
162  /// @brief set flag to preallocate scores container prior to catalog() to
163  /// attempt speedup
164  inline
165  void preallocate( bool const flag ) {
166  preallocate_ = flag;
167  }
168 
169 
170 public: // generator management
171 
172 
173  /// @brief add a fragment generator (aka extent generator)
174  inline
175  void add_fragment_gen( VallFragmentGenCOP const & gen ) {
176  Super::add_extent_gen( gen );
177  }
178 
179 
180  /// @brief clear list of generators
181  inline
184  }
185 
186 
187  /// @brief the number of currently defined fragment generators
188  inline
190  return Super::extent_gen().size();
191  }
192 
193 
194 public: // evaluator management
195 
196 
197  /// @brief add a fragment evaluator (aka extent evaluator)
198  inline
200  Super::add_extent_eval( eval );
201  }
202 
203 
204  /// @brief clear list of evaluators
205  inline
208  }
209 
210 
211  /// @brief the number of currently defined fragment evaluators
212  inline
214  return Super::extent_eval().size();
215  }
216 
217 
218 public: // library operations
219 
220 
221  /// @brief create sorted list corresponding to fragments in Library
222  /// @details uses Score's '<' for evaluation
223  /// @return true if creation successful, false otherwise (e.g. no VallFragmentEval or VallFragmentGen found)
224  bool catalog( VallLibrary const & library ) {
225  return catalog( library, std::less< VallFragmentScore >() );
226  }
227 
228 
229  /// @brief create sorted list corresponding to fragments in Library
230  /// @tparam LessThan predicate <tt> Pr( left, right ) </tt> evaluating <tt> left < right <tt> for Scores (aka Bookmarks)
231  /// @return true if creation successful, false otherwise (e.g. no VallFragmentEval or VallFragmentGen found)
232  template< typename LessThan >
233  bool catalog( VallLibrary const & library, LessThan const & lt ) {
234  pre_catalog_ops( library );
235 
236  TR_.Debug << "Cataloging " << library.size() << " residues in fragment library..." << std::endl;
237 
238  time_t time_start = time( NULL );
239  bool const status = Super::catalog( library, lt );
240  time_t time_end = time( NULL );
241 
242  TR_.Debug << "... done. " << scores().size() << " scores filed. Time elapsed: " << ( time_end - time_start ) << " seconds." << std::endl;
243 
244  post_catalog_ops( library );
245 
246  return status;
247  }
248 
249 
250  /// @brief number of scores currently filed
251  inline
252  Size n_scores() const {
253  return scores().size();
254  }
255 
256 
257 public: // fragment extraction
258 
259 
260  /// @brief get top 'N' fragments from prior catalog()
261  /// @param n The number of fragments to get.
262  /// @param srfd_type The BBTorsionSRFD type to use.
264  Size const n,
265  BBTorsionSRFD const & srfd_type = BBTorsionSRFD()
266  ) const;
267 
268 
269  /// @brief get fragments from prior catalog() [from, to]
270  /// @param from index of the first fragment in the list, indexing starts from '1'
271  /// @param to index of the last fragment in the list (inclusive)
272  /// @param srfd_type The BBTorsionSRFD type to use.
273  /// @return filled FragDataList if sort() was called successfully, otherwise empty FragDataList
275  Size from,
276  Size to,
277  BBTorsionSRFD const & srfd_type = BBTorsionSRFD()
278  ) const;
279 
280 
281 public: // concept translation
282 
283 
284  /// @brief return scores container
285  inline
286  Scores const & scores() const {
287  return Super::bookmarks();
288  }
289 
290 
291  /// @brief return scores container
292  inline
294  return Super::bookmarks();
295  }
296 
297 
298 private: // additional catalog methods
299 
300 
301  /// @brief this function runs before main routine in catalog() starts
302  void pre_catalog_ops( VallLibrary const & library );
303 
304 
305  /// @brief this function runs after main routine catalog() finishes
306  void post_catalog_ops( VallLibrary const & library );
307 
308 
309 private: // data
310 
311 
312  /// @brief flag controls preallocation of score container, default true
314 
315 
316  /// @brief static Tracer instance for this class
317  static basic::Tracer TR_;
318 
319 
320 };
321 
322 
323 } // namespace vall
324 } // namespace picking_old
325 } // namespace fragment
326 } // namespace core
327 
328 
329 #endif /* INCLUDED_core_fragment_picking_old_vall_VallLibrarian_HH */