Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SetAtomTree.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/protein_interface_design/movers/SetAtomTree.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarelf@u.washington.edu), Jacob Corn (jecorn@u.washington.edu), Eva-Maria Strauch (evas01@u.washington.edu)
13 
14 // Unit headers
19 
20 // Package headers
22 
23 // Project headers
25 #include <utility/tag/Tag.hh>
26 #include <basic/Tracer.hh>
28 #include <core/pose/Pose.hh>
30 #include <core/pose/PDBInfo.hh>
31 #include <core/pose/PDBPoseMap.hh>
33 #include <core/pose/selection.hh>
34 #include <utility/vector0.hh>
37 
38 
39 namespace protocols {
40 namespace protein_interface_design {
41 namespace movers {
42 
43 using namespace core;
44 using namespace std;
45 using namespace core::scoring;
46 using namespace protocols::moves;
47 
48 static basic::Tracer TR( "protocols.protein_interface_design.movers.SetAtomTree" );
49 
52 {
54 }
55 
58  return new SetAtomTree;
59 }
60 
63 {
64  return "AtomTree";
65 }
66 
67 //initializing
71 
73  protocols::moves::Mover( SetAtomTreeCreator::mover_name() ),
74  docking_ft_( false ),
75  simple_ft_( false ),
76  two_parts_chain1_( false ),
77  jump_( 1 ),
78  resnum_( "" ),
79  connect_to_( "" ),
80  anchor_res_( "" ),
81  connect_from_( "" ),
82  host_chain_( 2 )
83 {}
84 
86 
89  return (protocols::moves::MoverOP( new SetAtomTree( *this ) ) );
90 }
91 
92 void
94 {
95  docking_ft_ = tag->getOption< bool >("docking_ft", 0 );
96  simple_ft( tag->getOption< bool >( "simple_ft", 0 ) );
97  jump_ = tag->getOption< core::Size >( "jump", 1);
98  if( docking_ft_ ) return;
99  /// resnum & pdb_num are now equivalent
100  if( tag->hasOption( "resnum" ) )
101  resnum_ = tag->getOption< std::string > ("resnum" );
102  else if( tag->hasOption( "pdb_num" ) ){
103  resnum_ = tag->getOption< std::string > ("pdb_num" );
104  connect_to_ = tag->getOption< std::string >( "connect_to","" );
105  }
106  if( tag->hasOption( "anchor_res" ) ){
107  anchor_res_ = tag->getOption< std::string > ( "anchor_res" );
108  if( tag->hasOption( "connect_from" ) )
109  connect_from_ = tag->getOption< std::string >( "connect_from" );
110  }
111  host_chain_ = tag->getOption< core::Size >( "host_chain", 2);
112  two_parts_chain1( tag->getOption< bool >( "two_parts_chain1", false ) );
113  TR<<"resnum: "<<resnum_<<" anchor: "<< anchor_res_<<std::endl;
114 }//end parse my tag
115 
117 SetAtomTree::create_atom_tree( core::pose::Pose const & pose, core::Size const host_chain, core::Size const resnum, core::Size const anchor_num_in, std::string connect_to_in/*=""*/, std::string connect_from_in/*=""*/ )
118 {
120 
121  core::Size const begin( pose.conformation().chain_begin( host_chain == 1 ? 2 : 1 ) );
122  core::Size const end( pose.conformation().chain_end( host_chain == 1 ? 2 : 1 ) );
123  core::Real min_dist(10000);
124  core::conformation::Residue const res_central( pose.residue( resnum ) );
125  core::Size anchor_num = anchor_num_in;
126  std::string connect_to( connect_to_in );
127  std::string connect_from( connect_from_in );
128 
129  if( connect_to == "" )
130  connect_to = optimal_connection_point( res_central.name3() );
131 
132  core::Size nearest_res( 0 );
133 
134  if ( anchor_num == 0 ) {
135  for( core::Size res = begin+1; res <= end-1; ++res ) {
136  core::conformation::Residue const res2( pose.residue(res) );
137  core::Real const distance( res_central.xyz( res_central.nbr_atom() ).distance( res2.xyz( res2.nbr_atom() ) ) );
138  if( distance<=min_dist ) {
139  min_dist = distance;
140  nearest_res = res;
141  TR.Debug<<"anchor defaults to: "<<nearest_res<<std::endl;
142  }
143  }
144  }//end no anchor specified, hence finds the closest one
145  else
146  nearest_res = anchor_num;
147 
148 
149  core::Size const rb_jump( 1 );
150  core::Size const jump_pos1( host_chain == 1 ? resnum : nearest_res );
151  core::Size const jump_pos2( host_chain == 1 ? nearest_res : resnum );
152  if ( connect_from == "" ) connect_from = optimal_connection_point( pose.residue( jump_pos1 ).name3() );
153  fold_tree->clear();
154  fold_tree->add_edge( jump_pos1, jump_pos2, rb_jump );
155  fold_tree->add_edge( 1, jump_pos1, kinematics::Edge::PEPTIDE );
156  fold_tree->add_edge( jump_pos1, pose.conformation().chain_end( 1 ), kinematics::Edge::PEPTIDE );
157  fold_tree->add_edge( pose.conformation().chain_begin( 2 ), jump_pos2, kinematics::Edge::PEPTIDE );
158  fold_tree->add_edge( jump_pos2, pose.total_residue(), kinematics::Edge::PEPTIDE );
159  TR.Debug<<"CONNECT_FROM: "<<connect_from<<" and CONNECT TO: " <<connect_to<<std::endl;
160 
161  fold_tree->set_jump_atoms( rb_jump, connect_from , connect_to );
162  fold_tree->reorder( 1 );
163  return( fold_tree );
164 }
165 
166 void
168 {
169  if( docking_ft_ ){
170  docking::DockJumps jumps;
171  jumps.clear();
172  jumps.push_back( jump_ );
173  std::string const partners( "_" );
174  protocols::docking::setup_foldtree( pose, partners, jumps );
175  TR<<"Setting up docking foldtree over jump "<<jump_<<'\n';
176  TR<<"Docking foldtree: "<<pose.fold_tree()<<std::endl;
177  return;
178  }
179  if( simple_ft() ){
181  new_ft.clear();
182  core::conformation::Conformation const conf( pose.conformation() );
183  core::Size jump( 1 );
184  for( core::Size chain = 1; chain <= conf.num_chains(); ++chain ){
185  new_ft.add_edge( conf.chain_begin( chain ), conf.chain_end( chain ), -1 );
186  if( chain > 1 ){
187  new_ft.add_edge( conf.chain_begin( chain - 1 ), conf.chain_begin( chain ), jump );
188  jump++;
189  }
190  }
191  new_ft.reorder( 1 );
192  TR<<new_ft<<std::endl;
193  pose.fold_tree( new_ft );
194  TR<<"Simple tree: "<<pose.fold_tree()<<std::endl;
195  return;
196  }
197  if( two_parts_chain1() ){
198  using namespace protocols::geometry;
200  ccm.bond_length( 15.0 );
201  ccm.chain_id( 1 );
202  core::Size const cut( ccm.chain_cut( pose ) );
203  core::Size const CoM1 = (core::Size ) residue_center_of_mass( pose, 1, cut );
204  core::Size const CoM2 = (core::Size ) residue_center_of_mass( pose, cut + 1, pose.conformation().chain_end( 1 ) );
205  core::Size const CoM3 = (core::Size ) residue_center_of_mass( pose, pose.conformation().chain_begin( 2 ), pose.conformation().chain_end( 2 ) );
206  core::Size const CoM1_full_length = (core::Size ) residue_center_of_mass( pose, pose.conformation().chain_begin( 1 ), pose.conformation().chain_end( 1 ) );
207  TR<<"CoM1/CoM2/CoM3/CoM1_full_length/cut: "<<CoM1<<'/'<<CoM2<<'/'<<CoM3<<'/'<<'/'<<CoM1_full_length<<'/'<<cut<<std::endl;
209  new_ft.clear();
210  using namespace std;
211  if( CoM1_full_length <= cut ){
212  new_ft.add_edge( 1, min( CoM1_full_length, CoM1 ), -1 );
213  new_ft.add_edge( min( CoM1_full_length, CoM1 ), max( CoM1_full_length, CoM1 ), -1 );
214  new_ft.add_edge( max( CoM1_full_length, CoM1 ), cut, -1 );
215  new_ft.add_edge( cut + 1, CoM2, -1 );
216  new_ft.add_edge( CoM2, pose.conformation().chain_end( 1 ), -1 );
217  }
218  else{
219  new_ft.add_edge( 1, CoM1, -1 );
220  new_ft.add_edge( CoM1, cut, -1 );
221  new_ft.add_edge( cut + 1, min( CoM2, CoM1_full_length ), -1 );
222  new_ft.add_edge( min( CoM2, CoM1_full_length ), max( CoM2, CoM1_full_length ), -1 );
223  new_ft.add_edge( max( CoM2, CoM1_full_length ), pose.conformation().chain_end( 1 ), -1 );
224  }
225  new_ft.add_edge( pose.conformation().chain_begin( 2 ), CoM3, -1 );
226  new_ft.add_edge( CoM3, pose.conformation().chain_end( 2 ), -1 );
227  new_ft.add_edge( CoM1, CoM2, 1 );
228  new_ft.add_edge( CoM1_full_length, CoM3, 2 );
229  new_ft.delete_self_edges();
230  new_ft.reorder( 1 );
231  TR<<new_ft<<std::endl;
232  pose.fold_tree( new_ft );
233  return;
234  }
235 
236  core::Size const resnum( core::pose::parse_resnum( resnum_, pose ) );
237  core::conformation::Residue const res_central( pose.residue( resnum ) );;
238 
240  if( connect_to_ == "" ){
241  connect_to = optimal_connection_point( res_central.name3() );
242  TR<<"connect_to not defined by user. Defaulting to "<<connect_to<<std::endl;
243  }
244 
245  core::Size anchor_num( 0 );
247  if ( anchor_res_ != "" ) {
248  core::pose::PDBPoseMap const pose_map( pose.pdb_info()->pdb2pose() );
249  char const chain( anchor_res_[ anchor_res_.length() - 1 ] );
250  std::stringstream ss( anchor_res_.substr( 0, anchor_res_.length() - 1 ) );
251  core::Size number;
252  ss >> number;
253  anchor_num = pose_map.find( chain, number );
254  TR<<"anchor_num::: " << anchor_num << "and pdbnum:::" << resnum_ <<std::endl;
255 
256  core::conformation::Residue const res_anchor( pose.residue( anchor_num ) );;
257  if( connect_from_ == "" )
258  connect_from = optimal_connection_point( res_anchor.name3() );
259  } //end anchor reside
260 
261 
262  TR<<"Previous fold tree: "<<pose.fold_tree()<<'\n';
263  pose.fold_tree( *create_atom_tree( pose, host_chain_, resnum, anchor_num , connect_to, connect_from ) );
264  TR<<"New fold tree: "<<pose.fold_tree()<<std::endl;
265 }
266 
270 }
271 
272 } //movers
273 } //protein_interface_design
274 } //protocols
275