Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ScoreMap.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 ScoreMap.cc
11 /// @brief A place to put some common functions for scoremap output
12 /// @author Monica Berrondo
13 
14 // Unit headers
16 
17 // Project headers
18 #include <core/pose/Pose.hh>
19 #include <core/scoring/Energies.hh>
21 
22 // AUTO-REMOVED #include <basic/Tracer.hh>
23 
24 // ObjexxFCL headers
25 
26 #include <utility/vector1.hh>
27 #include <ObjexxFCL/format.hh>
28 
29 
30 using namespace core;
31 
32 namespace protocols {
33 namespace jd2 {
34 
35 /// @details Auto-generated virtual destructor
36 ScoreMap::~ScoreMap() {}
37 
38 /// Score output helper functions
39 /// @details
40 /// creates a list of non zero weighted energies and adds them to the
41 /// score_file information that is to be written out at the end of the
42 /// protocol.
43 void
44 ScoreMap::nonzero_energies(
45  std::map < std::string, core::Real > & score_map,
46  scoring::ScoreFunctionOP score_fxn,
47  pose::Pose & pose
48 )
49 {
50  using namespace core::scoring;
51 
52  (*score_fxn)(pose);
53 
54  score_map_from_scored_pose(score_map, pose);
55 }
56 
57 ///@details creates score map from scored pdb; const so it can be used in job distributor
58 void
59 ScoreMap::score_map_from_scored_pose(
60  std::map < std::string, core::Real > & score_map,
61  pose::Pose const & pose
62 ) {
63  using namespace core::scoring;
64 
65  // Which score terms to use
66  core::scoring::EnergyMap weights = pose.energies().weights();
67  typedef utility::vector1<core::scoring::ScoreType> ScoreTypeVec;
68  ScoreTypeVec score_types;
69  for(int i = 1; i <= core::scoring::n_score_types; ++i) {
71  if ( weights[ii] != 0 ) score_types.push_back(ii);
72  }
73 
74  core::Real total(0);
75 
76  for(ScoreTypeVec::iterator ii = score_types.begin(), end_ii = score_types.end(); ii != end_ii; ++ii) {
77  core::Real const some_score( weights[(*ii)] * pose.energies().total_energies()[ *ii ] );
78  score_map[ name_from_score_type(*ii) ] = some_score;
79  total += some_score;
80  }
82 }
83 
84 std::map< std::string, core::Real > ScoreMap::score_map_from_scored_pose( core::pose::Pose const & pose ){
85  std::map< std::string, core::Real > score_map;
86  score_map_from_scored_pose(score_map, pose);
87  return score_map;
88 }
89 
90 
91 ///@brief print out the contents of the ScoreMap
92 void
93 ScoreMap::print(
94  std::map < std::string, core::Real > & score_map,
95  std::ostream & out
96 )
97 {
98  using namespace ObjexxFCL::fmt;
99 
100  std::map< std::string, Real >::const_iterator pair;
101  Size width (8), precision (3);
102 
103  //print the header
104  for ( pair=score_map.begin(); pair!=score_map.end(); ++pair )
105  {
106  if ( pair->first.length() > 8 ) width = pair->first.length();
107  out << ' ' << A( width, pair->first );
108  }
109  out << std::endl;
110 
111  //print the information
112  for ( pair=score_map.begin(); pair!=score_map.end(); ++pair )
113  {
114  if ( pair->first.length() > 8 ) width = pair->first.length();
115  out << ' ' << F( width, precision, pair->second );
116  }
117  out << std::endl;
118 
119 }
120 
121 
122 } //jd2
123 } //protocols