Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StepWiseBetaAntiParallelUtil.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 StepWiseBetaAntiParallelJumpSampleGenerator
11 /// @brief Subclass of StepWisePoseSampleGenerator
12 /// @detailed
13 /// @author Rhiju Das
14 
15 
16 //////////////////////////////////
20 #include <utility/io/ozstream.hh>
21 // AUTO-REMOVED #include <utility/io/izstream.hh>
23 // AUTO-REMOVED #include <core/chemical/util.hh>
25 #include <core/id/NamedAtomID.hh>
26 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
28 #include <core/pose/Pose.hh>
29 
30 #include <core/pose/util.hh>
31 
33 
36 
39 // AUTO-REMOVED #include <core/scoring/ScoringManager.hh>
42 #include <basic/options/option.hh>
43 // AUTO-REMOVED #include <basic/options/after_opts.hh>
44 // AUTO-REMOVED #include <basic/options/util.hh>
45 #include <basic/options/keys/out.OptionKeys.gen.hh>
46 // AUTO-REMOVED #include <basic/options/keys/score.OptionKeys.gen.hh>
47 #include <basic/options/keys/cluster.OptionKeys.gen.hh>
48 #include <numeric/xyz.functions.hh>
49 
50 #include <ObjexxFCL/string.functions.hh>
51 
52 #include <iostream>
53 #include <string>
54 
55 //Auto Headers
57 #include <utility/vector1.hh>
58 
59 
60 
61 using namespace core;
62 
63 namespace protocols {
64 namespace swa {
65 namespace protein {
66 
67  ////////////////////////////////////////////////////////
68  // Move ths out of stepwise_protein_test.cc!!
69  ////////////////////////////////////////////////////////
70  ///////////////////////////////////////////////////////////////////////
71  void
72  do_set_xyz( pose::Pose const & pose, Size const i, pose::Pose & scratch_pose, Size const i_scratch, core::kinematics::Stub const & stub ) {
73 
74  using namespace core::id;
75  using namespace core::chemical;
76 
77  scratch_pose.set_xyz( NamedAtomID( " CA ", i_scratch), stub.global2local( pose.xyz( NamedAtomID( " CA ", i) ) ) );
78  scratch_pose.set_xyz( NamedAtomID( " N ", i_scratch), stub.global2local( pose.xyz( NamedAtomID( " N ", i) ) ) );
79  scratch_pose.set_xyz( NamedAtomID( " C ", i_scratch), stub.global2local( pose.xyz( NamedAtomID( " C ", i) ) ) );
80  scratch_pose.set_xyz( NamedAtomID( " O ", i_scratch), stub.global2local( pose.xyz( NamedAtomID( " O ", i) ) ) );
81 
82  if ( pose.residue_type(i).has( " H " ) ){
83  scratch_pose.set_xyz( NamedAtomID( " H ", i_scratch), stub.global2local( pose.xyz( NamedAtomID( " H ", i) ) ) );
84  } else if ( pose.residue_type(i).has( " H1 " ) ){
85  scratch_pose.set_xyz( NamedAtomID( " H ", i_scratch), stub.global2local( pose.xyz( NamedAtomID( " H1 ", i) ) ) );
86  }
87 
88  if ( pose.residue_type(i).has( "1HA " ) ){
89  scratch_pose.set_xyz( NamedAtomID( "1HA ", i_scratch), stub.global2local( pose.xyz( NamedAtomID( "1HA ", i) ) ) );
90  } else if ( pose.residue_type(i).has( " HA " ) ){
91  scratch_pose.set_xyz( NamedAtomID( "1HA ", i_scratch), stub.global2local( pose.xyz( NamedAtomID( " HA ", i) ) ) );
92  }
93 
94  if ( pose.residue_type(i).has( "2HA " ) ){
95  scratch_pose.set_xyz( NamedAtomID( "2HA ", i_scratch), stub.global2local( pose.xyz( NamedAtomID( "2HA ", i) ) ) );
96  } else if ( pose.residue_type(i).has( " CB " ) ){
97  scratch_pose.set_xyz( NamedAtomID( "2HA ", i_scratch), stub.global2local( pose.xyz( NamedAtomID( " CB ", i) ) ) );
98  }
99 
100 
101  }
102 
103 
104  ////////////////////////////////////////////////////////
105  // Move ths out of stepwise_protein_test.cc!!
106  ////////////////////////////////////////////////////////
107  ///////////////////////////////////////////////////////////////////////
108  void
110 
111  using namespace basic::options;
112  using namespace basic::options::OptionKeys;
113  using namespace core::scoring;
114  using namespace core::scoring::hbonds;
115  using namespace core::chemical;
116  using namespace core::kinematics;
117  using namespace core::pose;
118  using namespace core::conformation;
119  using namespace core::id;
120  using namespace core::io::silent;
121 
122  static ScoreFunctionOP scorefxn = getScoreFunction();
123  ResidueTypeSetCAP rsd_set;
125 
126  Pose pose, scratch_pose;
127 
128  // little pose will be used to output beta geometries.
129  std::string sequence = "GG";
130  core::pose::make_pose_from_sequence( scratch_pose, sequence, *rsd_set );
131  FoldTree f( scratch_pose.fold_tree() );
132 
133  f.new_jump(1,2,1);
134  f.set_jump_atoms( 1, " CA ", " CA ", true /*bKeepStubInResidue. I think this is still protein-centric*/ );
135  f.reassign_atoms_for_intra_residue_stubs(); // it seems silly that we need to do this separately.
136  scratch_pose.fold_tree( f );
137 
140 
141  // main loop
143 
144  SilentFileDataOP silent_file_data = new SilentFileData;
145  std::string const silent_file( option[ out::file::silent ]() );
146 
147  Size count( 0 );
148  for ( Size n = 1; n <= in_files.size(); n++ ) {
149 
150  std::cout << "-------- " << in_files[n] << "----------" << std::endl;
151  import_pose::pose_from_pdb( pose, *rsd_set, in_files[ n ] );
152 
153  // Look for beta pairings (antiparallel for now)
154  (*scorefxn)(pose);
155  HBondOptionsOP hbond_options( new hbonds::HBondOptions() );
156  hbond_options->use_hb_env_dep( false );
157  HBondSetOP hbond_set( new hbonds::HBondSet( hbond_options ) );
158 
159  fill_hbond_set( pose, false /*calc deriv*/, *hbond_set );
160 
161  std::map< std::pair< Size, Size >, bool > donor_to_acceptor_bb_hb;
162 
163  // In antiparallel HB, there are two hbonds between the residue backbones:
164  // C=O ... HN and a NH ... O=C
165 
166  for (Size i = 1; i <= hbond_set->nhbonds(); i++ ) {
167  hbonds::HBond const & hbond( hbond_set->hbond( i ) );
168 
169  Size const don_res_num = hbond.don_res();
170  Size const acc_res_num = hbond.acc_res();
171 
172  if ( hbond.don_hatm_is_protein_backbone() && hbond.acc_atm_is_protein_backbone() ) {
173  donor_to_acceptor_bb_hb[ std::make_pair( don_res_num, acc_res_num ) ] = true;
174  }
175 
176  }
177 
178  for ( Size i = 1; i <= pose.total_residue(); i++ ){
179  for ( Size j = 1; j <= pose.total_residue(); j++ ){
180  if ( donor_to_acceptor_bb_hb[ std::make_pair( i, j ) ] &&
181  donor_to_acceptor_bb_hb[ std::make_pair( j, i ) ] ){
182  //Create a coordinate system at residue i,
183  Stub stub( pose.xyz( NamedAtomID( " CA ", i ) ),
184  pose.xyz( NamedAtomID( " CA ", i ) ),
185  pose.xyz( NamedAtomID( " N ", i ) ),
186  pose.xyz( NamedAtomID( " C ", i ) ) );
187 
188  // spit out coordinates.
189  do_set_xyz( pose, i, scratch_pose, 1, stub );
190  do_set_xyz( pose, j, scratch_pose, 2, stub );
191 
192  count++;
193 
194  std::string const tag = "S_"+ObjexxFCL::string_of( count );
195  (*scorefxn)( scratch_pose );
196  BinaryProteinSilentStruct s( scratch_pose, tag );
197 
198  silent_file_data->write_silent_struct( s, silent_file, false /*write score only*/ );
199  silent_file_data->add_structure( s );
200 
201  }
202  }
203  }
204 
205  }
206 
207  /////////////////////////////////////////////////////////////////////
208  // CLUSTER!
209  /////////////////////////////////////////////////////////////////////
210  protocols::swa::StepWiseClusterer stepwise_clusterer( silent_file_data );
211  Size max_decoys( 400 );
212  if ( option[ out::nstruct].user() ) max_decoys = option[ out::nstruct ];
213  stepwise_clusterer.set_max_decoys( max_decoys );
214  // stepwise_clusterer.set_cluster_by_all_atom_rmsd( option[ cluster_by_all_atom_rmsd ] ); // false by default
215  stepwise_clusterer.set_rename_tags( true /*option[ rename_tags ]*/ );
216  stepwise_clusterer.set_score_diff_cut( 10.0 );
217 
218  // Do not superimpose inside the clusterer -- trust our superposition over residue 1.
219  utility::vector1< Size > calc_rms_residues;
220  calc_rms_residues.push_back( 1 );
221  calc_rms_residues.push_back( 2 );
222  stepwise_clusterer.set_calc_rms_res( calc_rms_residues );
223 
224  Real cluster_radius( 0.1 );
225  if ( option[ OptionKeys::cluster::radius ].user() ) cluster_radius = option[ OptionKeys::cluster::radius ]();
226  stepwise_clusterer.set_cluster_radius( cluster_radius );
227 
228  stepwise_clusterer.cluster();
229 
230  std::string const silent_file_cluster = get_file_name( silent_file, "_cluster" );
231  stepwise_clusterer.output_silent_file( silent_file_cluster );
232 
233  /////////////////////////////////////////////////////////////////////
234  // Output jump information
235  /////////////////////////////////////////////////////////////////////
236  std::string outfile = option[ out::file::o ];
237  utility::io::ozstream out( outfile );
238 
239  using namespace protocols::swa;
240  PoseList const & pose_list = stepwise_clusterer.clustered_pose_list();
241 
242  for ( PoseList::const_iterator it = pose_list.begin(); it != pose_list.end(); it++ ){
243  pose = *(it->second);
244  Stub stub1_forward( pose.xyz( NamedAtomID( " N ", 1) ),pose.xyz( NamedAtomID( " CA ", 1) ),pose.xyz( NamedAtomID( " C ", 1) ));
245  Stub stub1_reverse( pose.xyz( NamedAtomID( " C ", 1) ),pose.xyz( NamedAtomID( " CA ", 1) ),pose.xyz( NamedAtomID( " N ", 1) ));
246 
247  Stub stub2_forward( pose.xyz( NamedAtomID( " N ", 2) ),pose.xyz( NamedAtomID( " CA ", 2) ),pose.xyz( NamedAtomID( " C ", 2) ));
248  Stub stub2_reverse( pose.xyz( NamedAtomID( " C ", 2) ),pose.xyz( NamedAtomID( " CA ", 2) ),pose.xyz( NamedAtomID( " N ", 2) ));
249 
250  out << "A N N " << Jump( stub1_forward, stub2_forward ) << std::endl;
251  out << "A N C " << Jump( stub1_forward, stub2_reverse ) << std::endl;
252  out << "A C N " << Jump( stub1_reverse, stub2_forward ) << std::endl;
253  out << "A C C " << Jump( stub1_reverse, stub2_reverse ) << std::endl;
254 
255  }
256 
257  out.close();
258 
259  std::cout << "Put JUMP transforms in " << outfile << std::endl;
260 
261  }
262 
263 
264 
265 }
266 }
267 }