Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HotspotStubSet.hh
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 /// @author John Karanicolas, Jacob Corn (jecorn@u.washington.edu), Sarel Fleishman
13 
14 
15 #ifndef INCLUDED_protocols_hotspot_hashing_HotspotStubSet_hh
16 #define INCLUDED_protocols_hotspot_hashing_HotspotStubSet_hh
17 
20 #include <core/pose/Pose.fwd.hh>
21 //#include <core/scoring/constraints/ConstraintSet.fwd.hh>
26 #include <core/id/AtomID.fwd.hh>
28 // AUTO-REMOVED #include <core/scoring/constraints/AmbiguousConstraint.fwd.hh>
29 // AUTO-REMOVED #include <core/scoring/constraints/MultiConstraint.fwd.hh>
31 
32 // Utility Headers
33 #include <core/types.hh>
34 #include <utility/pointer/ReferenceCount.hh>
35 #include <utility/pointer/owning_ptr.fwd.hh>
36 #include <utility/exit.hh>
37 // AUTO-REMOVED #include <utility/io/izstream.hh>
38 // AUTO-REMOVED #include <utility/io/ozstream.hh>
39 
40 // C++ Headers
41 #include <map>
42 #include <vector>
43 #include <set>
44 
45 #include <utility/vector1.hh>
46 #include <utility/io/ozstream.fwd.hh>
47 
48 
49 #ifdef WIN32
50 #include <core/scoring/constraints/Constraint.hh> // WIN32 INCLUDE
51 #endif
52 
53 namespace protocols {
54 namespace hotspot_hashing {
55 typedef platform::Size Size;
56 
58 public:
59  typedef std::multimap< core::Real, HotspotStubOP > Hotspots;
60  typedef std::map< std::string, Hotspots > Hs_map;
61  typedef std::pair< std::string, std::pair< core::Real, HotspotStubOP > > Hs_data;
62 // for iterator type access of stubs
63  typedef std::vector< Hs_data > Hs_vec;
64  typedef Hs_vec::iterator iterator;
65  typedef Hs_vec::const_iterator const_iterator;
66 public:
67 
70  virtual ~HotspotStubSet();
71  void clear();
72 
73 //iterator functions
74 // iterators
76  runtime_assert( stub_set_vec_.size() == size() );
77  return stub_set_vec_.begin();
78  }
79  inline HotspotStubSet::const_iterator end() const { return stub_set_vec_.end(); }
81  runtime_assert( stub_set_vec_.size() == size() );
82  return stub_set_vec_.begin();
83  }
84  inline HotspotStubSet::iterator end(){ return stub_set_vec_.end(); }
85 
86  /// @brief set length of hotspot peptide used for finding stubs. Default=1, Hotspot stored in set will always be only 1 residue
87  Size hotspot_length( ) const;
88  void hotspot_length( Size const length );
89 
90  /// @brief returns a new stub_set with stub scores recalculated by colony energy (Xiang, Soto, and Honig PNAS 2002)
92  /// @brief cluster stubs, returning a new stubset of cluster centers for each residue
94 
95  /// @brief retrieve all stubs with a given residue name
96  Hotspots retrieve( std::string const & residue_name3 );
97 
98  /// @brief gets a stub from the stub_set_. A version returning an OP is private
99  HotspotStubOP get_stub( std::string const residue_name3, core::Real const score ) const;
100  // @brief build a new stubset containing stubs with a given residue name3 and score cutoff
101  HotspotStubSetOP subset( std::string const & residue_name3, core::Real const scorecut );
102  /// @brief build a new stubset containing stubs that pass a score cutoff
103  HotspotStubSetOP subset( core::Real const scorecut ) const;
104 
105  /// @brief gets the best energy stub in the set
107  /// @brief get the stub that's nearest to a residue
109  /// @brief finds neighbors to stub based on distance between atoms.
110  std::set< std::pair< std::string, core::Real > > find_neighboring_stubs( HotspotStubCOP stub ) const;
111  /// @brief removes neighbors of stub based on repulsive energy between the pair of residues
112  void remove_stubs_from_set( std::set< std::pair< std::string, core::Real > > const );
113  void remove_random_stubs_from_set( int const num_to_remove );
114  ///@brief removes a single stub. Reports false if stub is not found
115  bool remove_stub( HotspotStubCOP stub );
116 
117  /// @brief add to stubset by reading from a file
118  void read_data( std::string const filename );
119  // unfortunately, this won't compile on Windows with the BOINC libraries. Ask
120  // tex for more information.
121  //void read( std::string const filename );
122 
123  /// @brief fill the stub set with n_stubs by Rosetta residue name
124  void fill( core::pose::Pose const & reference_pose, core::scoring::ScoreFunctionCOP scorefxn_in, std::string const residue_name3, Size const n_stubs );
125  /// @brief only keep stubs within a certain distance of a residue on the target pose.
126  void fill( core::pose::Pose const & reference_pose, core::scoring::ScoreFunctionCOP scorefxn_in, core::Size const target, core::Real const distance, std::string const residue_name3, Size const n_stubs );
127 
128  /// @brief rescore all stubs in this set based on current flags (eg - sc_only() )
130 
131 
132  /// @brief fill the stub set with n_stubs each of A, R, N, D, E, Q, H, I, L, K, M, P, F, S, T, W, Y, and V
133  void autofill ( core::pose::Pose const & pose, core::scoring::ScoreFunctionCOP scorefxn, Size const n_stubs );
134  void autofill( core::pose::Pose const & pose, core::scoring::ScoreFunctionCOP scorefxn, core::Size const target, core::Real const distance, Size const n_stubs );
135 
136  /// @brief only accept stubs that score better than this threshold (default is -1.0)
137  void score_threshold( core::Real const threshold );
138 
139  /// @brief write all stubs contained in this set to filename
140  void write_all( std::string const & filename ) const;
141  /// @brief write one stub with a user-supplied tag
142  void write_stub( utility::io::ozstream & outstream, HotspotStubCOP stub, std::string const & tag ) const;
143 
144  /// @brief associate all stubs in the set with a scaffold partner
145 //SJF does it make sense to associate the entire stubset with a filter? The filter is going to change ALL the time.
147  /// @brief set the filter to use for scaffold matching within this set
149 
150  /// @brief true if these stubs are sidechain-only (defaults true)
151  bool sc_only() const;
152 
153  /// @brief set whether or not sidechains are included
154  void sc_only( bool sc_switch );
155 
156 
157  /// @brief how many total stubs are in the set (all residues)?
158  core::Size size() const;
159  /// @brief how many stubs are in the set by residue?
160  core::Size size( std::string const resname );
161 
162  /// @brief returns a random stub either from the entire set or based on residue name
164  HotspotStubOP random_stub( std::string const resname );
165 
166  /// @brief Sets up constraints using a given partner (auto choose packer task and fixed reference atom)
168  core::pose::Pose & pose,
169  core::Size const partner,
170  HotspotStubSetOP hotspot_stub_set,
171  core::Real const & CB_force_constant,
172  core::Real const & worst_allowed_stub_bonus,
173  bool const apply_self_energies,
174  core::Real const & bump_cutoff,
175  bool const apply_ambiguous_constraints = false
176  );
177 
178  /// @brief Sets up constraints with user-supplied packer task and fixed reference atom
180  core::pose::Pose & pose,
181  core::id::AtomID const & fixed_atom,
182  core::pack::task::PackerTaskCOP const packer_task,
183  HotspotStubSetOP hotspot_stub_set,
184  core::Real const & CB_force_constant,
185  core::Real const & worst_allowed_stub_bonus, // = 0.
186  bool const apply_self_energies,
187  core::Real const & bump_cutoff,
188  bool const apply_ambiguous_constraints = false
189  );
190 
191  /// @brief remove all ambiguous constraints that contain backbone_stub_constraints from the supplied pose
193  void set_chain_to_design( core::Size const chain_to_design = 2 );
194  // Constraint creation methods
196  core::pose::Pose const & pose,
197  core::Size const chain_to_redesign = 2
198  );
199 
200  /// @brief return bbcst's associatied with this stub set
202 
203  void add_stub_( HotspotStubCOP stub );
204  void add_stub_set( HotspotStubSet const & stubset );
205 private:
206  friend class HotspotStub;
207  // Stub data storage
208  // This was previously a map of multisets, but multisets only allow const iteration (even if you use a normal iterator)
209  // The use of a map of multimaps allows us to make changes to the stub_status, but somewhat obscures stub iteration
210  // So when iterating over a retrieved stubset, be sure you get the second element
212  Hs_vec stub_set_vec_; // A mirror of the data in stub_set_ for easier iterator access
213  bool sc_only_;
214  core::Size target_resnum_; // resnum to use for focused hashing
215  core::Real target_distance_; // radius from resnum for focused hashing
216 
219  core::Real score_threshold_; // only accept stubs with this score or better
221  Size hotspot_length_; // length of peptide to use for hotspot searching (polyAla, except for central hotspot). only hotspot itself is scored/stored in the set.
222 
223 
224 /// @brief clears stub_set_vec_ and inserts all the elements in stub_set_ to it.
225  void handshake_stub_sets( void );
226 
228 
229 
230  // predicate for keeping the multiset sorted by bonus value
231  // obsolete, since we're now using a multimap
232 /* struct stubsort_pred_
233  {
234  bool operator () ( HotspotStub const & left, HotspotStub const & right )
235  {
236  return left.bonus_value() < right.bonus_value();
237  }
238  };
239 */
240  // Stub creation methods
241  //void dock_residue_lowres_ ( core::pose::Pose & pose, platform::Size const jump_number ) ;
242  //void dock_residue_highres_ ( core::pose::Pose & pose, core::scoring::ScoreFunctionOP scorefxn, Size const jump_number ) ;
243  void create_hotspot_after_pose ( core::pose::Pose & pose, std::string const & resname ) ;
244  void setup_hotspot_foldtree_ ( core::pose::Pose & pose ) ;
245  /// @brief utility function to find distance of stub from the end of the pose.
247 
248  core::Real get_residue_score_ ( core::pose::Pose const & pose, core::scoring::ScoreFunctionCOP scorefxn, Size const seqpos) ;
249 
251  core::conformation::Residue const & placed_stub_residue,
252  core::pose::Pose const & unbound_pose,
253  core::Size const resnum,
254  core::scoring::TenANeighborGraph const & unbound_neighbor_graph,
255  core::scoring::ScoreFunctionCOP const & bump_scorefxn,
256  core::Real const & max_bump_energy
257  );
258 
260  core::conformation::Residue const & stub_residue,
261  core::pose::Pose const & unbound_pose,
262  core::Size const resnum,
263  core::scoring::TenANeighborGraph const & unbound_neighbor_graph,
264  core::scoring::ScoreFunctionCOP const & full_scorefxn
265  );
266 
268 
269  /// @brief gets a stub from the stub_set_
270 };
271 
272 /// @brief utility function for deleting all backbone stub constraints from a pose.
273 /// Returns the removed constraints (ambiguous).
276 
277 /// @brief utility function to calculate per-residue sidechain rmsd without superposition
279 
280 /// @brief utility function to make sure stub's Cbeta is not pointed away from the target.
282 
283 
284 } // namespace hotspot_hashing
285 } // namespace protocols
286 
287 
288 #endif