Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ContactOrderEnergy.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 src/core/scoring/methods/ContactOrderEnergy.cc
11 /// @brief calculates the contact order of a given conformation average sequence.
12 /// @detailed contact order is defined as the average sequence separation of
13 /// residues that are in contact.
14 ///
15 /// @author James Thompson
16 
17 // Unit Headers
20 
21 // Package Headers
22 
23 // Project Headers
25 #include <core/pose/Pose.hh>
26 #include <core/types.hh>
27 // AUTO-REMOVED #include <core/scoring/ScoreFunction.hh>
28 //#include <core/scoring/ScoringManager.hh>
29 
30 // ObjexxFCL Headers
31 
32 // Utility headers
33 #include <basic/Tracer.hh>
34 
36 #include <utility/vector1.hh>
37 
38 
39 
40 //// C++ headers
41 static basic::Tracer tr("core.scoring.methods.ContactOrderEnergy");
42 
43 namespace core {
44 namespace scoring {
45 namespace methods {
46 
47 
48 /// @details This must return a fresh instance of the ContactOrderEnergy class,
49 /// never an instance already in use
53 ) const {
54  return new ContactOrderEnergy;
55 }
56 
59  ScoreTypes sts;
60  sts.push_back( co );
61  return sts;
62 }
63 
64 
65 /// c-tor
68 {}
69 
70 /// clone
73 {
74  return new ContactOrderEnergy();
75 }
76 
77 /////////////////////////////////////////////////////////////////////////////
78 // scoring
79 /////////////////////////////////////////////////////////////////////////////
81  pose::Pose & pose,
82  ScoreFunction const &,
83  EnergyMap & totals
84 ) const {
85 
86  totals[ co ] = calculate_contact_order( pose );
87 
88 }
89 
92 {
93 
94 // tex: below is old code for calculating contact order from rosetta++
95 // int nco = 0;
96 // for ( int i = 1; i <= pose.total_residue(); ++i ) {
97 // if ( is_protein(res(i)) || is_nonnatural(res(i)) ) { /// <---
98 // for ( int kk = 1, kke = cen12up(i); kk <= kke; ++kk ) { /// <---
99 // int j = cen_list(kk,i); /// <---
100 // if ( cendist(i,j) < 64.0 && std::abs(j-i) > 2 ) { /// <---
101 // co += std::abs(j-i);
102 // ++nco;
103 // }
104 // }
105 // }
106 // }
107 // notes on what things mean:
108 // cenlist(*,i) contains the list of residues within 12A of residue i
109 // cen12up(i) is the number of residues in cen_list(*,i)
110 
111  using core::Real;
112  using core::Size;
113  using core::Vector;
114 
115  Real co_score = 0.0;
116  Size n_in_contact = 0;
117  for ( Size i = 1; i <= pose.total_residue(); ++i ) {
118  Vector const v1( pose.residue(i).nbr_atom_xyz() );
119 
120  for ( Size j = i + 3; j <= pose.total_residue(); ++j ) {
121  Vector const v2( pose.residue(j).nbr_atom_xyz() );
122  if ( v1.distance_squared( v2 ) < 64.0 ) {
123  co_score += j - i;
124  ++n_in_contact;
125  }
126  }
127  }
128 
129  if ( n_in_contact > 0 ) {
130  co_score /= static_cast< Real >( n_in_contact );
131  }
132 
133  return co_score;
134 }
137 {
138  return 1; // Initial versioning
139 }
140 
141 
142 } // methods
143 } // scoring
144 } // core