Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pocket_measure.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 /// @brief
11 /// @author jk+dj
12 
13 #include <iostream>
14 #include <iomanip>
15 
16 // Protocol Headers
17 #include <protocols/rigid/RigidBodyMover.hh>
18 #include <protocols/backrub/BackrubMover.hh>
19 #include <protocols/moves/MonteCarlo.hh>
20 
21 // Core Headers
22 #include <core/conformation/Residue.hh>
23 #include <core/conformation/Conformation.hh>
24 #include <devel/init.hh>
25 #include <core/io/pdb/pose_io.hh>
26 #include <core/pack/task/TaskFactory.hh>
27 #include <core/pack/task/PackerTask.hh>
28 #include <core/pack/pack_rotamers.hh>
29 #include <core/pose/Pose.hh>
30 #include <core/scoring/ScoreFunction.hh>
31 #include <core/scoring/ScoreFunctionFactory.hh>
32 #include <core/scoring/TenANeighborGraph.hh>
33 #include <core/pose/PDBInfo.hh>
34 #include <core/kinematics/MoveMap.hh>
35 #include <core/optimization/MinimizerOptions.hh>
36 #include <core/optimization/AtomTreeMinimizer.hh>
37 #include <basic/options/util.hh>
39 #include <core/id/AtomID_Map.hh>
40 #include <protocols/pockets/PocketConstraint.hh>
41 #include <protocols/pockets/PocketGrid.hh>
42 #include <core/scoring/func/ScalarWeightedFunc.hh>
43 #include <core/scoring/Energies.hh>
44 
45 #include <basic/options/keys/out.OptionKeys.gen.hh>
46 #include <basic/options/keys/pocket_grid.OptionKeys.gen.hh>
47 
49 
50 // Numeric Headers
51 #include <numeric/xyz.functions.hh>
52 #include <numeric/xyzMatrix.hh>
53 #include <numeric/conversions.hh>
54 
55 // Utility Headers
56 #include <utility/vector1.hh>
57 #include <utility/io/ozstream.hh>
58 
59 //Auto Headers
60 #include <core/import_pose/import_pose.hh>
62 
63 
64 using namespace core;
65 using namespace basic::options;
66 using namespace core::scoring;
67 using namespace core::optimization;
68 using namespace basic::options::OptionKeys;
69 
70 OPT_KEY( Integer, num_angles )
71 
72 /// General testing code
73 int
74 main( int argc, char * argv [] )
75 {
76  try {
77  NEW_OPT ( num_angles, "Number of different pose angles to measure score at", 1);
78 
79  devel::init(argc, argv);
80  int angles = option[ num_angles ];
81  if ( angles <1 ) {
82  fprintf (stderr, "Error: invalid number of angles. Must be greather than 0\n");
83  return -1;
84  }
85 
86  //std::string const output_tag = option[ OptionKeys::out::output_tag ]();
87  pose::Pose input_pose;
88 
89  //read in pdb file from command line
90  std::string const input_pdb_name ( basic::options::start_file() );
91  core::import_pose::pose_from_pdb( input_pose, input_pdb_name );
92 
93 
94  scoring::ScoreFunctionOP scorefxn( get_score_function() );
95 
96  (*scorefxn)(input_pose);
97  core::Real const starting_total_score = input_pose.energies().total_energies()[ total_score ];
98  std::cout << "Total score at start without constraint is: " << starting_total_score << std::endl;
99 
100 
101  std::string resid(option[ OptionKeys::pocket_grid::central_relax_pdb_num ]);
102 
103 
104  std::vector< conformation::ResidueCOP > residues = protocols::pockets::PocketGrid::getRelaxResidues(input_pose, resid);
105 
106  /*
107  int central_relax_pdb_number;
108  char chain = ' ';
109  std::size_t fpos( resid.find(':') );
110  if ( fpos != std::string::npos ) {
111  central_relax_pdb_number = ObjexxFCL::int_of( resid.substr(0,fpos) );
112  if (fpos != resid.size()-1 ) {
113  chain = resid[ fpos+1 ];
114  }
115  } else {
116  central_relax_pdb_number = ObjexxFCL::int_of( resid );
117  }
118 
119  int seqpos = 0;
120  for ( int j = 1, resnum = input_pose.total_residue(); j <= resnum; ++j ) {
121  if ( input_pose.pdb_info()->number(j) == central_relax_pdb_number ) {
122  //seqpos_ = j;
123  if (chain != ' '){
124  if ( input_pose.pdb_info()->chain(j) == chain ) {
125  seqpos = j;
126  }
127  }else{
128  seqpos = j;
129  }
130  }
131  }
132 
133  if ( seqpos == 0 ) {
134  */
135  if ( residues.size() == 0 ) {
136  std::cout << "ERROR!! Invalid residue to backrub around" << std::endl;
137  exit(1);
138  }
139 
140  core::Real constraint_pocket_score = 0;
141  core::Real largest_pocket_score = 0;
142 
143  protocols::pockets::PocketGrid pg( residues );
144  for ( int i=0; i<angles; ++i ) {
145  if ( i>0 ) {
146  /* core::Real x,y,z;
147  x = (int) (numeric::random::uniform() *89 +1);
148  y = (int) (numeric::random::uniform() *89 +1);
149  z = (int) (numeric::random::uniform() *89 +1);
150  numeric::xyzMatrix<core::Real> x_rot_mat( numeric::x_rotation_matrix_degrees(x) );
151  numeric::xyzMatrix<core::Real> y_rot_mat( numeric::y_rotation_matrix_degrees(y) );
152  numeric::xyzMatrix<core::Real> z_rot_mat( numeric::z_rotation_matrix_degrees(z) );
153  core::Vector v(0,0,0);
154  input_pose.apply_transform_Rx_plus_v(x_rot_mat, v);
155  input_pose.apply_transform_Rx_plus_v(y_rot_mat, v);
156  input_pose.apply_transform_Rx_plus_v(z_rot_mat, v);
157  */
158  pg.randomAngle();
159  } else {
160  pg.zeroAngle();
161  }
162  //protocols::pockets::PocketGrid pg( input_pose.conformation().residue(seqpos) );
163  //if ( pg.autoexpanding_pocket_eval( input_pose.conformation().residue(seqpos), input_pose ) ){
164  if ( pg.autoexpanding_pocket_eval( residues, input_pose ) ) {
165  constraint_pocket_score += pg.netTargetPocketVolume();
166  largest_pocket_score += pg.netTargetPocketVolume();
167  //std::cout<<pg.netTargetPocketVolume()<<std::endl;
168  }//else std::cout<<"0\n";
169 
170  if ( i==0 ) {
171  if ( option[ OptionKeys::pocket_grid::pocket_dump_pdbs ]() ) {
172  pg.dumpGridToFile();
173  }
174  if ( option[ OptionKeys::pocket_grid::pocket_dump_exemplars ]() ) {
175  pg.dumpExemplarToFile();
176  }
177  }
178  }
179  constraint_pocket_score /= angles;
180  largest_pocket_score /= angles;
181  std::cout << "Pocket score (unweighted) is: " << constraint_pocket_score << std::endl;
182  std::cout << "Largest pocket score (unweighted) is: " << largest_pocket_score << std::endl;
183  } catch ( utility::excn::EXCN_Base const & e ) {
184  std::cout << "caught exception " << e.msg() << std::endl;
185  return -1;
186  }
187  return 0;
188 }
189 
190 
int main(int argc, char *argv[])
General testing code.
virtual std::string const msg() const
Definition: EXCN_Base.hh:70
void init(int argc, char *argv[])
Command line init() version.
Definition: init.cc:23
core::pose::Pose Pose
Definition: supercharge.cc:101
Conversions between degrees and radians.
Fast 3x3 matrix.
common derived classes for thrown exceptions
std::string start_file()
kind of like the old -s – just one file
Definition: util.cc:41
tuple scorefxn
Definition: PyMOL_demo.py:63
rule< Scanner, options_closure::context_t > options
Definition: Tag.cc:377
#define OPT_KEY(type, key)
Output file stream wrapper for uncompressed and compressed files.
double Real
Definition: types.hh:39
Option lookup functions emulating Rosetta++ equivalents for transitional use.
#define NEW_OPT(akey, help, adef)
ocstream cout(std::cout)
Wrapper around std::cout.
Definition: ocstream.hh:287
BooleanOptionKey const exit("options:exit")
Definition: OptionKeys.hh:51
vector1: std::vector with 1-based indexing
xyzVector and xyzMatrix functions
rule< Scanner, option_closure::context_t > option
Definition: Tag.cc:378