Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SetupNCSMover.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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file SetupNCSMover.cc
10 /// @brief Sets up NCS restraints
11 /// @author Frank DiMaio
12 
13 // Unit headers
16 
17 // AUTO-REMOVED #include <protocols/moves/DataMap.hh>
19 #include <core/pose/selection.hh>
20 
21 #include <core/id/TorsionID.hh>
22 #include <core/id/AtomID.hh>
23 #include <core/pose/Pose.hh>
24 // AUTO-REMOVED #include <core/pose/PDBInfo.hh>
25 // AUTO-REMOVED #include <core/pose/symmetry/util.hh>
28 // AUTO-REMOVED #include <core/conformation/symmetry/util.hh>
29 
34 
35 #include <utility/vector1.hh>
36 #include <utility/exit.hh>
37 #include <utility/tag/Tag.hh>
38 
39 #include <basic/Tracer.hh>
40 
41 #include <utility/vector0.hh>
42 
43 
44 namespace protocols {
45 namespace simple_moves {
46 namespace symmetry {
47 
48 static basic::Tracer TZ("protocols.simple_moves.symmetry.SetupNCSMover");
49 
50 // creators
54 }
55 
58  return new SetupNCSMover;
59 }
60 
63  return "SetupNCS";
64 }
65 
66 ////////////////////
67 ////////////////////
68 
69 SetupNCSMover::SetupNCSMover() : protocols::moves::Mover("SetupNCSMover") {
70  set_defaults();
71 }
72 
73 SetupNCSMover::SetupNCSMover( std::string src, std::string tgt ) : protocols::moves::Mover("SetupNCSMover") {
74  add_group( src, tgt );
75  set_defaults();
76 }
77 
78 SetupNCSMover::SetupNCSMover( std::string src, utility::vector1<std::string> tgt ): protocols::moves::Mover("SetupNCSMover") {
79  for (Size i=1; i<=tgt.size(); ++i)
80  add_group( src, tgt[i] );
81  set_defaults();
82 }
83 
85  runtime_assert( src.size() == tgt.size() );
86  for (Size i=1; i<=tgt.size(); ++i)
87  add_group( src[i], tgt[i] );
88  set_defaults();
89 }
90 
92 
94  wt_ = 0.01; //fpd this seems reasonable in fullatom
95  limit_ = 10.0; // in degrees
96  bb_ = chi_ = true;
97  symmetric_sequence_ = false;
98  sd_ = 1000; // for Harmonic, distance. Value determined empirically after test with relaxed structures
99  distance_pair_ = false;
100 }
101 
103  src_.push_back( src );
104  tgt_.push_back( tgt );
105 }
106 
108  srcE_.push_back( src );
109  tgtE_.push_back( tgt );
110 }
111 
113  srcD_.push_back( src );
114  tgtD_.push_back( tgt );
115 }
116 
117 //
119  using namespace std;
120  using namespace utility;
121  using namespace core;
122  using namespace core::id;
123  using namespace core::scoring::constraints;
124 
125  assert( src_.size() == tgt_.size() );
126 
127  core::Real test1a=src_.size();
128  core::Real test2a=tgt_.size();
129  TZ.Debug << "Size src angle " << test1a << " Size tgt angle " << test2a << std::endl;
130 
131 
132  // map residue ranges -> resid pairs (using PDBinfo if necessary)
133  for (Size i=1; i<=src_.size(); ++i) {
135 
136  core::Real temp_a=src_i.size();
137  TZ.Debug << "src angle size " << temp_a << std::endl;
138 
140 
141  core::Real temp_b=tgt_i.size();
142  TZ.Debug << "src angle size " << temp_b << std::endl;
143 
144  runtime_assert( src_i.size() == tgt_i.size() );
145 
146  //
147  if ( src_i.size() == 0 ) {
148  utility_exit_with_message("Error creating NCS constraints: " + src_[i] +" : "+tgt_[i]);
149  }
150 
151  for (Size j=1; j<=src_i.size(); ++j) {
152  core::Size resnum_src = src_i[j], resnum_tgt = tgt_i[j];
153  id::AtomID id_a1,id_a2,id_a3,id_a4, id_b1,id_b2,id_b3,id_b4;
154 
155  TZ.Debug << "Add constraint " << resnum_src << " <--> " << resnum_tgt << std::endl;
156 
157 
158  //replace residue identity to match reference positions
159  if (symmetric_sequence_) {
160  pose.replace_residue( resnum_tgt, pose.residue(resnum_src), true );
161  }
162 
163  if (bb_) {
164  // fpd better safe than sorry
165  runtime_assert (pose.residue(resnum_src).mainchain_torsions().size() == pose.residue(resnum_tgt).mainchain_torsions().size());
166  for ( Size k=1, k_end = pose.residue(resnum_src).mainchain_torsions().size(); k<= k_end; ++k ) {
167  id::TorsionID tors_src(resnum_src,BB,k);
168  id::TorsionID tors_tgt(resnum_tgt,BB,k);
169 
170  pose.conformation().get_torsion_angle_atom_ids(tors_src, id_a1, id_a2, id_a3, id_a4 );
171  pose.conformation().get_torsion_angle_atom_ids(tors_tgt, id_b1, id_b2, id_b3, id_b4 );
172 
173  // make the cst
174  pose.add_constraint( new DihedralPairConstraint( id_a1, id_a2, id_a3, id_a4, id_b1, id_b2, id_b3, id_b4,
175  new TopOutFunc( wt_, 0.0, limit_ ) ) );
176  }
177  }
178 
179  if (chi_) {
180  if ( pose.residue(resnum_src).aa() != pose.residue(resnum_tgt).aa() ) {
181  TZ.Error << "Trying to constrain sidechain torsions of different residue types!" << std::endl;
182  TZ.Error << " >>> " << resnum_src << " vs " << resnum_tgt << std::endl;
183  continue;
184  }
185 
186  // cys/cyd messes this up I think
187  if ( pose.residue(resnum_src).nchi() != pose.residue(resnum_tgt).nchi() ) {
188  TZ.Error << "Trying to constrain sidechains with different number of chi angles!" << std::endl;
189  continue;
190  }
191 
192  for ( Size k=1, k_end = pose.residue(resnum_src).nchi(); k<= k_end; ++k ) {
193  id::TorsionID tors_src(resnum_src,CHI,k);
194  id::TorsionID tors_tgt(resnum_tgt,CHI,k);
195 
196  pose.conformation().get_torsion_angle_atom_ids(tors_src, id_a1, id_a2, id_a3, id_a4 );
197  pose.conformation().get_torsion_angle_atom_ids(tors_tgt, id_b1, id_b2, id_b3, id_b4 );
198 
199  // make the cst
200  pose.add_constraint( new DihedralPairConstraint( id_a1, id_a2, id_a3, id_a4, id_b1, id_b2, id_b3, id_b4,
201  new TopOutFunc( wt_, 0.0, limit_ ) ) );
202  }
203  }
204  }
205  }
206 
207 
208 //symmetrize ONLY sequence (eg. N- and C-term)
209  if (symmetric_sequence_) {
210 
211  assert( srcE_.size() == tgtE_.size() );
212 
213  // map residue ranges -> resid pairs (using PDBinfo if necessary)
214  for (Size i=1; i<=srcE_.size(); ++i) {
217  runtime_assert( srcE_i.size() == tgtE_i.size() );
218 
219  //
220  if ( srcE_i.size() == 0 ) {
221  utility_exit_with_message("Error creating NCS constraints: " + srcE_[i] +" : "+tgtE_[i]);
222  }
223 
224  for (Size j=1; j<=srcE_i.size(); ++j) {
225  core::Size resnum_srcE = srcE_i[j], resnum_tgtE = tgtE_i[j];
226 
227  TZ.Debug << "Symmetrizing residues " << resnum_srcE << " <--> " << resnum_tgtE << std::endl;
228 
229  //replace residue identity to match reference positions
230  pose.replace_residue( resnum_tgtE, pose.residue(resnum_srcE), true );
231  }
232  }
233  }
234 
235 
236 //calculate distance pairing constraints
237  if (distance_pair_) {
238  assert( srcD_.size() == tgtD_.size() );
239 
240  core::Real test1=srcD_.size();
241  core::Real test2=tgtD_.size();
242  TZ.Debug << "Size src " << test1 << " Size tgt " << test2 << std::endl;
243 
244 
245  // map residue ranges -> resid pairs (using PDBinfo if necessary)
246  for (Size i=1; i<=srcD_.size(); ++i ) {
248 
249  core::Real temp_d=srcD_i.size();
250  TZ.Debug << "src 1 size " << temp_d << std::endl;
251 
253  runtime_assert( srcD_i.size() == tgtD_i.size() );
254  runtime_assert( srcD_i.size() % 2 == 0 );
255 
256  //
257  if ( srcD_i.size() == 0 ) {
258  utility_exit_with_message("Error creating NCS distance pair constraints: " + srcD_[i] + " : " + tgtD_[i] );
259  }
260 
261  for (Size j=1; j<=srcD_i.size()/2; ++j) {
262  core::Size resnum_src1 = srcD_i[j], resnum_tgt1 = tgtD_i[j], resnum_src2 = srcD_i[j+srcD_i.size()/2], resnum_tgt2 = tgtD_i[j+srcD_i.size()/2];
263  id::AtomID id_ad1,id_ad2, id_bd1,id_bd2;
264 
265  TZ.Debug << "Add distance pair constraint " << resnum_src1 << " - " << resnum_src2 << " <--> " << resnum_tgt1 << " - " << resnum_tgt2 << std::endl;
266 
267  //get the ca atoms
268  id_ad1 = id::AtomID(pose.residue(resnum_src1).atom_index("CA") , resnum_src1);
269  id_ad2 = id::AtomID(pose.residue(resnum_src2).atom_index("CA") , resnum_src2);
270  id_bd1 = id::AtomID(pose.residue(resnum_tgt1).atom_index("CA") , resnum_tgt1);
271  id_bd2 = id::AtomID(pose.residue(resnum_tgt2).atom_index("CA") , resnum_tgt2);
272 
273  // make the cst
274  pose.add_constraint( new DistancePairConstraint( id_ad1, id_ad2, id_bd1, id_bd2, new HarmonicFunc( 0.0, sd_ ) ) ); // for Harmonic
275 
276  }
277  }
278 
279  }
280 
281 
282 
283 
284 
285 }
286 
288  utility::tag::TagPtr const tag,
289  moves::DataMap & /*data*/,
290  filters::Filters_map const & /*filters*/,
291  moves::Movers_map const & /*movers*/,
292  core::pose::Pose const & /*pose*/ ) {
293  if (tag->hasOption( "bb" )) bb_ = tag->getOption< bool >( "bb" );
294  if (tag->hasOption( "chi" )) chi_ = tag->getOption< bool >( "chi" );
295  if (tag->hasOption( "wt" )) wt_ = tag->getOption< core::Real >( "wt" );
296  if (tag->hasOption( "limit" )) limit_ = tag->getOption< core::Real >( "limit" );
297  if (tag->hasOption( "symmetric_sequence" )) symmetric_sequence_ = tag->getOption< bool >( "symmetric_sequence" );
298  if (tag->hasOption( "sd" )) sd_ = tag->getOption< core::Real >( "sd" ); // for Harmonic, distance
299  if (tag->hasOption( "distance_pair" )) distance_pair_ = tag->getOption< bool >( "distance_pair" );
300 
301 
302  // now parse ncs groups <<< subtags
303  utility::vector1< TagPtr > const branch_tags( tag->getTags() );
305  for( tag_it = branch_tags.begin(); tag_it!=branch_tags.end(); ++tag_it ){
306  if( (*tag_it)->getName() == "NCSgroup" || (*tag_it)->getName() == "ncsgroup" ){
307  std::string src_i = (*tag_it)->getOption<std::string>( "source" );
308  std::string tgt_i = (*tag_it)->getOption<std::string>( "target" );
309  if (symmetric_sequence_) {
310  TZ.Debug << "Symmetrizing sequences " << src_i << " -> " << tgt_i << std::endl;
311  }
312  TZ.Debug << "Adding NCS cst " << src_i << " -> " << tgt_i << std::endl;
313  add_group( src_i, tgt_i );
314  }
315 
316  if( (*tag_it)->getName() == "NCSend" || (*tag_it)->getName() == "ncsend" ){
317  std::string srcE_i = (*tag_it)->getOption<std::string>( "source" );
318  std::string tgtE_i = (*tag_it)->getOption<std::string>( "target" );
319  if (symmetric_sequence_) {
320  TZ.Debug << "Symmetrizing sequences at ends" << srcE_i << " -> " << tgtE_i << std::endl;
321  }
322  add_groupE( srcE_i, tgtE_i );
323  }
324 
325 //group in the format <NCSdistance source="2A,9A" target="28A,35A"/> or
326 // <NCSdistance source="2A-20A,42A-60A" target="128A-156A,168A-186A"/>
327  if( (*tag_it)->getName() == "NCSdistance" || (*tag_it)->getName() == "ncsdistance" ){
328  std::string srcD_i = (*tag_it)->getOption<std::string>( "source" );
329  std::string tgtD_i = (*tag_it)->getOption<std::string>( "target" );
330  add_groupD( srcD_i, tgtD_i );
331  }
332 
333  }
334 }
335 
339 }
340 
341 
342 } // symmetry
343 } // moves
344 } // protocols