Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LigandDesign.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/ligand_docking/LigandDesign.cc
11 ///
12 /// @brief
13 /// @Gordon Lemmon
14 
17 
18 #include <core/pose/util.hh>
19 
20 
21 #include <protocols/moves/Mover.hh>
22 
23 #include <basic/options/option.hh>
24 
25 #include <core/types.hh>
26 // AUTO-REMOVED #include <basic/prof.hh>
27 
28 #include <basic/Tracer.hh>
29 
30 // AUTO-REMOVED #include <utility/file/file_sys_util.hh>
31 #include <utility/assert.hh>
32 
33 // option key includes
34 
36 // AUTO-REMOVED #include <basic/options/keys/docking.OptionKeys.gen.hh>
37 // AUTO-REMOVED #include <basic/options/keys/in.OptionKeys.gen.hh>
38 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
41 #include <utility/tag/Tag.hh>
42 
43 #include <utility/vector0.hh>
44 #include <utility/vector1.hh>
45 #include <numeric/random/random.hh>
46 #include <boost/foreach.hpp>
47 
48 //Auto Headers
50 #include <core/pose/Pose.hh>
51 
52 #define foreach BOOST_FOREACH
53 
54 namespace protocols {
55 namespace ligand_docking {
56 
57 static basic::Tracer ligand_design_tracer("protocols.ligand_docking.LigandDesign", basic::t_debug);
58 
61 {
63 }
64 
67  return new LigandDesign;
68 }
69 
72 {
73  return "LigandDesign";
74 }
75 
76 LigandDesign::LigandDesign(): Mover("LigandDesign"){
77  Mover::type( "LigandDesign" );
78  set_fragments();
79 }
80 
82  //utility::pointer::ReferenceCount(),
83  protocols::moves::Mover( that ),
84  option_file_(that.option_file_),
85  fragments_(that.fragments_)
86 {}
87 
89 
90 void
93  rs.set_property("FRAGMENT");
96  core::chemical::ResidueTypeCOPs fragment_types= rs.select( *rsd_set );
97  ligand_design_tracer<< fragment_types.size()<< " fragment_types"<< std::endl;
98 
99  foreach(core::chemical::ResidueTypeCOP fragment_type, fragment_types){
100  core::conformation::ResidueOP temp = new core::conformation::Residue( *fragment_type, true);
101  fragments_.push_back(temp);
102  ligand_design_tracer<< "frag_name: "<< temp->name()<< std::endl;
103  }
104 }
105 
107  return new LigandDesign( *this );
108 }
109 
111  return new LigandDesign;
112 }
113 
115  return "LigandDesign";
116 }
117 
118 ///@brief parse XML (specifically in the context of the parser/scripting scheme)
119 void
121  utility::tag::TagPtr const tag,
122  protocols::moves::DataMap & /*datamap*/,
123  protocols::filters::Filters_map const & /*filters*/,
124  protocols::moves::Movers_map const & /*movers*/,
125  core::pose::Pose const & /*pose*/
126 )
127 {
128  if ( tag->getName() != "LigandDesign" ) {
129  ligand_design_tracer << " received incompatible Tag " << tag << std::endl;
130  assert(false);
131  return;
132  }
133  if ( tag->hasOption("option_file") ) {
134  option_file_ = tag->getOption<std::string>("option_file");
135  }
136  //parse_score_function( tag, datamap, filters, movers, pose );
137  //parse_task_operations( tag, datamap, filters, movers, pose );
138 }
139 
141  return passes_filters(pose,start,end) && has_incomplete_connections(pose,start,end);
142 }
143 
145  for(;start <= end; ++start){
146  core::conformation::Residue const & res= pose.residue(start);
147  ligand_design_tracer<< res.name();
148  if(res.has_incomplete_connection()){
149  ligand_design_tracer<<" has incomplete connection"<< std::endl;
150  return true;
151  }
152  ligand_design_tracer<<" completely connected"<< std::endl;
153  }
154  ligand_design_tracer<< "no more connections"<< std::endl;
155  return false;
156 }
157 
159  /// User Defined Filters
160  // example
161  if( core::pose::num_heavy_atoms(start,end,pose)>20 ){
162  ligand_design_tracer<< "Reached heavy atom limit"<< std::endl;
163  return false;
164  }
165  if (core::pose::num_chi_angles(start,end,pose)>10){
166  ligand_design_tracer<< "Reached chi angle limit"<< std::endl;
167  return false;
168  }
169  else return true;
170 }
171 
174  //find connections that are incomplete
175  utility::vector1<core::Size> incomplete_connections= get_incomplete_connections(residue);
176  return numeric::random::random_element(incomplete_connections);
177 }
178 
179 // should be a helper function of residue class
182  utility::vector1<core::Size> incomplete_connections;
183  for(core::Size i=1; i<= residue->n_residue_connections(); ++i){
184  if(residue->connection_incomplete(i)){
185  incomplete_connections.push_back(i);
186  }
187  }
188  return incomplete_connections;
189 }
190 
193  core::pose::Pose const & pose,
195  core::Size const end
196 ){
197  utility::vector1<core::Size> unconnected_residues;
198  for(; start <= end; ++start){
199  if( pose.residue(start).has_incomplete_connection() ){
200  unconnected_residues.push_back(start);
201  }
202  }
203  return unconnected_residues;
204 }
205 
206 void
208 {
209  assert(!fragments_.empty());
210  using namespace basic::options::OptionKeys;
211  using basic::options::option;
212  core::Size ligand_residue_id= pose.n_residue();
213  ASSERT_ONLY(core::conformation::Residue const & ligand= pose.residue(ligand_residue_id);)
214  assert(ligand.is_ligand());
215  assert( ligand.n_residue_connections() > 0);
216  core::Size const & chain_id= pose.chain(ligand_residue_id);
217  core::Size const start = pose.conformation().chain_begin(chain_id);
218  core::Size end = pose.conformation().chain_end(chain_id);
219  while(grow(pose, start, end)){
220  utility::vector1<core::Size> unconnected_residues = find_unconnected_residues(pose, start,end);
221  core::Size const & grow_from= numeric::random::random_element(unconnected_residues);
222  core::conformation::ResidueCOP const growth= numeric::random::random_element(fragments_);;
223  core::Size grow_from_connection= random_connection(&pose.residue(grow_from));
224  core::Size growth_connection= random_connection(growth);
225  pose.append_residue_by_bond(*growth, true, growth_connection, grow_from, grow_from_connection);
226  //end = pose.conformation().chain_end(chain_id);
227  ++end;
228  }
229 
230 }
231 
233  foreach(core::conformation::ResidueCOP fragment, fragments_){
234  core::conformation::Residue const & res= *fragment;
235  std::string name= res.name();
236  core::Size total= res.n_residue_connections();
237  core::Size incomplete= get_incomplete_connections(&res).size();
238  ligand_design_tracer<< "name, total, incomplete"<< name<< " "<< total<<" "<< incomplete<< std::endl;
239  }
240 }
241 
243  core::pose::Pose & /*pose*/
244 )
245 {
246 // using namespace core::scoring;
247 // ScoreFunctionCOP sfxn = command_map_.get_score_function();
248 //
249 // core::Real const tot_score = sfxn->score( pose );
250 //
251 // // Which score terms to use
252 // typedef utility::vector1<ScoreType> ScoreTypeVec;
253 // ScoreTypeVec score_types;
254 // for(int i = 1; i <= n_score_types; ++i) {
255 // ScoreType ii = ScoreType(i);
256 // if ( sfxn->has_nonzero_weight(ii) ) score_types.push_back(ii);
257 // }
258 //
259 // protocols::jd2::JobOP job( protocols::jd2::JobDistributor::get_instance()->current_job() );
260 // for(ScoreTypeVec::iterator ii = score_types.begin(), end_ii = score_types.end(); ii != end_ii; ++ii) {
261 // job->add_string_real_pair(name_from_score_type(*ii), sfxn->get_weight(*ii) * pose.energies().total_energies()[ *ii ]);
262 // }
263 // job->add_string_real_pair(name_from_score_type(core::scoring::total_score), tot_score);
264 }
265 
266 } // namespace ligand_docking
267 } // namespace protocols