Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SequenceDependentRefEnergy.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/methods/SequenceDependentRefEnergy.hh
11 /// @brief Reference energy method implementation
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 // Unit headers
17 
18 // Package headers
20 // AUTO-REMOVED #include <core/scoring/methods/EnergyMethodOptions.hh>
21 
22 // Project headers
23 #include <core/chemical/AA.hh>
25 
26 // C++ Headers
27 #include <string>
28 #include <vector>
29 
30 // Utility Headers
31 #include <utility/io/izstream.hh>
32 #include <utility/string_util.hh>
33 
34 #include <basic/options/option.hh>
35 #include <basic/options/keys/score.OptionKeys.gen.hh>
36 
37 #include <utility/vector1.hh>
38 
39 
40 namespace core {
41 namespace scoring {
42 namespace methods {
43 
44 
45 /// @details This must return a fresh instance of the SequenceDependentRefEnergy class,
46 /// never an instance already in use
50 ) const {
51  return new SequenceDependentRefEnergy;
52 }
53 
56  ScoreTypes sts;
57  sts.push_back( seqdep_ref );
58  return sts;
59 }
60 
61 
62 
65 {
67 }
68 
71 {
72  aa_seq_weights_.clear();
73  for ( utility::vector1<utility::vector1< Real > >::const_iterator it = aa_seq_weights_in.begin(); it != aa_seq_weights_in.end(); ++it ) {
74  aa_seq_weights_.push_back(*it);
75  }
76 }
77 
79 
80 
81 
83 
84  using namespace basic::options;
85 
86  std::cout << "JL checking for SequenceDependentRefEnergy weights" << std::endl;
87 
88  if ( option[ OptionKeys::score::seqdep_refene_fname ].user() ) {
89  std::string const in_fname( option[ OptionKeys::score::seqdep_refene_fname ] );
90  std::cout << "JL reading SequenceDependentRefEnergy weights from " << in_fname << std::endl;
91  utility::io::izstream in_stream( in_fname );
92  if (!in_stream.good()) {
93  utility_exit_with_message( "[ERROR] Error opening SequenceDependentRefEnergy file" );
94  }
95  std::string line;
96  core::Size seqpos(0);
97  while( getline( in_stream, line) ) {
98  ++seqpos;
99  std::cout << "JL got " << seqpos << " line " << line << std::endl;
100  utility::vector1< std::string > const tokens ( utility::split( line ) );
101  utility::vector1< Real > energies;
102  for ( utility::vector1< std::string >::const_iterator it = tokens.begin(); it != tokens.end(); ++it ) {
103  energies.push_back( atof(it->c_str()) );
104  }
105  aa_seq_weights_.push_back(energies);
106  }
107 
108  if ( option[ OptionKeys::score::secondary_seqdep_refene_fname ].user() ) {
109  std::string const in_fname( option[ OptionKeys::score::secondary_seqdep_refene_fname ] );
110  std::cout << "JL reading SECONDARY SequenceDependentRefEnergy weights from " << in_fname << std::endl;
111  utility::io::izstream in_stream( in_fname );
112  if (!in_stream.good()) {
113  utility_exit_with_message( "[ERROR] Error opening SECONDARY SequenceDependentRefEnergy file" );
114  }
115  std::string line;
116  core::Size seqpos(0);
117  while( getline( in_stream, line) ) {
118  ++seqpos;
119  std::cout << "JL got " << seqpos << " line " << line << std::endl;
120  utility::vector1< std::string > const tokens ( utility::split( line ) );
121  utility::vector1< Real > energies;
122  for ( utility::vector1< std::string >::const_iterator it = tokens.begin(); it != tokens.end(); ++it ) {
123  energies.push_back( atof(it->c_str()) );
124  }
125  core::Size aa(0);
126  for ( utility::vector1< Real >::const_iterator it = energies.begin(); it != energies.end(); ++it ) {
127  ++aa;
128  (aa_seq_weights_[seqpos])[ aa ] += *it;
129  }
130  }
131  }
132 
133  }
134 
135 }
136 
137 
140 {
142 }
143 
144 
145 void
147  conformation::Residue const & rsd,
148  pose::Pose const &,
149  EnergyMap & emap
150 ) const
151 {
152  using namespace chemical;
153 
154  if ( aa_seq_weights_.empty() ) return;
155 
156  AA const & aa( rsd.aa() );
157  Size const & seqpos( rsd.seqpos() );
158  if ( seqpos > aa_seq_weights_.size() ) return;
159 
160  Real const ene = (aa_seq_weights_[seqpos])[ aa ];
161  emap[ seqdep_ref ] += ene;
162  // std::cout << "JL at seqpos " << seqpos << " for aa " << aa << " using seqdep_ref " << ene << std::endl;
163 
164  return;
165 
166 }
167 
168 
169 Real
171  id::DOF_ID const &,
172  id::TorsionID const &,
173  pose::Pose const &,
174  ScoreFunction const &,
175  EnergyMap const &
176 ) const
177 {
178  return 0.0;
179 }
180 
181 /// @brief SequenceDependentRefEnergy is context independent; indicates that no
182 /// context graphs are required
183 void
185 {}
188 {
189  return 1; // Initial versioning
190 }
191 } // methods
192 } // scoring
193 } // core
194