Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DockingEnsemble.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 DockingEnsemble.cc
11 /// @brief container class for ensemble docking information to be used with ConformerSwitchMover
12 /// @author Monica Berrondo
13 
15 
16 // Rosetta Headers
17 #include <basic/datacache/CacheableStringFloatMap.hh>
18 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
20 // AUTO-REMOVED #include <core/id/types.hh>
22 // AUTO-REMOVED #include <core/pose/util.hh>
23 #include <core/pose/Pose.hh>
24 // AUTO-REMOVED #include <core/scoring/Energies.hh>
25 // AUTO-REMOVED #include <core/scoring/rms_util.hh>
27 #include <core/types.hh>
28 
29 // AUTO-REMOVED #include <protocols/scoring/Interface.hh>
34 
35 
36 // Random number generator
37 #include <numeric/random/random.hh>
38 //
39 #include <string>
40 
41 #include <basic/Tracer.hh>
42 
43 #include <utility/io/izstream.hh>
44 #include <utility/io/ozstream.hh>
45 
47 #include <utility/vector0.hh>
48 #include <utility/vector1.hh>
49 
50 //Auto Headers
51 #include <core/kinematics/Jump.hh>
52 #include <basic/datacache/BasicDataCache.hh>
53 
54 
55 using basic::T;
56 using basic::Error;
57 using basic::Warning;
58 
59 static numeric::random::RandomGenerator RG(2357892);
60 static basic::Tracer TR("protocols.moves.DockingEnsemble");
61 
62 namespace protocols {
63 namespace docking {
64 
65 /// @details Auto-generated virtual destructor
67 
68 
69 //constructor with arguments
71  Size start_res,
72  Size end_res,
73  Size jump_id,
74  std::string ensemble_file_path,
75  std::string partner,
78 ) :
79  start_res_(start_res),
80  end_res_(end_res),
81  jump_id_(jump_id),
82  ensemble_file_path_(ensemble_file_path),
83  partner_(partner)
84 {
85  // initialize current conf_num to zero
86  conf_num_ = 0;
87 
89  scorefxn_high_ = scorefxn_high;
90 
91  load_ensemble();
93 
94  runtime_assert(ensemble_size_ > 0);
95  conf_size_ = ensemble_list_[1].total_residue();
96  runtime_assert((end_res_ - start_res_ + 1) == conf_size_);
97 
98  TR << "ensemble summary: start_res_ " << start_res_ <<
99  " end_res_ " << end_res_ <<
100  " conf_size_ " << conf_size_ <<
101  " ensemble_size_ " << ensemble_size_ << std::endl;
102 }
103 
105 {
107  utility::io::izstream file( ensemble_file_path_ );
108  std::string line;
109  TR << "Loading Ensemble" << std::endl;
110 
111  // read file names
112  while( getline(file, line) ) {
113  // read pdb file names into filename array
114  if ( line.find("pdb") != std::string::npos )
115  pdb_filenames_.push_back( line );
116  // read the rest of the data as Reals into data array
117  else data.push_back( atof( line.c_str() ) );
118  }
119 
120  if ( data.size() > 1 ) {
121  core::Size count = 1;
122  for ( Size i=count; i<count+pdb_filenames_.size(); ++i )
123  lowres_reference_energies_.push_back( data[i] );
124 
125  count = count+pdb_filenames_.size();
126  for ( Size i=count; i<count+pdb_filenames_.size(); ++i )
127  highres_reference_energies_.push_back( data[i] );
128  }
129 
132 
133  //Add by DK
134  for (Size i = 1; i <= ensemble_list_cen_.size(); i++){
136  to_centroid.apply( ensemble_list_cen_[i] );
137  }
138 }
139 
141 {
142  using namespace core::pose::datacache;
143  core::pose::Pose recover_pose = ensemble_list_[conf_num_];
145  recover_mover->apply( pose );
146 
147  // make sure that the pose has ARBITRARY_FLOAT_DATA in the DataCache
148  if ( !pose.data().has( ( CacheableDataType::ARBITRARY_FLOAT_DATA ) ) ){
149  pose.data().set(
150  CacheableDataType::ARBITRARY_FLOAT_DATA,
151  new basic::datacache::CacheableStringFloatMap()
152  );
153  }
154 
155  basic::datacache::CacheableStringFloatMapOP data
156  = dynamic_cast< basic::datacache::CacheableStringFloatMap * >
157  ( pose.data().get_raw_ptr(CacheableDataType::ARBITRARY_FLOAT_DATA) );
158 
161 
162  //jjg: need to cache pointer to this function in the pose too!
163 }
164 
166 {
167  core::Real score_low = ( *scorefxn_low_ )( pose );
168  TR << "score_low: " << score_low << std::endl;
169  lowres_reference_energies_.push_back( score_low );
170 }
171 
173 {
174  core::pose::Pose conformer = ensemble_list_[conf_num];
176  to_fullatom.apply( conformer );
177 
178  pack_operations_->apply( conformer );
179 
180  core::Real score_high = ( *scorefxn_high_ )( conformer );
181  TR << "score_high: " << score_high << std::endl;
182  highres_reference_energies_.push_back( score_high );
183 
185  TR << "filename: " << filename << std::endl;
186  conformer.dump_pdb( filename );
188  TR << "filename in array: " << pdb_filenames_[highres_reference_energies_.size()] << std::endl;
189 }
190 
192 {
193  utility::io::ozstream data;
194  data.open( ensemble_file_path_ );
195 
196  // write out new filenames
197  core::Size conf = 1;
198  while ( conf <= pdb_filenames_.size() ) {
199  data << pdb_filenames_[conf] << '\n';
200  ++conf;
201  }
202 
203  // normalize centroid reference energies
204  core::Real adjustment = lowres_reference_energies_[1];
205  for ( core::Size i=1; i<=lowres_reference_energies_.size(); ++i ) {
206  core::Real ref_energy = lowres_reference_energies_[i];
207  adjustment = std::min( ref_energy, adjustment );
208  }
209  for ( core::Size i=1; i<= lowres_reference_energies_.size(); ++i )
211 
212  // write out centroid reference energies
213  conf = 1;
214  while ( conf <= pdb_filenames_.size() ) {
215  data << lowres_reference_energies_[conf] << '\n';
216  ++conf;
217  }
218 
219  // write out fullatom reference energies
220  conf = 1;
221  while ( conf <= pdb_filenames_.size() ) {
222  data << highres_reference_energies_[conf] << '\n';
223  ++conf;
224  }
225 }
226 
228 {
229  pack_operations_ = packer;
230 }
231 
232 } // namespace docking
233 } // namespace protocols