33 #include <utility/io/izstream.hh>
34 #include <utility/string_util.hh>
36 #include <basic/options/option.hh>
37 #include <basic/options/keys/score.OptionKeys.gen.hh>
39 #include <utility/vector1.hh>
41 static basic::Tracer
TR(
"core.scoring.methods.NMerPSSMEnergy" );
84 using namespace basic::options;
104 for(
Size ipssm = 1; ipssm <= all_nmer_pssms_in.size(); ++ipssm ){
105 std::map< chemical::AA, utility::vector1< core::Real > >
nmer_pssm;
106 std::map< chemical::AA, utility::vector1< core::Real > >
const nmer_pssm_in( all_nmer_pssms_in[ ipssm ] );
109 nmer_pssm.insert( *it );
120 using namespace basic::options;
122 TR <<
"checking for NMerPSSMEnergy PSSM list" << std::endl;
125 if ( option[ OptionKeys::score::nmer_pssm_list ].user() ) {
126 std::string const pssm_list_fname( option[ OptionKeys::score::nmer_pssm_list ] );
138 TR <<
"reading NMerPSSMEnergy list from " << pssm_list_fname << std::endl;
139 utility::io::izstream in_stream( pssm_list_fname );
140 if (!in_stream.good()) {
141 utility_exit_with_message(
"[ERROR] Error opening NMerPSSMEnergy list file" );
145 while( getline( in_stream, pssm_fname ) ){
148 if( tokens[ 1 ][ 0 ] ==
'#' )
continue;
157 TR <<
"reading NMerPSSMEnergy scores from " << pssm_fname << std::endl;
158 utility::io::izstream in_stream( pssm_fname );
159 if (!in_stream.good()) {
160 utility_exit_with_message(
"[ERROR] Error opening NMerPSSMEnergy file" );
163 std::map< chemical::AA, utility::vector1< core::Real > >
nmer_pssm;
165 while( getline( in_stream, line) ) {
168 if( tokens[ 1 ][ 0 ] ==
'#' )
continue;
169 char const char_aa( tokens[ 1 ][ 0 ] );
171 if( nmer_pssm.count( aa ) ) utility_exit_with_message(
"[ERROR] NMer ref energy database file "
172 + pssm_fname +
" has double entry for aa " + char_aa );
173 if( tokens.size() !=
nmer_length_ + 1 ) utility_exit_with_message(
"[ERROR] NMer PSSM database file "
174 + pssm_fname +
" has wrong number entries at line " + line
175 +
"\n\tfound: " + utility::to_string( tokens.size() ) +
" expected: " + utility::to_string(
Size(
nmer_length_ + 1 ) ) +
"\nNote: Whitespace delimited!" );
177 for(
Size ival = 2; ival <= tokens.size(); ++ival ){
178 Real const score( atof( tokens[ ival ].c_str() ) );
179 seqpos_scores[ ival - 1 ] = score;
181 nmer_pssm[ aa ] = seqpos_scores;
205 using namespace chemical;
211 for(
Size ipssm = 1; ipssm <= n_pssms; ++ipssm ){
212 std::map< chemical::AA, utility::vector1< core::Real > >
const this_nmer_pssm(
all_nmer_pssms_[ ipssm ] );
213 if( this_nmer_pssm.empty() )
continue;
215 Real rsd_energy( 0.0 );
226 for(
Size p1_seqpos = p1_seqpos_begin; p1_seqpos <= p1_seqpos_end; ++p1_seqpos ){
228 Size rsd_iseq_nmer( seqpos - p1_seqpos + 1 );
230 Real rsd_energy_this_nmer( this_nmer_pssm.find( rsd_aa )->second[ rsd_iseq_nmer ] );
236 Size iseq_pose( iseq_nmer + p1_seqpos - 1 );
238 if( iseq_pose > chain_end )
break;
241 if( !this_nmer_pssm.count( aa ) )
continue;
242 Real this_rsd_energy( this_nmer_pssm.find( aa )->second[ iseq_nmer ] );
243 energy += this_rsd_energy;
249 rsd_energy += rsd_energy_this_nmer;