Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NVscore.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 core/scoring/NV/NVscore.cc
11 /// @details Implementation of Neighbor Vector estimation ( from Durham EA, Et. Al. "Solvent Accessible Surface Area Approximations for Protein Structure Prediction"
12 /// @author Sam DeLuca (samuel.l.deluca@vanderbilt.edu)
13 
16 
17 #include <core/pose/Pose.hh>
18 
19 #include <core/scoring/Energies.hh>
24 
26 #include <core/chemical/AA.hh>
27 
29 
30 #include <core/kinematics/Jump.hh>
31 
32 #include <utility/vector1.hh>
33 
34 #include <numeric/constants.hh>
35 
36 #include <basic/options/option.hh>
37 #include <basic/options/keys/score.OptionKeys.gen.hh>
38 #include <basic/Tracer.hh>
39 
40 
41 
42 namespace core {
43 namespace scoring {
44 namespace nv {
45 
46 
47 /// @details This must return a fresh instance of the NVscore class,
48 /// never an instance already in use
52 ) const {
53  return new NVscore;
54 }
55 
58  ScoreTypes sts;
59  sts.push_back( neigh_count );
60  sts.push_back( neigh_vect );
61  sts.push_back( neigh_vect_raw );
62  return sts;
63 }
64 
65 
66 static basic::Tracer TR("core.scoring.NVscore");
67 
68 
70  parent( new NVscoreCreator ),
71  lookup_table_(ScoringManager::get_instance()->get_NVLookupTable() )
72 {
73  //lbound defaults to 3.3 and ubound defaults to 11.1. If you change these values the lookup table may no longer be accurate
74  lower_bound_ = basic::options::option[ basic::options::OptionKeys::score::NV_lbound]();
75  upper_bound_ = basic::options::option[ basic::options::OptionKeys::score::NV_ubound]();
76 
78  upper_bound_squared_ = upper_bound_*upper_bound_;
79 
80 }
81 
82 
84 {
85  return new NVscore(*this);
86 }
87 
88 
90 {
92 }
93 
95 {
97 }
98 
100 {
101  //pose.update_residue_neighbors();
102 }
103 
105 {
106  //pose.update_residue_neighbors();
107 }
108 
109 
110 
112 {
113  context_graphs_required[twelve_A_neighbor_graph] = true;
114 }
115 
116 ///Calculate the weighted neighbor count given an upper and lower bound
117 Real NVscore::neighbor_weight(Vector::Value const & distance2) const
118 {
119 
120 
121  if(distance2 <= lower_bound_squared_)
122  {
123  //neighbor count score is 1 if less than the lower bound
124  return(1);
125  }else if(distance2 >= upper_bound_squared_)
126  {
127  //neighbor count score is 0 if greater than upper bound
128  return(0);
129  }else if( (lower_bound_squared_ < distance2) && (upper_bound_squared_ > distance2) )
130  {
131  //if between upper and lower bound, score follows a smooth function
132  core::Real distance(sqrt(distance2));
133  Real weight = ( cos( ( (distance-lower_bound_) / (upper_bound_-lower_bound_) ) * numeric::constants::r::pi ) + 1 )/2.0;
134  return(weight);
135  }
136  return(0);
137 }
138 
139 void NVscore::residue_energy( conformation::Residue const &current_residue, pose::Pose const & pose, EnergyMap & emap) const
140 {
141 
142  Real neighbor_count(0);
143  Vector neighbor_vector_sum(0,0,0);
144 
145  conformation::ResidueOPs::iterator poseIT;
146  //use the coordinates of residue neighbor atom for all calcuations
147  Vector current_vector(current_residue.nbr_atom_xyz());
148 
149  TwelveANeighborGraph const & graph(pose.energies().twelveA_neighbor_graph());
150 
152  node_index = graph.get_node( current_residue.seqpos() )->const_edge_list_begin(),
153  node_index_end = graph.get_node( current_residue.seqpos() )->const_edge_list_end();
154  node_index != node_index_end; ++node_index )
155 
156  {
157  //get the residue to compare to the current residue
158  core::Size comparison_residue_index((*node_index)->get_other_ind(current_residue.seqpos()));
159  conformation::ResidueCOP comparison_residue(&pose.residue(comparison_residue_index));
160  //you don't want to compare a residue to itself
161  if(current_residue.seqpos() == comparison_residue->seqpos()) continue;
162  Vector const & comparison_vector(comparison_residue->nbr_atom_xyz());
163  //calculate the distance between the two residues
164  Vector::Value distance2 = current_vector.distance_squared(comparison_vector);
165  //get the weighted neighbor count
166  Real weight = neighbor_weight(distance2);
167 
168  //calculate the weighted neighbor vector for this pair and sum
169  if(weight != 0)
170  {
171  Vector weighted_vector = ( (comparison_vector-current_vector) / sqrt(distance2)) * weight;
172  neighbor_count += weight;
173  neighbor_vector_sum += weighted_vector;
174  }
175 
176  }
177 
178 
179  if ( neighbor_count == 0.0 ) return; // do not try to divide by zero
180 
181  Vector average_sum = neighbor_vector_sum/neighbor_count;
182  //neighbor vector score is the norm of the average sum of all neighbor vectors
183  Real neighbor_vector = average_sum.norm();
184 
185  core::chemical::AA aa_type = current_residue.aa();
186  //use the neighbor vector score to look up the potential from the knowledge base
187  Real nv_potential = lookup_table_.get_potentials(aa_type,neighbor_vector);
188 
189  emap[ neigh_vect ] += nv_potential;
190  emap[ neigh_vect_raw ] += neighbor_vector;
191  emap[ neigh_count ] += neighbor_count;
192 
193 }
194 
197 {
198  return 1; // Initial versioning
199 }
200 
201 } //NV
202 } //scoring
203 } //core