Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MembraneJump.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
11 /// @brief
12 /// @detailed
13 /// @author Bjorn Wallner
14 /// @author Christopher Miles (cmiles@uw.edu)
15 
16 // Unit Headers
21 
22 // Project Headers
25 #include <core/id/NamedStubID.hh>
26 #include <core/kinematics/Jump.hh>
27 #include <core/pose/Pose.hh>
28 #include <core/pose/util.hh>
30 #include <basic/datacache/BasicDataCache.hh>
33 
34 // ObjexxFCL Headers
35 #include <ObjexxFCL/FArray1D.hh>
36 #include <ObjexxFCL/FArray2D.hh>
37 
38 // Utility headers
39 #include <basic/Tracer.hh>
40 #include <utility/vector1.hh>
41 
42 // numeric headers
43 #include <numeric/random/random.hh>
44 #include <numeric/xyzVector.hh>
45 
46 // C++ headers
47 #include <cstdlib>
48 #include <string>
49 
50 
51 namespace protocols {
52 namespace jumping {
53 
54 /// @details Auto-generated virtual destructor
56 using namespace core;
57 using namespace fragment;
58 static basic::Tracer tr("protocols.jumping.MembraneJump");
59  static numeric::random::RandomGenerator RG(750107); // <- Magic number, do not change it!
60 
62 {
63  template_size_=0;
64  pairings_size_=0;
65 }
66 
67 void
68 MembraneJump::init(std::string const& template_file,std::string const& pairings_file) {
69  templates_.read_from_file_no_filters(template_file);
70  read_pairing_list( pairings_file, pairings_);
71  template_size_=templates_.size();
72  pairings_size_=pairings_.size();
73 
74 }
75 
76 //this function will setup a fold tree to be used consisting of njumps using the info in templates_ and pairings_
77 void
79 {
80  using namespace ObjexxFCL;
81  //using core::pose::datacache::CacheableDataType::MEMBRANE_TOPOLOGY;
82 
83  if(pairings_.size()==0)
84  return;
85  std::cout << "setting up fold_tree with " << njumps << " jump(s)\n";
86  Size nres=pose.total_residue();
88  Size tries(0);
89  core::scoring::MembraneTopology const & topology(*( static_cast< core::scoring::MembraneTopology const * >( pose.data().get_const_ptr( core::pose::datacache::CacheableDataType::MEMBRANE_TOPOLOGY )() )));
90  core::scoring::dssp::PairingList selected_pairings;
91  FArray1D_int tmh(pose.total_residue());
92  FArray1D_int tmh2(pose.total_residue(),0);
93  Size total_tmhelix(topology.tmhelix());
94  FArray1D_bool tmh_involved_in_jump(total_tmhelix,false);
95 
96  for ( Size j = 1; j <= pose.total_residue(); ++j ) {
97  //bw change definition of membrane region to include jumps to non-tmh.
98  if(j<=topology.span_end(1)) //membrane_helix(1,2))
99  {
100  tmh(j)=1;
101  } else if(j>topology.span_end(total_tmhelix)) {
102  tmh(j)=total_tmhelix;
103  }
104  else
105  {
106  for ( Size reg = 2; reg <= total_tmhelix; ++reg ) {
107  if(j>topology.span_end(reg-1) && j<=topology.span_end(reg)) //membrane_helix( reg-1, 2 ) && j<=membrane_helix(reg,2))
108  {
109  tmh(j)=reg;
110  }
111  }
112  }
113  }
114  for ( Size i = 1; i <= pose.total_residue(); ++i ) {
115  for ( Size j = 1; j <= total_tmhelix; ++j ) {
116  if(i>topology.span_begin(j) && i < topology.span_end(j)) {
117  tmh2(i)=j;
118  }
119  }
120  }
121 
122  while(selected_pairings.size()<njumps && tries < 10) {
123  Size index=static_cast< int >(RG.uniform()*pairings_.size()+1);
124  std::cout << "Tries : " << tries << " " << index << ' ' << pairings_[index].Pos1() << ' ' << tmh(pairings_[index].Pos1()) << ' ' << pairings_[index].Pos2() << ' ' << tmh(pairings_[index].Pos2()) <<std::endl;
125  bool check_compatible=true;
126 
127  {
128  if(tmh_involved_in_jump(tmh(pairings_[index].Pos1())) ||
129  tmh_involved_in_jump(tmh(pairings_[index].Pos2()))){
130  check_compatible=false;
131  }
132  }
133  for (Size j = 1; j <= selected_pairings.size(); ++j) {
134  if(selected_pairings[j].Pos1() == pairings_[index].Pos1() &&
135  selected_pairings[j].Pos2() == pairings_[index].Pos2()) // already in a jump
136  {
137  check_compatible=false;
138  }
139  }
140 
141  if(check_compatible)
142  {
143  selected_pairings.push_back(pairings_[index]);
144  tmh_involved_in_jump(tmh(pairings_[index].Pos1()))=true;
145  tmh_involved_in_jump(tmh(pairings_[index].Pos2()))=true;
146  }
147  ++tries;
148  }
149  if(selected_pairings.size()<njumps)
150  {
151  std::cout << "WARNING: Only picked " << selected_pairings.size() << " given number was " << njumps << " only allow one jump between any two TMHs " << std::endl;
152  }
153  FArray2D_int jumps(2,selected_pairings.size());
154  for(Size i=1;i<=selected_pairings.size();++i) {
155  jumps(1,i)=selected_pairings[i].Pos1();
156  jumps(2,i)=selected_pairings[i].Pos2();
157  }
158  FArray1D_float cut_bias(nres,0.0);
159  for ( Size i = 1; i <= pose.total_residue(); ++i ) {
160  if(tmh2(i)==0) {
161  cut_bias(i)=1;
162  }
163  }
164 
165  int num_jumps_in=selected_pairings.size();
166  f.random_tree_from_jump_points(nres,num_jumps_in,jumps,cut_bias);
168 
169  std::cout << f;
170  pose.fold_tree(f);
171 
172  for(Size i=1;i<=selected_pairings.size();++i) {
173  Size p1=selected_pairings[i].Pos1();
174  Size p2=selected_pairings[i].Pos2();
175 
176  core::kinematics::RT rt(templates_.get_random_tmh_jump(selected_pairings[i].Orientation(),p1,p2));
177  id::StubID up_stub( core::pose::named_stub_id_to_stub_id( core::id::NamedStubID( "CA","N","CA","C", p1 ), pose ) );
178  id::StubID down_stub( core::pose::named_stub_id_to_stub_id( core::id::NamedStubID( "CA","N","CA","C", p2 ), pose ) );
179  pose.conformation().set_stub_transform( up_stub, down_stub, rt );
182  }
183 }
184 
185 } //jumping
186 } //protocols