Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InvrotTarget.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file protocols/toolbox/match_enzdes_util/InvrotTarget.hh
12 /// @brief .hh file for inverse rotamer target
13 /// @author Florian Richter, flosopher@gmail.com, mar 2012
14 
15 
16 //unit headers
18 
19 //package headers
23 
24 //project headers
25 #include <core/pose/Pose.hh>
28 
29 #include <basic/Tracer.hh>
30 
31 //utility headers
32 #include <utility/string_util.hh>
33 
34 namespace protocols {
35 namespace toolbox {
36 namespace match_enzdes_util {
37 
38 static basic::Tracer tr( "protocols.toolbox.match_enzdes_util.InvrotTarget" );
39 
41  : InvrotTreeNodeBase( NULL )
42 {
44  all_target_res_.clear();
45  next_nodes_.clear();
46 }
47 
49 
52 {
53  return representative_target_res_for_geom_cst_[ geom_cst ];
54 }
55 
56 std::list< core::conformation::ResidueCOP >
58 {
59  return all_target_res_;
60 }
61 
64  core::pose::Pose const & pose,
65  AllowedSeqposForGeomCstCOP geomcst_seqpos
66 ) const
67 {
68  if( next_nodes_.size() == 0 ) utility_exit_with_message("generate constraints function called on InvrotTraget that's not pointing to any next_nodes, something's wrong somewhere.");
69 
71 
72  for( Size i =1; i <= next_nodes_.size(); ++i ){
73  core::scoring::constraints::ConstraintCOP this_child_cst( (next_nodes_[i]->generate_constraints( pose, geomcst_seqpos ) ) );
74  if( this_child_cst) node_constraints.push_back( this_child_cst );
75  }
76  if( node_constraints.size() == 0 ) return NULL;
77 
78  return new core::scoring::constraints::MultiConstraint( node_constraints );
79 }
80 
81 
82 /// @details the meat...
83 bool
85  EnzConstraintIOCOP enzcst_io )
86 {
87  next_nodes_.clear();
89  this->generate_representative_target_res_for_geom_cst( enzcst_io->num_mcfi_lists() );
90  if( representative_target_res_for_geom_cst_.size() != enzcst_io->num_mcfi_lists() ){
91  utility_exit_with_message("child class failed to properly implement 'generate_representative_target_res_for_geom_cst' method.");
92  }
93 
94  utility::vector1< Size > mcfi_to_build;
95  for( Size i =1; i <= enzcst_io->num_mcfi_lists(); ++i){
96  //make sure this geom cst is concerned with the downstream residue / object
97  std::pair< Size, Size> const & target_res( enzcst_io->target_downstream_res()[i] );
98  if( (target_res.first == 1 ) && (target_res.second == 1 ) ){
99  mcfi_to_build.push_back( i );
100  next_nodes_.push_back( new InvrotTreeNode( this ) );
101  }
102  }
103 
104  for( Size i =1; i <= next_nodes_.size(); ++i ){
105  if( !next_nodes_[i]->initialize_from_enzcst_io( *representative_target_res_for_geom_cst_[ mcfi_to_build[i] ], enzcst_io, mcfi_to_build[i]) ){
106  tr << "InvrotTarget could not initialize because node initialization for geom_cst " << mcfi_to_build[i] << " failed." << std::endl;
107  return false;
108  }
109  }
110  return true;
111 }
112 
115 {
117  to_return.push_back( all_target_res_ );
118  return to_return;
119 }
120 
121 
122 void
124  utility::vector1< InvrotCollectorOP > & invrot_collectors
125 ) const
126 {
127  //1. make space
128  Size num_residue_lists( representative_target_res_for_geom_cst_.size() + 1 ); //+1 bc we're also counting the ligand now
129  Size input_size( invrot_collectors.size() );
130  invrot_collectors.push_back( new InvrotCollector( num_residue_lists ) );
131 
132  //2. put target res into 0th element
133  invrot_collectors[ invrot_collectors.size() ]->set_invrots_for_listnum( 0, all_target_res_, this, 1 );
134 
135  //3. collect daughter node invrots
136  for( Size i = 1; i <= next_nodes_.size(); ++i ){
137  next_nodes_[i]->collect_all_inverse_rotamers( invrot_collectors );
138  }
139 
140  //4. some kind of sanity check to make sure this shit actually worked maybe?
141  Size output_size( invrot_collectors.size() );
142  for( Size i = input_size + 1; i <= output_size; ++i ){
143 
144  if( invrot_collectors[ i ]->invrots().size() != num_residue_lists ){
145  utility_exit_with_message("Tree definition "+utility::to_string( i )+" does not contain the necessary "+utility::to_string( num_residue_lists )+" residue lists.");
146  }
147 
148  for( Size j = 0; j < num_residue_lists; ++j){
149  if( invrot_collectors[i]->invrots()[j].size() == 0 ) utility_exit_with_message("Tree definition "+utility::to_string( i )+" does not contain rotamers for residue list "+utility::to_string( j )+".");
150  }
151  //other sanity checks necessary?
152  }
153 }
154 
155 
156 void
157 InvrotTarget::set_all_target_res( std::list< core::conformation::ResidueCOP > const & all_target_res )
158 {
160 }
161 
162 void
164  utility::vector1< core::conformation::ResidueCOP > const & representative_res )
165 {
166  representative_target_res_for_geom_cst_ = representative_res;
167 }
168 
169 
172 {
173  //this might seem a bit clumsy, but at some point we have to change from vector to list
174  std::list< core::conformation::ResidueCOP > all_targets;
175  for( utility::vector1< core::conformation::ResidueCOP >::const_iterator res_it( single_res.begin() ); res_it != single_res.end(); ++res_it ) all_targets.push_back( *res_it );
176  this->set_all_target_res( all_targets );
177 }
178 
180 
181 void
183 {
185  for( Size i =1; i <= num_geom_cst; ++i ) representative_res.push_back( (*this->all_target_res().begin()) );
186  this->set_representative_target_res_for_geom_cst( representative_res );
187 }
188 
189 }
190 }
191 }