Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UnfoldedStatePotential.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/UnfoldedStatePotential.cc
11 /// @brief Unfolded state energies based on energies of residues in fragments, definition file
12 /// @author Ron Jacak (ronj@email.unc.edu)
13 /// @author P. Douglas Renfrew (renfrew@unc.edu)
14 
15 // Unit headers
17 
18 // Project headers
19 // AUTO-REMOVED #include <basic/database/open.hh>
20 
22 
26 
27 #include <core/pose/Pose.hh>
28 
29 // Numeric headers
30 
31 // ObjexxFCL headers
32 #include <ObjexxFCL/string.functions.hh>
33 
34 // Utility headers
35 #include <utility/io/izstream.hh>
36 #include <utility/file/file_sys_util.hh>
37 
38 // C++ headers
39 #include <iostream>
40 
41 #include <utility/vector1.hh>
42 
43 
44 namespace core {
45 namespace scoring {
46 
47 
49  read_database_file( filename );
50 }
51 
53 
54 
55 void
57 
58  using namespace core::chemical;
59  using namespace core::scoring;
60 
61  if( ! utility::file::file_exists( filename ) ) {
62  utility_exit_with_message("Cannot find file '"+filename+"'");
63  }
64 
65  utility::io::izstream data( filename );
66  if ( !data.good() ) {
67  utility_exit_with_message("Cannot open file '"+filename+"'");
68  }
69 
70  // read in all lines in file
72  std::string line;
73  while ( getline( data, line ) ) {
74  std::istringstream l( line );
75  if ( line.size() < 1 || line[0] == '#' ) continue; // skip comment lines
76  lines.push_back( line );
77  }
78  data.close();
79 
80  // parse the first line that contains the score types
81  std::string const & first_line( lines[1] );
82  std::istringstream h( first_line );
83  std::string tag;
84  utility::vector1< ScoreType > unfolded_score_types;
85 
86  h >> tag;
87  if ( tag != "AA" ) {
88  utility_exit_with_message("Error parsing first line of '"+filename+"'");
89  }
90  while ( !h.fail() ) {
91  h >> tag;
92  if ( h.fail() ) break;
93  if ( ScoreTypeManager::is_score_type( tag ) ) {
94  unfolded_score_types.push_back( ScoreTypeManager::score_type_from_name( tag ) );
95  } else {
96  utility_exit_with_message("Error, score type '"+tag+"' spcified in '"+filename+"' doesn't exist.");
97  }
98  }
99 
100  // parse the second line that contains the weights
101  std::string const & second_line( lines[2] );
102  std::istringstream k( second_line );
103  Size const ntypes( unfolded_score_types.size() );
104  Real weight;
105 
106  k >> tag;
107  if ( tag != "WEIGHT" ) {
108  utility_exit_with_message("Error parsing second line of '"+filename+"'");
109  }
110  for ( Size i=1; i <= ntypes; ++i ) {
111  k >> weight;
112  if ( k.fail() ) {
113  utility_exit_with_message("Error, number of energies doesn't match number of score types in '"+filename+"'");
114  }
115  unfolded_potential_file_weights_[ unfolded_score_types[i] ] = weight; // add energy to appropriate score type in temp emap
116  }
117 
118  // parse the rest of the file
119  Size const nlines( lines.size() );
120 
121  for ( Size i=3; i <= nlines; ++i ) {
122  std::string const & temp_line( lines[i] );
123  std::istringstream l( temp_line );
124  std::string tlc;
125  Real val;
126  EnergyMap emap;
127 
128  l >> tlc;
129  ObjexxFCL::lpad( tlc, 3 ); // RNA codes are rA, etc. (two letters)
130 
131  for ( Size i=1; i <= ntypes; ++i ) {
132  l >> val;
133  if ( l.fail() ) {
134  utility_exit_with_message("Error, number of energies doesn't match number of score types in '"+filename+"'");
135  }
136  emap[ unfolded_score_types[i] ] = val; // add energy to appropriate score type in temp emap
137  }
138 
139  // add tlc/emap pair to map
140  unfolded_energy_[ tlc ] = emap;
141  }
142 
143 }
144 
148 }
149 
150 
151 void
153 
154  // the energies stored in the database file aren't probabilities; don't take the log of them, that doesn't make sense!
155  e = ( unfolded_energy_.find( aa_name3 ) )->second;
156 }
157 
158 
159 void
161 
162  EnergyMap unf_total;
163 
164  for ( Size ii = 1; ii <= pose.total_residue(); ++ii ) {
165  if ( ! pose.residue(ii).is_protein() && ! pose.residue(ii).is_RNA() ) {
166  continue;
167  }
168 
169  // EnergyMap's know how to add, so we can take advantage of that feature to come up with a total unfolded state
170  // energy (broken down by score type anyway).
171  unf_total += ( unfolded_energy_.find( pose.residue(ii).name3() ) )->second;
172  }
173 
174  e = unf_total;
175 }
176 
177 } // namespace scoring
178 } // namespace core
179