Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MatcherMover.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/match/MatcherMover.cc
12 /// @brief Implementation of mover wrapper for matcher
13 /// @author Florian Richter (floric@u.washington.edu), june 2010
14 
15 
16 // Unit headers
19 
20 //package headers
26 
27 //project headers
34 #include <core/id/AtomID.hh>
35 #include <basic/options/option.hh>
36 #include <basic/options/keys/match.OptionKeys.gen.hh>
37 #include <basic/options/keys/run.OptionKeys.gen.hh>
38 #include <core/pose/Pose.hh>
39 #include <basic/Tracer.hh>
40 #include <utility/tag/Tag.hh>
41 
42 #include <utility/vector0.hh>
43 #include <utility/vector1.hh>
44 
45 
46 #if defined(WIN32) || defined(__CYGWIN__)
47  #include <ctime>
48 #endif
49 
50 
51 namespace protocols {
52 namespace match {
53 
54 static basic::Tracer tr( "protocols.match.MatcherMover" );
55 
56 
59 {
61 }
62 
65  return new MatcherMover;
66 }
67 
70 {
71  return "MatcherMover";
72 }
73 
74 MatcherMover::MatcherMover( bool incorporate_matches_into_pose ):
75  Mover( "MatcherMover" ),
76  incorporate_matches_into_pose_( incorporate_matches_into_pose ),
77  ligres_(NULL)
78 {
79  //we need this for the output to be correct
80  basic::options::option[basic::options::OptionKeys::run::preserve_header ].value(true);
81 }
82 
84 
86  //utility::pointer::ReferenceCount(),
87  Mover( rval ),
88  incorporate_matches_into_pose_( rval.incorporate_matches_into_pose_ ),
89  ligres_( rval.ligres_ ),
90  match_positions_( rval.match_positions_ )
91 {}
92 
93 /// @brief clone this object
95 {
96  return new MatcherMover( *this );
97 }
98 
99 /// @brief create this type of object
101 {
102  return new MatcherMover();
103 }
104 
105 ///
106 void
108 {
109 
111 
112  core::pose::Pose ligpose;
113  core::pose::Pose save_pose = pose;
116  basic::options::option[ basic::options::OptionKeys::match::lig_name ] ) );
117 
118  if( !ligres_->type().is_ligand() ) std::cerr << "WARNING: downstream residue " << ligres_->type().name3() << " set in the matcher mover does not seem to be a ligand residue, matcher will likely not behave properly." << std::endl;
119 
120  ligpose.append_residue_by_jump( *ligres_, 1 );
121 
122  //we might have to remove the downstream pose from the input
124  for( core::Size i = pose.total_residue(); i > 0; --i ){
125  if( pose.residue_type( i ).name3() == ligres_->type().name3() ) pose.conformation().delete_residue_slow( i );
126  }
127  }
128 
129  //if ( option[ OptionKeys::match::ligand_rotamer_index ].user() ) {
130  // set_ligpose_rotamer( ligpose );
131  //}
132  Size cent, nbr1, nbr2;
133  ligres_->select_orient_atoms( cent, nbr1, nbr2 );
134 
135  tr << "Selecting orientation atoms:";
136  tr << " " << ligres_->atom_name( cent );
137  tr << " " << ligres_->atom_name( nbr1 );
138  tr << " " << ligres_->atom_name( nbr2 ) << std::endl;
139  //pose.dump_pdb("pose_going_into_matcher.pdb");
140  mtask->set_upstream_pose( pose );
141 
143  oats[ 1 ] = core::id::AtomID( nbr2, 1 ); oats[ 2 ] = core::id::AtomID( nbr1, 1 ); oats[ 3 ] = core::id::AtomID( cent, 1 );
144 
145  mtask->set_downstream_pose( ligpose, oats );
146  if( match_positions_.size() != 0 ){
147  mtask->set_ignore_cmdline_for_build_points( true );
148  mtask->set_original_scaffold_build_points( match_positions_ );
149  }
150 
151  mtask->initialize_from_command_line();
152 
153  if( incorporate_matches_into_pose_ ) mtask->output_writer_name("PoseMatchOutputWriter");
154 
155  time_t matcher_start_time = time(NULL);
157  matcher->initialize_from_task( *mtask );
158 
159 
161 
162  if( matcher->find_hits() ){
163  matcher->process_matches( *processor );
164  }
165 
166  time_t matcher_end_time = time(NULL);
167  std::string success_str( processor->match_processing_successful() ? "successful." : "not sucessful." );
168  tr << "Matcher ran for " << (long)(matcher_end_time - matcher_start_time) << " seconds and was " << success_str << std::endl;
169 
170  if( processor->match_processing_successful() ) this->set_last_move_status( protocols::moves::MS_SUCCESS );
171  else{
173  pose = save_pose;
174  return;
175  }
176 
178  protocols::match::output::PoseMatchOutputWriterOP outputter( static_cast< protocols::match::output::PoseMatchOutputWriter * >( processor->output_writer().get() ) );
179  outputter->insert_match_into_pose( pose );
180  // should make another mover to set these constraints flo and nobu
181  //protocols::enzdes::AddOrRemoveMatchCsts addcsts = protocols::enzdes::AddOrRemoveMatchCsts();
182  //addcsts.set_cst_action(protocols::enzdes::ADD_NEW);
183  //addcsts.apply(pose);
184  }
185  //pose.dump_pdb("pose_coming_from_matcher.pdb");
186 
187 } //MatcherMover::apply function
188 
191 {
192  return "MatcherMover";
193 }
194 
195 void
198 {
199  ligres_ = new core::conformation::Residue(*ligres);
200 }
201 
202 void
204  utility::vector1< core::Size > const & match_positions )
205 {
206  match_positions_ = match_positions;
207 }
208 
209 void
211  TagPtr const tag,
212  DataMap &,
213  Filters_map const &,
214  Movers_map const &,
215  Pose const & )
216 {
217  incorporate_matches_into_pose_ = tag->getOption<bool>( "incorporate_matches_into_pose", 1 );
218 }
219 
220 }
221 }