Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Fingerprint.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 protocols/pockets/Fingerprint.hh
11 /// @brief protocols::pockets::Fingerprint header
12 /// @author Ragul Gowthaman
13 
14 #ifndef INCLUDED_protocols_pockets_Fingerprint_hh
15 #define INCLUDED_protocols_pockets_Fingerprint_hh
16 
17 #include <utility/pointer/ReferenceCount.hh>
22 #include <core/types.hh>
23 #include <core/pose/Pose.hh>
25 #include <numeric/constants.hh>
26 #include <numeric/xyzVector.hh>
27 #include <utility/vector1_bool.hh>
28 #include <list>
29 #include <cmath>
30 #include <iostream>
31 #include <utility/vector1.hh>
32 #include <basic/gpu/GPU.hh>
33 
34 #define NUMBER_OF_PARTICLES 200
35 #define ATOMS_ARRAY 20000
36 #define RAY_SCORE_ARRAY 2500000
37 #define MAX_NUM_RAYS 100000
38 
39 namespace protocols {
40 namespace pockets {
41 
42  typedef struct {
43  // note: these are in radians
48 
49  typedef struct {
57 
59 
60  friend class FingerprintMultifunc;
62 
63  public:
64 
66  virtual ~FingerprintBase();
67  void print_to_file(std::string const & output_filename) const;
68  //void print_to_file(std::string const & output_filename, core::Real const & angle1_offset, core::Real const & angle2_offset, core::Real const & angle3_offset) const;
69 
70  void print_to_pdb(std::string const & output_pdbname) const;
71 
72  void print_to_pdb(std::string const & output_pdbname, numeric::xyzVector<core::Real> const & translation ) const;
73 
74  // const accessor functions
76 
78 
79  std::list< spherical_coor_triplet > const & triplet_fingerprint_data() const { return triplet_fingerprint_data_; };
80 
81  // CHEAT!!
82  void CHEAT_CoM( numeric::xyzVector<core::Real> const & inp_CoM ) { CoM_ = inp_CoM; };
83 
84  protected:
86  std::list< spherical_coor_triplet > triplet_fingerprint_data_;
88 
89  };
90 
92  public:
94 
95  std::list< numeric::xyzVector<core::Real> > egg_and_ext_list_;
96  std::list< numeric::xyzVector<core::Real> > eggshell_list_;
97  std::list< numeric::xyzVector<core::Real> > extshell_list_;
98 
99  void setup_from_PocketGrid( core::pose::Pose const & protein_pose, PocketGrid const & pocket_grid );
100 
101  void setup_from_PocketGrid( core::pose::Pose const & protein_pose, PocketGrid const & pocket_grid, PocketGrid const & grid_for_extshell );
102 
104 
105  void write_eggshell_to_pdb_file( std::string const & output_eggshell_name ) const;
106 
107 #ifdef USEOPENCL
108  void setup_gpu( core::Real const & missing_point_weight, core::Real const & steric_weight, core::Real const & extra_point_weight, int & num_particles, PlaidFingerprint & pf );
109 
110  void free_gpu();
111 
112  void setup_gpu_rays();
113 #endif
114 
115  void setup_from_eggshell_pdb_file( std::string const & input_filename);
116 
117  void trim_based_on_known_ligand( core::pose::Pose const & known_ligand_pose );
118 
119  void setup_from_eggshell_triplet_file(std::string const & input_filename);
120 
121  void setup_from_PlaidFingerprint( PlaidFingerprint const & pfp );
122 
123  void set_origin ( core::pose::Pose const & protein_pose, std::list< numeric::xyzVector<core::Real> > const & egg_and_extra_shell );
124 
125  void set_origin_from_option_( core::pose::Pose const & protein_pose, std::list< numeric::xyzVector<core::Real> > const & egg_and_extra_shell, Size const & set_origin_option );
126 
127  void set_origin_away_from_protein_center ( core::pose::Pose const & protein_pose );
128 
129  void set_origin_away_from_eggshell( std::list< numeric::xyzVector<core::Real> > const & egg_and_extra_shell, core::pose::Pose const & protein_pose );
130 
131  void set_origin_away_from_eggshell_plane( std::list< numeric::xyzVector<core::Real> > const & egg_and_extra_shell, core::pose::Pose const & protein_pose, Size const & set_origin_option );
132 
133  core::Real get_Rvalue (core::pose::Pose const & protein_pose, std::list< numeric::xyzVector<core::Real> > const & egg_and_extra_shell, Size const & set_origin_option);
134 
136 
137  std::list< numeric::xyzVector<core::Real> > combine_xyz_lists (std::list< numeric::xyzVector<core::Real> > const & xyz_list_1 , std::list< numeric::xyzVector<core::Real> > const & xyz_list_2);
138 
139 #ifdef USEOPENCL
140  basic::gpu::GPU gpu_;
141  cl_mem gpu_rays_, gpu_atoms_, gpu_ray_scores_, gpu_particle_scores_, gpu_weights_, gpu_atom_maxmin_phipsi_;
142  int gpu_num_rays_, gpu_num_atoms_, gpu_num_particles_;
143  float ray_scores_[RAY_SCORE_ARRAY], particle_scores_[NUMBER_OF_PARTICLES];
144 #endif
145  typedef struct {
146  float x, y, z, w;
147  } float4;
151 
152  };
153 
155 
156  friend class FingerprintMultifunc;
158 
159  public:
160 
161  PlaidFingerprint( core::pose::Pose const & input_pose, FingerprintBase & fp );
162 
163  core::Real find_optimal_rotation( FingerprintBase & fp, core::Real const & angle_increment, core::Real & optimal_angle1, core::Real & optimal_angle2, core::Real & optimal_angle3, core::Real const & missing_point_weight, core::Real const & steric_weight, core::Real const & extra_point_weight );
164 
165  core::Real find_optimal_rotation( FingerprintBase & fp, core::Real const & angle_increment, core::Real & optimal_angle1, core::Real & optimal_angle2, core::Real & optimal_angle3, core::Real const & missing_point_weight, core::Real const & steric_weight, core::Real const & extra_point_weight, numeric::xyzVector<core::Real> const & no_CoM_offset );
166 
167  core::Real search_random_poses( FingerprintBase & fp, core::Size const & num_pose_search, core::Real & optimal_angle1, core::Real & optimal_angle2, core::Real & optimal_angle3, core::Real const & missing_point_weight, core::Real const & steric_weight, core::Real const & extra_point_weight );
168 
169  core::Real search_random_poses( FingerprintBase & fp, core::Size const & num_pose_search, core::Real & optimal_angle1, core::Real & optimal_angle2, core::Real & optimal_angle3, core::Real const & missing_point_weight, core::Real const & steric_weight, core::Real const & extra_point_weight, numeric::xyzVector<core::Real> const & no_CoM_offset );
170 
171  core::Real fp_compare( FingerprintBase & fp, core::Real const & missing_point_weight, core::Real const & steric_weight, core::Real const & extra_point_weight ) const;
172 
173  void fp_compare_deriv( FingerprintBase & fp, core::Real const & missing_point_weight, core::Real const & steric_weight, core::Real const & extra_point_weight, core::Real & dE_dx, core::Real & dE_dy, core::Real & dE_dz, core::Real & dE_dv4, core::Real & dE_dv5, core::Real & dE_dv6 ) const;
174 
175  void dump_oriented_pose_and_fp_to_pdb( std::string const & pose_filename, std::string const & fp_filename, FingerprintBase & fp, core::Real const & angle1_offset, core::Real const & angle2_offset, core::Real const & angle3_offset );
176 
177  void dump_oriented_pose_and_fp_to_pdb( std::string const & pose_filename, std::string const & fp_filename, FingerprintBase & fp, core::Real const & angle1_offset, core::Real const & angle2_offset, core::Real const & angle3_offset, utility::vector1<core::Real> const & original_pocket_angle_transform );
178 
179  void dump_oriented_pose_and_fp_to_pdb( std::string const & pose_filename, std::string const & fp_filename, FingerprintBase & fp, core::Real const & angle1_offset, core::Real const & angle2_offset, core::Real const & angle3_offset, numeric::xyzVector<core::Real> const & CoM_offset );
180 
181  void dump_oriented_pose_and_fp_to_pdb( std::string const & pose_filename, std::string const & fp_filename, FingerprintBase & fp, core::Real const & angle1_offset, core::Real const & angle2_offset, core::Real const & angle3_offset, utility::vector1<core::Real> const & original_pocket_angle_transform, numeric::xyzVector<core::Real> const & CoM_offset );
182 
183  core::pose::Pose get_oriented_pose( FingerprintBase & fp, core::Real const & angle1_offset, core::Real const & angle2_offset, core::Real const & angle3_offset, numeric::xyzVector<core::Real> const & CoM_offset );
184 
185  core::pose::Pose get_oriented_pose( FingerprintBase & fp, core::Real const & angle1_offset, core::Real const & angle2_offset, core::Real const & angle3_offset, utility::vector1<core::Real> const & original_pocket_angle_transform, numeric::xyzVector<core::Real> const & CoM_offset );
186 
187  core::Real rmsd( core::pose::Pose const & original_pose, core::pose::Pose const & oriented_pose );
188 
189  // void move_origin(numeric::xyzVector<core::Real> const & new_origin );
190 
192 
193  core::pose::Pose & pose() { return pose_; };
198 
199  private:
200  PlaidFingerprint(); // no default constructor
201 
203 
204  // derivatives are optionally filled by build_from_pose_ , used in fp_compare_deriv
205  std::list< ray_distance_derivs > derivs_of_ray_distances_; // note: refers to rays in the same order as the triplet data
206 
207  void move_ligand_and_update_rhos_(FingerprintBase & fp, numeric::xyzVector<core::Real> const & CoM_offset, core::Real const & angle1_offset, core::Real const & angle2_offset, core::Real const & angle3_offset, bool const update_derivatives = false ) {
208  core::conformation::ResidueCOP ligand_rsd = move_ligand_( fp, CoM_offset, angle1_offset, angle2_offset, angle3_offset );
209  update_rhos_( fp, ligand_rsd, update_derivatives );
210  }
211 
212  void update_rhos_( FingerprintBase & fp, core::conformation::ResidueCOP curr_ligand_rsd, bool const update_derivatives = false );
213 
214  core::conformation::ResidueCOP move_ligand_( FingerprintBase & fp, numeric::xyzVector<core::Real> const & CoM_offset, core::Real const & angle1_offset, core::Real const & angle2_offset, core::Real const & angle3_offset );
215 
216  void apply_rotation_offset_to_pose_( core::pose::Pose & pose, core::Real const & angle1_offset, core::Real const & angle2_offset, core::Real const & angle3_offset ) const;
217 
218  };
219 
220  //void correct_phi_psi( core::Real & phi, core::Real & psi );
221 
223  core::Real const triplet_rho = sqrt((coord.x()*coord.x())+(coord.y()*coord.y())+(coord.z()*coord.z()));
224  triplet.rho = triplet_rho;
225  triplet.phi = acos(coord.z()/triplet_rho);
226  triplet.psi = atan2((coord.y()),(coord.x()));
227  }
228 
230  core::Real const triplet_phi = triplet.phi;
231  core::Real const triplet_psi = triplet.psi;
232  core::Real const triplet_rho = triplet.rho;
233  core::Real const rho_times_sin_triplet_phi = triplet_rho*sin(triplet_phi);
234  coord.x() = rho_times_sin_triplet_phi*cos(triplet_psi);
235  coord.y() = rho_times_sin_triplet_phi*sin(triplet_psi);
236  coord.z() = triplet_rho*cos(triplet_phi);
237  }
238 
239  // helper functions to compute derivatives
240  double dD_dv1(const double,const double,const double,const double,const double,const double,const double,const double,const double,const double) ;
241  double dD_dv2(const double,const double,const double,const double,const double,const double,const double,const double,const double,const double) ;
242  double dD_dv3(const double,const double,const double,const double,const double,const double,const double,const double,const double,const double) ;
243  double dD_dv4(const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double) ;
244  double dD_dv5(const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double) ;
245  double dD_dv6(const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double,const double) ;
246 
247  // another helper function
248  core::Real Find_Closest_Intersect_SQ(core::Real const & phiAngle, core::Real const & psiAngle, core::Real const & atomX, core::Real const & atomY, core::Real const & atomZ, core::Real const & atom_radius );
249 
250 }//pockets
251 }//protocols
252 
253 #endif