Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LoopFinder.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 
11 /// @file protocols/protein_interface_design/LoopFinder.cc
12 /// @brief Finds loops and adds them to the DataMap. Parseable options to control how loops are found
13 /// @author Jacob Corn (jecorn@u.washington.edu)
14 
15 // Unit headers
18 
19 // Package headers
21 #include <core/pose/selection.hh>
22 
23 // Project headers
24 #include <core/pose/Pose.hh>
28 
29 #include <protocols/loops/Loop.hh>
30 #include <protocols/loops/Loops.hh>
31 // AUTO-REMOVED #include <protocols/loops/util.hh>
33 
34 
35 // Numeric headers
36 #include <numeric/xyzVector.hh>
37 
38 
39 // the following must be included because LoopFinder is derived from DRMover
41 //#include <core/pose/Pose.hh>
44 
46 #include <utility/vector0.hh>
47 #include <utility/vector1.hh>
48 #include <utility/tag/Tag.hh>
49 #include <basic/Tracer.hh>
50 
51 //Auto Headers
53 
54 
55 
56 
57 namespace protocols {
58 namespace protein_interface_design {
59 namespace movers {
60 
61 using namespace protocols::moves;
62 
63 static basic::Tracer TR( "protocols.protein_interface_design.movers.LoopFinder" );
64 
67 {
69 }
70 
73  return new LoopFinder;
74 }
75 
78 {
79  return "LoopFinder";
80 }
81 
83  simple_moves::DesignRepackMover( LoopFinderCreator::mover_name() )
84 {}
85 
87  bool const interface,
88  bool const ch1,
89  bool const ch2,
90  core::Size const min_length,
91  core::Size const max_length,
92  core::Size const mingap,
93  core::Size const resnum,
94  core::Real const ca_ca_distance,
95  core::Real const iface_cutoff,
97 ) :
98  simple_moves::DesignRepackMover( LoopFinderCreator::mover_name() ),
99  interface_(interface),
100  ch1_(ch1),
101  ch2_(ch2),
102  min_length_(min_length),
103  max_length_(max_length),
104  mingap_( mingap ),
105  resnum_( resnum ),
106  ca_ca_distance_( ca_ca_distance ),
107  iface_cutoff_(iface_cutoff)
108 {
109  loops_ = new protocols::loops::Loops( *loops );
110 }
111 
113 
115  return( protocols::moves::MoverOP( new LoopFinder( *this ) ) );
116 }
117 
118 void
120 {
121  using namespace protocols::loops;
122 
124  iface.distance( iface_cutoff_ );
125  if( interface_ ) {
126  iface.jump( interface_ );
127  iface.calculate( pose );
128  }
129 
130  LoopsOP all_loops( new Loops );
131  LoopsOP temp_loops( new Loops );
132  LoopsOP ch1ch2_loops( new Loops );
133  LoopsOP ch1_loops( new Loops );
134  LoopsOP ch2_loops( new Loops );
135  loopfinder( pose, *all_loops ); // runs dssp, inserts ss into the pose, and extracts all loops at least 3 residues long
136 
137  // all loops, no restrictions
138  if( !interface_ && ch1_ && ch2_ && (max_length_ >= 1000) && (min_length_ <= 1) && (mingap_ == 0) ) {
139  loops_ = all_loops ;
140  return;
141  }
142 
143  if( all_loops->size() > 0 ) {
144  for( Loops::const_iterator it = all_loops->begin(); it != all_loops->end(); ++it ) {
145  LoopCOP loop( new Loop(*it) );
146  if( pose.residue( loop->start() ).is_upper_terminus() || pose.residue( loop->stop() ).is_lower_terminus() ) continue; // skip if terminal loop
147  if( loop->size() < min_length_ || loop->size() > max_length_ ) continue; // skip this loop
148 
149  // look at all residues in each loop.
150  // do we want interface residues?
151  // if so, go through all residues of each loop, checking whether interfacial and which chain it's in.
152  // if not, only end up looking at 1st residue in loop to check which chain it's in (break statements prevent multiple addition)
153 
154  for( core::Size i = loop->start(); i <= loop->stop(); ++i ) {
155  if( interface_ ) {
156  // if even one residue is at the interface, count whole loop as interface for purposes of aggressive remodeling
157  if( !iface.is_interface(i) ) continue;
158  }
159 
160  if( resnum_ > 0) {
161  TR.Debug <<"residue : " << resnum_ << " was specified" << std::endl;
162  if( pose.residue( i ).xyz( "CA" ).distance( pose.residue( resnum_ ).xyz( "CA" ) ) < ca_ca_distance_ ) {
163  TR.Debug<< "residue is within " << ca_ca_distance_ << " of the specified target chain(s)" << std::endl;
164  }
165  else {
166  TR.Debug<<"residue is not within " << ca_ca_distance_ << " of this loop residue " << std::endl;
167  break;
168  }
169  }
170  if( ch1_ && ch2_ ) {
171  ch1ch2_loops->add_loop( *loop, mingap_ );
172  break;
173  }
174  if( ch1_ ) {
175  if( pose.residue(i).chain() == 1 ) ch1_loops->add_loop( *loop, mingap_ );
176  break;
177  }
178  if( ch2_ ) {
179  if( pose.residue(i).chain() == 2 ) ch2_loops->add_loop( *loop, mingap_ );
180  break;
181  }
182  else TR << "Neither chain1 nor chain2 specified for loop finding. No loops added!" << std::endl;
183  }
184  }
185  TR.Debug << "ch1ch2 loops " << *ch1ch2_loops << std::endl;
186  TR.Debug << "ch1 loops " << *ch1_loops << std::endl;
187  TR.Debug << "ch2 loops " << *ch2_loops << std::endl;
188  if( ch1_ && ch2_ ) *loops_ = *ch1ch2_loops ; // copy, rather than change pointer address
189  else if( ch1_ ) *loops_ = *ch1_loops ;
190  else if( ch2_ ) *loops_ = *ch2_loops ;
191  //runtime_assert( data_->has( "loops", "loops" ) );
192  }
193  else
194  TR << "No loops found." << std::endl;
195 }
196 
200 }
201 
202 
203 void
205 {
206  interface_ = tag->getOption<Size>( "interface", 1 );
207  ch1_ = tag->getOption<bool>( "ch1", 0 );
208  ch2_ = tag->getOption<bool>( "ch2", 1 );
209  min_length_ = tag->getOption<core::Size>( "min_length", 3 );
210  max_length_ = tag->getOption<core::Size>( "max_length", 1000 );
211  iface_cutoff_ = tag->getOption<core::Real>( "iface_cutoff", 8.0 );
212  runtime_assert( ch1_ || ch2_ );
213  if( interface_ ) runtime_assert( pose.num_jump() >= 1 );
214  mingap_ = tag->getOption<core::Size>( "mingap", 1 );
215  if( tag->hasOption( "resnum" ) || ( tag->hasOption( "pdb_num" ) )) {
216  resnum_ = core::pose::get_resnum( tag, pose );
217  TR<<"user specified residue " << resnum_ << " for distance cutoff" << std::endl;
218 
219  }
220  else {
221  resnum_ = 0;
222  TR<<"no target residue has been specified"<< std::endl;
223  }
224  ca_ca_distance_ = tag->getOption<core::Real>( "CA_CA_distance", 15 );
225  if( resnum_ != 0 ) TR<<"distance cutoff from user defined residue is " << ca_ca_distance_ << std::endl;
226 
227  // add loopsOP to the DataMap
229  data.add( "loops", "found_loops", loops_ );
230 
231  TR << "LoopFinder mover: interface="<<interface_<<" iface_cutoff="<<iface_cutoff_<<" ch1="<<ch1_<<" ch2="<<ch2_<<" min_length="<<min_length_<<
232  " max_length="<<max_length_<< std::endl;
233 
234 }
235 
236 } //movers
237 } //protein_interface_design
238 } //protocols