Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SilentStructStore.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/wum/SilentStructStore.hh
11 /// @brief
12 /// @author Mike Tyka
13 
14 
15 
16 #ifndef INCLUDED_protocols_wum_SilentStructStore_hh
17 #define INCLUDED_protocols_wum_SilentStructStore_hh
18 
20 
21 #include <core/types.hh>
22 #include <core/pose/Pose.fwd.hh>
23 // AUTO-REMOVED #include <protocols/moves/Mover.hh>
25 #include <utility/pointer/ReferenceCount.hh>
26 #include <utility/vector1.hh>
27 // AUTO-REMOVED #include <core/io/silent/SilentFileData.hh>
28 // AUTO-REMOVED #include <core/scoring/ScoreFunction.hh>
29 // AUTO-REMOVED #include <core/optimization/MinimizerOptions.hh>
30 #include <utility/exit.hh>
31 #include <string>
32 #include <vector>
33 
34 //Auto Headers
35 namespace protocols {
36 namespace wum {
37 
38 /// @brief this little class is a predicate for finding silent structures in say a vector of silent structures
40 {
41 public:
42  find_SilentStructOPs(std::string field, core::Real value ): field_(field), value_(value) {}
43 
45 
46 private:
49 };
50 
52 public:
53  ///@brief Automatically generated virtual destructor for class deriving directly from ReferenceCount
54  virtual ~SilentStructStore();
56  {
57 
58  }
59 
60 public:
61 
62  // some wrapper stuff to allow iteration of the structure store
63  typedef std::vector < core::io::silent::SilentStructOP >::iterator iterator;
64  typedef std::vector < core::io::silent::SilentStructOP >::const_iterator const_iterator;
65 
66  /// @brief Returns an iterator to the start of the members of this container.
67  iterator begin() { return store_.begin(); }
68 
69  /// @brief Returns an iterator to the start of the members of this container.
70  const_iterator begin() const { return store_.begin(); }
71 
72  /// @brief Returns an iterator to the end of the members of this container.
73  iterator end() { return store_.end(); }
74 
75  /// @brief Returns an iterator to the end of the members of this container.
76  const_iterator end() const { return store_.end(); }
77 
78  void sort_by( std::string field = "score" );
79 
80 public:
81 
82  /// @brief Remove all structures
83  void clear();
84 
85  /// @brief add a pose
86  void add( const core::pose::Pose &pose );
87 
88  /// @brief Add a core::io::silent::SilentStruct
89  void add( core::io::silent::SilentStructOP new_struct );
90 
91  /// @brief Add a core::io::silent::SilentStruct
92  void add( const core::io::silent::SilentStruct &new_struct );
93 
94  /// @brief Add structures froma silent file data object
95  void add( core::io::silent::SilentFileData const& sfd ) ;
96 
97  /// @brief Add the contents of another SilentStructStore
98  void add( SilentStructStore &mergestore ) ;
99 
100  /// @brief THis uses the pose stream to read in everything from -l, -s and -in:file:silent into this store.
101  void read_from_cmd_line( );
102 
103  /// @brief read from string
104  void read_from_string( const std::string & input );
105 
106  /// @brief read from silent file
107  void read_from_stream( std::istream & input );
108 
109  /// @brief read from string
110  void read_from_file( const std::string & filename );
111 
112  /// @brief Obtain a new pose from a given index. must provide a template pose though!
113  void get_pose( core::Size index, core::pose::Pose &pose ) const ;
114 
115  /// @brief How many structures
116  core::Size size(){ return store_.size(); }
117 
118  /// @brief Get a structure with a certain index
120  if( index >= store_.size() ) runtime_assert( false );
121  return (core::io::silent::SilentStructCOP) store_[ index ];
122  }
123 
124  /// @brief Get a structure with a certain index
126  if( index >= store_.size() ) runtime_assert( false );
127  return store_[ index ];
128  }
129 
130  /// @brief Get a random structure
132 
133  /// @brief Print silent file
134  void serialize( std::ostream & out ) const ;
135 
136  /// @brief Print silent file
137  void serialize( std::string & out ) const ;
138 
139  /// @brief Print silent file
140  void serialize_to_file( const std::string &file ) const ;
141 
142  /// @brief Print silent file
143  void print( std::ostream & out ) const ;
144 
145  std::vector < core::io::silent::SilentStructOP > & store() { return store_; }
146 
147  void limit( core::Size limit_size ){
148  if( store().size() > limit_size ) store().resize( limit_size );
149  }
150 
151  /// @brief Return memory usage
152  virtual core::Size mem_footprint() const;
153 
154  /// @brief return numner of structures
155  core::Size size() const { return store_.size(); }
156 
157  /// @brief return numner of structures
158  void erase( iterator it ) { store_.erase(it); }
159 
160  /// Manipulators:
161  void all_add_energy( std::string scorename, core::Real value, core::Real weight = 1.0 );
162 
163  /// Manipulators:
164  void all_sort_silent_scores( );
165 
166 
167 
168 private:
169  std::vector < core::io::silent::SilentStructOP > store_;
170 };
171 
172 
173 
174 
175 // Some additional tools!
176 
178 
179 
180 
181 
182 
183 }
184 }
185 
186 #endif
187 
188