33 #include <basic/Tracer.hh>
43 namespace match_enzdes_util {
45 static basic::Tracer
tr(
"protocols.toolbox.match_enzdes_util.InvrotTreeNode" );
49 geom_cst_(0), generate_invrot_csts_(true)
71 std::list< core::conformation::ResidueCOP > all_invrots;
75 if( cst_res ) all_invrots.push_back( cst_res );
83 if( all_invrots.size() == 0 ){
84 all_invrots = enzcst_io->mcfi_list( invrot_geomcst)->inverse_rotamers_against_residue( enzcst_io->mcfi_list( invrot_geomcst )->mcfi( 1 )->downstream_res(), &target_residue );
89 Size num_rots_total( all_invrots.size() );
91 Size num_invrots_clashing( num_rots_total - all_invrots.size() );
92 tr <<
"When initializing a node for geomcst " <<invrot_geomcst <<
", " << num_invrots_clashing <<
" of a total of " << num_rots_total <<
" inverse rotamers were found to clash with something." << std::endl;
93 if( all_invrots.size() == 0 ){
103 std::list< core::conformation::ResidueCOP >
const & all_invrots,
117 for(
Size i =
geom_cst_ +1; i <= enzcst_io->num_mcfi_lists(); ++i){
118 std::pair< Size, Size>
const & target_res( enzcst_io->target_downstream_res()[i] );
119 if( (target_res.first ==
geom_cst_) && (target_res.second == 2 ) ) dependent_mcfi.push_back( i );
125 if( dependent_mcfi.size() == 0 ){
146 std::list<core::conformation::ResidueCOP>::const_iterator invrot_it1 = all_invrots.begin();
148 while( invrot_it1 != all_invrots.end() ){
149 bool this_invrot_redundant(
false);
158 bool these_two_redundant(
true);
159 for(
Size j = 1; j <= dependent_mcfi.size(); ++j){
161 if( !enzcst_io->mcfi_list( dependent_mcfi[j])->mcfi(1)->enz_cst_template_res( enzcst_io->mcfi_list( dependent_mcfi[j])->mcfi(1)->downstream_res() )->residue_conformations_redundant( cur_rot, test_rot ) ){
162 these_two_redundant =
false;
166 if( these_two_redundant ){
168 this_invrot_redundant =
true;
174 if( !this_invrot_redundant ){
180 tr <<
"Node initialization for geomcst " <<
geom_cst_ <<
". After redundancy determination, " <<
invrots_and_next_nodes_.size() <<
" non-redundant sets of inverse rotamers exist." << std::endl;
188 bool all_initialization_successful(
true);
189 for(
Size j = 1; j <= dependent_mcfi.size(); ++j ){
191 pair_it->second.push_back( child );
192 if( ! child->initialize_from_enzcst_io( this_target, enzcst_io, dependent_mcfi[j], pose ) ){
194 all_initialization_successful =
false;
198 if( all_initialization_successful ){
204 tr <<
"Node initialization for geomcst " <<
geom_cst_ <<
". After child node initialization, " <<
invrots_and_next_nodes_.size() <<
" non-redundant sets of inverse rotamers exist." << std::endl;
208 (*child_it)->set_location_in_parent_node( i );
242 if( this_child_cst) constraints_this_invrot_node_pair.push_back( this_child_cst );
246 if( constraints_this_invrot_node_pair.size() == 1 ) constraints_this_node.push_back( constraints_this_invrot_node_pair[1] );
251 if( constraints_this_node.size() == 0 )
return NULL;
253 if( constraints_this_node.size() == 1 )
return constraints_this_node[1];
268 if( !parent ) utility_exit_with_message(
"the impossible just happened");
271 std::string target_name3( (*parent_res[1].begin())->name3() );
272 core::Vector const & xyz_to_find( (*parent_res[1].begin())->nbr_atom_xyz() );
277 if( xyz_to_find.distance_squared( pose.
residue(i).
atom(j).
xyz() ) < 0.1 ){
284 utility_exit_with_message(
"No success when trying to find a fixed pt in the InvrotTree that's also in the pose. Shit's fucked up somewhere.");
297 if( parent ) to_return = parent->all_target_residues(
this );
300 bool child_found(
false);
309 if( child_found )
break;
322 std::list< core::conformation::ResidueCOP > & invrots,
332 if( !parent )
return;
337 if( covalent ) all_targets.pop_back();
341 if( all_targets.size() == 0 )
return;
346 for( std::list <core::conformation::ResidueCOP >::iterator invrot_it( invrots.begin() ); invrot_it != invrots.end(); ){
347 bool cur_invrot_clashes(
false);
349 for(
Size i =1; i <= all_targets.size(); ++i){
352 if( all_targets[i].
size() == 0 )
continue;
354 bool this_list_all_clash(
true );
355 for( std::list <core::conformation::ResidueCOP >::const_iterator target_rot_it( all_targets[i].begin() ), target_rot_it_end( all_targets[i].
end() ); target_rot_it != target_rot_it_end; ++target_rot_it ){
360 bool these_two_clash(
false);
363 for(
Size res1at = 1; res1at <= res1.nheavyatoms(); ++res1at ){
364 if( res1.type().is_virtual( res1at ) )
continue;
367 if( res1.atom( res1at ).xyz().distance_squared( res2.
atom( res2at ).
xyz() ) < cutoff_sq ){
368 these_two_clash =
true;
384 if( these_two_clash )
break;
386 if( !these_two_clash){
387 this_list_all_clash =
false;
391 if( this_list_all_clash ){
392 cur_invrot_clashes =
true;
397 if( cur_invrot_clashes ) invrot_it = invrots.erase( invrot_it );
415 for(
Size i =1; i <= invrot_collectors.size(); ++i ){
416 std::map< InvrotTreeNodeBaseCOP, Size >
const & collector_map( invrot_collectors[i]->owner_nodes_and_locations() );
418 if( collector_map.find(
this ) != collector_map.end() ) utility_exit_with_message(
"InvrotTreeNode being asked to fill a collector that it apparently already previously filled.");
420 std::map< InvrotTreeNodeBaseCOP, Size >::const_iterator map_it( collector_map.find( &(*(this->parent_node())) ) );
422 if( map_it != collector_map.end() ){
423 if( map_it->second == this->location_in_parent_node() ){
424 if( invrot_collectors[i]->invrots()[
geom_cst_].size() == 0 ) empty_parent_collectors.push_back( i );
425 else filled_parent_collectors.push_back( i );
429 tr <<
"Collecting inverse rotamers for a node from geomcst " <<
geom_cst_ <<
". " << empty_parent_collectors.size() <<
" empty parent collectors and " << filled_parent_collectors.size() <<
" filled parent collectors were found." << std::endl;
432 Size total_parents( empty_parent_collectors.size() + filled_parent_collectors.size() );
433 runtime_assert( total_parents != 0);
437 for(
Size i =1; i <= filled_parent_collectors.size(); ++ i ){
438 invrot_collectors.push_back( invrot_collectors[ filled_parent_collectors[i] ]->
clone() );
439 collectors_to_fill.push_back( invrot_collectors.size() );
443 for(
Size i = 1; i <= collectors_to_fill.size(); ++i ){
444 Size overflow_start( invrot_collectors.size());
446 invrot_collectors.push_back( invrot_collectors[ collectors_to_fill[i] ]->
clone() );
459 (*child_it)->collect_all_inverse_rotamers( invrot_collectors );