21 #include <utility/excn/Exceptions.hh>
35 #include <utility/pointer/ReferenceCount.hh>
37 #include <basic/Tracer.hh>
38 #include <utility/exit.hh>
44 #include <utility/vector1.hh>
45 #include <numeric/xyzMatrix.hh>
46 #include <basic/prof.hh>
48 static basic::Tracer
tr(
"protocols.canonical_sampling.mc_convergence_check.Pool",basic::t_info);
53 namespace canonical_sampling {
54 namespace mc_convergence_checks {
65 using namespace ObjexxFCL;
67 using namespace basic;
70 tr.Debug <<
"getting " << index <<
" coords of " << pool_.n_decoys() << std::endl;
71 FArray2P_double temp = pool_.coords( index );
72 result.dimension(temp.u1(),temp.u2(),0.0);
73 for(
int i = 1; i <= result.u1(); i++){
74 for(
int j = 1; j <= result.u2(); j++){
75 result( i, j ) = temp( i, j );
81 tr.Debug <<
"getting tag " << index <<
" of " << tags_.size() <<
" which has value " << tags_[index] << std::endl;
82 return tags_[ index ];
87 tr.Debug <<
"checking size before popping back " << pool_.n_decoys() << std::endl;
88 pool_.pop_back_CA_xyz();
89 pool_.center_structure( pool_.n_decoys(), weights_ );
90 tr.Debug <<
"finished popping back. size is now " << pool_.n_decoys() << std::endl;
91 tr.Debug <<
"just checking that size of arrays match up " << tags_.size() <<
" " << pool_.n_decoys() << std::endl;
93 runtime_assert( tags_.size() == pool_.n_decoys() );
104 excluded_residues_ = excluded_residues;
115 }
catch( utility::excn::EXCN_BadInput
const& excn ) {
116 excn.show(
tr.Warning );
117 tr.Warning <<
"Pool_RMSD did not find any structures, will output n/a 10000 for converged_tag and converged_rmsd" << std::endl;
120 pool_.push_back_CA_xyz_from_silent_file( sfd,
false );
121 tags_.reserve( sfd.
size() );
123 tags_.push_back( it->decoy_tag() );
125 weights_.dimension( pool_.n_atoms(), 1.0 );
126 if ( pool_.n_decoys() ) pool_.center_all( weights_ );
132 if ( new_tag ==
"keep_silent_tag" ) {
147 if( weights_.size() == 0 ){
148 weights_.dimension( nres, 1.0 );
152 PROF_START( basic::POOL_RMSD_ADD_STRUCTURE );
154 if ( pool_.n_decoys_max() >= pool_.n_decoys() ) {
156 pool_.reserve( pool_.n_decoys() + reserve_size_ );
160 tags_.push_back( new_tag );
161 pool_.push_back_CA_xyz( xyz, nres );
162 pool_.center_structure( pool_.n_decoys(), weights_ );
164 runtime_assert( tags_.size() == pool_.n_decoys() );
165 PROF_STOP( basic::POOL_RMSD_ADD_STRUCTURE );
170 reserve_size_ = max_size;
175 tr.Debug <<
"using Pool_RMSD::evaluate_and_add " << std::endl;
179 return evaluate_and_add( coords, cluster_center, rms_to_cluster, transition_threshold );
183 core::Size best_index = evaluate( coords, best_decoy, best_rmsd );
184 if( best_rmsd > transition_threshold ){
185 tr.Debug <<
"adding structure to pool " << std::endl;
186 using namespace ObjexxFCL;
189 std::string new_cluster_tag =
"new."+lead_zero_string_of(
size(), 8 )+
".0"+
"_"+jobname;
190 add( coords, coords.u2(), new_cluster_tag);
196 if ( pool_.n_decoys() == 0 ) {
202 runtime_assert( pss.
nres() == pool_.n_atoms() );
203 return evaluate( coords, best_decoy, best_rmsd );
207 if ( pool_.n_decoys() == 0 ) {
213 runtime_assert( pool_.n_atoms() <= fit_pose.
total_residue() );
215 return evaluate( coords, best_decoy, best_rmsd );
219 return evaluate( coords, best_decoy, best_rmsd, 1);
225 PROF_START( basic::POOL_RMSD_EVALUATE );
226 if ( pool_.n_decoys() == 0 ) {
231 tr.Debug <<
"evaluating: start from index " << index <<
" of " << pool_.n_decoys() << std::endl;
233 FArray1D_double weights( pool_.n_atoms(), 1.0 );
235 weights( *it ) = 0.0;
238 FArray1D_double transvec( 3 );
241 Real invn( 1.0 / pool_.n_atoms() );
243 Size best_index( 0 );
244 for (
Size i = index; i <= pool_.n_decoys(); i++ ) {
246 ObjexxFCL::FArray2P_double xx2( pool_.coords( i ) );
249 for (
Size n = 1; n <= pool_.n_atoms(); n++) {
250 for (
Size d = 1; d<=3; ++d ) {
251 rmsd += ( coords( d, n ) - xx2( d, n ) ) * ( coords( d, n ) - xx2( d, n ) ) * invn;
255 if ( rmsd <= best_rmsd ) {
262 best_decoy = tags_[ best_index ];
263 PROF_STOP( basic::POOL_RMSD_EVALUATE );
268 if ( reject )
return true;
273 rmsd_pool_->evaluate( fit_pose, best_decoy, best_rmsd );
279 return best_rmsd >= threshold_;
287 rmsd_pool_->evaluate( fit_pose, best_decoy, best_rmsd );
302 rmsd_pool_->evaluate( pss, best_decoy, best_rmsd );