33 #include <basic/options/option.hh>
45 #include <basic/Tracer.hh>
56 #include <utility/exit.hh>
58 #include <utility/pointer/owning_ptr.hh>
59 #include <utility/io/izstream.hh>
73 #include <basic/options/keys/in.OptionKeys.gen.hh>
74 #include <basic/options/keys/lh.OptionKeys.gen.hh>
80 #include <utility/vector1.hh>
81 #include <numeric/random/random.hh>
82 #include <boost/unordered/unordered_map.hpp>
86 using namespace kinematics;
88 using namespace core::io::silent;
89 using namespace core::pose;
90 using namespace core::scoring;
91 using namespace conformation;
92 using namespace protocols::moves;
101 SilentStructStore::~SilentStructStore() {}
112 runtime_assert( left );
113 runtime_assert( right );
114 return left->get_energy( field_ ) < right->get_energy( field_ );
123 if ( check->get_energy(field_) == value_ )
return true;
129 static basic::Tracer
TR(
"SilentStructStore");
131 static numeric::random::RandomGenerator
RG(1931333);
134 SilentStructStore::clear()
141 using namespace basic::options;
142 using namespace basic::options::OptionKeys;
146 ss->fill_struct( pose );
153 store_.push_back( new_struct );
159 store_.push_back( pss );
164 using namespace core::io::silent;
165 using namespace core::chemical;
173 for( std::vector < SilentStructOP >::const_iterator it = mergestore.
store_.begin();
174 it != mergestore.
store_.end();
176 runtime_assert( *it );
177 store_.push_back( *it );
184 SilentStructStore::read_from_cmd_line( ) {
185 using namespace basic::options;
186 using namespace basic::options::OptionKeys;
189 if ( option[ in::file::fullatom ]() ) {
197 while( input.has_another_pose() && (count < 400 ) ) {
199 input.fill_pose( pose, *rsd_set );
203 TR.Info <<
"Read " << count <<
" structures from command line" << std::endl;
209 SilentStructStore::read_from_string(
const std::string & input ) {
210 std::istringstream iss(input);
211 read_from_stream( iss );
216 SilentStructStore::read_from_stream( std::istream & input ) {
230 utility::io::izstream data( filename.c_str() );
231 if ( !data.good() ) {
232 utility_exit_with_message(
233 "ERROR: Unable to open silent strcuture store file: '" + filename +
"'"
236 read_from_stream( data );
243 runtime_assert( index < store_.size() );
245 temp_struct->fill_pose( pose );
250 if( store_.size() == 0 ) runtime_assert(
false);
252 runtime_assert( choice < store_.size() );
253 return store_[ choice ];
256 void SilentStructStore::serialize( std::ostream & out )
const {
257 if( store_.size() == 0 ){
258 TR.Warning <<
"WARNING: Empty silent struct store serialized." << std::endl;
260 (*store_.begin())->print_header( out );
262 for( std::vector < SilentStructOP >::const_iterator it = store_.begin();
265 runtime_assert( *it );
272 std::ostringstream ss;
279 std::ofstream out( filename.c_str() );
281 utility_exit_with_message(
"ERROR: Unable to open output file : '" + filename +
"'" );
291 void SilentStructStore::print( std::ostream & out )
const {
294 out <<
"----------------------------------------------" << std::endl;
295 for( std::vector < SilentStructOP >::const_iterator it = store_.begin();
299 runtime_assert( *it );
300 (*it)->print_scores( out );
302 out <<
"----------------------------------------------" << std::endl;
308 SilentStructStore::mem_footprint()
const {
310 for( std::vector < SilentStructOP >::const_iterator it = store_.begin();
313 total += (*it)->mem_footprint();
322 if( store_.size() == 0 )
return;
324 std::sort( store_.begin(), store_.end(), sort_by_field );
331 for( std::vector < SilentStructOP >::iterator it = store_.begin();
334 (*it)->add_energy( scorename, value, weight );
339 SilentStructStore::all_sort_silent_scores()
341 for( std::vector < SilentStructOP >::iterator it = store_.begin();
344 (*it)->sort_silent_scores( );
357 const static char *codes =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
358 const static int codes_len = 52;
362 unsigned int digit = number % codes_len;
363 code = codes[digit] + code;
368 while( count_len < pad_width ){
369 code = pad_char + code;
383 static long unique_count=0;
387 MPI_Comm_rank( MPI_COMM_WORLD, (
int* )( &mpi_rank ) );
388 MPI_Comm_size( MPI_COMM_WORLD, (
int* )( &mpi_npes ) );
390 int width =
int(floor(log(
float(mpi_npes))/log(62.0)) + 1.0);