Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SeededAbinitio_util.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/seeded_abinitio/SeededAbinitio_util.cc
11 /// @brief
12 /// @author Eva-Maria Strauch ( evas01@u.washington.edu )
13 
14 // Unit Headers
16 
17 // Project Headers
18 #include <core/types.hh>
19 #include <core/pose/Pose.hh>
20 #include <core/pose/PDBPoseMap.hh>
21 #include <core/pose/PDBInfo.hh>
23 
25 //#include <core/chemical/ResidueSelector.hh>
26 //#include <core/chemical/ResidueTypeSet.hh>
27 //#include <core/chemical/ResidueTypeSet.fwd.hh>
28 //#include <core/conformation/ResidueFactory.hh>
30 
31 
36 
37 #include <core/types.hh>
38 #include <basic/Tracer.hh>
39 
40 #include <core/pose/Pose.hh>
41 #include <core/pose/selection.hh>
42 #include <utility/vector1.hh>
43 
44 #include <core/pose/util.hh>
45 #include <core/pose/PDBInfo.hh>
46 
47 //#include <basic/options/keys/in.OptionKeys.gen.hh>
48 //#include <basic/options/option.hh>
49 //#include <core/id/AtomID_Map.hh>
50 //#include <core/import_pose/import_pose.hh>
51 //#include <core/init.hh>
52 //#include <core/io/pdb/pose_io.hh>
53 //#include <core/scoring/rms_util.hh>
54 
57 
58 
59 #include <protocols/loops/Loop.hh>
60 #include <protocols/loops/Loops.hh>
64 #include <protocols/loops/util.hh>
65 
66 //Auto Headers
68 
69 // Utility Headers
70 #include <basic/Tracer.hh>
71 #include <utility/string_util.hh>
72 #include <utility/vector1.hh>
73 #include <utility/tag/Tag.hh>
74 
75 // C++ headers
76 #include <map>
77 #include <algorithm>
78 
79 static basic::Tracer TR( "seeded_abinitio.SeededAbinitio_util" );
80 
81 namespace protocols {
82  namespace seeded_abinitio{
83 
84  using namespace core::scoring;
85  //using namespace protocols::moves;
86  using namespace core;
87  using namespace std;
88  using utility::vector1;
89 
90 
91 /// @brief method to update numbering of a movemap if the pose length was changed previously
92 /// only works if a LengthEventCollector is set in the pose's observer cache
93 ///default behavior is to set everything new to be movable and adjust the numbering of the residues that were previously
94 /// not allowed to move to the appropriate new numbering
95 
96 void
98 
99  TR<<"adjusting the movemap to current numbering of the decoy" <<std::endl;
100 
102  TR<<"WARNING there is no length observer attached to the pose! no adjustments can be made" <<std::endl;
103  return;
104  }
105 
106  //get data from the pose observer
108  pose::datacache::LengthEventCollectorCOP lencollect( utility::pointer::static_pointer_cast< pose::datacache::LengthEventCollector const >( len_obs ) );
109 
110  utility::vector1< core::conformation::signals::LengthEvent > const & events( lencollect->events() );
112 
113  for( Size i =1; i <= events.size(); ++i ){
114  smaps.push_back( core::id::SequenceMapping( events[i] ) );
115  }
117 
118  //make a new movemap in which everything is set to true (set_bb..)
119  //iterate through the movemap and if get_bb (false) adjust that position
120  //replace the old movemap with the new one, assert total residue size with the new mm size and all is good!
121 
123  new_mm->set_bb( false );
124  new_mm->set_chi( false );
125 // new_mm->set_jump( false );
126 
127  for( Size resi = 1; resi <= pose.total_residue(); ++resi ){
128  Size previous_pos ( (*fullsmap)[resi] );
129  TR.Debug<<"previous position "<<previous_pos <<", current residue: " << resi << std::endl;
130 
131  //if the residue didnt exist before
132  if( previous_pos == 0 || !previous_pos) continue;
133 
134  //if the residue was set to NOT move, update the position
135  TR.Debug<<"mm set to: "<< mm->get_bb( previous_pos) << std::endl;
136  if( !mm->get_bb( previous_pos ) ){
137  TR.Debug<<"adjusting NOT movable position to: " << resi <<std::endl;
138  new_mm->set_bb( resi, false );
139  }
140  if( !mm->get_chi( previous_pos ) ){
141  TR.Debug<<"adjusting NOT movable position to: " << resi <<std::endl;
142  new_mm->set_chi( resi, false );
143  }
144  }
145 }
146 
147 //runtime parsing of seeds
149 parse_seeds( core::pose::Pose const & pose, utility::vector1 < std::pair < std::string, std::string > > seed_vector){
150 
151  protocols::loops::Loops tmpseed;
152 
153  for( Size iter = 1 ; iter <= seed_vector.size() ; ++ iter ){
154  TR.Debug<<"sanity check, seed_vector[iter].first " <<seed_vector[iter].first <<std::endl; ////////////
155  core::Size const begin = core::pose::parse_resnum( seed_vector[iter].first, pose ) ;
156  core::Size const end = core::pose::parse_resnum( seed_vector[iter].second, pose );
157  //runtime_assert( end > begin );
158  //runtime_assert( begin>=1);
159  //runtime_assert( end<=pose.total_residue() );
160  tmpseed.add_loop( begin , end , 0, 0, false );
161  }
162  TR.Debug<<"runtime parsed: "<< tmpseed <<std::endl;
163  return tmpseed;
164 }//end parse seeds
165 
166 void
168 
169  core::pose::PoseOP combo_pose = new core::pose::Pose;
170  combo_pose = target_chain;
171 
172  TR<<"new poseOP total number should contain the additional target chain number: " << combo_pose->total_residue();
173 
174  core::pose::PDBInfoOP pdb_info_design( new core::pose::PDBInfo( design_pose ) );
175  core::pose::PDBInfoOP pdb_info_target( new core::pose::PDBInfo( target_chain ) );
176  pdb_info_target->set_chains( 'A');
177  pdb_info_design->set_chains('B');
178 
179  // take the target chain pose and append through a jump the newly folded protein pose
180 
181  TR<< "folded proteins has " << design_pose.total_residue() << " total residues \n";
182  TR<< "the target protein (chain A) has " << target_chain->total_residue() << " total residues "<<std::endl;
183 
184  for ( core::Size i=1; i<=design_pose.total_residue(); ++i ) {
185  core::conformation::ResidueCOP new_rsd = design_pose.residue(i).clone();
186  if ( i == 1 ) {
187  combo_pose->append_residue_by_jump( *new_rsd, combo_pose->total_residue(), "", "", true /*new chain*/ );//anchor and start atomes are not defined, wonder whether the constructor can deal wtih taht
188  }
189  else {
190  combo_pose->append_residue_by_bond( *new_rsd );
191  }
192  }//done adding chain by residues
193 
194  combo_pose->dump_pdb( "target_plus_folded.pdb" );
195  TR.Debug<<" total residues of new pdb: " <<combo_pose->total_residue()<<std::endl;
196 
197  design_pose = *combo_pose;
198 
199 }//end combining
200 
201  /*
202 void
203 dump_pymol( std::string fn ) const {
204  utility::io::ozstream out( fn );
205  if ( out ) {
206  out << "from pymol import cmd\n";
207  for ( Size i=1; i<=size(); i++ ) {
208  out << "cmd.select( \"jumps"<<i<<"\", \"resi "<<jumps_(1,i)<<"+"<<jumps_(2,i)<<"\");" << std::endl;
209  out << "cmd.show( \"sticks\", \"jumps"<<i<<"\");\n";
210  out << "cmd.select( \"cut"<<i<<"\", \"resi " <<cuts_(i)<<"\");\n";
211  out << "cmd.show( \"sphere\",\"cut"<<i<<"\");" << std::endl;
212  }
213  */
214  }
215 }