Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LoopHashLibrary.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 protocols/loophash/LoopHashLibrary.hh
11 /// @brief
12 /// @author Mike Tyka
13 
14 
15 
16 #ifndef INCLUDED_protocols_loophash_LoopHashLibrary_hh
17 #define INCLUDED_protocols_loophash_LoopHashLibrary_hh
18 
20 // AUTO-REMOVED #include <protocols/loophash/LoopHashSampler.fwd.hh>
21 // AUTO-REMOVED #include <protocols/loophash/LocalInserter.fwd.hh>
22 
23 #include <core/types.hh>
24 #include <core/pose/Pose.fwd.hh>
25 #include <protocols/moves/Mover.hh>
26 // AUTO-REMOVED #include <protocols/loops/Loop.hh>
28 // AUTO-REMOVED #include <protocols/frag_picker/VallChunk.hh>
29 // AUTO-REMOVED #include <protocols/frag_picker/VallProvider.hh>
30 #include <utility/vector1.hh>
34 #include <string>
35 #include <vector>
36 #include <map>
37 
39 
40 
41 namespace protocols {
42 namespace loophash {
43 
44 
46 
47 public:
48 
49  LoopHashLibrary( const utility::vector1< core::Size > &init_sizes = utility::vector1< core::Size >(), const core::Size num_partitions = 1, const core::Size assigned_num = 0);
50 
52 
54 
55  bool test_saving_library( core::pose::Pose, core::Size ir, bool deposit );
56 
57  void test_loop_sample( core::pose::Pose& pose, core::Size nres );
58 
59  void apply_random(
60  core::pose::Pose& pose,
61  core::Size &fir,
62  core::Size &fjr,
63  core::Real min_rms,
64  core::Real max_rms
65  );
66 
67  void get_all(
68  core::pose::Pose& pose,
69  std::vector< core::io::silent::SilentStructOP > &lib_structs,
70 
71  core::Size start_res = 1,
72  core::Size stop_res = 0,
73 
74  core::Real min_bbrms = 0.0,
75  core::Real max_bbrms = 100000.0,
76  core::Real min_rms = 0.0,
77  core::Real max_rms = 100.0
78  );
79 
80  virtual void apply( core::pose::Pose& pose );
81 
82  virtual protocols::moves::MoverOP clone() const {
83  return new LoopHashLibrary( *this );
84  }
85 
86 
87  virtual std::string get_name() const {
88  return "LoopHashLibrary";
89  }
90 
92  return new LoopHashLibrary;
93  }
94 
95 
96  void setup_hash_maps();
97 
98  // simple accessors
100 
101 
102  const std::vector < core::Size > & hash_sizes() const { return hash_sizes_; }
103 
104  const BackboneDB & backbone_database() const { return bbdb_; }
105 
106  const std::pair< core::Size, core::Size > loopdb_range() { return loopdb_range_; }
107 
108  // Only support writing to text, always include extra data
109  void save_db();
110 
111  // Only support reading from text, extra data is mandatory
112  // used when created merged text db
113  void load_db();
114 
115  // Only support reading from merged text
116  // Extra data is optional and handled by extra_
117  void load_mergeddb();
118 
119  // For backwards-compability
120  //void load_legacydb();
121 
122  void delete_db();
123 
124  // Takes two LoopHashLibrary and merges them
125  // Throws out nonunique fragments defined as follows
126  // If a new frag is in a bucket with a key also in the master library, and if the rms between
127  // the new frag and the members of the master bucket is lower than the rms_cutoff, it is nonunique
128  // Thus, an rms_cutoff of zero will not throw away any fragments
129  void merge( LoopHashLibraryOP second_lib, utility::vector1< core::Real> rms_cutoffs );
130 
131  // Takes two bbdb and merges them
132  // Just takes Data structs from one and copies to the other
133  bool merge_bbdb( const BackboneDB & second_bbdb, core::Size & index_offset );
134 
135  // This function destroys the backbone_index_map reference, so sorting is only done when the hash will not longer be used
136  // Required after merging, before saving so that merged db can be loaded as slices
137  void sort();
138 
139  void create_db();
140  void set_create_db( bool setting = true ){ create_db_ = setting; }
141  void set_db_path( std::string setting ){ db_path_ = setting; }
142 
143  void graft_loop(
144  const core::pose::Pose& src_pose,
145  core::pose::Pose& tgt_pose,
147  );
148 
149  // setup scorefunctions for
151 
152 
153  void mem_foot_print();
154 
155  bool get_extra() const { return extra_; }
156 
157 private:
158 
159  // The backbone library for this HashLibrary (the actual data)
161 
162  // A map of Hashmaps, each for a different loop size
163  std::map < core::Size, LoopHashMap > hash_;
164 
165  // Kindof a redundant store of sizes - remove this ?
166  std::vector < core::Size > hash_sizes_;
167 
168  // Path to db
170 
171  // the number of partitions the database is split into
173 
174  // which partition slice is assigned to this Library
176 
177  // Need so we can set the db string once
179 
180  // Whether this database holds extra data in the bbdb or not
181  bool extra_;
182 
183  // The proteins of the backbone db that are loaded (when loading a merged db, otherwise (0,0)
184  std::pair< core::Size, core::Size > loopdb_range_;
185 
186  // Some basic flags
189 
190  // Used for grafting - ultimately to move into a seperate Mover class.
191 
194 
197 };
198 
199 
200 
201 
202 
203 
204 //class LoopHashSampler {
205 // public:
206 //
207 // LoopHashSampler(
208 // LoopHashLibraryOP library,
209 // LocalInserterOP inserter
210 // ):
211 // library_(library),
212 // inserter_(inserter),
213 // start_res_ ( 1 ),
214 // stop_res_ ( 0 ),
215 // min_bbrms_ ( 0.0 ),
216 // max_bbrms_ ( 100000.0 ),
217 // min_rms_ ( 0.0 ),
218 // max_rms_ ( 100.0 )
219 // {
220 //
221 // }
222 //
223 // // @brief create a set of structures for a the given range of residues and other parameters
224 // void build_structures(
225 // core::pose::Pose& start_pose,
226 // std::vector< core::io::silent::SilentStructOP > &lib_structs
227 // );
228 //
229 //
230 //
231 // private:
232 // // pointer to the library used for insertion
233 // LoopHashLibraryOP library_;
234 //
235 // // pointer to the insertion functor which provides the peptide insertion facility
236 // LocalInserterOP inserter_;
237 //
238 // // parameters for insertion positions
239 // core::Size start_res_;
240 // core::Size stop_res_ ;
241 // core::Real min_bbrms_;
242 // core::Real max_bbrms_;
243 // core::Real min_rms_ ;
244 // core::Real max_rms_ ;
245 //
246 //};
247 
248 
249 
250 
251 
252 } // namespace loops
253 } // namespace protocols
254 
255 
256 
257 #endif
258 
259 
260