Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WorkUnit_LoopHash.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/wum/WorkUnitBase.cc
11 /// @brief
12 /// @author Mike Tyka
13 
15 // AUTO-REMOVED #include <protocols/loophash/Exceptions.hh>
18 
21 
22 // AUTO-REMOVED #include <core/import_pose/pose_stream/MetaPoseInputStream.hh>
23 // AUTO-REMOVED #include <core/import_pose/pose_stream/util.hh>
29 #include <basic/options/keys/in.OptionKeys.gen.hh>
30 // AUTO-REMOVED #include <basic/options/keys/out.OptionKeys.gen.hh>
31 #include <basic/options/keys/lh.OptionKeys.gen.hh>
32 #include <basic/options/keys/wum.OptionKeys.gen.hh>
33 // AUTO-REMOVED #include <basic/options/keys/relax.OptionKeys.gen.hh>
34 #include <basic/options/option.hh>
35 // AUTO-REMOVED #include <core/pose/Pose.hh>
36 // AUTO-REMOVED #include <core/pose/util.hh>
37 // AUTO-REMOVED #include <core/scoring/ScoreFunctionFactory.hh>
39 // AUTO-REMOVED #include <basic/Tracer.hh>
40 // AUTO-REMOVED #include <protocols/relax/FastRelax.hh>
43 
44 //Auto Headers
45 #include <utility/vector1.hh>
46 //Auto Headers
49 #include <utility/excn/Exceptions.hh>
50 
51 
52 
53 
54 #if defined(WIN32) || defined(__CYGWIN__)
55  #include <ctime>
56 #endif
57 
58 namespace protocols {
59 namespace loophash {
60 
61 
62 static basic::Tracer TR("WorkUnit_LoopHash");
63 
64 
65 
68 {
69  set_defaults();
70  set_start(start_ir);
71  set_end(end_ir);
72  set_ssid(ssid);
73 }
74 
75 void
77 {
78  TR.Debug << "Setting type to WU_Type_LoopHash" << std::endl;
79 }
80 
81 void
83 {
84  using namespace basic::options;
85  using namespace basic::options::OptionKeys;
86 
87  utility::vector1 < core::Size > loop_sizes = option[ OptionKeys::lh::loopsizes]();
88  core::Size num_partitions = option[ OptionKeys::wum::n_slaves_per_master]();
89  if( option[ OptionKeys::lh::num_partitions].user() )
90  num_partitions = option[ OptionKeys::lh::num_partitions]();
91  core::Size assigned_num = mpi_rank % num_partitions;
92  try{
93  library_ = new LoopHashLibrary( loop_sizes, num_partitions, assigned_num );
94  // load initial library from disk
95  library_->load_mergeddb();
96  }
97  catch( utility::excn::EXCN_Msg_Exception e ){
98  e.show( std::cout );
99  e.show( std::cerr );
100  throw;
101  }
102  library_->mem_foot_print();
103 }
104 
105 void
107 {
108  using namespace core::pose;
109  using namespace protocols::loops;
110  using namespace basic::options;
111  using namespace basic::options::OptionKeys;
112 
113  if( decoys().size() == 0 ){
114  TR << "Empty WorkUnit ! Cannot execute run() " << std::endl;
115  return;
116  }
117 
119  core::pose::Pose pose;
120  decoys().get_pose( 0, pose );
121 
122  // clear the sotre of structures
123  decoys().clear();
124 
125  runtime_assert( library_ );
126 
127  TR << "Executing WorkUnit_LoopHash_Mover..." << std::endl;
128  LocalInserter_SimpleMinOP simple_inserter( new LocalInserter_SimpleMin() );
129  LoopHashSampler lsampler( library_, simple_inserter );
130  lsampler.set_start_res( get_start() );
131  lsampler.set_stop_res ( get_end() );
132  lsampler.set_min_bbrms( 20.0 );
133  lsampler.set_max_bbrms( 1400.0 );
134  lsampler.set_min_rms( 0.5 );
135  lsampler.set_max_rms( 4.0 );
136  if( option[ OptionKeys::lh::bss]() ) lsampler.set_nonideal(true);
137 
138  // convert pose to centroid pose:
139  if( pose.is_fullatom() ){
141  }
143 
144  TR.Info << "Running loophash function: Start: " << get_start() << " End: " << get_end() << std::endl;
145  core::Size starttime = time(NULL);
146 
147  lsampler.build_structures( pose, decoys().store() );
148 
149  core::Size endtime = time(NULL);
150  TR.Info << "Build " << decoys().size() << " structures in " << endtime - starttime << " s " << std::endl;
151 
152  // transfer any tags from input structure:
153 
154  const core::io::silent::SilentStruct *ss2 = &( *start_struct );
155 
157  it != decoys().end(); ++ it ){
158 
159  core::io::silent::SilentStruct *ss = &(*(*it));
160  // preserve the centroid score!
161  core::Real censcore = (*it)->get_energy("censcore");
162  (*it)->copy_scores( *start_struct );
163  (*it)->add_energy("censcore", censcore );
165  (*it)->add_string_value( "husid", (*it)->get_string_value("husid") + "." + new_usid );
166  (*it)->add_string_value( "usid", new_usid );
167  (*it)->add_energy( "state", 1 );
168 
169  if( option[ OptionKeys::lh::bss]() ) {
172  if( (pss != NULL) && (pss2 != NULL) ){
173  TR.Debug << "LoophashResult: " << pss->CA_rmsd( *pss2 ) << " " << pss->get_energy("censcore") << std::endl;
174  } else {
175  TR << "LoophashResult: ERROR, dynamic cast to BSS failed" << std::endl;
176  }
177  } else {
178  const core::io::silent::ProteinSilentStruct *pss2 = dynamic_cast< const core::io::silent::ProteinSilentStruct* > ( ss2 );
180  if( (pss != NULL) && (pss2 != NULL) ){
181  TR.Debug << "LoophashResult: " << pss->CA_rmsd( *pss2 ) << " " << pss->get_energy("censcore") << std::endl;
182  } else {
183  TR << "LoophashResult: ERROR, dynamic cast to PSS failed" << std::endl;
184  }
185  }
186  }
187 }
188 
189 
190 
191 
192 
193 }
194 }
195