Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DesignVsNativeComparison.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 stuff to compare designs against the native pdb
11 /// @brief
12 /// @author Florian Richter, floric@u.washington.edu
13 
14 // Unit headers
17 
18 // Project headers
19 #include <core/pose/Pose.hh>
20 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
21 #include <basic/options/option.hh>
22 //#include <core/pose/metrics/PoseMetricCalculatorBase.fwd.hh>
23 #include <core/scoring/Energies.hh>
25 #include <basic/MetricValue.hh>
27 
28 #include <core/scoring/constraints/ConstraintSet.hh> //temporary include
29 
30 // Utility Headers
31 // AUTO-REMOVED #include <utility/io/izstream.hh>
32 // AUTO-REMOVED #include <utility/string_util.hh>
33 
34 #include <basic/Tracer.hh>
35 
36 
37 // option key includes
38 
39 #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
40 
42 #include <utility/vector1.hh>
43 
44 
45 
46 static basic::Tracer tr("protocols.enzdes.DesignVsNativeComparison");
47 
48 namespace protocols {
49 namespace enzdes {
50 
51 
53  native_poses_.clear();
54 }
55 
57 
58 void
60  core::pose::Pose const & pose,
61  utility::vector1< std::pair< std::string, std::string > > const & calculators,
64 {
65 
66  //first, extract the pdb code from the pose input tag
68 
69  std::map< std::string, core::pose::PoseOP >::iterator map_it = native_poses_.find( pdb_code );
70 
71  if( map_it == native_poses_.end() ){
72 
73  std::string native_path = basic::options::option[basic::options::OptionKeys::enzdes::compare_native].value();
74 
75  std::string native_filename = native_path + pdb_code + ".pdb";
76  core::pose::PoseOP new_native = new core::pose::Pose();
77 
78  core::import_pose::pose_from_pdb( *new_native, native_filename );
79 
80  //need to score the native, in case the calculators rely on cached energies
81  //also need to remove non protein residues, just to make sure
83 
84  (*scorefxn)(*new_native);
85 
86  native_poses_.insert( std::pair< std::string, core::pose::PoseOP >( pdb_code, new_native ) );
87 
88  map_it = native_poses_.find( pdb_code );
89 
90  }
91 
92  core::pose::PoseOP native = map_it->second;
93 
94  core::Real native_totalE = native->energies().total_energies().dot( native->energies().weights() );
95 
96  //remove the ligand from the pose, so the comparison makes sense
97  core::pose::PoseOP pureprotpose = new core::pose::Pose( pose );
98 
100 
101  //arrghh, bug, when scoring a pose where one of the deleted residues was constrained, program crashes
102  //because the deleted residue survives in the long range energy containers:(
103  //temporary hack workaround: put an empty constraint set into the pureprotpose
104  pureprotpose->constraint_set( new core::scoring::constraints::ConstraintSet() );
105  core::Real pose_totalE = (*scorefxn)(*pureprotpose );
106 
107  //ok, we have our native, now use each of the calculators to compare
108  //and of course we're also looking at the total energy
109  silent_Es.push_back( core::io::silent::SilentEnergy( "NaCo_dTotE", pose_totalE - native_totalE, 1, 12) );
110 
111  basic::MetricValue< core::Real > mval_real;
112  basic::MetricValue< core::Size > mval_size;
113 
114  core::Real poseval, nativeval;
115 
116  for( utility::vector1< std::pair< std::string, std::string > >::const_iterator calc_it = calculators.begin();
117  calc_it != calculators.end(); ++calc_it ){
118 
119 
120  if( calc_it->first == "hbond_pm" || calc_it->first == "burunsat_pm" || calc_it->first == "NLconts_pm" || calc_it->second == "total_pos_charges" || calc_it->second == "total_neg_charges" ){
121  pureprotpose->metric( calc_it->first, calc_it->second, mval_size );
122  poseval = mval_size.value();
123 
124  native->metric( calc_it->first, calc_it->second, mval_size );
125  nativeval = mval_size.value();
126  }
127  else{
128  pureprotpose->metric( calc_it->first, calc_it->second, mval_real );
129  poseval = mval_real.value();
130 
131  native->metric( calc_it->first, calc_it->second, mval_real );
132  nativeval = mval_real.value();
133  }
134 
135  //std::cerr << "For " << calc_it->first << ", design val is " << poseval << " and nativeval is " << nativeval << std::endl;
136 
137  //now create a silent energy out of the calculated value
138  core::Real native_diff = poseval - nativeval;
139  std::string se_name = "NaCo_"+calc_it->first;
140  if( calc_it->first == "charges_pm" ) se_name = "NaCo_" + calc_it->second;
141  int width = std::max( 10, (int) se_name.length() + 3 );
142 
143  //core::io::SilentEnergy se( se_name , native_diff, 1, width );
144  silent_Es.push_back( core::io::silent::SilentEnergy ( se_name , native_diff, 1, width ) );
145 
146  } //loop over calculators
147 
148 
149 } //compare_to_native
150 
151 
152 }//enzdes
153 }//protocols