Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ContactMapEvaluator.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 protocols/simple_filters/ContactMapEvaluator.cc
11 /// @brief
12 /// @author James Thompson
13 
14 // libRosetta headers
15 
16 #include <core/types.hh>
17 #include <core/pose/Pose.hh>
20 
22 
23 #include <ObjexxFCL/string.functions.hh>
24 #include <boost/dynamic_bitset.hpp>
25 #include <algorithm>
26 
27 #include <utility/vector1.hh>
28 
29 
30 namespace protocols {
31 namespace simple_filters {
32 
33 boost::dynamic_bitset<>
35  core::pose::Pose const & pose,
36  core::Real const dist_threshold,
37  std::string const & atom_name,
38  core::Size const min_seqsep = 12,
39  core::Size const skip_res = 0
40 ) {
41  using core::Size;
42  using core::Real;
43  using utility::vector1;
44  using boost::dynamic_bitset;
45 
46  Real const dist_threshold_sq( dist_threshold * dist_threshold );
47 
48  Size const N( pose.total_residue() );
49  dynamic_bitset<> features( (N*N - N) / 2 );
50  Size feat_idx(1);
51  Size const step_size( 1 + skip_res );
52  for ( Size ii = 1; ii <= pose.total_residue(); ii += step_size ) {
53  for ( Size jj = ii + min_seqsep; jj <= pose.total_residue(); jj += step_size ) {
54  Real const dist_sq(
55  pose.residue(ii).xyz(atom_name).distance_squared(
56  pose.residue(jj).xyz(atom_name)
57  )
58  );
59 
60  if ( dist_sq < dist_threshold_sq ) {
61  features[feat_idx] = 1;
62  }
63  feat_idx++;
64  } // jj
65  } // ii
66 
67  return features;
68 }
69 
71  boost::dynamic_bitset<> const & set1,
72  boost::dynamic_bitset<> const & set2
73 ) {
74  using core::Real;
75 
76  boost::dynamic_bitset<> result = (set1 & set2);
77  //( set1 & set2) |
78  //(~set1 & ~set2);
79  //std::string s1, s2;
80  //boost::to_string(set1,s1);
81  //boost::to_string(set2,s2);
82  //std::cout << s1 << " cmp " << s2 << std::endl;
83  Real const dist(
84  static_cast< Real >( result.count() ) /
85  //static_cast< Real >( std::max( set1.count(),set2.count() ) )
86  static_cast< Real >( set2.count() )
87  );
88  //std::cout << result.count() << " " << result.size() << std::endl;
89  return dist;
90 }
91 
93  core::pose::Pose const & native_pose,
94  core::Real const max_dist,
95  core::Size const min_seqsep
96 ) :
97  evaluation::SingleValuePoseEvaluator< core::Real >( "contact_map" ),
98  max_dist_(max_dist),
99  min_seqsep_(min_seqsep),
100  native_(native_pose)
101 {}
102 
104  core::pose::Pose & pose,
105  std::string,
107 ) const {
108  using ObjexxFCL::string_of;
109  using core::pose::Pose;
110 
111  boost::dynamic_bitset<> native_features = get_contact_features(
113  );
114  boost::dynamic_bitset<> features = get_contact_features( pose, max_dist_, "CA", min_seqsep_ );
115  core::Real const cm_score(
116  pct_features_in_common(features,native_features)
117  );
118  std::string const output_name(
119  "contact_score_" + string_of(max_dist_) + "_" + string_of(min_seqsep_)
120  );
121  ss.add_energy( output_name, cm_score );
122 }
123 
124 } // simple_filter
125 } // protocols